Technical Debt — Warehouse Stock Entry Gaps
By Engineering Team•October 8, 2026•5 min read
| Metadata | Details |
|---|---|
| System | inventory-service — Admin Stock Entry (StockEntryService) |
| Document ID | TD-2026-INV-002 |
| Author | Engineering Team |
| Status | Tracked |
SR-020’s FR-10, FR-14, and FR-15 link here rather than restating these gaps inline; this is the one place they’re tracked.
TD-01 — RequiresSupervisorCheck is stored and passed through, but never enforced as an approval-role gate
- Status: Open
- Severity: Medium — escalates to High the moment this feature is relied on as an actual internal control, since today it provides no real control at all
- Affected component:
inventory-service’sservice/stockentry/stock_entry_write_impl_svc.go(ApproveStockEntry,RejectStockEntry) andtransport/api/stockentry/stock_entry_controller.go - Evidence:
StockTransaction.RequiresSupervisorCheckis set at creation and read back on every subsequent fetch, but a repository-wide search ofservice/stockentry/*.goandtransport/api/stockentry/*.gofor any role/permission check against the caller (role,Role,GetRole) touchingRequiresSupervisorCheckreturns only pass-through field references — the value is stored and displayed, never checked against who is calling Approve or Reject. Any caller able to reachPOST /inventory/admin/api/v1/stock-entries/:id/approvecan approve a flagged movement exactly as if it were unflagged. - Impact: BRD-019 BR-02 (“a movement flagged as requiring review must not change stock on hand until a second person explicitly approves it”) is only partially met — the flag exists and the approve/reject action is a distinct step from creation, but nothing today stops the same person who created the movement, or any caller with access to the endpoint at all, from also being the one who approves it. The two-person control the business requirement describes is not actually enforced.
- Remediation direction: Gate
ApproveStockEntry/RejectStockEntryon the caller’s role (via the platform’s standardAuthClaims/auth.GetRolemechanism) wheneverRequiresSupervisorCheckis true on the target movement, rejecting the call as unauthorized if the caller doesn’t hold the required role — and, ideally, also rejecting a caller who matches the movement’s owncreated_user_id, so the same person can’t both record and approve a flagged movement. The specific role/permission name to check for is a product decision BRD-019 itself leaves out of scope today (see its Out-of-Scope section) — this remediation should be sequenced after that naming decision is made, not ahead of it. - Related requirement: SR-020 FR-14, BRD-019 BR-02
TD-02 — CloneStockEntry never copies the source movement’s line items
- Status: Open
- Severity: Medium — the feature appears to work (a new movement is created, no error is returned) but silently produces an incomplete result
- Affected component:
inventory-service’sservice/stockentry/stock_entry_write_impl_svc.go,CloneStockEntry - Evidence:
CloneStockEntryinserts a new header row (new UUID,ReferenceInvoiceIDprefixed"CLONE-", copying the source’s mode/warehouse/product/supervisor-flag/type) but builds its return value viatoDomainTransaction(cloned, nil)— passingnilwhere the source movement’s line items should be read and re-inserted. The clone operation never reads the source’sstock_transaction_entriesrows at all. - Impact: BRD-019 BR-05 (“staff can start a new movement from a previous one, rather than re-entering everything from scratch”) is not actually satisfied — the clone produces a new
PENDINGheader with zero line items, which is no faster to complete than creating a fresh movement from nothing; an operator has to re-enter every SKU and quantity exactly as if Clone didn’t exist. - Remediation direction: Have
CloneStockEntryread the source transaction’s line items (the same queryGetStockEntryalready uses to populate entries) and insert a copy of each one, with new IDs, against the newly-created header, before returning — mirroring the same entry-insertion stepCreateStockEntryalready performs for a brand-new movement, just sourced from the clone target’s existing lines instead of the caller’s request body. - Related requirement: SR-020 FR-10, BRD-019 BR-05
TD-03 — ProcessOpeningEntry’s own doc-comment claims a gRPC/product-catalog-publish auto-trigger that was never built — a different automated caller exists instead
- Status: Open
- Severity: Low today (the endpoint already has a real, working automated caller — just not the one the doc-comment describes); escalates if a future reader takes the doc-comment at face value and assumes the described gRPC/product-catalog-publish integration already exists
- Affected component:
inventory-service’sdomain/stockentryprocess/stock_entry_process.go(the misleading doc-comment) and the entirely absenttransport/grpc/stockentryprocess/layer - Evidence:
ProcessOpeningEntry’s struct doc-comment states it is “the input for the gRPC-triggered opening stock initialization that runs when a product is published from product-catalog.” A real proto (grpc/stockentryprocess.proto) definesStockEntryProcessService.ProcessOpeningEntry. But a search oftransport/grpc/withininventory-servicefor any file matchingstockentryprocess/StockEntryProcessreturns nothing — no gRPC server implementation exists for this service. A separate search across all ofproduct-catalog/srcforStockEntryProcessService,ProcessOpeningEntry, orstockentryprocessalso returns nothing —product-catalog’s publish flow never calls this RPC, or any RPC, oninventory-servicefor this purpose. However, the two REST endpoints this capability actually exposes (PUT /inventory/admin/api/v1/sku-opening-entry,POST /inventory/admin/api/v1/sku-opening-entry/process) do have a second, genuinely automated caller:tenant-migration-orchestrator’srepository/product-opening-entry/product-opening-entry-migration.repository.tscalls both via a plain axios client againstinventoryService.baseUrl, dispatched fromservice/product-opening-entry/product-opening-entry-migration.service.tsandservice/product-opening-entry-process/product-opening-entry-process-migration.service.ts(entity typesPRODUCT_OPENING_ENTRY/PRODUCT_OPENING_ENTRY_PROCESS, both registered inmigration/category/category-migration.module.ts’sENTITY_MIGRATION_SERVICESfactory) — triggered whentenant-migrationpublishes CSV-sourced opening-entry records to Pub/Sub as part of a bulk tenant-catalog-migration run, not when a product is published for sale. This is a real, wired, HTTP-based automated path; it is simply a different trigger and transport (CSV-driven migration dispatch over REST) than the one the doc-comment and proto describe (publish-driven, over gRPC). - Impact: No functional gap exists for bulk opening-entry initialization today — it already has two real callers, an operator acting directly and the tenant-migration pipeline, and BRD-019’s own Out-of-Scope section already excludes automatic, publish-triggered initialization from current scope. The actual risk is documentation drift: the proto file and the struct’s own comment describe a gRPC/product-catalog-publish integration that a future engineer could reasonably believe already exists and build against, when it does not — and could mistake the real migration-pipeline caller for that described integration if the doc-comment isn’t corrected.
- Remediation direction: Either (a) build the described integration — wire a gRPC server for
StockEntryProcessServiceininventory-serviceand add the corresponding client call fromproduct-catalog’s publish flow, turning this from a stale claim into a real feature, consistent with BRD-019’s Out-of-Scope note that this remains future scope until a business need calls for it; or (b) at minimum, correctProcessOpeningEntry’s doc-comment to describe what actually exists today — a manually-triggerable REST bulk-initialization endpoint with a second, already-wired automated caller in the tenant-migration pipeline — so it stops asserting a gRPC/product-catalog-publish integration that was never built. Option (b) should happen regardless of whether/when option (a) is pursued. - Related requirement: SR-020 FR-15
Related Documents
- BRD-019 — Warehouse Stock Entry: Auditable Movement Recording & Approval Control
- SR-020 — Warehouse Stock Entry: Ledger & Approval Control System Requirements
- ADR-00036 — Deferred, Approval-Gated Balance Mutation and a Database-Enforced Immutable Ledger for Stock Entry
- Architecture — Warehouse Stock Entry: Creation, Approval-Gated Balance Mutation, and Immutable Ledger
- Technical Debt — Product Catalog Admin-to-Mobile Gaps — TD-03 there, the related, already-tracked gap of
inventory-service/CLAUDE.mddescribing a different non-existentValidateAndCreateSkusgRPC endpoint - Microservices: inventory-service, product-catalog