Chapter 7 — Supply¶
7.1 — Chapter summary¶
⚙ Processes: the
supplystep — one engine chosen per supply scenario:config_supply_scenario.solver_type('mrp'= the Rust greedy engine;'lp_transport'= the Pyomo/HiGHS cost-minimizing solver; anything else = the documented default + a loud warning) — followed by the separateallocationstep. Run: the ProcessRunner cards (Supply, then Allocation), or the full pipeline run (the API/CLI equivalents are in 7.D). The netting pre-step refreshes netting before planning (5.8).Netted demand PIPE_forecast_netting.supply_plan_qty (5.8) → MEIO safety-stock floor PIPE_meio_results.safety_stock (6) → Routes · capacity ranges firm & open orders on-hand (good/bad) → MRP (Rust greedy) netting → sourcing → scheduling order consolidation · transfer allocation → LP solver (HiGHS) cost minimization buy/transfer/repair × weeks → PIPE_supply_recommendations + exceptions + pegging + projection + capacity usage → Allocation step (7.13)
The one-sentence model: supply turns each site's netted demand plus its safety-stock floor into concrete replenishment orders — what to buy, make, transfer, collect, repair, and when — under lead times, capacity, lot constraints, and the good/bad stock conditions, with every order pegged back to the demand it serves and every capacity use tracked.
Timing model (Nov 2026): the MRP engine plans every chain of transfers on the departure clock by default — a warehouse ships only stock that exists on its departure day, kits are built only when their components exist, and shipping / receiving closures are pre-positioned along the whole chain (7.11). The legacy arrival clock stays selectable per supply scenario (Pipelines → Supply Planning → Lane Timing).
7.2 — Multi granularity, multi condition, and the two engines¶
Multi granularity — the plan's TIME AXIS operates at different precisions depending on how far out you look (fine near, coarse far), configured as the Planning Periods ladder on the supply scenario:
| Horizon zone (first row = nearest) | Meaning |
|---|---|
| The first 3 days | Granularity: hourly. Why: operations are committed; picking, loading, and dock scheduling need hour-level precision. |
| The next 4 weeks | Granularity: daily. Why: tactical decisions such as order timing and transport booking work at daily resolution. |
| The rest of the horizon | Granularity: weekly. Why: strategic sizing, capacity, and stock build do not need finer-than-weekly buckets. |
Where to configure it: Pipelines → the supply scenario editor → the
Planning Periods panel — a ladder of rows, each with a length and a granularity
dropdown (first row = nearest term; "rest" = the remainder of the horizon). The engine
builds its bucket grid from this ladder; the default (no ladder) is the legacy uniform weekly
grid — byte-identical to the pre-multi-granularity behaviour.

