Repository navigation
Implement deterministic ProductionUnit lifecycle and startup safety - #636
Conversation
zen-edit: applied
From |
zen-edit: applied
From |
zen-edit: applied
From |
zen-edit: applied
From |
zen-edit: applied
From |
zen-edit: applied
From |
zen-edit: applied
From |
Producer handoff — exact head
|
drevendev
left a comment
There was a problem hiding this comment.
Exact-head content review for 112eecbe98dc74f3c971cf3de5caf728fae0877d.
This is a COMMENT, not the formal scheme/8 verdict: the PR author and authenticated reviewer are both drevendev, while this repository assigns the formal verdict to SLOPSTER (andy-zen-dev).
I found two blocking contract defects despite the exact-head required checks being green:
-
The MOTHBALLED recapitalization path required by REQ-PRODUCTION-007 is missing. Handoff/05 §19 explicitly says that eligible MOTHBALLED expansion is activated by REQ-PRODUCTION-007 once reactivation eligibility exists. On this head,
planProductionUnitPhase2()emits startup INVESTMENT intents only forPLANNED; everyMOTHBALLEDunit receives zero investment intents.planOneUnit()incapitalFormation.tslikewise permits capital formation only forACTIVE | PLANNED. But Handoff/05 §25 requiresinstalledCapital >= minimumStartupCapitalfor MOTHBALLED→ACTIVE, while Phase 12 still depreciates MOTHBALLED capital. A mothballed unit that falls below the startup-capital threshold therefore has no canonical way to recapitalize and can never satisfy its reactivation gate even after margin/infrastructure/cash recover. Please add the bounded MOTHBALLED investment/capital-formation path required by §19 (without re-enabling normal hiring/input procurement/production) and a regression covering recovery from belowminimumStartupCapital. -
Owner funding is not exactly zero-sum at the cash boundary.
applyProductionUnitOwnerFundingTransition()rejects only whenamount > openingOwnerCash + moneyEpsilon, then clamps the owner treasury withMath.max(0, openingOwnerCash - amount)but credits the unit with the full requestedamount. Reproduction: with owner cashC, requestC + moneyEpsilon/2; the request passes, the owner loses onlyC, and the unit gainsC + moneyEpsilon/2, creatingmoneyEpsilon/2. Issue #635 criterion 5 and Handoff/05 invariant PCL-I19 require exact owner debit == unit credit / no money creation. Reject any request above available owner cash (or credit exactly the amount actually debited) and add a boundary regression.
Because these are content blockers, I cannot give a clean-content judgement on this head. Formal acceptance remains with the repository's SLOPSTER exact-head verdict.
Verdict: REQUEST_CHANGESHead Independent scheme/8 judgement of Issue #635 / I independently verified both blockers against the current diff and Handoff/05:
Smallest required next action: add bounded MOTHBALLED investment/capital formation without re-enabling normal hiring/input procurement/production, and make owner funding an exact debit==credit transfer with boundary regressions. Push a new head for fresh exact-head judgement. |
zen-edit: applied
From |
Producer handoff — exact head
|
SLOPSTER QA: FINDINGHead Phase-14 readiness still does not enforce the legal-eligibility gate required by Issue #635 /
This is part of the existing acceptance contract rather than a new requirement: #635 acceptance criterion 3 explicitly requires Please bind lifecycle readiness to the authoritative current-tick M4 legal/ownership-eligibility evidence (or an explicit deterministic fixture owned by the existing policy boundary), fail closed when required eligibility evidence is unavailable, and add focused regressions where all physical/cash gates pass but legal eligibility is false: neither PLANNED activation nor MOTHBALLED reactivation may be queued; the corresponding eligible control should still pass. This must remain a readiness gate only and should not widen into M5+ policy formation. |
Verdict: REQUEST_CHANGESHead Independent scheme/8 exact-head judgement of Issue #635 / The two blockers from the prior refused head are repaired on this revision: viable However, the current head still misses a merge-blocking part of the existing lifecycle acceptance contract: Phase-14 readiness has no effective legal/ownership-eligibility gate. Exact-head mechanical evidence is green: Verdict is bound only to this exact head. |
zen-edit: applied
From |
Producer handoff — exact head
|
Verdict: ACCEPTHead Independent scheme/8 exact-head judgement of Issue #635 / The previous legal-eligibility blocker is repaired on this revision. Phase-14 readiness now derives explicit I re-checked the surrounding lifecycle contract rather than only the repair delta. The prior MOTHBALLED recapitalization and exact owner-funding blockers remain fixed; N+1 lifecycle timing, live-status authority, safe-retirement checks, and evidence re-derivation remain intact. I found no remaining merge-blocking source or contract defect on this exact head. Exact-head mechanical evidence is green: CI run #1485 reports Verdict is bound only to this exact head. |
Closes #635
Achieved outcome
Implements bounded M4
REQ-PRODUCTION-007: one mutable live ProductionUnit lifecycle status initialized from immutable seed status; deterministic Phase-14 lifecycle review with explicit tick-N+1 activation/removal; PLANNED startup and viable MOTHBALLED recapitalization through real INVESTMENT goods only; exact owner-to-unit home-currency funding; explicit current-tick M4 ownership/production legal-eligibility readiness from the existing read-only State policy fixture; configured ACTIVE→MOTHBALLED, MOTHBALLED→ACTIVE/CLOSING, and CLOSING→retirement behavior; live-status gating in planning/execution/capital formation; and fail-closed retirement/evidence validation. MOTHBALLED recapitalization does not re-enable normal hiring, INPUT procurement or production. No M5+ FX, credit, mutable fiscal institution, or trade behavior is introduced.Tested revision
2df457f1f68cfae69dfffe638d0a664af04f4cdc— current exact producer head after repairing SLOPSTER's legal-eligibility finding. Exact-head CI #1485 passes retained .NET restore/build/test, TypeScript install/typecheck/full tests/build, and policy guard;mergeabilityis green.Changed artifacts
docs/spec/IMPLEMENTATION_STATUS.md— generated implementation coverage updated to match the authoritative ledger.docs/spec/implementation_status.csv— recordsREQ-PRODUCTION-007as implemented by REQ-PRODUCTION-007: Phase-14 ProductionUnit lifecycle and startup safety #635/Implement deterministic ProductionUnit lifecycle and startup safety #636 with merge SHA intentionally blank before integration.src/config/fixtures/baselineScenario.ts— makes the M4 State policy fixture explicitly permit baseline lifecycle ownership/production eligibility instead of relying on a hidden default.src/config/scenarioDefinition.ts— exposes the explicit read-only M4 lifecycle ownership/production eligibility fixture on the existing State production-policy boundary.src/simulation/capitalFormation.test.ts— makes Phase-12 regression fixtures opt into the live ACTIVE lifecycle authority explicitly.src/simulation/capitalFormation.ts— permits capital formation from real INVESTMENT stock for live ACTIVE, PLANNED and MOTHBALLED units while keeping CLOSING excluded.src/simulation/index.ts— exports lifecycle/startup APIs and live status type.src/simulation/pendingTransitions.ts— preserves and filters explicit ProductionUnit lifecycle transitions.src/simulation/productionExecution.test.ts— updates non-ACTIVE regression evidence to set live status rather than mutating immutable seed status.src/simulation/productionExecution.ts— consumes mutable live status rather than immutable seed status.src/simulation/productionPlanning.test.ts— updates non-ACTIVE regression evidence to set live status rather than mutating immutable seed status.src/simulation/productionPlanning.ts— consumes live status; admits bounded PLANNED startup and viable MOTHBALLED recapitalization INVESTMENT while keeping normal labor/input/production demand at zero.src/simulation/productionStartupPlanning.test.ts— covers PLANNED startup plus viable MOTHBALLED recovery from belowminimumStartupCapital, cadence, live/seed divergence, CLOSING isolation and Phase-12→Phase-14 causal ordering.src/simulation/productionStartupPlanning.ts— plans bounded PLANNED startup / viable MOTHBALLED recapitalization INVESTMENT demand from opening cash and prior-close prices, including same-tick depreciation safety.src/simulation/productionUnitLifecycle.test.ts— covers genesis status, readiness/N+1 activation, explicit legal denial/allow controls, missing-policy fail-closed behavior, consecutive counters/reset/reactivation/closing, safe retirement, exact owner-funding conservation including sub-epsilon overdraw rejection, insertion-order determinism and evidence tampering.src/simulation/productionUnitLifecycle.ts— deterministic Phase-14 lifecycle/readiness engine, including current controller-State ownership/production legal eligibility, authoritative evidence re-derivation, N+1 Phase-1 activation/removal, retirement safety, and exact zero-sum owner funding with no epsilon overdraft allowance.src/simulation/productionUnitLifecycleContext.ts— typed immutable Phase-14 lifecycle evidence on TickContext.src/simulation/productionUnitState.ts— defines and validates the sole mutable runtime lifecycle status.src/simulation/worldState.ts— initializes live status from seed status and defines pending lifecycle transition state.Acceptance criteria
PLANNED|ACTIVE|MOTHBALLED|CLOSING) is initialized from immutable seed status.minimumStartupCapitalthrough real investment goods without bypassing lifecycle reactivation reviews.moneyEpsilon.Checks
SLOPSTER correctly refused
112eecbe98dc74f3c971cf3de5caf728fae0877dfor missing MOTHBALLED recapitalization and epsilon-tolerant owner overdraw;cf733bba6594eb2cc6ce298159ecf9072455cb09repaired both. SLOPSTER then correctly refusedcf733bba...because Phase-14 readiness still lacked the existing contract's effective ownership/production legal gate.Exact head
2df457f1f68cfae69dfffe638d0a664af04f4cdcrepairs that remaining finding by reading explicit M4 lifecycle law outputs from the effective controller State's existing read-only production-policy fixture. Controlled Regions fail closed when that fixture/evidence is missing. Focused regressions deny otherwise-ready PLANNED activation and MOTHBALLED viable-review accrual when ownership or production eligibility is false, and retain eligible positive controls. Exact-head CI #1485 passes retained .NET restore/build/test, TypeScriptnpm ci, typecheck, full tests and build, and policy guard.mergeabilityis success.Assumptions and unknowns
The current M4 schema has no autonomous owner strategy, mutable fiscal-law institution, or separate startup-cash-floor field. This implementation therefore uses the existing
minOperatingCashas the M4 operating-cash readiness floor and the existing Statem4ProductionPlanningfixture as the deterministic read-only source for lifecycleownershipAllowed/productionAllowedquery outputs. The fixture is deliberately coarse for M4; M6 may back the same pure-query semantics from canonical mutable institutions without changing Phase-14 readiness. MOTHBALLED recapitalization is limited to units whose current margin signal clears the configured reactivation margin threshold and only fills the real-capital gap required by the existing reactivation readiness gate.Highest-risk area for review
Lifecycle authority and causal timing: effective controller-State legal eligibility, fail-closed missing policy evidence, live-vs-seed status, MOTHBALLED recapitalization without normal operation, Phase-14 N+1 transitions, exact money conservation at the owner-funding boundary, and fail-closed safe retirement.
Remaining gate
Fresh SLOPSTER independent judgement of exact head
2df457f1f68cfae69dfffe638d0a664af04f4cdc. This IMPLEMENT run does not merge the PR.