Skip to content

REQ-ACCEPTANCE-004: prove MTFX-T5 insertion-order invariance - #424

Merged
zendev-acceptor[bot] merged 2 commits into
masterfrom
claude/issue-268-mtfx-t5-insertion-order
Sep 11, 2026
Merged

zendev-acceptor[bot] merged 2 commits into
masterfrom
claude/issue-268-mtfx-t5-insertion-order

Conversation

@zendev-author

@zendev-author zendev-author Bot commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Closes #268

Achieved outcome

The M3 golden-gate acceptance suite (REQ-ACCEPTANCE-004) now proves Handoff/04 §39 MTFX-T5 ("Proportional seller/buyer rationing conserves quantity and is insertion-order invariant"), one of the enumerated remaining acceptance artifacts named on the current ledger row. This is one bounded slice of the composite requirement, not full closure — MTFX-T4, MTFX-T6, MTFX-I5, MTFX-I6 and the full local-shortage orchestration golden-gate scenario remain outstanding, exactly as before this PR.

Tested revision

a3b0c5ab803be7c469f0be8cd0385628cd921862

Changed artifacts

  • src/simulation/acceptance-004-m3-golden-gate.test.ts — added a new describe("MTFX-T5: ...") block. It reuses the exact multi-seller (3) / multi-buyer (2) shortage fixture already used by the file's MTFX-I3 block (sellable 50/30/20, effective demand 40/35, cleared quantity 75 < either side's raw total), which forces proportional rationing whose per-seller share for the 20-unit seller is not exactly representable in binary floating point — so computeLocalClearing()'s residual-correction pass actually executes rather than being a no-op. The test calls computeLocalClearing() three times with the identical intents in three different array orders (forward, fully reversed, and a third non-reversed shuffle) and asserts bit-identical per-participant summed fills and conserved total cleared quantity across all three, proving the stable actor/intent-ID sort — not input array position — drives both residual correction and two-pointer matching.
  • docs/spec/implementation_status.csv / docs/spec/IMPLEMENTATION_STATUS.md — updated the existing REQ-ACCEPTANCE-004 row's PR field to this PR and appended this PR's contribution to EVIDENCE; STATUS remains PARTIAL (unchanged, correctly — this PR does not close the composite requirement).

Acceptance criteria

Issue #268's own acceptance criteria are for the full composite REQ-ACCEPTANCE-004 (all MTFX-T1..T6/I1..I6 plus the orchestration golden-gate). This PR is one bounded slice within that Issue's remaining work, matching the pattern established by the prior merged PRs #417/#419 against the same Issue:

  • MTFX-T5 (Handoff/04 §39): proportional rationing conserves quantity and is insertion-order invariant — proven by the new test.
  • MTFX-T4, MTFX-T6, MTFX-I5, MTFX-I6, full orchestration golden-gate scenario — still outstanding, unchanged by this PR.

Checks

Check Outcome Evidence
npm run typecheck passed clean, no errors
npm test passed 564/564 tests passed (40 files; 563 pre-existing + 1 new)
npm run build passed vite build succeeded
dotnet build --configuration Release --no-restore passed 0 warnings, 0 errors
dotnet test --configuration Release --no-build passed 45/45 tests passed (REQ-MIGRATION-003 maintained)
python scripts/implementation_status.py --check passed ledger/rendered table in sync after regeneration

Not checked

Assumptions and unknowns

  • Assumption: the existing MTFX-I3 fixture's numeric shape (sellable 50/30/20, demand 40/35) is a legitimate reuse for MTFX-T5 since both invariants examine the same proportional-rationing pass from different angles (fill conservation vs. order invariance). No new economic fixture semantics were invented.
  • Assumption: toBe (exact equality) is an appropriate assertion strength here because the production sort key is deterministic and the same arithmetic executes in the same order regardless of input array position; if a future legitimate change makes the arithmetic order genuinely non-deterministic (e.g. real concurrency), this test would need loosening — not expected pre-M11.

Highest-risk area for review

The strength of the toBe (bit-exact) equality assertions across the three orderings. If this is judged too strict for legitimate floating-point non-determinism, the fallback is a tight epsilon (e.g. 1e-12) rather than the file's usual quantityEpsilon (1e-8), to keep the test meaningfully sensitive to an order-dependent regression rather than passing vacuously.

Remaining gate

