L4 — Decision runtime architecture
The decision layer lives in knowledge-reasoning. Its DecisionRuntime takes evidence into a plant work queue, builds a decision case against the Plant Situation Model, and produces at most one owned Prescription draft per condition. As built, that draft is the card proposal, and L4 can also withhold or abstain, always with a trace. L4 runs scheduling repair and Ask, where agents use typed read-only tools. It never assigns the final person, sends messages or writes equipment or master data. Thirty-one deep docs cover the runtime, from the kernel to the as-built map.
- Status
- contract + as-built (runtime) + direction
- Conceptual layer
- ④ Decision
- Repo layer
- L4
knowledge-reasoning - Source
- architecture section 1, section 3.6.4, section 5.3, section 8
- As-built map
30-as-built.md- Normative kernel
00-kernel.md- Product
Stamped_Master_Document.md· ADR-018 amended
L4 turns plant conditions into at most one owned PrescriptionWhat to do, why, who, check plan (direction; as built: prescription.json 1.0.0 / card-proposal) draft (as built: card proposal) — or withholds / abstains with a full trace. Humans decide and execute. L5 owns the live card (ClosureStateEleven code states on the live card (direction; as built: stamped_l5_domain/cards/states.py)). L3 owns detection methods and money calculation. L2 owns plant source-of-truth records. L4 owns DecisionRuntime, the derived Plant Situation Model, and the opportunity ledgerStore of every blocked candidate with gate id and later outcome if known.
The live compile path is DecisionRuntime (stamped_l4.runtime + worker/decision_runner.py). Legacy LangGraph prescription-compiler graphs may remain in the consumer tree; they are not the EvidenceLayer contract for detector output (direction; as built: Finding finding.json 1.2.0) → card compile path. See 30-as-built.md.
How to read it.
- Evidence or discovery enters the per-plant queue and becomes a DecisionCase with a frozen PSM snapshot.
- The registry stage graph runs constraints and portfolio before the kernel re-check.
- Only
emit/supersedecall CardSink; everything else is traced and soft blocks feed the opportunity ledger.
Build now: shadow DecisionRuntime + Ask read path. Later: full Prescription contract fields and Plant Box fast-loop coupling (../fast-loop/).
View Mermaid source
flowchart TB
%% house-style: l4-readme-runtime
subgraph in["Intake"]
direction LR
ev["L3 Evidence<br/>(as built: Finding)"]
disc["Discovery / shift sweep"]
end
subgraph rt["DecisionRuntime"]
direction LR
q["Plant work queue"]
dc["DecisionCase + PSM"]
st["Stage graph + portfolio"]
end
gate{{"Kernel re-check"}}
l5["CardSink → L5 Prescription"]
tr(["↩ DecisionTrace + opportunity ledger"])
in --> q --> dc --> st --> gate
gate -->|"emit / supersede"| l5
gate -->|"withhold / abstain / hold"| tr
classDef govc fill:#fff4d6,stroke:#c99a2e,color:#000
classDef agentc fill:#e8f0ff,stroke:#5b7bd5,color:#000
classDef loopc fill:#eef7ee,stroke:#4f9a4f,color:#000
class gate govc
class tr loopc
Eight ideas this set leads with#
- A small kernel of rules; everything else is replaceable. Code owns terminals, hard stops, money references, constraint checks, and the one-card rule. Models, prompts, and registries live inside and swap by release (D9).
- See the whole plant, decide about one thing. The Plant Situation Model holds structure, history, and state. Each run gets a focused, provenance-tagged slice.
- Constraints are code, not prose. Typed predicates return satisfied, violated, or unknown. A model may explain; it never evaluates a gate.
- Evidence before words. Every claim cites a ledger row. Uncited claims are dropped. Models never assign an evidence tierContract tier on claims: measured / confirmed / modeled / unknown; quantity labels per D13 or a rupee (D13).
- Two ways in, one way out. Evidence (FindingAs-built L3 detector output admitted to L4 (finding.json 1.2.0)) and discoveries meet the same floor, the same constraint check, and the same portfolio.
- The plant is a portfolio. Cards carry footprints; overlapping footprints conflict; owners have a per-shift budget (exceptions exempt via registry).
- Built to change, including at the core. Domains, families, workflows, stages, analyses, patterns, constraint kinds, tools, prompts, memory missions, and model pins are versioned registry entries under one release lockfile. The kernel never names a specific domain.
- Nothing is silently lost, and every block teaches. Soft-gate blocks reach the opportunity ledger and the owner's backlog. Exploration measures whether blocked items would have helped. Soft gates then move on evidence.
Reading order#
Table: 32 rows by order
| Order | Doc | Role |
|---|---|---|
| 0 | 00-kernel.md | Normative frozen surface |
| 1 | 01-system-overview.md | End-to-end picture + Mermaid |
| 2 | 02-plant-structure.md | Site-pack topology |
| 3 | 03-plant-situation-model.md | PSM |
| 4 | 04-constraints.md | Typed constraints |
| 5 | 05-context-engineering.md | Ledgers and zoom |
| 6 | 06-memory.md | Hindsight, case library |
| 7 | 07-finding-runtime.md | Finding → terminal |
| 8 | 08-discovery.md | Scanners, patterns, hypothesis lane |
| 9 | 09-portfolio.md | Dedupe, conflict, attention |
| 10 | 10-domain-analyses.md | Domain plug-ins |
| 11 | 11-models-and-seams.md | Dual family, Jev seams |
| 12 | 12-trace-and-eval.md | Trace and pass^k |
| 13 | 13-improvement.md | Offline council |
| 14 | 14-ask.md | Ask over L4 |
| 15 | 15-l3-l4-interface.md | Contract with L3 |
| 16 | 16-operations.md | Deploy and monitor |
| 17 | 17-change-guide.md | How to expand |
| 18 | 18-contract-deltas.md | Cross-layer deltas |
| 19 | 19-failure-modes.md | Named failure modes |
| 20 | 20-benchmark.md | How we know it works |
| 21 | 21-registries-and-stage-graph.md | Registries |
| 22 | 22-missed-opportunities.md | Opportunity ledger |
| 23 | 23-oe-knowledge-corpus.md | OE literature RAG (advisory) |
| 24 | 24-architecture-gaps.md | Gap audit (historical + pointers) |
| 25 | 25-work-queue-and-concurrency.md | Plant work queue |
| 26 | 26-decision-case-lifecycle.md | Case states, leases, resume |
| 27 | 27-ports-and-reliability.md | Timeouts, retries, breakers, idempotency |
| 28 | 28-commissioning-and-controls.md | Safe-start, kill switch |
| 29 | 29-software-quality-and-release.md | Tests, CI, SLOs, durability |
| 30 | 30-as-built.md | Shipped package map + compile path |
| — | glossary.md | Terms |
Fast loop (direction): plant-side twin, writer and message budgets live outside L4; L4's touch points are 15 section 13 and 22 (missed-savings vs opportunity ledger). Design: ../fast-loop/.
ADRs#
| ADR | Title |
|---|---|
| 020 | Decision runtime |
| 021 | PSM and memory |
| 022 | Discovery |
| 023 | Dual-family models |
| 024 | Site-pack topology |
| 025 | Soft gates / opportunity ledger |
| 027 | Production hardness |
Research#
- Peers and literature:
../../research/plant-efficiency-exploration-2026-09/19-l4-agent-peer-systems.md - Vision wins on conflict:
../../research/plant-efficiency-exploration-2026-09/09-stamped-founder-vision.md
What this is not#
Not code. Not a schedule optimizer. Not equipment write. Not a second plant UI. Not a graph product in L2.
v1 slice vs later#
| v1 (docs + as-built runtime) | Later |
|---|---|
Architecture docs 00–29 + as-built Finding runtime / PSM / seams / ledger / queue / controls (30-as-built.md) | Harden SQL-backed case/trace loop; expand discovery certification |
| Four outcomes (master document); registry ids may expand | Additional outcomes / families by registration |
| Cross-plant memory / priors | Not in v1 (designed seam only) |
| OE corpus Tier A public ingest | Broader Tier B/C under license / owner packs |
Deep docs in L4
- L4 kernel (normative)Frozen surface — changes only through an ADR, a kernel version bump, and a full replay.
- L4 system overviewHumans decide and execute. L5 owns the live card after emit.
- Plant structure and commissioningCross-asset checks need more than a list of assets.
- Plant Situation Model (PSM)A DecisionCase needs more than the Evidence (Finding) local window.
- Constraints and resources“Code withholds on a known constraint conflict” is only true if code can evaluate the constraint.
- L4 context engineering — ledger, partitions, zoomModels judge options. They do not invent plant facts, money, or evidence tiers.
- MemoryMemory improves the next card without poisoning thresholds, inventing outcomes, or letting Ask chat rewrite plant truth.
- Finding runtimeThis doc is the Evidence (as built: Finding finding.json 1.2.0) path from L3 intake to a terminal.
- DiscoveryL3 detectors catch registered conditions.
- PortfolioThe plant is not one card at a time in isolation.
- Domain analysesProduct framing today is five domains (ADR-018).
- 11. Models and seamsL4 puts models inside named seams. Code owns the stage graph, money references, constraint evaluation, and terminals.
- 12. Trace and evaluationEvery L4 run leaves a DecisionTrace. Replay, eval, and improvement all read the same ledger.
- 13. Improvement loopL4 gets better from what it sent and from what it held back.
- 14. AskAsk is a view over L4, not a second product.
- 15. L3-L4 interfaceL3 owns methods (detect, price, test, simulate, build verification plans).
- OperationsL4 on a live plant is a pinned release, a dual-family model slot, and a short list of rates somebody watches.
- Change guideL4 is built to change at the edges and, when needed, at the core — without rewriting the kernel every time.
- Contract deltas (cross-layer)Documentation and schema intents for L4 to run against L1–L6.
- Failure modesNamed ways L4 goes wrong on a plant — each with a detection signal and a mitigation that points at the kernel or a sibling doc.
- BenchmarkL4 works when held-out DecisionCases, gates, and human closures say so — not when a vendor claims a model is “best for manufacturing.” Numbers that are not measured on a named suite or plant are illustrative or omitted.
- Registries and stage graphThe kernel stays small. Domains, workflows, soft thresholds, and model pins change weekly in v1.
- Missed opportunities and gate calibrationStrict gates protect the floor. The same strictness can hide real waste.
- OE knowledge corpus (advisory retrieval)Plant memory answers what worked here. Detectors answer what is happening now.
- L4 architecture gap audit — agentic stack + industrial hardnessNothing in this table loosens hard stops or claims verified savings; verified savings are ₹0.
- Work queue and concurrencyL3 Evidence (as built: Findings), PSM events, shift sweeps, Ask sweeps, and backlog promotes arrive together.
- DecisionCase lifecycleA DecisionCase is a durable unit of work, not a single request.
- Ports and reliabilityL4 is a composition of ports. Production readiness is mostly how those ports fail.
- Commissioning, safe-start, and plant controlsA correct DecisionCase design can still harm a plant if emit is enabled before topology, constraints, and methods are honest.
- Software quality and release gatesDecision integrity (kernel) is necessary but not sufficient.
- L4 — As-built decision runtimeMaps what is implemented today under src/stamped_l4/runtime/.
Page history: last 5 changes
- docs(technical): rewrite l4 21-30, glossary and README; reconcile architecture gaps
e7fead7 - docs(handoff,l4): fast-loop architecture handoff, L4 procedure and ledger links, indexes
0f45a47 - docs(decisions): add ADR-033..038 (twin runtime, fast read path, plant-side writer, message classes, alerts and quality-to-lot link, part-keyed parameters), fast-loop technical set, rebuilt index with renumbering map; fix bare-number link text and ranges
22e2872 - docs(decisions): renumber live ADRs 001-032 in order, mark withdrawn refs ADR-W###, repoint withdrawn links to archive, note partial supersessions
36c944e - docs(architecture): align identity with the four-outcome master document
1663dd2