Skip to content

REQ-PRODUCTION-004: settle Phase-5 wages atomically - #585

Merged
drevendev merged 13 commits into
masterfrom
zen/issue-584-phase5-wage-settlement
Sep 19, 2026
Merged

drevendev merged 13 commits into
masterfrom
zen/issue-584-phase5-wage-settlement

Conversation

@drevendev

@drevendev drevendev commented Sep 19, 2026 •

Copy link
Copy Markdown
Owner

Closes #584

Achieved outcome

Implements canonical REQ-PRODUCTION-004 Phase-5 wage settlement over Phase-3 labor allocations. The complete payroll bundle is provenance-checked and preflighted before any stock transition; each accepted employer gross debit is split into cohort net wage plus controlled-State collected wage tax, assessed-but-uncollected tax stays with the cohort, and uncontrolled Regions collect zero State wage tax. Settlement emits stable linked wage/tax transactions, reuses the existing canonical actor-wallet ownership/mutation seam, keeps WorldState immutable during the tick, and exposes accepted post-wage current-tick spendable balances for later affordability checks without introducing M6 fiscal dynamics.

Tested revision

e29e79b407668a0e63b0bb04ab36bc6ec0c0cd9c

Changed artifacts

  • src/simulation/wageSettlement.ts — Phase-5 settlement planning, fiscal fixture boundary, whole-payroll preflight, linked transactions, immutable transition and current-tick spendable-balance projection.
  • src/simulation/wageSettlementContext.ts — tick-scoped WageSettlement evidence on TickContext.
  • src/simulation/wageSettlement.test.ts — focused PCL-I9/PCL-I10/PCL-T6 regressions and negative controls.
  • src/simulation/marketSettlementTransition.ts — narrow public money-only actor-wallet seam reusing the existing market-settlement endpoint/mutation convention.
  • src/simulation/tickOrchestrator.ts — canonical optional gross/assessed-tax transaction metadata fields.
  • src/simulation/index.ts — public exports for the Phase-5 wage-settlement API.
  • docs/spec/implementation_status.csv — REQ-PRODUCTION-004 = IMPLEMENTED evidence with merge SHA intentionally blank until integration.
  • docs/spec/IMPLEMENTATION_STATUS.md — generated coverage projection for the ledger change.

Acceptance criteria

  • 1. Every accepted wage bundle conserves employer gross debit = cohort net + controlled-State collected tax; assessed-but-uncollected tax remains with the cohort.
  • 2. Whole-tick payroll is preflighted against Phase-3 worker demand, gross payroll caps and available Region settlement-currency cash before persistence.
  • 3. Allocation provenance is validated against tick, cohort/unit/region, demand region/category, ACTIVE status, allocated worker cap and exact gross obligation.
  • 4. Controlled Regions use only an explicit deterministic read-only M4 WageTaxPolicyProvider; uncontrolled Regions assess/collect zero State wage tax, with no M6 mutable fiscal state.
  • 5. Stable linked WAGE_PAYMENT / positive WAGE_TAX_WITHHELD transactions carry actors, currency, gross/net/assessed/collected amounts and tax→wage causal linkage.
  • 6. Phase-5 leaves the input WorldState immutable, exposes an explicit persistence transition and current-tick post-wage spendable balances.
  • 7. Settlement output is deterministic under shuffled allocation input order.
  • 8. Focused tests cover conservation, partial/zero withholding, uncontrolled jurisdiction, worker/payroll caps, insufficient cash, malformed/duplicate/stale/cross-provenance evidence, deterministic order, immutability and spendable-balance visibility.
  • 9. Exact-head TypeScript, retained .NET, policy/generated-status/ledger and mergeability gates are green before producer handoff.

Checks

Check Outcome Evidence
npm run typecheck passed CI 35436853191, typescript, exact head e29e79b4….
npm test passed CI 35436853191, typescript, exact head e29e79b4…; all tests passed.
npm run build passed CI 35436853191, typescript, exact head e29e79b4….
dotnet build --configuration Release passed CI 35436853191, build-and-test, exact head e29e79b4….
dotnet test --configuration Release passed CI 35436853191, build-and-test, exact head e29e79b4….
policy-guard passed CI 35436853191; handoff declaration, Issue labels, generated coverage and ledger-honesty gates passed.
mergeability passed write-mergeability-status run 35436851950, exact head e29e79b4….

Not checked

A fresh SLOPSTER exact-head verdict is intentionally not part of this IMPLEMENT run. Producer/judge separation requires this run to stop before merge.

Assumptions and unknowns

Established from canonical Handoff/05 §15: Phase-3 LaborAllocation.grossWageObligation is the fixed gross payroll obligation; current M4 uses Region settlement currency for the ProductionUnit payroll wallet; wage-tax and collection evidence is read-only injected evidence until M6; an uncontrolled Region collects zero State wage tax. Household consumption planning itself remains a separate Population requirement, so this slice exposes the authoritative post-wage affordability query rather than inventing a second shopping path.

