Goal
Implement permanent REQ-PRODUCTION-005: deterministic Phase-5 physical production/extraction execution from the already-integrated ProductionPlan and LaborAllocation evidence, followed by the canonical post-production OUTPUT sell intent, with exact input/resource conservation and no phantom stock.
Evidence
- Current
master is 06bd1a5082015f0bac08ba30f0b71a7c3f217155; REQ-PRODUCTION-002..004 are integrated, so Phase 5 can consume deterministic current-tick ProductionPlan/LaborAllocation evidence and authoritative ProductionUnit live inventories/capital.
- Canonical Drive Handoff/05 §16 defines realized batches as the non-negative minimum of planned, input, allocated-labor, effective-capacity and finite-resource bounds. Exact recipe inputs and extraction deposits decline once; exact recipe output enters the ProductionUnit OUTPUT inventory first; labor is not refunded when a later physical bottleneck binds; no routine random production multiplier exists.
- Handoff/05 §17 requires the post-production OUTPUT SELL intent before Phase 6: reserve =
outputSalesEma × outputCoverageTicks; sellable output = max(0, outputInventory - reserve); actor is the ProductionUnit, purpose INVENTORY_REBALANCE, bucket OUTPUT, and sourcePlanId is the ProductionPlan.
- Handoff/05 §26 requires finite extraction deposits to bind and deplete exactly once; depleted deposits produce zero further extraction.
- The registry acceptance for
REQ-PRODUCTION-005 requires realized batches never exceed plan/input/labor/capital/resource bounds, exact stock deltas, output-first inventory flow, canonical market settlement for sales, and no phantom/random stock creation.
OPEN_QUESTIONS.md has no unresolved blocker for this boundary.
Scope
- Add an authoritative live Region resource-deposit balance keyed by resource/good identity, initialized deterministically from
RegionSeed.deposits without changing the immutable scenario seed.
- Implement deterministic one-unit Phase-5 production execution for ACTIVE units only. Validate current-tick plan/unit/recipe provenance and finite non-negative evidence before deriving bottleneck bounds.
- Input bound: minimum live INPUT quantity / recipe input-per-batch coefficient; zero-input recipes are unbounded by inputs.
- Labor bound: current unit allocation total /
max(recipe.laborPerBatch, numeric.quantityEpsilon), with +Infinity when laborPerBatch == 0.
- Capital bound: current ProductionPlan
effectiveCapacityBatches.
- Extraction bound: for recipes with
extractionResourceId, remaining live regional deposit / positive extractedResourcePerBatch; non-extraction recipes are unbounded by resources.
- Realized batches =
max(0, min(planned, input, labor, capital, resource)); consume exact input quantities once, deplete exact extraction quantity once, and credit exact recipe output once to the unit OUTPUT inventory.
- Preserve
WorldState immutability during planning/execution evidence creation; persist the physical deltas through an explicit state-transition function returning a new WorldState/registries.
- Execute units in stable
ProductionUnitId order and reject duplicate/stale/cross-unit/cross-region evidence rather than silently aggregating it.
- Build canonical post-production SELL intents from the post-execution OUTPUT balance and
outputCoverageTicks, using OUTPUT inventory bucket and the ProductionPlan as source.
- Add sensitive regressions for plan/input/labor/capital/resource bottlenecks, finite depletion and depleted-zero behavior, exact once-only input/resource/output stock transitions, output-first sale intent, non-ACTIVE zero execution, malformed provenance, insertion-order determinism and input-world immutability.
- Add a truthful
REQ-PRODUCTION-005 = IMPLEMENTED ledger row only if this exact branch earns the full boundary; keep MERGE_COMMIT blank until integration.
Non-goals
- No Phase-6/8 market-clearing or settlement algorithm changes; this slice emits the existing canonical MarketIntent and ordinary sale realization remains owned by the market stack.
- No Phase-12 investment conversion/capital formation/depreciation (
REQ-PRODUCTION-006).
- No Phase-14 lifecycle transitions (
REQ-PRODUCTION-007) or integrated M4 closure (REQ-PRODUCTION-008).
- No new random production multiplier, same-tick revenue financing, labor refund/reallocation, persistent worker-employer matrix, M5 trade/FX, M6 fiscal/Clan dynamics, M7 monetary dynamics, M8 demography/migration, or
docs/spec/mirror/** edits.
Acceptance criteria
- ACTIVE-unit realized batches equal the non-negative minimum of planned, live-input, actual-labor, effective-capacity and finite-resource bounds; no bound may be exceeded and non-ACTIVE units realize zero.
- Exact recipe input quantities are debited once from INPUT inventory; exact finite extraction quantity is debited once from the owning Region's live deposit; exact output is credited once to OUTPUT inventory. No negative stock, duplicate depletion or phantom output can occur.
- Extraction recipes with depleted deposits realize zero; non-extraction recipes have no fabricated resource constraint. Invalid extraction provenance/amounts fail fast.
- Labor evidence comes only from current-tick allocations for the same unit/region/category and is never refunded/reallocated because another Phase-5 bottleneck binds.
- Phase-5 evidence construction does not mutate input WorldState. The explicit physical transition returns a new world and preserves unrelated wallets/inventories/capital/state.
- Post-production OUTPUT SELL intent uses the post-execution OUTPUT balance, canonical reserve
outputSalesEma × outputCoverageTicks, purpose INVENTORY_REBALANCE, bucket OUTPUT, stable MarketIntent ID and the current ProductionPlan as sourcePlanId; zero sellable output emits no material sale quantity.
- Shuffled plan/allocation/registry insertion order produces normalized-equivalent execution results and intents in stable unit order.
- Sensitive tests cover Handoff/05 PCL-T1/T2/T3/T10/T12/T18/T26-shaped cases and fail under controlled removal of an input/resource/output mutation or a bottleneck.
- Exact-head TypeScript typecheck/tests/build, retained .NET build/test, policy/generated-status/ledger checks and mergeability are green before handoff. The authoring run stops at the producer→judgement boundary for SLOPSTER.
Verification
Run focused production-execution regressions plus repository TypeScript gates, retained .NET gates, implementation-status generation/check, policy checks and exact-head mergeability. Inspect the final diff for no mirror edits, no market-settlement rewrite, no investment/lifecycle/M5+ scope creep, and no second physical-stock authority.
Goal
Implement permanent
REQ-PRODUCTION-005: deterministic Phase-5 physical production/extraction execution from the already-integrated ProductionPlan and LaborAllocation evidence, followed by the canonical post-production OUTPUT sell intent, with exact input/resource conservation and no phantom stock.Evidence
masteris06bd1a5082015f0bac08ba30f0b71a7c3f217155;REQ-PRODUCTION-002..004are integrated, so Phase 5 can consume deterministic current-tick ProductionPlan/LaborAllocation evidence and authoritative ProductionUnit live inventories/capital.outputSalesEma × outputCoverageTicks; sellable output =max(0, outputInventory - reserve); actor is the ProductionUnit, purposeINVENTORY_REBALANCE, bucketOUTPUT, andsourcePlanIdis the ProductionPlan.REQ-PRODUCTION-005requires realized batches never exceed plan/input/labor/capital/resource bounds, exact stock deltas, output-first inventory flow, canonical market settlement for sales, and no phantom/random stock creation.OPEN_QUESTIONS.mdhas no unresolved blocker for this boundary.Scope
RegionSeed.depositswithout changing the immutable scenario seed.max(recipe.laborPerBatch, numeric.quantityEpsilon), with +Infinity whenlaborPerBatch == 0.effectiveCapacityBatches.extractionResourceId, remaining live regional deposit / positiveextractedResourcePerBatch; non-extraction recipes are unbounded by resources.max(0, min(planned, input, labor, capital, resource)); consume exact input quantities once, deplete exact extraction quantity once, and credit exact recipe output once to the unit OUTPUT inventory.WorldStateimmutability during planning/execution evidence creation; persist the physical deltas through an explicit state-transition function returning a new WorldState/registries.ProductionUnitIdorder and reject duplicate/stale/cross-unit/cross-region evidence rather than silently aggregating it.outputCoverageTicks, using OUTPUT inventory bucket and the ProductionPlan as source.REQ-PRODUCTION-005 = IMPLEMENTEDledger row only if this exact branch earns the full boundary; keepMERGE_COMMITblank until integration.Non-goals
REQ-PRODUCTION-006).REQ-PRODUCTION-007) or integrated M4 closure (REQ-PRODUCTION-008).docs/spec/mirror/**edits.Acceptance criteria
outputSalesEma × outputCoverageTicks, purposeINVENTORY_REBALANCE, bucketOUTPUT, stable MarketIntent ID and the current ProductionPlan assourcePlanId; zero sellable output emits no material sale quantity.Verification
Run focused production-execution regressions plus repository TypeScript gates, retained .NET gates, implementation-status generation/check, policy checks and exact-head mergeability. Inspect the final diff for no mirror edits, no market-settlement rewrite, no investment/lifecycle/M5+ scope creep, and no second physical-stock authority.