Skip to content

REQ-PRODUCTION-005: Phase-5 production/extraction execution and output sale intent #587

Description

@drevendev

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

  1. 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.
  2. 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.
  3. Extraction recipes with depleted deposits realize zero; non-extraction recipes have no fabricated resource constraint. Invalid extraction provenance/amounts fail fast.
  4. 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.
  5. Phase-5 evidence construction does not mutate input WorldState. The explicit physical transition returns a new world and preserves unrelated wallets/inventories/capital/state.
  6. 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.
  7. Shuffled plan/allocation/registry insertion order produces normalized-equivalent execution results and intents in stable unit order.
  8. 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.
  9. 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.

Activity

  1. added
    priority:highImportant and time-sensitive; schedule ahead of normal work
    type:featureNew simulation capability or observable behavior
    area:simulation-coreTick loop, ordering, determinism, configuration
    status:in-progressClaimed work with an active branch or pull request
    on Sep 19, 2026
  2. drevendev commented on Sep 19, 2026

    @drevendev
    OwnerAuthor

    Claimed for EndlessZen primary delivery in one bounded IMPLEMENT unit: permanent REQ-PRODUCTION-005 / Handoff/05 §§16–17,26 on branch zen/issue-587-production-execution. Scope is deterministic Phase-5 physical production/extraction plus post-production OUTPUT sell-intent construction, with exact input/resource/output conservation and sensitive regressions. Non-goals: market-clearing rewrite, Phase-12 capital formation/depreciation, lifecycle, M5+, and any manual mirror edit. Production stops at PR #588's producer→judgement boundary for independent SLOPSTER review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:simulation-coreTick loop, ordering, determinism, configurationpriority:highImportant and time-sensitive; schedule ahead of normal worktype:featureNew simulation capability or observable behavior

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions