Technical Debt — Order Inventory Reservation History Has No Query Surface
By Engineering Team•October 9, 2026•3 min read
| Metadata | Details |
|---|---|
| System | inventory-service — StockBalanceService |
| Document ID | TD-2026-INV-002 |
| Author | Engineering Team |
| Status | Tracked |
SR-019’s FR-12 and Architecture-00015’s “History & audit trail” section link here rather than restating this gap inline; this is the one place it’s tracked.
TD-01 — Reservation history is recorded but not retrievable by any caller
- Status: Open
- Severity: Low today; escalates whenever customer support or Finance & Operations actually needs to investigate a specific disputed or unusual order’s reservation history and finds no supported way to do so
- Affected component:
inventory-service’sStockBalanceService(ReserveInventory/ReleaseInventory/ConsumeInventory) and theorder_inventory_reservationstable those three methods write to - Evidence:
grpc/stockbalance.protodefines exactly three RPCs —ReserveInventory,ReleaseInventory,ConsumeInventory— with no fourth, read-oriented method. Insidestock_balance_reservation_impl_svc.goandstock_balance_consumption_impl_svc.go, the only reads againstorder_inventory_reservationsare inlineDISTINCT ON (sku_id, warehouse_id) ... ORDER BY created_at DESCqueries used solely to decide each write call’s own idempotent no-op behavior — their results are never returned to a caller.inventory-service’s repository layer (repository/stockbalance/) has no method touching this table at all; the table is read and written exclusively from inline SQL in the service layer. No REST controller, gRPC method, ororder-serviceactivity anywhere in the monorepo asks for a line’s reservation history. - Impact: BRD-018 BR-06 requires that a reservation’s full lifecycle remain a permanent, investigable record — and the data itself already satisfies that, by construction, per SR-019 FR-07. But today, “investigable” in practice means “investigable by someone with direct database access” — customer support resolving “what happened to the stock on my order” and Finance & Operations auditing a disputed order both have no tenant-scoped, audited, application-level way to retrieve that sequence. The record exists; nothing can read it except a raw database query that bypasses normal access controls.
- Remediation direction: Add a read path that stays inside the existing layering: a domain type (e.g.
OrderReservationHistoryEntry{Status, Quantity, WarehouseID, SkuID, CreatedAt, CreatedUserID}), a repository method (e.g.GetReservationHistoryByOrderID) added torepository/stockbalance/, a service method wrapping it, and a newStockBalanceServiceRPC (or a REST endpoint on an existing admin controller) that returns every guard row for a given(tenant_id, order_id)ordered bycreated_at— surfacing exactly the sequenceorder_inventory_reservationsalready preserves, without changing how any of the three existing write methods behave. - Related requirement: SR-019 FR-12, BRD-018 BR-06
Related Documents
- BRD-018 — Concurrent Demand: Stock Integrity Under Simultaneous Orders and the Scaling Decision — BR-06
- SR-019 — Concurrent Demand: Stock Integrity Under Simultaneous Orders System Requirements — FR-07, FR-12
- Architecture — Inventory Stock Reservation, Consumption, and Concurrency Control — the “History & audit trail” section this gap sits beneath
- Technical Debt — High-Concurrency Stock Contention Scaling Gap — the sibling named gap in the same feature area
- Microservices: inventory-service