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’s service/stockentry/stock_entry_write_impl_svc.go (ApproveStockEntry, RejectStockEntry) and transport/api/stockentry/stock_entry_controller.go
  • Evidence: StockTransaction.RequiresSupervisorCheck is set at creation and read back on every subsequent fetch, but a repository-wide search of service/stockentry/*.go and transport/api/stockentry/*.go for any role/permission check against the caller (role, Role, GetRole) touching RequiresSupervisorCheck returns only pass-through field references — the value is stored and displayed, never checked against who is calling Approve or Reject. Any caller able to reach POST /inventory/admin/api/v1/stock-entries/:id/approve can 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/RejectStockEntry on the caller’s role (via the platform’s standard AuthClaims/auth.GetRole mechanism) whenever RequiresSupervisorCheck is 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 own created_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’s service/stockentry/stock_entry_write_impl_svc.go, CloneStockEntry
  • Evidence: CloneStockEntry inserts a new header row (new UUID, ReferenceInvoiceID prefixed "CLONE-", copying the source’s mode/warehouse/product/supervisor-flag/type) but builds its return value via toDomainTransaction(cloned, nil) — passing nil where the source movement’s line items should be read and re-inserted. The clone operation never reads the source’s stock_transaction_entries rows 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 PENDING header 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 CloneStockEntry read the source transaction’s line items (the same query GetStockEntry already 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 step CreateStockEntry already 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’s domain/stockentryprocess/stock_entry_process.go (the misleading doc-comment) and the entirely absent transport/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) defines StockEntryProcessService.ProcessOpeningEntry. But a search of transport/grpc/ within inventory-service for any file matching stockentryprocess/StockEntryProcess returns nothing — no gRPC server implementation exists for this service. A separate search across all of product-catalog/src for StockEntryProcessService, ProcessOpeningEntry, or stockentryprocess also returns nothing — product-catalog’s publish flow never calls this RPC, or any RPC, on inventory-service for 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’s repository/product-opening-entry/product-opening-entry-migration.repository.ts calls both via a plain axios client against inventoryService.baseUrl, dispatched from service/product-opening-entry/product-opening-entry-migration.service.ts and service/product-opening-entry-process/product-opening-entry-process-migration.service.ts (entity types PRODUCT_OPENING_ENTRY/PRODUCT_OPENING_ENTRY_PROCESS, both registered in migration/category/category-migration.module.ts’s ENTITY_MIGRATION_SERVICES factory) — triggered when tenant-migration publishes 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 StockEntryProcessService in inventory-service and add the corresponding client call from product-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, correct ProcessOpeningEntry’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