Highest-risk area for review

The timing and conservation boundary: the whole tick payroll must fail before persistence if any employer cannot fund its gross obligation, while later same-tick affordability must observe accepted cohort net wages even though canonical WorldState remains immutable during executeTick. Review planWageSettlementsPhase5, applyActorMoneyDeltas, and getPostWageSpendableBalance together.

Remaining gate

Fresh exact-head SLOPSTER judgement on e29e79b407668a0e63b0bb04ab36bc6ec0c0cd9c. This IMPLEMENT run does not merge PR #585.

@zendev-machine

Copy link
Copy Markdown
Contributor

zen-edit: applied

  • src/simulation/index.ts
  • src/simulation/marketSettlementTransition.ts

From .zen/edits/issue-584-wallet-and-exports.edit, removed in the same commit. The required checks run on the new head; the head you pushed is no longer the one to judge.

@zendev-machine

Copy link
Copy Markdown
Contributor

zen-edit: applied

  • src/simulation/wageSettlement.ts

From .zen/edits/issue-584-exact-optional.edit, removed in the same commit. The required checks run on the new head; the head you pushed is no longer the one to judge.

@zendev-machine

Copy link
Copy Markdown
Contributor

zen-edit: applied

  • docs/spec/IMPLEMENTATION_STATUS.md
  • docs/spec/implementation_status.csv

From .zen/edits/issue-584-ledger-status.edit, removed in the same commit. The required checks run on the new head; the head you pushed is no longer the one to judge.

@zendev-machine

Copy link
Copy Markdown
Contributor

zen-edit: applied

  • src/simulation/tickOrchestrator.ts
  • src/simulation/wageSettlement.test.ts
  • src/simulation/wageSettlement.ts

From .zen/edits/issue-584-worker-cap-metadata.edit, removed in the same commit. The required checks run on the new head; the head you pushed is no longer the one to judge.

@zendev-machine

Copy link
Copy Markdown
Contributor

zen-edit: applied

  • src/simulation/wageSettlement.test.ts

From .zen/edits/issue-584-fix-cap-regression.edit, removed in the same commit. The required checks run on the new head; the head you pushed is no longer the one to judge.

@drevendev
drevendev marked this pull request as ready for review September 19, 2026 10:16

Copy link
Copy Markdown
Owner Author

EndlessZen producer handoff — REQ-PRODUCTION-004

Exact judgement head: e29e79b407668a0e63b0bb04ab36bc6ec0c0cd9c.

This IMPLEMENT unit is complete and stops at the production→judgement boundary. PR #585 is READY FOR REVIEW and remains unmerged.

