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’s StockBalanceService (ReserveInventory/ReleaseInventory/ConsumeInventory) and the order_inventory_reservations table those three methods write to
  • Evidence: grpc/stockbalance.proto defines exactly three RPCs — ReserveInventory, ReleaseInventory, ConsumeInventory — with no fourth, read-oriented method. Inside stock_balance_reservation_impl_svc.go and stock_balance_consumption_impl_svc.go, the only reads against order_inventory_reservations are inline DISTINCT ON (sku_id, warehouse_id) ... ORDER BY created_at DESC queries 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, or order-service activity 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 to repository/stockbalance/, a service method wrapping it, and a new StockBalanceService RPC (or a REST endpoint on an existing admin controller) that returns every guard row for a given (tenant_id, order_id) ordered by created_at — surfacing exactly the sequence order_inventory_reservations already preserves, without changing how any of the three existing write methods behave.
  • Related requirement: SR-019 FR-12, BRD-018 BR-06