Chapter 10 — Scenario Planning¶
10.1 — Chapter summary¶
⚙ Processes: no single step — the scenario-planning surfaces orchestrate the pipeline steps. The pipelines (config_scenario_pipeline) link the scenario of each type to the steps; workflows (process_workflow) chain the steps and can be run, modified, and inspected in the ProcessRunner; replay re-runs supply+allocation at historical planning dates; historization archives the outputs; the approval gates release forecast/MEIO results; the auto-approval engine decides supply recommendations.
Scenarios (12+ types, per segment) → Pipelines (config_scenario_pipeline links each type) → Workflows (process_runner chains the steps) → PIPE_ outputs (Points 3–7) → Approval gates → Replay & the audit surfaces
10.2 — Pipelines & scenarios¶
⚙ Process: no engine of its own — the pipeline editor binds, the scenario editors configure. Run: Pipelines → Pipeline tab → a pipeline's Edit (the linking modal), or any of the per-type tabs (Forecast / Causal / MEIO / Supply / Allocation / Exceptions / Classification / Lead Time / Archiving / Import) for the scenario's own parameters. All auto-saved (~800 ms); creating a scenario is the one explicit Create button.
A scenario really is a configuration that can be varied and reused in various pipelines.
A scenario carries a name, a description, and TYPED parameters — it owns no data of its own until a pipeline
runs it. A pipeline binds ONE scenario per type via config_scenario_pipeline — the 13+ FK columns
(series, causal, maintenance, inventory, meio, supply, allocation, exception, classification, import, approval,
lead_time, historization, demand_coverage) — and every step resolves its own scenario from the pipeline at
run time, never from global state. The split of labor:
| Scenario type | Configuration and consumers |
|---|---|
| Series (forecast) | Configures: method-selection pools, confidence levels, horizon limits, netting toggles, and forecast mode. Consumed by: forecast, outlier, and backtest (5). |
| Causal | Configures: fleet plans, usage, deployments, failure rates, coverage, and causal BOM. Consumed by: causal (5.4). |
| Maintenance | Configures: events, maintenance BOM, and firm-vs-net mode. Consumed by: maintenance (5.5). |
| MEIO | Configures: service level, zone pass, V4 mode, demand basis, scope, and universe. Consumed by: MEIO (6). |
| Supply | Configures: solver type (MRP/LP), fences, and source priorities. Consumed by: supply (7). |
| Allocation | Configures: seven policy sets (priority, starvation, reservation, fairness, routing, aging, lateness). Consumed by: allocation (7.9). |
| Exception | Configures: thresholds, snoozes, and the review workflow. Consumed by: exceptions (8). |
| Import | Configures: object list, load modes, and dependency order. Consumed by: import (2). |
| Approval | Configures: auto-approval rules, SL-recovery guard, and thresholds. Consumed by: approval (10.5). |
| Lead-time | Configures: lookback, min_obs, and bootstrap iterations.Consumed by: lead-time (3.6). |
| Historization | Configures: object list, retention, and trigger. Consumed by: archiving (10.6). |
Reuse and variation, live (the demo tenant, 5 pipelines). The same scenario linked from several pipelines is ONE configuration executed in several contexts — and varying the LINK (not the scenario) is the A/B experiment. On the demo tenant the series scenario #1 "Base" is linked by all five pipelines (one forecast configuration shared everywhere); the supply scenarios split the family: #2 on the two MRP pipelines (2 "Rust greedy", 4 "copy") vs #3 on the LP pipeline (3 "HiGHS") — everything else identical, so pipelines 2 and 3 are a controlled MRP-vs-LP A/B; the MEIO scenario is varied on pipeline 4 (#2) against the shared #1 on the others. A NULL link = the feature is dormant on that pipeline (approval, import, historization and allocation are NULL on all the demo tenant pipelines — those steps no-op or fall back to engine defaults).

