Repository navigation
refactor(inventory): put general inventory behind an IInventoryModule contract - #1027
Conversation
|
Review of record: Codex Approve with one documentation nit. No product defect or blocking correctness finding was found. Reviewed PR #1027, issue #855, at The one nit is separate from correctness findings:
Behavior review found parity:
The ledger is accurate. Its edge and adapter sections are structurally identical to the base. The five implementation entries are exactly I regenerated the coupling matrix using Local execution passed:
That is 169 distinct integration tests. After restoring mutations, the 13 selected contract/projection/matrix checks and both lock-order tests plus the chronology list test passed again. The initial parallel build exited with MSB4166 child-worker failures; serial builds with All 11 deliberate mutations failed for the intended assertion, rather than a compilation error:
Evidence is alongside this report in Every throwaway mutation was reverted; final Verdict: APPROVE WITH NIT for |
… contract InventoryEndpoints, WaterUsageEndpoints and SimulationDataSeeder now reach General Inventory through IInventoryModule, which forwards to the existing handlers and repositories and returns *Details records. Handler bodies are untouched, so RecordFeedUsage keeps item lock, flock eligibility, then the FIFO lots, in one transaction. The ledger lists the contract and the five repositories as implementations, registers the seeder's seven remaining Inventory reads for #858, and adds the currency probe's Inventory row. Both probe rows now wait for #854, because Commerce is the last of the probe's modules to get a contract.
…r and the probe's re-date
ac25073 to
208335a
Compare
|
Rebased onto
|
Closes #855
General Inventory now sits behind an
IInventoryModulecontract, the fourth module after Finance (#849), Farm (#851) and Flock Management (#852). No route, response, status, query or schema changes.Checkpoint decisions (owner-approved)
ExportQueries) reads its tables through that declared edge.InventoryItemDetails(with on-hand quantity),InventoryLotDetails,InventoryMovementDetails,FeedUsageDetailsandWaterUsageDetails. Writes take the existing commands and returnResult,Result<Guid>or the existingRecordFeedUsageResponse.InventoryModuleonly forwards to the eight existing handlers and five repositories; get and list keep the same queries in the same order.InventoryEndpointsandWaterUsageEndpoints(all routes) andSimulationDataSeeder. No job or CLI verb reaches General Inventory. Validators stay on the endpoints, because the commands are contract types.RecordFeedUsagekeeps item lock, then flock eligibility throughIFlockLookup, then FIFO lots, in one transaction, with the flock row unlocked.IAccountRepository.GetCurrentSharedLockedAsync(Close the §4.6 currency-lock race properly (shared lock on the account row across money-writing handlers) #162FOR SHARE), per [C] #514 slice 9: Farm contract, with tenant identity staying in Platform #851.CurrencyBoundRowProbe.AnyAsyncreads Commerce, Finance and General Inventory tables. [C] #514 slice 8: close or date every compatibility exception #850 assigned it here because it expected General Inventory to be the last of the three modules to get a contract; Commerce ([C] #514 slice 12: Commerce contract, consuming the stock seam #854) is now the last, and its reads only become exceptions once it has a contract. A partial move would have added aboolread toIFinanceModuleandIInventoryModuleand widened Finance's repository port for one caller, and [C] #514 slice 12: Commerce contract, consuming the stock seam #854 would reshape the probe again. So the probe's new General Inventory read is a registered exception (owner Farm), and the existing Finance row'sdeleteWhenmoves from [C] #514 slice 13: General Inventory contract and the flock-eligibility read #855 to [C] #514 slice 12: Commerce contract, consuming the stock seam #854.IInventoryItemRepository.HasLotsAsynccall became the identicaldb.InventoryLots.AnyAsyncinsideEnsureOpeningPurchaseAsync, which already needed a row.IDailyEntryRepositoryprovenance read (Egg Operations' slice owns that port), renames, namespace moves, schema changes.Rationale:
docs/decisions/855-inventory-contract.md. AGENTS.md's #849 paragraph now names General Inventory and the lock-order rule.Reach
main6e3f584, placeholder contract)Platform -> GeneralInventory)implementationscompatibilityExceptionsrowsNo edges added or removed. The regenerated
coupling-matrix.mdis byte-identical, and the adapter pruning list (Loosenable) is empty.Change map
Verification
Test counts, measured, never quoted:
main6e3f584main08cf44c (#1021)main582f8c8 (#1026)InventoryModuleTests)dotnet build Cluckwork.slnis clean with warnings as errors. No existing test was edited. The only test-file changes are the newInventoryModuleTests, test B appended to #1026's newFeedUsageLockOrderTests, and ledger data.EF model digest: SHA-256 of the design-time
Model.ToDebugString(LongDefault)is45F550E426163CEBEFF36E509CFC6E53B36D26D3D89C72E0F728855BCC8FB9AEonmain6e3f584 and on this branch's head. The 1486-line dumps are byte-identical.Ordering and race evidence.
FeedUsageLockOrderTestsholds one row lock in a separate connection, waits until the usage request is provably parked on it (pg_blocking_pids), archives the flock, then releases the lock:422 FeedUsage.FlockNotActive. Moving the eligibility read above the item lock turns it RED.200, because eligibility was read before the lots and the flock row is deliberately unlocked. Moving the lot read above the eligibility read turns it RED.Suites run one by one on this branch, all green and unedited:
Version(exactly one wins), daily-entry linkMutations, each RED, then reverted:
IInventoryLotRepository lotsadded back toInventoryEndpoints.ListLots:AdapterReachRealTreeTestsreportscontract bypass ... ListLots -> GeneralInventory through ...IInventoryLotRepository.InventoryItemadded toIInventoryModule:ModuleContractRealAssemblyTestsfails.InventoryLotRepositoryremoved fromimplementations:CompatibilityExceptionRealTreeTestsreports its eight members as undeclared.CompatibilityExceptionRealTreeTestsfails.QuantityReceivedandQuantityAvailableswapped in the lot copy:InventoryModuleTests.ListLots_CopiesEveryFieldfails.MeterStartandMeterEndswapped in the water copy:InventoryModuleTests.ListWaterUsage_...fails.Cleanup.
pstack:deslopran on this branch's diff before opening and found nothing to remove. A/noslopself-review of the full diff followed and found nothing either.Nothing user-visible changes, so this PR has no screenshots.