# Foundation Integrity Gate v36

## Scope

v36 deliberately pauses feature expansion and repairs three accumulated foundation risks.

### 1. Inventory transfer value conservation

Problem:
`transfer_out` and `transfer_in` were posted independently.

That allows destination valuation to derive a different cost from the source warehouse,
which can create or destroy inventory value during an internal transfer.

Repair:
- post source `transfer_out`
- capture the ledger's authoritative `unit_cost_amount`
- pass that exact amount to destination `transfer_in`
- include transferred unit cost in audit metadata

Invariant:

`source value decrease == destination value increase`

for the transferred quantity.

### 2. Supplier invoice received-quantity consumption

Problem:
3-way matching compared every invoice line against the PO line lifetime
`received_quantity`.

Two different invoices could therefore each consume the same received quantity.

Repair:
- lock the PO line during match
- calculate quantities already committed by other fully matched/approved invoices
- `available_received = received - already_committed`
- compare the current invoice billed quantity against `available_received`
- snapshot committed and available quantities in match details
- process PO lines in deterministic ID order

This is a concurrency-safe application boundary because the PO line lock serializes
matching attempts for the same received quantity.

### 3. Purchasing → Payables boundary

Problem:
Purchasing approval directly imported and created the Payables domain model.

Repair:
- Payables now owns `EnsureAccountPayableForSupplierInvoiceAction`
- Purchasing invokes the Payables application contract
- direct cross-domain model mutation is removed from Purchasing

## No schema change

v36 is intentionally application-only.

All migrations through v35 remain untouched and immutable.

## Remaining integrity debt

Still tracked for later gates:
- pricing temporal overlap exclusion
- cart promotion two-pass basket evaluation
- stronger idempotency fingerprints
- branch/company timezone business-date normalization
- exact goods-receipt-line → supplier-invoice-line allocation