The Planning Periods configuration (the demo tenant): the supply scenario
editor's Planning Periods panel — the ladder of horizon zones with their granularity dropdowns
(first row = nearest term, "rest" = the remainder of the horizon). The default is a single
rest / weekly row = the uniform weekly grid.
A sub-weekly ladder needs the Arrival clock
The default departure clock (7.11) counts in 168-hour buckets, so a scenario whose ladder has hourly or daily rows must choose Arrival clock (legacy) in its Lane Timing panel — otherwise the supply run stops with an explicit error naming the ladder (it never plans on the wrong clock).
The multi-granularity grid gives the planner execution-ready detail where it matters and aggregated views where fine detail would be noise. Every order still carries its dated release/arrival regardless of the zone it falls in; the CH week columns are mapped from the bucket grid (each bucket belongs to its legacy week index).
Multi condition — stock is condition-typed: routes carry
stock_type (good vs bad flows), on-hand splits by condition (good / bad_lvl1 — 3.2's the customer storage
locations), and the engines plan the two separately: good stock serves good demand; the bad pool feeds
the wash loop (7.8) and never silently substitutes for good. The another demo tenant condition demo exists precisely to
exercise this split.
MRP vs solver — the per-scenario solver_type switch (the old auto-promote guard
that silently upgraded MRP to LP on USE/BALANCING routes is removed — the planner's explicit
choice wins; USE and BALANCING are fully supported in the Rust MRP since Aug 2026):
| MRP (Rust greedy) | LP solver (Pyomo/HiGHS) | |
|---|---|---|
| Philosophy | Echelon rollup + per-SKU netting, sourcing by priority, week-by-week scheduling — fast, explainable, locally optimal | Global cost minimization — one optimization over all sites × weeks × order types |
| Objective | Feasibility-first: cover the netted demand + the SS floor under lead times and capacity | Minimize ordering + holding + transport (+ capacity overtime penalties) — the cost optimum, not just a feasible plan |
| Strengths | Scale (the the demo tenant 433k-order runs), the transfer allocator's echelon balance-keeping, determinism | Cost trade-offs the greedy can't see (buy earlier vs transfer, repair vs replace), hard constraints with slack visibility |
| Live pair | another demo tenant: pipeline 2 "the network — MRP (Rust greedy)" vs pipeline 3 "the network — LP (HiGHS)" — the same network planned both ways (the MRP-vs-LP comparison test bench) | |
Certified supply — both engines respect: lead times (days → ceil-weeks), lot min/mult/max, the MEIO floor (the LP makes it hard from the fill week with the two-step infeasibility ladder + time-limit discrimination), capacity (7.4), committed shipments and receipts (7.5), and supersession cutovers (5.9's taper + route blocking). The MRP engine additionally plans on the departure clock by default — day-level lane times, shipments only against stock that exists, closures pre-positioned along the chain (7.11); the LP solver keeps its own flow-balance timing.
7.3 — Cost minimization: the LP's objective, with a worked example¶
⚙ Process: inside the supply step when
solver_type='lp_transport'. The Pyomo model minimizes total plan cost.
The objective function¶
Each cost term — what it is, where the inputs come from, and how it is computed¶
| Cost term | Formula | Input variables | Where each input is defined |
|---|---|---|---|
| Transport · (per unit shipped) | route_cost × qty summed · over all (item, route, week) |
route_cost =unit_cost + (order_cost + setup_cost) / batch_est |
unit_cost → the route's per-unit cost · order_cost → the route's fixed cost per order · setup_cost → the route's setup cost · batch_est → max(avg demand, min_qty, 1) — the estimated · order batch size (the fixed costs are spread over it) |
| Holding · (per unit-week in stock) | holding_cost × inventory · summed over all (site, week) |
holding_cost =unit_cost × holding_pct / 52 |
unit_cost → the item's cost (from its routes · or the item master) · holding_pct → the supply scenario's holding rate · (e.g. 0.20 = 20% of item value per year) · / 52 converts the annual rate to weekly |
| Shortage penalty | shortage_penalty × short |
the per-unit penalty for demand · that cannot be served | shortage_penalty → the supply scenario |
| SS penalty · (soft floor) | safety_stock_penalty × ss_slack |
the per-unit penalty for stock · below the safety-stock floor | safety_stock_penalty → the supply scenario |
| SS hard floor slack · (retry path only) | safety_stock_penalty × 100 × ss_hard_slack |
100× the SS penalty — only the · physically infeasible pairs bend | same scenario parameter, |
The worked example — one item, one site, one week¶
A single item with the following inputs:
| Input variable | Value | Source |
|---|---|---|
unit_cost (the item's value) |
$50/unit | the route or the item master data |
holding_pct |
20%/year (0.20) | the supply scenario's config |
order_cost (fixed cost per order) |
$150/order | the route |
setup_cost |
$0 (no setup cost) | the route |
min_qty (minimum order size) |
10 units | the route |
shortage_penalty |
$100/unit | the supply scenario |
safety_stock_penalty |
$10/unit-week | the supply scenario |
| Average weekly demand | 25 units/week | the netted demand (from Point 5.8) |
Step 1 — the per-unit route cost (the fixed cost spread over the estimated batch):
batch_est = max(25, 10, 1) = 25 units (the average weekly demand)
route_cost = unit_cost + (order_cost + setup_cost) / batch_est
= 50 + (150 + 0) / 25
= 50 + 6
= $56 per unit shipped
Step 2 — the per-unit-week holding cost (the annual rate converted to weekly):
Step 3 — the LP decides — suppose the solver is choosing between two plans:
| Plan A: order every week | Plan B: order every 2 weeks | |
|---|---|---|
| Orders placed | 1 order of 25 | 1 order of 50 (covers 2 weeks) |
| Transport cost | 25 × $56 = $1,400 | 50 × $56 = $2,800 |
| Avg inventory | 12.5 units (half of 25) | 25 units (half of 50) |
| Holding cost (1 week) | 12.5 × $0.192 = $2.40 | 25 × $0.192 = $4.81 |
| Fixed ordering cost | already in route_cost | already in route_cost |
| Total for the week | $1,402.40 | $1,402.40 (half of $2,804.81 for 2 wks) |
The two plans cost the same in this simplified example — the LP finds this balance across ALL items, ALL sites, and ALL weeks simultaneously, picking the globally cheapest combination. The key trade-off: ordering more (bigger batches) reduces the per-unit fixed cost but increases the average inventory (and thus the holding cost). The solver finds the exact optimum.
Where the input variables are configured in the UI¶
| Variable | UI surface |
|---|---|
unit_cost |
Master Data → Items (the item's cost field), or the route's unit cost column |
order_cost |
Master Data → Routes (the order cost column) |
setup_cost, min_qty |
Master Data → Routes |
holding_pct |
Pipelines → the supply scenario editor (the holding rate parameter) |
shortage_penalty, safety_stock_penalty |
Pipelines → the supply scenario editor (the penalty parameters) |
What ss_slack is — the safety-stock shortfall variable¶
The LP's safety-stock constraint for each (item, site, week) reads:
constraint: inventory[si, t] + ss_slack[si, t] >= safety_stock_target[si, t]
ss_slack[si, t] = max(0, safety_stock_target - inventory)
= how many units of safety stock the plan CANNOT hold that week
| Variable | What it is | Where it comes from |
|---|---|---|
safety_stock_target[si, t] |
The MEIO safety-stock floor for that (item, site) at that week — the buffer Point 6 sized | PIPE_meio_results.safety_stock — the per-week array loaded into the supply plan. Zero for weeks with no SS target (the constraint is skipped) |
inventory[si, t] |
The LP's projected on-hand at the site at week t (the model's own decision variable) | The LP's inv variable, driven by the buy/order/transfer/repair decisions |
ss_slack[si, t] |
A non-negative decision variable — the shortfall below the floor. Zero when the plan holds the full buffer (the normal case); positive only when the plan physically cannot build the buffer that week | A Pyomo Var(SKUS, T, domain=NonNegativeReals) — the solver decides its value |
The economics: every unit of ss_slack costs
safety_stock_penalty dollars (e.g. $10/unit-week). The solver builds the buffer when it can
(the holding cost of holding the buffer is cheaper than the penalty for violating it), and only violates
where physically infeasible — capacity, lead times, or stock availability prevent the build. The slack
makes infeasibility solvable instead of crashing, while making the violation visible and
costed in the objective.
The fill-rate chain behind ss_slack
the safety-stock target is not an arbitrary number — it is defined by the fill rate. The chain runs:
| Step | What happens |
|---|---|
| 1. The planner sets a fill rate | e.g. 95% — the business target (the MEIO scenario's fill_rate_target, Point 6) |
| 2. MEIO sizes the buffer | SS = z(0.95) × σ × √LT — the quantile buffer that achieves that fill rate given the demand variability and lead time (Point 6's worked example: z = 1.645, σ = 120, LT = 0.43 → SS = 129 units) |
| 3. The LP holds that buffer | safety_stock_target = 129 — the MEIO output loaded into the supply plan |
| 4. ss_slack = the fill-rate degradation | When the plan can't hold the buffer, ss_slack is the fill rate being traded away — each unit of slack is a unit of buffer the plan couldn't hold, which directly degrades the fill rate MEIO sized for |
The `safety_stock_penalty` is therefore the **price of
degrading the fill rate** — the LP trades fill rate against cost, and the penalty makes that
trade explicit and costed. The solver finds the global optimum: hold the buffer where it's worth the
holding cost, sacrifice it where the cost of holding exceeds the cost of the fill-rate loss.
The reverse-engineered fill rate — from the plan's projected inventory¶
The LP produces a projected inventory trajectory per (item, site, week). The plan's own fill rate is computed from that trajectory, not from the MEIO sizing input. The stock available to serve a week is what enters it — the prior week's closing stock plus that week's arrivals — and the plan's own shortage column is exactly the unserved part, so the two forms below are the same number:
available[si, t] = closing_stock[si, t-1] + supply_received[si, t]
served[si, t] = demand[si, t] - shortage[si, t] = min(available[si, t], demand[si, t])
plan_fill_rate = served / demand (per week, per item-site)
missed_orders[si, t] = demand - served = shortage[si, t]
| Week 1 | Week 2 | Week 3 | Week 4 | |
|---|---|---|---|---|
| Demand | 100 | 80 | 120 | 90 |
| Available stock (opening + arrivals) | 100 | 50 | 100 | 30 |
| Served = min(available, D) | 100 | 50 | 100 | 30 |
| Plan fill rate | 100% | 62.5% | 83.3% | 33.3% |
| Missed orders = D − served | 0 | 30 | 20 | 60 |
| Where it is stored | Who reads it |
|---|---|
served_qty and fill_rate columns on the supply inventory projection table — one value per (item, site, week), written by every supply run for both engine types |
A plan output kept for analysis and for the Mirabelle assistant. The series screens no longer show it — the fill rate on the Supply tab is the MEIO fill rate (next section) |
| NULL on snapshots written before the columns existed, and on bad-pool level rows (a level, not a serviceable balance) — never a fabricated 100%. Weeks without demand carry no ratio | Aggregate it demand-weighted (total served ÷ total demand), never as an average of the weekly ratios |
The relationship to ss_slack: the ss_slack measures the shortfall below the MEIO buffer, but the actual service impact depends on the demand in each week. A buffer shortfall of 10 units matters more in a 120-demand week than in a 20-demand week. The LP's objective (minimize total cost including the SS penalty) already weighs this implicitly, and the plan's own fill rate is always computed by this reverse-engineering: from the final plan's projected inventory, against the actual demand — never by re-deriving it from the MEIO target.
The fill rate the series screens show — MEIO's, the same on every tab¶
Open a series (Detail) and the Fill Rate on the IO tab and on the Supply tab is the same number: the node's MEIO fill rate at its committed buffer — what the inventory optimiser reached for this item at this site. The Supply tab no longer shows the plan's own served ÷ demand, for one reason: at a warehouse that only ships, that ratio is structurally 100 %. Its "demand" is its own outbound releases and the plan never records a shortage there, so it reads 100 % whatever stock the warehouse holds — while MEIO, when it committed no buffer for the node, reports a fill rate near 0 %. Two different quantities under one name is exactly what the planner should not have to reconcile; the MEIO figure is the one both tabs now show.
| You see | It means |
|---|---|
| a percentage | MEIO's fill rate at the committed buffer for this node (green from 90 %, amber from 70 %, red below) |
| — | MEIO has no result for this node — it was not sized, or the pipeline has no MEIO scenario linked. Nothing is substituted: in particular the plan's served ÷ demand is not shown in its place |
| — with a tooltip "MEIO fill rate unavailable" | the lookup failed; the projection itself is unaffected |
The IO tab no longer carries a Service Level card. The fill-rate target a segment is sized to stays where it is configured — the MEIO scenario editor (the segment's parameter set; see MEIO parameters) — and the Fill Rate card of the IO tab keeps its override for the node.
The failure ladder¶
A genuinely infeasible model never produces a silently-degraded plan:
| Step | What happens |
|---|---|
| 1 — hard SS floor | From the fill week, the floor is HARD with a per-node emergency slack penalized at 100× the SS penalty — only the physically unsatisfiable pairs bend |
| 2 — model-wide soft floor | Only if the infeasibility is elsewhere — the legacy penalty ($100/unit-week) |
| 3 — time limit retry | A solve that hits the time limit is retried once with an extended limit — never misreported as infeasible |
7.4 — Resource constraints (capacity)¶
⚙ Process: consumed inside the supply step (both engines) — the definition is dated ranges in
master.capacity(resource_type, resource_id, inclusive Monday-normalizedeffective_from/to,capacity_per_week, scenario-scoped rows beat global; NULL scenario = all scenarios), resolved by the ONE sharedutils/capacity_calendar.py(MRP scheduling, the LP, the usage persist, the MEIO V4 topology).
Resolution semantics — a range covers a planning week iff the week's Monday
label falls within it; latest effective_from wins; scenario rows beat global; a week
covered by NO range has capacity 0 (the resource is not provisioned — a shutdown is an explicit
zero range or a gap). Depot storage caps live on master.site.max_capacity_qty.
| Week | Covering ranges | Resolved capacity |
|---|---|---|
| W0 (Nov 9) | global 500/wk + scenario row 800/wk from Oct | 800 (scenario beats global) |
| W3 (Nov 30) | global 500/wk ends Nov 23; next range starts Dec 7 | 0 (the gap — not provisioned; the plan defers or overtime-exceeds) |
| W6 (Dec 21) | global 600/wk (the December range) | 600 (latest effective_from wins) |
Enforcement + visibility: the MRP's Rust scheduling.rs delays →
Overtime soft band → Constrained + CapacityExceeded exceptions; the LP
mirrors with its overtime penalty + ss_slack-style visibility. Usage persists to
PIPE_supply_capacity (with week_date + resource_name) — the
capacity heatmap on the Supply page and the known self-referential feedback between runs
(used_qty is an input to the next run; the golden harness resets it).
7.5 — Firm & open orders: the committed flows¶
What the plan must respect before recommending anything (all five.8-adjacent contracts, verified in the engines):
| Committed flow | Engine treatment |
|---|---|
| Firm TRANSFER/BALANCING rows with release after the anchor | Committed shipments — subtracted from the source's available stock (scheduled_shipments, guarded to keys with on-hand); every open TRANSFER also credits a scheduled receipt at its arrival week at the destination |
| Approved replenishments (non-IB → IB) | Netted on the demand side (5.8) AND — for the pairs netting marked covered — receipt suppression in _load_firm_supply_orders: the same physical flow counted once; the source's shipment minus is untouched |
| Already-shipped rows (release ≤ anchor) | In transit — outside the on-hand snapshot; their arrival credits "today" (week 0), never double-counted |
| ERP document identity | po_number/line_number flow through master_supply_orders_firm → the orders panel (the 🔒 locked firm rows, read-only qty/date, never approval-eligible) |
| Backorders (open past rows) | Treated like open future demand (week-0 clamp); never netted (5.8) |
The opt-in toggle — "Block per Order Type" (firm_orders_block_horizon).
The five contracts above are always on. On top of them the planner can ask the engine to never
create a recommendation of a category before a firm order of the same category: a supply-scenario
boolean (default OFF), scoped per (item, site, order_type). When ON, no
new recommendation of a given type can be positioned before the latest open firm order of the same
type for that (item, site) — the bound is the firm row's release week
(latest_firm_by_type, built from master_supply_orders_firm rows with
erp_status IN ('firm','released','in_transit'); the latest wins when several exist).
Recommendations of other order types inside the window are still allowed — the freeze is
per category, never global. Worked example: a firm BUY for (item 2, site 100) releases in W12
of the horizon → with the flag ON, no new BUY recommendation can be released in W0–W11 for that
pair, while REPAIR and TRANSFER recommendations there remain possible.
| Freeze control | Meaning |
|---|---|
Firm Freeze Period (firm_weeks) |
Time bound: global N weeks from the planning anchor. Granularity: all order types. |
Block per Order Type (firm_orders_block_horizon) |
Time bound: latest firm order's release week, per type. Granularity: per (item, site, order_type). |
Respect Lead Time (respect_lead_time) |
Time bound: minimum lead time across that type's routes. Granularity: per (item, site, order_type). |
Enforcement — both engines: the MRP skips same-type route candidates whose target week
falls before the bound (supply/src/sourcing.rs, checked against
latest_firm_by_type); the LP pins the corresponding arcs to zero flow (the
firm_block constraint, supply_solver/model.py). The always-on
scheduled-receipt netting (first row of the table above) already stops the engine from re-recommending
what a firm order delivers; the toggle adds the stricter per-type frozen window before the firm
row. Known gap (documented): the post-processor order kinds (BUY_EXPEDITE,
TRANSFER_PREPOS) do not respect the flag.
Live state: the demo tenant's base supply scenario Baseline carries the
flag ON — a scenario-level param_overrides value (firm_weeks: 2 and
respect_lead_time: true alongside it) that wins over the parameter-set base
(solver_config_from_supply_cfg merges the two). The screenshot shows that scenario's
Full-edit modal.

Where the toggle is* (the demo tenant, scenario Baseline, captured 2026-11-11):
the supply scenario's Full edit modal → Planning Horizon group
→ Block per Order Type — shown ON (blue) with its hover hint:
"When ON: for each (item, site, order_type), the engine cannot create a recommendation BEFORE the
latest firm order of the same type." Its siblings in the same group: Firm Freeze
Period (firm_weeks) and Respect Lead Time*
(respect_lead_time).
⚙ Process — configure & verify: open Dashboard → Supply tab → the "Pipeline Configuration" panel (collapsed by default → expand it) → the "Editing scenario:
" section → Full edit; the same modal opens from Pipelines → Supply Planning → scenario Edit. The toggle auto-saves as a scenario-level override (overridden cells render highlighted in the panel's inline table). Verify after a supply run: for each (item, site) holding an open firm order of type T, the recommendations carry no T order released before that firm row's release week.
7.7 — Zone balancing, pegging, and the projection¶
Balancing — lateral same-echelon moves on BALANCING lanes. These routes
exist independently of the MEIO zone version: they are plain master.route rows with
planning_type = 'BALANCING', and the transfer allocator processes them without any zone-membership
gate. The constraint model — you cannot just deplete anyone — is the protected stock floor,
not a membership requirement:
Two separate mechanisms, one route type:
(a) BALANCING lanes in the per-SKU transfer allocator — no zone gate, no MEIO dependency;
the protected stock floor and the bounded need are the only constraints (above); (b) the Rust
inter-zone rebalance pass (zone_rebalance.rs) — zone-gated (zone definitions +
config_zone_parameter), triggered by a zone's pooled stock breaching its zone SL, with its own
member floor (SS × balancing_excess_ratio) and zone hysteresis floor
(zone_SS × zone_ratio). The old ZONE_BALANCING route type was retired
(retire_zone_balancing_type.sql); stale rows are re-typed to plain BALANCING.
The protected stock — what a source never gives away¶
| Level | Meaning and example |
|---|---|
| Transfer allocator (the Python 2-pass, leaf/WH) | Floor: the source's own safety stock per week, SS_src[w].Giveable stock: max(0, carry − SS_src[w]), only the stock above its own buffer.Example: a WH carrying 500 with own SS 300 gives at most 200 and never dips below 300. |
| Zone rebalance (the Rust pass, member level) | Floor: SS_member[w] × balancing_excess_ratio, the per-item-location ratio editable in master.item_location.Giveable stock: giveable = pool[w] − member.floor[w], only excess above the member floor.Example: member SS 100, ratio 0.3 → floor 30; pool 80 → giveable 50. |
| Zone rebalance (the Rust pass, zone level) | Floor: zone_SS × zone_ratio, the anti-back-and-forth hysteresis floor.Giveable stock: the source zone's pooled stock must stay above this at every future week after shipment. Example: zone SS 3,460, ratio 0.8 → floor 2,768; the zone never falls below it while rescuing a neighbour. |
The balancing_excess_ratio (on
master.item_location, editable per item-site) is the "protected stock percentage" — 0.3 means
the member keeps 30% of its SS as untouchable. The zone_ratio (on
ZoneRebalanceConfig) is the zone-level hysteresis — it prevents the giving zone from immediately
becoming needy itself and triggering a counter-shipment (the pre-fix ping-pong).
The bounded need — what a destination can ask for¶
A BALANCING lane's destination need is bounded to its OWN SS shortfall — never its downstream demand, never its partner's full rolled-up volume:
| Destination type | Need, bound, and example |
|---|---|
| Leaf node (a store) | Need: need = max(0, SS_dest − (track + pending + repair)).Example: SS 50, available 20 → need 30, not the full demand. Bound: the leaf's own SS gap only. |
| Lateral partner (a sibling at the same echelon) | Need: need = max(0, SS_dest − (track + pending − demand + repair)).Example: SS 40, track 15, demand 10 → need max(0, 40 − 5) = 35, its own SS gap, not the 10 units of demand it will serve.Bound: the old formula used the partner's full downstream demand, causing infinite ping-pong. The fix is the destination's own SS shortfall only. |
| Intermediate WH (a wash depot, a country WH) | Need: need = max(0, SS_wh − inv_after) + max(0, cumss − own_gap − delivered).Example: SS 100, inventory 80 → gap 20; downstream SS build 150, own gap 20, already delivered 30 → +100, total need 120. Bound: the WH's own gap plus the one-time downstream SS build mass; ss_top_up parts retire via the shipper's outbound so the deficit does not re-demand every week. |
The three constraints together — why a balancing lane cannot just deplete anyone¶
Source floor gives only above SS × ratio (its own buffer) → Destination bound asks only for its OWN SS shortfall (never the partner's downstream demand) → Echelon exclusion BALANCING/ZB lanes NEVER feed the transfer rollup (lateral cycles double-count)
The concrete non-depletion example — two sibling depots (A and B) in the same zone, item X, weekly:
| Depot A (the potential giver) | Depot B (the potential receiver) | |
|---|---|---|
| On-hand (good only) | 200 | 60 |
| Own SS | 120 | 100 |
| balancing_excess_ratio | 0.3 | — |
| Protected floor | 120 × 0.3 = 36 | — |
| Giveable | 200 − 36 = 164 | — |
| B's need (bounded) | — | max(0, 100 − 60) = 40 (its own SS gap, not its downstream demand of, say, 300/wk) |
| The shipment | min(giveable 164, need 40) = 40 units — A keeps 160 (well above its floor 36), B gets exactly its own SS gap. Neither is depleted; the zone's pooled stock is unchanged; no ping-pong (B's floor is not breached by receiving). | |
Pegging — every order links to the demand it serves: direct demand pegs
(parent_order_id=0), order→order upstream links (hop_depth — the depth from end
demand), RETURN→REPAIR chains (FIFO by bad arrival ≤ release, qty in cores = good/yield), and
failure-source pegs (the bad-forecast row's series and week). The full_chain=true API walks the
whole tree (get_pegging_tree / get_order_pegging / get_demands_for_week /
_build_upstream — the PeggingTree/PeggingGraph views).

The graphical view of the full pegging* (the demo tenant, pipeline 4 “Default”,
captured 2026-11-11): series 1_315 (Chain Lube Finish Line 500ml @ Stuttgart Cycling) →
Supply tab → the projection grid’s Replenish → W30 cell (37 u
arriving) → the order’s Pegging button → Full chain toggled ON.
The graph merges same-lane orders into typed links: the root TRANSFER (W29→W30, Germany Country
Warehouse → the amber HERE demand node at Stuttgart Cycling, its 3 demand pegs merged
×3), plus its upstream replenishment lane — 4 inbound TRANSFERs merged
(×4, 194 u, W22→W23) from Central Warehouse Brussels* — the
multi-hop chain only full_chain=true walks.
The inventory projection — PIPE_supply_inventory_projection: the weekly
projected on-hand trajectory per (item, site), and its reconcile pass rebuilds non-demand-node rows from the
FINAL order set — demand-node rows are untouched (the explosion already folded the parent's demand into the
component plan); pass-through production consumption (BUILD orders decrement the maker's component stock via the
BOM map) is counted — the the demo tenant run-#11 fix. 70 verified readers: the projection charts, the exception
supply data, the replay fill-rate evolution, the constraints payloads, the route network state.
7.8 — Route inputs: LT swaps, coverage, quota schedules¶
The engines' route handling (verified): lanes WITH lead-time stats swap their LT for
final_lt_days (ceil→weeks); coverage IS the route set (the Demand-map editor writes real
inbound TRANSFER lanes — retunes, creates, retires; time-phased coverage = change points resolved per week
for demand formation, at the anchor for sizing/order choice); USE routes carry
push_quota_by_week for the LP's soiling synthesis at the release week; the MRP sourcing split is
coverage-based opportunity/cost (never the quota — the Oct 2026 directive); MEIO's LT blend and install-base
served stream read the same master.route lanes — coherent by construction since the route-native
unification (Nov 2026, 3.4–3.5).
7.9 — Allocation: turning the plan into customer promises¶
⚙ Process: the
allocationstep (allocation_runner.py+ the Rustscore_allocengine — greedy, single-level): given the supplies (planned arrivals, on-hand, the projections) and the demands (netted + firm), who gets what first? Run: the Allocation card on the Processes page (7.D for the equivalents). Its own scenario type (Point 4.5's map columns) carries the seven policy sets.
The score per (demand, supply) pair: priority policies (item/customer/segment weights) +
starvation + reservation + fairness + routing + aging + lateness + the opt-in consequence term
(a missing component's value is high only when it's the sole missing part for an otherwise-buildable
finished good — one binding child inherits the parent's priority; two binding children = doomed = zero). The
allocation consumes supply via PIPE_supply_recommendations.arrival_week (archive-pinned) + on-hand
+ firm rows — and its demand IS the netted plan (5.8's supply_plan_qty).
Outputs & consumers: PIPE_allocation_results (+ the score breakdown incl.
score_consequence) and PIPE_allocation_unfulfilled (the shortfalls); the
overview (Fig. 24) — the KPI row (clickable filters: Fill Rate → full, Total Backlog
→ shortfall, Unmet, Partially, Routing/Fair-Share flags) + the per-demand grid (requested/allocated/
shortfall/fill %/status/lateness/sources — "where from") with the drill arrows into the series pages; the
series detail Allocation tab (timeline, competition, explainability); the fill metrics feed the dashboards,
the replay's overall fill rate, and the exceptions (UnmetDemand).
7.10 — The outputs' consumers (verified)¶
| Output | Readers (grouped, verified against the code) |
|---|---|
PIPE_supply_recommendations the planned orders |
119 readers — the allocation step (its supplies), the supply page (orders panel, approval grid — approve_order/cancel_order, outbound orders), the series supply tab, the constraints/projection payloads, exceptions, alerts, the auto-approval step (ingests planned orders as recommendations), the aggregate views, the replay engine, freeze/ historize, Mirabelle ("arrivals"), the golden fixture |
PIPE_supply_exceptions |
35 readers — the supply exception list + dashboard, the sku-flow, the route-network constraints, the auto-approval constraint chain + features (a blocked order's rationale), the exceptions runner, the KPI compare |
PIPE_supply_pegging |
18 readers — the pegging tree/graph APIs, the demand-per-week drill, the upstream builder, the replay, freeze/historize, Mirabelle, scenario_guard |
PIPE_supply_capacity |
32 readers — the capacity usage/resources-overview APIs (the heatmap), the sku flow, the route network, the next run's used_qty input (the documented self-reference), the golden fixture's reset |
PIPE_supply_inventory_projection |
70 readers — the projection charts, the exception supply/IO data, the replay fill-rate evolution, the constraints + route-network state payloads, the aggregate supply view |
PIPE_allocation_results + _unfulfilled |
The overview KPIs/grid, the series allocation tab, the supply-path modal, the replay's overall fill rate (both tables — the shared compute_overall_fill_metrics), exceptions (UnmetDemand), alerts, freeze/historize |

Fig. 23 — The supply review surface (the demo tenant): the Supply page — the orders panel (planned recommendations with dates and lanes; firm rows locked with their PO refs), the capacity heatmap, the pegging views, and the approval grid. Captured 2026-11-10.

Fig. 24 — The allocation overview (the demo tenant): the KPI row (Allocated Qty, Fill Rate, Backlog, Unmet — each a clickable filter over the grid) and the per-demand fulfillment list — requested/allocated/shortfall, fill %, status, real priority/customer, lateness, and the sources ("where from"); row clicks drill into the series Allocation tab with the nav arrows. Captured 2026-11-10.
7.11 — Lane timing: the departure clock (the default)¶
⚙ Setting:
lane_timing_modeon the supply scenario.departure_clockis the default of every MRP scenario — there is nothing to switch on.arrival_clockis the legacy planner, kept for the few cases listed below. Where to change it: Pipelines → Supply Planning → open the scenario → the Lane Timing panel (auto-saved; the API equivalent is in 7.D). Thesupplystep reads it at the start of every run. The LP solver plans its own timing and ignores it.

The Lane Timing panel in the supply scenario editor (theBicycle, scenario "Baseline"): Departure clock is the default; the text under the dropdown says what it does. Captured 2026-11-18.
The problem it solves. A replenishment chain (supplier → hub → warehouse → shop) is planned backwards from the shop's demand. The legacy planner (arrival clock) sized every node on the week its demand is sold and booked each transfer one lead time earlier — but it only tested the stock a warehouse ships in the week the shipment arrives. So a warehouse could ship stock that had not landed yet (a negative balance on paper), the weekly safety-stock gap was chased by post-hoc expedite orders that piled up as surplus, and a kit could be built before its components existed. The shortage did not disappear; it was hidden as a negative warehouse balance.
The departure clock plans every node on its own clock — the day its shipment actually leaves:
| Arrival clock (legacy) | Departure clock (default) | |
|---|---|---|
| Lead times | whole weeks per lane, summed lane by lane (2 d + 2 d = two buckets) | days, with the weekday: 2 d + 2 d = one bucket |
| A shipment leaves… | when the shop needs it; the stock is tested in the arrival week | only against stock that exists on its departure day |
| Warehouse balance | can go negative (the backlog is hidden) | never negative — a shortage shows where it really occurs |
| Safety stock | shipped away like any stock | protected: real demand may use the buffer, a lateral balancing move never may |
| Closures (shipping / receiving calendars) | the shop's closed-week demand is bunched into its last open week | stock is pre-positioned along the chain (orders tagged Pre-Position); nothing ships into a closure |
| Expedites | also chase the safety-stock gap | real unmet demand only — never the safety-stock gap, never a pass-through warehouse |
| Repairs | can start on cores that do not exist yet | start only on cores that exist |
| Kits (bill of material) | built whenever the kit's demand asks | built only when the components exist; what the stock cannot back is cut and flagged |
Kits. The engine plans every SKU independently, so the departure clock adds three steps for bills of material: (1) after the first planning pass it reads, from the engine's own plan of the components, the first week each kit can start building, tells the engine, and plans again — a kit is simply not built before that week; (2) whatever the stock still cannot back is cut and raises a ComponentShortage exception that says why ("Build of 126 Drivetrain Service Kit cut to 107: component Cassette Shimano DA R9200 12sp 11-30T has 214 in stock at week 1 (1 per unit)"); (3) the components the accepted builds will use are reserved, so the transfer allocator never ships them away.
Where to change it¶
- UI — Pipelines → Supply Planning → click the scenario (or ✎) → scroll to Lane Timing (below Planning Periods). Pick Departure clock (default) or Arrival clock (legacy); the choice is saved immediately (Saving… / Saved). Choosing the default removes the explicit key, so a scenario that never left the default carries nothing in its overrides.
- API — the dedicated lane-timing endpoint (7.D): one atomic update of the single
key — it never overwrites the scenario's other overrides (unlike the replace-all
…/param-overrides). - Stored as
param_overrides.lane_timing_modeof the scenario (config_supply_scenario). Like every supply parameter it resolves scenario override → the scenario's supply parameter set → default (departure_clock); the panel shows the effective value. - Cloned with the scenario — Clone copies the whole definition row, including the setting.

The panel warns when the scenario has something the departure clock cannot plan (here theBicycle's 26-week "Short Horizon" scenario). LP-solver scenarios show the control disabled — "Not applicable".
Why you might still pick the Arrival clock¶
| Situation | Why | What to do |
|---|---|---|
| The scenario has a sub-weekly Planning Periods ladder (hourly / daily rows) | the departure clock counts in 168-hour buckets | choose Arrival clock (legacy) for that scenario (or use a single weekly row) |
| The TRANSFER lanes ship both ways between two sites, or from a site to itself (a data cycle) | the departure clock needs an acyclic forward chain: who ships to whom, never back | fix the lanes — model peer exchanges as BALANCING (lateral), delete self-loops — and pin Arrival clock until then |
| You must reproduce a plan made before 18 Nov 2026 (audit, golden-fixture comparison) | the legacy plan is byte-reproducible | choose Arrival clock (legacy) |
| The scenario uses the LP solver | the LP plans its own flow-balance timing | nothing — the control is disabled; an explicit departure_clock on an LP scenario is refused |
A planning horizon other than 52 weeks is not a reason to switch
The departure clock plans the standard 52 weekly buckets, so a scenario with another horizon_weeks
stops with an explicit error — but the legacy transfer allocator indexes the same 52-week arrays and fails
on such a horizon too (theBicycle's 26-week "Short Horizon" pipeline stops in it on either clock). Set the
horizon to 52 weeks in the scenario's supply parameter set.
What you will notice¶
- The service level of a chain can look lower than before — and that is the honest number. theBicycle's pipeline 85 went from 99.95 % to 95.88 %: the old plan reached 99.95 % only because warehouses shipped stock they did not hold. The new plan shows the physical start-up gap: with no stock on hand, the first purchase of the Cassette Shimano DA R9200 lands in week 5, so weeks 0–4 cannot be served.
- No warehouse below zero, no unbacked shipments, no safety-stock expedites — on every pipeline measured:
| Tenant · pipeline | Warehouse pairs below zero | Orders leaving before their stock exists | Expedite orders | Service level |
|---|---|---|---|---|
| theBicycle · 85 | 124 → 0 | 6,894 → 0 | 96 → 0 | 99.95 % → 95.88 % |
| theBicycle · 4 | 137 → 0 | 8,832 → 0 | 53 → 0 | 98.14 % → 94.86 % |
| theBicycle · 1 | 125 → 0 | 5,508 → 0 | 101 → 0 | 98.26 % → 96.08 % |
| GPS 1 · 2 | 2 → 0 | 16 → 0 | 0 → 0 | 88.11 % → 94.03 % |
| GPS 3 · 2 | 88 → 0 | 6,914 → 0 | 0 → 0 | 37.29 % → 49.21 % |
| GPS 4 · 2 | 84 → 0 | 6,716 → 0 | 0 → 0 | 38.90 % → 49.89 % |
| PH-ABC · 1 | 16 → 0 | 16 → 0 | 0 → 0 | no shortage in either mode |
Read-only dry runs of the supply step (files/scripts/supply_dry_run.py --compare), 18 Nov 2026 — nothing was
written. Two runs of the same input are byte-identical in both modes.
- A new order tag and a new exception type. Pre-Position orders (
TRANSFER_PREPOS) appear ahead of closures; ComponentShortage (Warning) appears when a kit build had to be cut. - The run log shows
[supply] lane timing mode: departure_clock, and the run summary carrieslane_timing_mode.
What stops the run — and what to do¶
The departure clock refuses what it cannot plan, loudly, before it plans anything:
| Message starts with | Cause | Remedy |
|---|---|---|
lane_timing: the TRANSFER lanes contain cycles … |
self-loop lanes, bidirectional TRANSFER pairs or longer cycles — named by item and site | model peer lanes as BALANCING, delete self-loops (Master Data → Routes), or pin Arrival clock meanwhile |
lane_timing_mode='departure_clock' … requires the uniform weekly planning grid |
a sub-weekly Planning Periods ladder | Arrival clock for the scenario, or a single weekly row |
lane_timing_mode='departure_clock' … plans the standard 52-week horizon |
horizon_weeks ≠ 52 |
set the horizon to 52 weeks |
lane_timing_mode='departure_clock' is set on supply scenario N, but the LP solver … |
an explicit departure_clock on an LP scenario |
remove the setting (the API refuses it at save time) |
supply_engine extension is stale … |
the Rust extension predates the kit release fence | rebuild the extension (maturin develop --release in files/supply + the copy step) |
An invalid value (anything but departure_clock / arrival_clock) is refused with HTTP 400 at save time and
with an error at run time.
After the default changed — determinism and re-baselining¶
- The setting does not weaken determinism: the same inputs and the same pinned planning date produce byte-identical plans in either mode.
- The next supply run of every MRP scenario produces a different plan than the previous one (the departure clock is a different planner). Stored results are not rewritten: frozen Scenario-Review snapshots and finished replay runs keep the plan they were made with, so comparing a new plan with them shows a one-time step caused by the planner, not by the business.
- Golden-fixture comparisons across the change must be re-baselined once per tenant; Arrival clock reproduces the legacy plan exactly (the saved-plan fingerprints of theBicycle pipelines 4 and 85 and of GPS 1 pipeline 2 were verified identical).
- Impact check before the first real run:
python files/scripts/supply_dry_run.py --db <tenant> --pipeline-id N --compareplans both clocks without writing anything and prints the comparison (pairs below zero, unbacked orders, expedites, service level, determinism).
Known limits
- A closure that pulls several weeks of a kit's need into one pre-closure build can exceed the plant's weekly capacity — the capacity scheduler only delays a build, it never builds earlier, so the lump lands after the closure (theBicycle what-if "shipping closed weeks 30–34": about 440 units short around the closure).
- A kit build the capacity scheduler pushes into overtime can still land inside a receiving closure.
- The quantity guard cuts a build; it does not re-time it. Kits planned at store sites are guarded but not fenced.
- Components that are stocked later by transfers are not judged at the first planning pass.
7.D — For developers — the supply & lane-timing APIs¶
The UI paths above cover the planner's loop; the equivalents for scripts and add-ons:
| Call | Purpose |
|---|---|
POST /api/pipeline/run/supply \| /allocation {"pipeline_id": N} |
Run the two steps standalone (CLI: python files/run_pipeline.py --only supply \| allocation --pipeline-id N). |
PUT /api/supply/scenarios/{id}/lane-timing — body {"mode": "departure_clock" \| "arrival_clock"} |
The Lane Timing panel's endpoint: one atomic update of the single key (COALESCE(param_overrides,'{}') - 'lane_timing_mode' then || jsonb_build_object(...)), never clobbering the scenario's other overrides. The response carries the effective mode. Invalid values → 400; departure_clock on an LP scenario → refused. |
PUT /api/supply/scenarios/{id}/param-overrides |
The replace-all overrides write the Full-edit modal saves (the lane-timing endpoint above is the safer single-key variant). |
7.T — Step-by-step test walkthrough¶
Supply planning and allocation, verified on real output.
| # | Where to look / what to click | You should see |
|---|---|---|
| 1 | Pipelines → Supply Planning → scenario editor | pick solver_type (MRP / LP); optionally the Planning Periods ladder |
| 2 | Processes → Supply card → Run | orders computed; exceptions flagged for anything the plan cannot do cleanly |
| 3 | Supply page (/supply) |
orders panel with release/arrival weeks; firm rows locked 🔒 with PO refs; capacity heatmap; approval grid |
| 4 | Click an order → Pegging → Full chain | the demand chain the order serves, multi-hop |
| 5 | Processes → Allocation card → Run | customer promises computed from the plan |
| 6 | Dashboard → Allocation tab | KPI row (click a KPI → filters the grid); per-demand rows with lateness + sources |
| 7 | Scenario → Full edit → Planning Horizon → Block per Order Type ON → re-run | no new recommendation of that type before the latest firm order's release week |
| 8 | Pipelines → Supply Planning → scenario editor → Lane Timing | Departure clock (default) selected; an amber note when the scenario has a sub-weekly ladder or a horizon ≠ 52; the control is disabled ("Not applicable") on an LP scenario |
| 9 | Lane Timing → Arrival clock (legacy) → Saved → re-run supply → Supply page | the plan is the pre-Nov-2026 plan (warehouses can go negative, safety-stock expedites return); switching back to the default removes the key and the next run is clean — no warehouse below zero |

The supply review surface: orders, capacity heatmap, approval.

KPI filters + the per-demand fulfillment grid.