Fig. 37 — The pipelines list (the demo tenant, Pipeline tab): one row per pipeline; the per-type scenario links — the forecast stack (series → causal → maintenance), inventory, MEIO, supply, exception — are INLINE editable dropdowns: changing a cell re-binds the pipeline to another existing scenario of that type (never a copy). The Config expander, Edit, Clone, Delete actions and the prod toggle sit on the right. Captured 2026-11-11.

Fig. 38 — The pipeline editor (the demo tenant, pipeline 3 "the network - LP (HiGHS)"): THE linking surface — one dropdown per scenario type (what the pipeline binds), plus the netting modes (causal/maintenance add-vs-replace), the netting sequence, the approval gates, segment scope and the input-provenance fields. Editing a scenario's PARAMETERS never happens here — that is the scenario editor's job. Captured 2026-11-11.

Fig. 39 — A scenario editor (MEIO, the demo tenant): the configuration side of the split — service-level type, the zone pass, V4 network mode, demand basis/scope, the per-segment parameter sets — all auto-saved ~800 ms after the last keystroke. The scenario never names a pipeline; pipelines name it. Captured 2026-11-11.
Cascade delete: a referenced scenario is blocked (409); a pipeline delete wipes all its
data (the dynamic column discovery in cascade_delete.py); base scenarios are non-deletable.
10.3 — Workflows & the ProcessRunner¶
⚙ Process: two layers on the Processes page (route
/processes): the Processes tab — every process individually configurable and runnable, each against a chosen pipeline — and the Workflows tab — ordered groups of steps run as one chain. Run: a process card's Run (it carries the chosen pipeline + the optional segment scope), or a workflow's Run with its live progress stream (the API equivalents are in 10.D).
Processes — run individually on different pipelines. The Processes tab shows one card per registered process: the two INDEPENDENT processes first (Stage — with its "Tenant-wide" chip and the configured customer-ETL process chip; Import — with its linked import scenario chip or the honest "None"), then the pipeline chain (Demand aggregation → … → Archiving) as numbered cards. Every card carries:
| On each process card | What it does |
|---|---|
| 📋 Pipeline selector | Overrides the left-toolbar active pipeline for THAT run — the run carries the chosen pipeline + that pipeline's own scenario resolution. Re-run MEIO on pipeline 2 while pipeline 3 keeps its last supply output; the card even shows "Pipeline: …" when the run landed elsewhere than the active. |
| 🏷 Segment scope | Optional segment_ids — the run touches only the scoped SKUs (NO_SEGMENT_STEPS excluded) |
| ⚙ Configure | Opens the process's configuration modal: Stage = the tenant-wide process + directory; Import = the linked import scenario; Demand aggregation = the data_source parameter set (zero-fill, min-observations, date range) |
| Run / Re-run / Stop | Per-card job with live log lines, progress (per-series for forecast/backtest/characterization), status badge and duration |

Fig. 40 — The Processes tab (the demo tenant): the independent processes (Stage "Tenant-wide" + process chip, Import with its scenario chip), then the numbered pipeline chain. Every card carries the 📋 pipeline selector (run THIS process on ANY pipeline), the segment scope, ⚙ Configure and Run. Captured 2026-11-11.
Workflows — the grouping. A workflow (process_workflow) = a name + an
ordered step list + an optional segment scope + an optional PINNED scenario pipeline (absent = the
left-toolbar active pipeline). The editor drags/reorders steps, adds/removes them from the palette —
stage/import are opt-in members like any other step (the stored list owns their presence, nothing
force-reinserts), and the stage row carries a per-workflow customer-ETL process dropdown. The seeded Default
Workflow carries ["stage","import"] + PIPELINE_STEP_ORDER. Run executes the chain sequentially
with per-step status, logs and SSE progress; Kill & Restart clears orphans; a run survives a page reload
(the run id re-attaches from the workflow runs registry).

Fig. 41 — The Workflows tab (the demo tenant): the four stored workflows — Default Workflow (pinned to pipeline #1), the full forecast workflow (#1), MRP (#2), LP (#3) — each card shows its step count and list, the 🏷 segment scope and the 📋 pinned pipeline. The same chain, pinned to different pipelines, is the reuse pattern at the process level. Captured 2026-11-11.

Fig. 42 — The workflow editor (the demo tenant, MRP): the grouped definition — name, the ordered step list (drag to reorder), the palette to add/remove steps (stage/import re-addable), the per-workflow stage customer-ETL dropdown, the segment scope and the pinned scenario pipeline. Captured 2026-11-11.
Not to be confused with the Replay. Workflows run the CURRENT planning week on a scenario pipeline; the replay engine (10.4) re-runs supply+allocation at HISTORICAL planning dates on a dedicated replay pipeline — a different thing entirely.
10.4 — Replay: re-running at historical dates¶
⚙ Process: the replay engine (
replay/replay_engine.py) behind the Replay page (sidebar → 🔄 Replay, route/replay). Run: the page's New replay run (source pipeline + a Monday-anchored date window) — a background thread iterates weekly; each iteration replans at its own pinned planning date (the API equivalents are in 10.D).
What it covers. A replay copies a source pipeline into a dedicated REPLAY pipeline, then iterates week by week over the historical window: each Monday iteration re-runs supply + allocation only, receiving the firm orders that arrived since the previous iteration (delta windows — iteration 1 receives nothing: pre-window arrivals are already in the on-hand snapshot). The forecast chain is NOT re-run — it bootstraps once from the frozen archive (a replay pipeline starts with empty PIPE_ data; the first iteration auto-runs the forecast chain and reuses it). Stage/import/demand-aggregation are REFUSED outright — they mutate master data. The engine's contracts:
| Contract | Meaning |
|---|---|
| Monday alignment | Every iteration's archive joins on the planning Monday. |
| Side-effect-free | Every on-hand delta is journaled and reversed on completion, failure, and cancel; replays never leave permanent state. |
| Forbidden steps | Stage, import, and demand aggregation are refused because they mutate master data. |
| Archive pinning | The supply engine reads netting and recommendations pinned to the exact archive Monday; this prevents Frankenstein streams. |
| Fresh slate | Previous attempts' partitions and journal are cleaned before re-running. |
What the dashboard shows. The runs list (each with its window, iteration count and status), the per-iteration fill-rate comparison against the frozen baseline, the per-SKU metrics, the worst-offenders ranking (which SKUs/sites systematically starved across the window), and the per-iteration drill (the exact orders, receipts and shortages the plan WOULD have committed that week).

Fig. 43 — The Replay Dashboard (the demo tenant): the historical re-run list (each iteration at a pinned planning date, with the supply+allocation results and the fill-rate comparison against the frozen baseline), the journal reversal contract (side-effect-free replays), and the iteration timeline. Captured 2026-11-10.
Why this is important — where the business value is. A backtest scores a forecast (sMAPE on a series); the replay scores the plan end-to-end: it re-runs the real chain at past dates with only the data known at the time, then compares against what actually happened — answering the questions a backtest cannot:
| The question | What the replay answers it with |
|---|---|
| Would the plan have WORKED? | Hindsight measurement: end-to-end fill rate, backlog and shortage per iteration vs the real demand that materialized — the plan's true quality, not the forecast's fit statistic |
| Where does the plan break? | The worst-offenders list turns "the plan feels off" into a ranked, quantified hit list of SKUs/sites — a targeted worklist, not a feeling |
| Would a change have been better? | Counterfactual A/B: clone the replay pipeline, vary one link (the supply scenario, a fence, a safety stock), re-run the SAME window — compare against the real past |
| Why should planners trust it? | The receipts: week-by-week evidence of what the engine WOULD have done — the adoption driver for the live weekly plan |
Because replays are side-effect-free (the on-hand journal is reversed on success, failure AND cancel) and run on their own dedicated pipeline, the historical re-run never contaminates the live plan — the experiment is always safe to run.
10.5 — Approvals: release gates + the auto-approval engine¶
The result approval gates (Design A) — the forecast and MEIO release gates
(utils/result_approval.py): approved results are the released plan; unapproved results are
drafts. When a re-run supersedes an approved week, the old approval is auto-marked superseded and the plan
falls back to the previous approved bucket. The approval UI offers a re-run (compute + approve in one).
The auto-approval engine (Point 7's supply recommendations) — the rule+model decision
pipeline: LightGBM champion / XGBoost challenger, isotonic calibration, one champion per tenant DB. Rules
short-circuit the model (auto_approve/auto_reject/mandatory_review); thresholds are governance-tunable via
files/auto_approval/config.yaml without redeploying.
| Decision | Condition | Outcome |
|---|---|---|
| auto_approve | p_approve > 0.99 (or a matching auto_approve rule) |
Approved automatically |
| review_approve | p_approve > 0.95 |
Planner confirms |
| manual_review | Everything else | Routed to the supply approval grid |
10.6 — History: the archive-date buckets¶
The standalone PIPE_ → HIST_ archiver and the HIST_ mirrors were retired
(Dec 2026): every run's results live in the PIPE_ tables' own
(pipeline_id, archive_date) partitions — a writer replaces the partition
holding the same archive date before inserting, so the latest bucket is
always the current plan and older buckets remain the run history. The
result-approval gate (§10.5) certifies released buckets; a cleanup pass
keeps the last two live buckets plus every approved one.
10.7 — Replay: the page¶
The Scenario Review / freeze surface (the former KPIs page — frozen
snapshots, KPI compare, delta explorer, snapshot replay, stability, pareto)
was removed in Dec 2026: the archive-date buckets above keep every
run's history and the approval gate certifies released content, so the
frozen-copy machinery had no remaining job. What survives is the Replay
page (sidebar → 🔄 Replay, route /replay): the replay engine's run
management — start a historical re-run, watch progress, analyse fill-rate
and stock evolution per iteration (§10.4).
10.D — For developers — the orchestration APIs¶
The UI paths above cover the planner's loop; the equivalents for scripts and add-ons:
| Call | Purpose |
|---|---|
POST /api/pipeline/run/{step} |
Run one process standalone — carries the chosen pipeline_id + optional segment_ids; that pipeline's own scenario resolution applies. |
POST /api/workflow/run · GET /api/workflow/runs (+ /{id}) · GET /api/workflow/runs/{id}/stream · POST /api/workflow/runs/{id}/kill |
The workflow chain: start, re-attach after a page reload (the registry), the SSE progress stream, and Kill & Restart. Each replay iteration runs its steps as subprocesses with REPLAY_PLANNING_DATE set — never mutating the API process's environment. |
POST /api/replay/runs (+ /{id} PUT/GET/DELETE, /{id}/start, /{id}/cancel, /{id}/iterations, /{id}/stock-evolution, /{id}/fill-rate-evolution, /{id}/supply-orders, /{id}/allocation-results, /{id}/sku-metrics, /{id}/series-detail) |
The replay lifecycle + the per-iteration drill-downs the dashboard renders. |
10.T — Step-by-step test walkthrough¶
Scenario planning, workflows, replay — the orchestration layer.
| # | Where to look / what to click | You should see |
|---|---|---|
| 1 | Pipelines → Pipeline tab | one row per pipeline; the per-type scenario cells are INLINE dropdowns (re-bind) |
| 2 | Row → Edit | the linking modal: one dropdown per scenario type + netting modes + approval gates |
| 3 | Bind the same series scenario on two pipelines → run both | one configuration, two contexts — the reuse pattern |
| 4 | Row → Clone | a pipeline copy for A/B |
| 5 | Processes tab → any card → 📋 pipeline selector → Run | THIS step runs on the CHOSEN pipeline, not the toolbar's |
| 6 | Workflows tab → New workflow → add/reorder steps → Run | SSE progress streams; reload the page → the run re-attaches |
| 7 | Replay page (sidebar → 🔄 Replay) → New replay run | pick source pipeline + Monday window → run; review iterations, fill-rate deltas, worst offenders |

The per-type scenario links — inline editable dropdowns.

Step order, palette, scope, pinned pipeline.

Historical re-run comparison.