Skip to content

MK Inventory Allocation — Current Baseline And Caller Refresh — 2026-08-08

  • Status: CURRENT STATIC SOURCE REFRESH COMPLETE / DATA, ROLE AND RECOVERY EVIDENCE REQUIRED
  • Process: PROC-OMS-INVENTORY-TO-OUTBOUND-ALLOCATION-MK
  • Operating profile: mk-order
  • Previous source-authority issue: exact source SHA absent from the header
  • Current review ref: qa/master@a71386e3baf176534939a42397249bcd2b535c49
  • Existing authority: MK_INVENTORY_ALLOCATION_SOURCE_AUTHORITY.md
  • Existing rebuild packet: MK_INVENTORY_ALLOCATION_CAPABILITY_REBUILD_PACKET.md
  • Read-only evidence package: RBR-ALLOC-001-READONLY-CURRENT-SURFACE-PREFLIGHT.md
  • Phase implementation: USER HOLD
  • Effects: repository source inspection and documentation only

1. Purpose

The Allocation source-authority packet contains detailed current behavior but did not declare an exact source revision. This prevented a source-freshness claim even though the semantic packet remained useful.

This refresh:

  1. pins the exact current review revision;
  2. records exact owner blob identities;
  3. inventories current page/API/navigation callers;
  4. separates the Workbench owner from adjacent Inbound/Outbound/Booking writers;
  5. defines current evidence required before any correction or migration.

It does not authorize an allocation, reversal, balance repair, role change or migration.


2. Exact Current Owner Set

Owner Current blob Responsibility
frontend/pages/system/OMS/allocation/mk-allocation-workbench.php 4e0af1183da1248f16cd934d8f9460f2142819ce page shell, initial context and assets
public/assets/js/modules/oms/allocation-workbench.js 21c9b03e8edf7bdc51a8f89591e29ecb24d3e01e source/target/basket/apply browser behavior
app/systems/OMS/allocation/api_routes.php 155667c3b43d1bbd5886f048b16ae2785645dac4 sources, targets and apply routes
app/systems/OMS/allocation/query_handler.php 130d3d8b69594a3a55baa9e4cd610d21aacdf2f6 read-model dispatch
app/systems/OMS/allocation/allocation_query_helper.php 3b55d878c7f2d5d9d8e42a081c727a05c0d8fa78 source/target eligibility projections
app/systems/OMS/allocation/post_handler.php 035056fc74fa95f314b55c6710dc1e5da2fa5921 Apply-only command adapter
app/systems/OMS/inbound-order/mk_post_helper.php cf05b7096ef46b8215c2a8c9f9d13e4dba9bae00 shared allocation write, lot balance and adjacent correction behavior

The Allocation route blob and shared write-helper blob are byte-identical to the reviewed 4f6165... ancestor. No material current Allocation core-owner drift was located in the reviewed set.

Current classification:

BASELINE MISSING:
RESOLVED

CORE OWNER SOURCE:
PINNED AT a71386e

CURRENT DATA / ROLE / RUNTIME:
NOT VERIFIED

3. Current Entry And Navigation Callers

Primary page

?page=mk-allocation-workbench

Registered through:

config/page_routes.php
config/modules.php
module key = oms.allocation

Direct browser owner

frontend/pages/system/OMS/allocation/mk-allocation-workbench.php
public/assets/js/modules/oms/allocation-workbench.js

Current API callers

GET  /api/oms/allocation-workbench/sources
GET  /api/oms/allocation-workbench/targets
POST /api/oms/allocation-workbench/apply

Adjacent navigation/caller surfaces

Repository search identifies current Allocation links or context handoffs from:

MK inbound-order editor
MK outbound-order editor
MK order schedule
validated MK screen/UAT assets
page/module registration

These callers can pass source, inbound, outbound, inventory, schedule, lot, commodity or branch context. That context is navigation/display input only; the server command must re-establish authoritative source lot and target shipment state.


4. Current Read Model

4.1 Source identity

Current source basket identity:

INVENTORY_LOT_ID
+ SOURCE_ORDER_ITEM_ID

Current source-query eligibility includes:

  • active tenant-owned T_INVENTORY_LOT;
  • LOT_STATUS IN ('OPEN', 'PARTIAL');
  • RECEIVED_DATE IS NOT NULL;
  • REMAIN_NET_WEIGHT > 0;
  • active source order and source item when present;
  • source item not already in ALLOCATED, COMPLETED or TRANSLOADED;
  • optional inbound/order/reference/owner/commodity/stock-bucket filters;
  • bounded default result set unless an explicitly selected commodity context requests all matching lots.

The current query returns, among other values:

INBOUND_QUANTITY
INBOUND_NET_WEIGHT
REMAIN_QUANTITY
REMAIN_NET_WEIGHT
UOM
UNIT_RATE
OWNER_COMPANY_ID
RECEIVED_DATE
LOT_STATUS
source order/item state
active allocation count and allocated net weight

A source row being visible does not prove it is still eligible when Apply runs.

4.2 Target identity

Target eligibility includes:

  • active Outbound Sales order;
  • active equipment/equipment-load bridge;
  • nonempty container and size;
  • equipment-load state that is not Returned/Broken under the current query;
  • optional date/search/target context;
  • current allocated-weight projection.

A target row being listed does not prove it remains eligible when Apply executes.


5. Current Write Contract

Current command path:

POST /api/oms/allocation-workbench/apply
-> apiRouteRunLegacyWrite()
-> omsAllocationPostHandle(APPLY_WORKBENCH)
-> mk_sales_order_post_handle(APPLY_WORKBENCH)
-> local transaction commit/rollback

Current transaction performs, per accepted basket row:

validate target order/container bridge
validate source lot and balance
create target T_LOAD_ITEM
insert T_LOAD_ALLOCATION with:
  OUTBOUND_ORDER_ID
  OUTBOUND_ORDER_ITEM_ID
  INVENTORY_LOT_ID
  ALLOCATED_QUANTITY
  ALLOCATED_NET_WEIGHT
  ALLOCATED_RATE
conditionally decrement T_INVENTORY_LOT.REMAIN_NET_WEIGHT
verify affected row count
synchronize related projections
return target order and created item IDs

Current direct Apply does not immediately decrement REMAIN_QUANTITY.


6. Current Caller/Authority Separation

Concern Current caller Authority boundary
source discovery Workbench query API projection only
target discovery Workbench query API projection only
basket browser JS/local state not authoritative
apply Allocation API/post handler current command entry
target item create shared MK helper invoked under Allocation command
allocation relation T_LOAD_ALLOCATION insert authoritative accepted relation
lot remaining weight conditional lot update immediate accepted consumption balance
quantity balance later synchronization/recalculation not immediate Apply decrement
outbound ordinary save Outbound owner not allocation authority
inbound correction Inbound/Inventory owner can affect allocation balance evidence
Booking compatibility Booking/shared helper adjacent writer requiring reconciliation

7. Current Risks Retained

7.1 Query/write predicate asymmetry

The source and target lists apply several joins and filters. The write helper rechecks tenant, source balance and target identity, but current eligibility is not expressed as one shared policy object.

Risk:

listed source/target
-> state changes before Apply
-> server accepts, rejects or differs from displayed assumptions

7.2 Weight/quantity asymmetry

Current Apply persists allocated quantity and net weight but immediately decrements only remaining net weight.

Required policy/evidence:

  • whether full-lot is required;
  • whether partial allocation is allowed;
  • how remaining quantity is derived or synchronized;
  • UOM and decimal precision;
  • zero/negative and over-allocation handling;
  • rate ownership;
  • correction/reversal behavior.

7.3 Missing durable request identity

local transaction
!= durable idempotent command

A response loss can leave the operator unable to distinguish:

not committed
committed once
duplicate second command
partial adjacent conflict

The exact target item/allocation/lot balance must be reread before replay.

7.4 Adjacent correction writers

Inbound, Outbound and Booking helpers can modify records that Allocation reads or owns.

Particular risks:

  • inbound source correction after consumption;
  • outbound allocated-item update;
  • allocated-item delete guard versus other delete paths;
  • Booking cleanup or compatibility mutation;
  • direct/manual balance repair;
  • source lot recalculation producing a value inconsistent with active allocation relations.

8. Current Access Questions

Current route registration declares moduleKey = oms.allocation but no accepted semantic action capability is established.

Required current evidence:

which roles can open the Workbench
which roles can read sources/targets
which roles can Apply
whether direct API access matches page visibility
foreign-tenant and foreign-record denial
Client 1 non-regression
Client 2 expected MK profile behavior

Candidate target action:

oms.inventory-allocation.apply

This is documentation input, not a current permission change.


9. Exact Current Evidence Required

Evidence owner:

RBR-ALLOC-001

Schema/data

  • T_INVENTORY_LOT, T_LOAD_ALLOCATION, T_LOAD, T_LOAD_ITEM columns/indexes;
  • current remaining quantity/weight precision;
  • active allocation relation integrity;
  • orphan/duplicate target items and relations;
  • lot remaining balance versus active allocation sums;
  • allocated-item correction history;
  • OPEN/PARTIAL lot behavior and received-date predicates.

Caller/role

  • current menu/page/module rows;
  • intended and denied controlled accounts;
  • source/target GET parity;
  • Apply control visibility;
  • no write during read-only preflight.

Runtime/recovery

  • one normal Apply;
  • concurrent Apply against the same lot;
  • response loss after commit;
  • stale target/container;
  • over-allocation;
  • Inbound/Outbound/Booking correction interaction;
  • exact cleanup/reversal owner.

Wiki

  • current Allocation procedure;
  • full-lot versus partial policy wording;
  • response-loss recovery;
  • source/target identity;
  • completion non-implications.

10. Target Migration Boundary

A future React/Next.js implementation must preserve one Allocation command authority.

React basket/presentation
-> Next.js validated adapter
-> TypeScript Allocation Application
-> Allocation Policy
-> typed repositories
-> MySQL transaction

The target must not:

  • move balance policy into React;
  • let ordinary Outbound Save allocate;
  • dual-write from PHP and TypeScript;
  • infer success from target item presence alone;
  • start PostgreSQL migration before one-writer/rollback/caller-zero.

11. Current Conclusion

Exact source baseline:
PINNED

Current owner/caller inventory:
REFRESHED

Core source drift:
NO MATERIAL DRIFT LOCATED IN REVIEWED SET

Current DB/role/runtime evidence:
NOT RUN

Canonical quantity/weight policy:
OPEN

Correction/reversal authority:
OPEN

M3:
NO

M4:
NO

Phase progress:
NONE

---

Source: docs/reconstruction/MK_INVENTORY_ALLOCATION_CURRENT_BASELINE_AND_CALLER_REFRESH_2026-08-08.md — ctc repository · This page is an English translation of the source document. Identifiers, file paths and code symbols are unchanged.