None for this bounded slice. Issue #268 stays open and status:ready after this PR (once merged) for the next AUTHOR run to pick up the next enumerated slice (MTFX-T4, T6, I5, I6, or the orchestration golden-gate scenario). REQ-ACCEPTANCE-004 correctly remains PARTIAL in the ledger.

github-actions Bot and others added 2 commits September 11, 2026 05:24
Adds a proving test for Handoff/04 §39 MTFX-T5 ("Proportional
seller/buyer rationing conserves quantity and is insertion-order
invariant") to the M3 golden-gate acceptance suite. The test runs
computeLocalClearing() three times over the same multi-seller/
multi-buyer shortage fixture used by the existing MTFX-I3 block,
varying only the input array order (forward, fully reversed, and a
third non-reversed shuffle), and asserts bit-identical per-participant
fills and conserved total cleared quantity across all three orderings.
The fixture's 20-unit seller share (75 * 20 / 100) is not exactly
representable in binary floating point, so the residual-correction
pass in marketClearing.ts actually executes rather than being a
no-op, making the test sensitive to a regression that keyed the
correction/matching order on input array position instead of the
stable actor/intent ID.

TypeScript: 564 tests passed, typecheck clean, build succeeded.
C#/.NET: build clean, 45 tests passed (REQ-MIGRATION-003 maintained).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Updates the existing PARTIAL REQ-ACCEPTANCE-004 row's PR field to this
pull request and appends the MTFX-T5 insertion-order-invariance
evidence. STATUS remains PARTIAL; MERGE_COMMIT is left empty per the
AUTHOR runbook until the pull request merges and
scripts/backfill_merge_commits.py fills it in. Regenerated
IMPLEMENTATION_STATUS.md.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

@zendev-acceptor zendev-acceptor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ACCEPT — head revision 6fdb2772363501ba9444239ae1c1a9313d44165a.

  1. Checks green at head: build-and-test (CI), typescript (CI), policy-guard (CI), both write-mergeability-status runs, and the mergeability status context are all SUCCESS at this exact head SHA (confirmed via gh pr checks/gh pr view). Branch is not behind master (git log origin/master..pr-424 shows only this PR's own two commits; git log pr-424..origin/master is empty) and mergeable: MERGEABLE.
  2. Independent re-execution at this head (checked out into a worktree, not read from the checks tab):
    • npm ci && npm run typecheck — clean
    • npm test — 564/564 passed (40 files), matching the PR body's claim exactly
    • npm run build — succeeded
    • dotnet build --configuration Release — 0 warnings/errors
    • dotnet test --configuration Release --no-build — 45/45 passed (REQ-MIGRATION-003 maintained)
  3. Scope: diff touches exactly the three files declared in "Changed artifacts" — src/simulation/acceptance-004-m3-golden-gate.test.ts (new MTFX-T5 describe block, purely additive), docs/spec/implementation_status.csv and docs/spec/IMPLEMENTATION_STATUS.md (ledger row update). No workflow/AGENTS.md/docs/zendev policy paths touched.
  4. No invariant or test weakened: purely additive test file change — no deletions, no .skip, no loosened assertions. The new test uses toBe (bit-exact) equality on real per-participant fills computed by the actual exported computeLocalClearing(), deliberately choosing a fixture (20-unit seller's 15-unit share is not binary-exact) that forces the residual-correction pass to actually execute, then checks three distinct intent-array orderings (forward, reversed, shuffled) for bit-identical fills and conserved total — this is a real, non-vacuous proof of MTFX-T5 (insertion-order invariance), reusing the same fixture and helper pattern already established and accepted in the merged MTFX-I3 PR (#419).
  5. No secret/credential/personal data/local path anywhere in the diff (read in full).
  6. Handoff record complete: achieved outcome, tested revision, changed artifacts, acceptance-criteria table, checks table, not-checked section, assumptions/unknowns, highest-risk area, and remaining-gate statement are all present and accurate. Ledger STATUS correctly stays PARTIAL — this is one bounded slice of the composite REQ-ACCEPTANCE-004, consistent with the pattern of prior merged slices (#417, #419) against the same still-open Issue #268.

Linked Issue #268 carries priority:high, type:feature, area:simulation-core, Goal/Evidence/Scope/Non-goals/Acceptance-criteria/Verification are all present. No standing CHANGES_REQUESTED from any account; no prior reviews on this PR. No status:needs-decision label.

Merging.

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-ACCEPTANCE-004: Golden-gate M3 local-market acceptance test

0 participants