Exact-head verification

  • CI 35436937718 / typescript: SUCCESS — npm run typecheck, npm test, and npm run build all passed on e29e79b4….
  • CI 35436937718 / build-and-test: SUCCESS — retained .NET restore/build/test passed on the same head.
  • CI 35436937718 / policy-guard: SUCCESS — scheme guard, declared-artifact handoff, linked Issue labels, generated coverage and ledger-honesty checks all passed.
  • Mergeability 35436941534: SUCCESS on the same head.
  • PR is open, mergeable, non-draft, with exactly 8 changed artifacts and no docs/spec/mirror/** edits.

Earned implementation evidence

  • Whole-tick Phase-5 payroll is preflighted before persistence against current-tick allocation provenance, ACTIVE employers, allocated worker limits, Phase-3 gross payroll caps and available Region settlement-currency cash.
  • Controlled Regions use only the explicit read-only M4 WageTaxPolicyProvider; uncontrolled Regions assess/collect zero State wage tax.
  • Every accepted bundle preserves employer gross debit = cohort net wage + State collected wage tax; assessed-but-uncollected tax remains with the cohort.
  • Stable WAGE_PAYMENT and positive WAGE_TAX_WITHHELD transactions share a bundle and carry tax→wage causal linkage.
  • Wage persistence reuses the existing strict actor-wallet endpoint/mutation convention through a narrow shared money-delta seam; no second wallet ownership model was introduced.
  • WorldState stays immutable during tick execution; accepted Phase-5 deltas expose current-tick post-wage spendable balances for later affordability checks.
  • Focused regressions cover PCL-I9/PCL-I10/PCL-T6 conservation, partial/zero withholding, uncontrolled jurisdiction, worker/payroll caps, insufficient cash, malformed/duplicate/stale/cross-provenance evidence, deterministic ordering, input-world immutability, and same-tick spendable-balance visibility.
  • Branch ledger truthfully records REQ-PRODUCTION-004 = IMPLEMENTED for Issue REQ-PRODUCTION-004: Phase-5 atomic wage settlement and withholding #584 / PR REQ-PRODUCTION-004: settle Phase-5 wages atomically #585 with MERGE_COMMIT intentionally blank until integration; generated status is 37/49 implemented on this branch.

Explicit non-goals preserved

No production/extraction output execution (REQ-PRODUCTION-005), no household consumption planner, transfers/benefits/owner distributions/residual business tax, no mutable M6 fiscal/debt/policy-review machinery, no M5 trade/FX, M7 monetary dynamics or M8 demography/migration.

SLOPSTER: please judge this exact head. A later VERIFY_INTEGRATE run may merge only on a fresh exact-head ACCEPT/approval with required gates still green and no unresolved material finding.

Copy link
Copy Markdown

Verdict: ACCEPT

Exact head judged: e29e79b407668a0e63b0bb04ab36bc6ec0c0cd9c.

I independently re-read Issue #584, the complete 8-file change set, the Phase-5 settlement implementation and focused regressions, the existing PR discussion/review state, the active scheme, and exact-head checks. I found no merge-blocking defect in the bounded REQ-PRODUCTION-004 slice.

The implementation fail-fast validates current-tick allocation/demand provenance, ACTIVE employers, worker-equivalent and gross-payroll caps, exact allocation gross obligations, canonical Region/cohort/unit relationships, and available employer settlement-currency cash before persistence. Controlled Regions use the explicit read-only WageTaxPolicyProvider; uncontrolled Regions do not consult it. Accepted bundles conserve employer gross debit as cohort net wage plus collected State tax, while assessed-but-uncollected tax remains with the cohort. The linked wage/tax transactions have stable IDs/bundles and tax→wage provenance.

The persistence path reuses the existing canonical actor-wallet endpoint/mutation seam and preflights the netted money deltas before rebuilding WorldState. Tick execution itself remains immutable; getPostWageSpendableBalance projects the accepted Phase-5 deltas for later same-tick affordability without mutating canonical state. The focused tests cover conservation, withholding variants, uncontrolled jurisdiction, worker/payroll/cash refusal, malformed/duplicate/stale/cross-provenance evidence, allocation-order determinism, input-world immutability, and same-tick spendable-balance visibility.

Exact-head required checks are green on this SHA: typescript, retained build-and-test, policy-guard, and mergeability all completed successfully. There are no formal reviews or unresolved review threads.

This verdict is limited to this exact head and the scoped M4 wage-settlement boundary. REQ-PRODUCTION-005, household consumption planning, and mutable M6 fiscal/transfer/debt policy remain outside this judgement.

@drevendev drevendev left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cross-project review evidence — no blocking content finding

Reviewed exact head e29e79b407668a0e63b0bb04ab36bc6ec0c0cd9c against Issue #584, canonical Handoff/05 §15, the eight-file PR diff, current review channels, and exact-head provider verification.

I found no blocking content defect in the REQ-PRODUCTION-004 slice.

Specific checks from the review:

  • planWageSettlementsPhase5 preflights the complete payroll set before persistence, validates current-tick allocations and unit/demand/region/category/ACTIVE provenance, independently caps allocated workers and aggregate gross payroll per unit, and verifies available settlement-currency cash.
  • Withholding uses net = gross - collectedTax, so assessed-but-uncollected tax remains with the cohort as required; uncontrolled Regions skip the tax provider and collect zero State wage tax.
  • WAGE_PAYMENT plus positive WAGE_TAX_WITHHELD preserve the required gross = net + collected identity and carry stable bundle/causal linkage.
  • Persistence reuses the existing actor-wallet resolution/mutation seam through applyActorMoneyDeltas; getPostWageSpendableBalance overlays only accepted Phase-5 deltas while leaving the tick input WorldState immutable.
  • The focused regressions cover conservation, partial withholding, zero/uncontrolled tax, worker/payroll/cash refusal, malformed/stale/duplicate/cross-group evidence, deterministic ordering, immutability, and current-tick spendable-balance visibility.
  • No docs/spec/mirror/** contract is changed and I found no M6 fiscal/transfer/debt/policy-review scope creep.

Exact-head CI run 35436937718 is green for typescript, build-and-test, and policy-guard; its TypeScript job ran npm run typecheck, npm test, and npm run build on this head. I did not independently rerun those commands outside the provider run.

Formal gate limitation: the authenticated reviewer here is drevendev, which is also the PR author. Active scheme/8 assigns the authoritative verdict to andy-zen-dev / SLOPSTER. This review is therefore content evidence only and must not be interpreted as the required SLOPSTER ACCEPT verdict or as independent actor-separated approval.

@drevendev
drevendev merged commit 401f048 into master Sep 19, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

REQ-PRODUCTION-004: Phase-5 atomic wage settlement and withholding

2 participants