Skip to content

test(ratchet): the mavis CLI ratchet could not say no — fix 3 defects load-bearingly - #3427

Merged
POWERFULMOVES merged 13 commits into
mainfrom
fix/ratchet-upstream-matrix-and-shim-origin
Oct 31, 2026
Merged

POWERFULMOVES merged 13 commits into
mainfrom
fix/ratchet-upstream-matrix-and-shim-origin

Conversation

@POWERFULMOVES

Copy link
Copy Markdown
Owner

Summary

The test-gap ratchet slice shipped in PR #3095. A follow-up audit on 2026-10-30 found that the ratchet itself could not say no — two defects, plus a third surfaced while repairing them. All three are the exact failure mode this lane exists to prevent: a ratchet reporting GREEN while the thing it guards is broken.

This PR fixes all three load-bearingly and preserves the original defect as a tracked mutation-kill so it can never silently return.


Defect A — stderr accepted as a version string

The shipped mavis --version gate was:

version = (proc.stdout or proc.stderr or "").strip()
assert version

Node's module loader writes Error: Cannot find module '<path>' to stderr and exits 1. A 100%-broken launcher therefore satisfied the non-empty assertion.

Measured on the operator's host before this fix:

$ mavis --version
Error: Cannot find module 'C:\Users\russe\AppData\Local\Programs\MiniMax Code\resources\resources\daemon\cli.js'
rc=1, stdout='', elapsed=0.16s

test_mavis_cli_version_completes_within_timeout ... PASSED

Repair: the gate is extracted to _assert_healthy_version_output() (pmoves/tests/test_mavis_cli_timeout.py) and asserts what a working CLI has and a broken one cannot fake:

  1. rc == 0 — the command succeeded;
  2. non-empty stdout — and specifically not stderr; reading stderr as a fallback is what let the defect through;
  3. stdout is not an error banner — rejects error: / cannot find module / traceback / not found, because some launchers print the error to stdout and still exit 0.

The --help gate gets the same treatment (rc must be 0 or 2; stdout-only).


Defect B — the upstream pin pointed at a 404

The matrix cross-check pinned MiniMaxInc/MiniMax-Code, which does not exist:

$ gh api repos/MiniMaxInc/MiniMax-Code/contents/.github/workflows
gh: Not Found (HTTP 404)

The real upstream is MiniMax-AI/minimax-code. A 404 body is a JSON object where the helper expected a list, so the fetch hit the not isinstance(payload, list) branch and returned None — the cross-check degraded to a permanent SKIP. It could never report green or red.

Repair: the pin is corrected to MiniMax-AI/minimax-code and the pin itself is now assertable (test_mutation_wrong_upstream_repo_is_detectable).


Defect C — filename-derived platform set (found while repairing B)

The platform detector scanned workflow filenames for ubuntu/macos/windows. Upstream's actual workflow filenames are:

ci.yml  cli-release.yml  compatibility.yml  label-issue-product.yml
performance.yml  security.yml  source-candidate.yml  sync-issue-to-feishu.yml

Not one carries an OS name. The upstream matrix is declared inside ci.yml's body as runs-on: ${{ matrix.os }} with os: [ubuntu-latest, macos-latest, windows-latest]. The filename scan therefore returned an empty set, so assert "windows" in platforms would have FAILED once enabled — the ratchet was inverted, reporting "upstream does not cover Windows" for an upstream that does.

Repair: _fetch_upstream_matrix() now fetches each workflow's download_url body and scans for the runner labels.


The upstream matrix answer (the operator's actual question)

Upstream's Linux matrix is GREEN, and upstream DOES cover Windows.

MiniMax-AI/minimax-code's ci.yml declares os: [ubuntu-latest, macos-latest, windows-latest] with profile: full on Ubuntu and a focused profile: windows on Windows ("Windows runs a focused contract; full capability coverage remains on Linux/macOS").

Live probe 2026-10-30:

{'platforms': ['macos', 'ubuntu', 'windows'], 'status': 'ok'}

So the operator's 240s timeout is the platform-specific Windows case (operator's lane), not a known-broken upstream — but only once the ratchet can actually read the matrix, which it previously could not.


Mutation-kills — the load-bearing proof

pmoves/tests/tools/test_mavis_ratchet_mutation_kill.py (NEW, 3 tests) rewrites the gate and the upstream pin back to their original defective forms and asserts the ratchet module then FAILS:

test_mutation_original_version_gate_is_killed    PASSED
test_mutation_original_upstream_pin_is_killed    PASSED
test_ratchet_file_is_left_clean_after_mutations  PASSED

The meta-lesson (recorded as lesson #12): the first attempt at this harness re-implemented the gate inline instead of invoking it. Restoring the original defective gate left the suite at 7 passed — the mutation survived. The gate is now shared between the ratchet and the mutation-kill, so the two are genuinely coupled. A mutation-kill that restates the assertion instead of invoking it proves nothing.


Host shim repair

~/.minimax/bin/{mavis,minimax}.cmd pointed at ...\MiniMax Code\resources\resources\daemon\cli.js — a path that no longer exists (the daemon now ships inside app.asar; neither the doubled nor the single-resources variant resolves on disk).

Per the operator's direction that the CLI runs from our fork, both shims now exec the fork build:

C:\Users\russe\AppData\Local\Programs\node-v22.22.1-win-x64\node.exe
  C:\Users\russe\pmoves-fork-minimax-code\dist\cli.js

Node 22.22.1 is required — the host's default node is 22.17.1 and @minimax-ai/code requires >=22.19 <23 || >=24.2 <27.

Result: mavis --version → 0.6.5, rc=0, 0.47s. The ratchet now passes legitimately rather than vacuously.

The fork build came from POWERFULMOVES/PMOVES-minimax-code fast-forwarded to upstream main via PMOVES-minimax-code#1 (pnpm build → Built MiniMax Code 0.6.5 from 6285 source files).


Tests

File Result
pmoves/tests/test_mavis_cli_timeout.py 7 passed, 1 skipped (4 → 8 tests)
same, with PMOVES_MAVIS_MATRIX_CHECK=1 8 passed — the cross-check now actually runs
pmoves/tests/tools/test_mavis_ratchet_mutation_kill.py 3 passed (NEW)
pmoves/tests/test_kilo_binary_path.py 6 passed — no regression on the sibling ratchet

Docs + SDK provenance

  • pmoves/docs/AGENTS/test_gap_ratchet_LEARNINGS.md — lessons docs(yt): clarify summary styles and chapter extraction #9–test(pmoves-yt): add endpoint tests #12 added to the 4-bucket × 5-class taxonomy (now 12 lessons, cross-check re-tallied to reasoning-gap 3 / semantic-naming 1 / contract-correctness 3 / defense-in-depth 5); the post-merge correction table and the upstream-matrix answer recorded; SDK-provenance and live-state sections updated with the 2026-10-30 measurements.
  • pmoves/docs/AGENTS/AGNOTE4482PHI.t1.md — CLAIM row 2026-10-30T23:00:00Z, signature 5090-CLAUDE, unsigned-local, with full SDK file:line provenance, the measured before/after, and cross-references.
  • SDK files changed: pmoves/tests/test_mavis_cli_timeout.py (+360 lines net) · pmoves/tests/tools/test_mavis_ratchet_mutation_kill.py (135 lines, NEW) · the two docs files above.
  • Cross-references: PR test(ratchet): kilo binary-path + minimax-code 240s timeout + upstream matrix #3095 (original slice) · pmoves_launcher_generator_LEARNINGS.md lesson docs(yt): clarify summary styles and chapter extraction #9 ("a test that can only assert absence cannot say no") · pmoves/tests/test_kilo_binary_path.py::test_mutation_js_only_path_fails_ratchet (the sibling mutation-kill idiom this correction follows).

No workarounds. Every fix is an SDK-file change with a load-bearing mutation-kill. No behaviour was suppressed, skipped, or loosened to make a test pass.

+1 from Mavis.

@coderabbitai

coderabbitai Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are limited based on label configuration.

🏷️ Required labels (at least one): 1
  • coderabbit

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-30T19:23:54.631176Z 0aaba68 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions github-actions Bot added docs Documentation governance AGNOTE register / agent definitions / damage-control hooks labels Oct 30, 2026
@github-actions

Copy link
Copy Markdown
Contributor

ORGSIM-MIRROR drift check (advisory, fail-soft)

vv3 / 7 files / VERIFIED 99 / UNDECIDED 61 / digest 2db10ab3b0b3

Zero-LLM deterministic audit - unreachable = UNDECIDED, never dead - scripts/runbook_drift.py

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0aaba68cb6

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread pmoves/tests/test_mavis_cli_timeout.py Resolved
Comment thread pmoves/tests/test_mavis_cli_timeout.py Resolved
Comment thread pmoves/tests/test_mavis_cli_timeout.py Resolved
Comment thread pmoves/tests/test_mavis_cli_timeout.py Resolved
Comment thread pmoves/tests/test_mavis_cli_timeout.py Resolved
@kilo-code-bot

kilo-code-bot Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Roast 🔥

Verdict: No Issues Found | Recommendation: Merge

Oh wait, this PR is actually clean. I need to sit down. I had my flamethrower warmed up and everything.

Incremental verification (round 7, d39b11c..64fc604): the two round-7 findings are closed at the source, not just answered:

  • Pass budget trapdoor — FIXED. fallback_budget_seconds() (pmoves/tools/pytest_ratchet.py:282) adds the chunk's allowances to FALLBACK_BUDGET_SECONDS, and the isolation loop now compares spent against the allowance-aware pass_budget (:478, :487), which the (budget %ds) banner echoes (:480). A chunk with no declared-slow file still gets exactly the flat default.
  • Silent parse-skip — FIXED. An unparseable line inside the slow_files: block now emits a one-line stderr warning quoting the raw line (:229–:231); lines outside the block stay quiet.
  • The new tests pin both the helper (:248, :313, :320, negative control :328) AND the wiring (:264 — run_chunk_with_fallback with FALLBACK_BUDGET_SECONDS = 0, which the flat-budget mutation genuinely kills) plus the warning (:348, :369). The wiring test is the one that mattered; testing only the pure helper would have stayed green against a broken call site, which is precisely the trap this repo keeps documenting and then escaping.

📊 Overall: Round 7 reviews round 6's fix and finds… the holes already patched, with mutation kills proving the tests bite. Like reviewing a firewall patch and finding the fire already out — suspiciously competent.

Files Reviewed (4 files)
  • pmoves/tools/pytest_ratchet.py — both round-7 findings re-verified FIXED at HEAD (fallback_budget_seconds :282 with loop use :478/:487; unparseable-entry warning :229); helper is pure and additive; default path numerically unchanged. No new issues.
  • pmoves/tests/tools/test_pytest_ratchet.py — 7 new tests read in full; docstring line anchors in the round-7 LEARNINGS table (:264, :348, :369) match the actual code; the wiring test (:264) correctly forces the trapdoor path via FALLBACK_BUDGET_SECONDS = 0. No new issues.
  • pmoves/docs/AGENTS/test_gap_ratchet_LEARNINGS.md — prose-only round-7 section (lessons docs: reconcile creator milestone status #30–chore(agent-zero): sync requirements and persist runtime #32). No code issues.
  • pmoves/docs/AGENTS/AGNOTE4482PHI.t1.md — prose-only round-7 NOTE append. No code issues.

Carried findings resolved: both previous threads (pytest_ratchet.py:463/:498 pass-budget trapdoor, :223 silent parse-skip) are closed at the source in this delta and answered by the author at comments 4430065917/4430066028 — not re-posted, no duplicates. The extra <= 0 silent drop at :235–:236 is unchanged context in this incremental delta and was reviewed at earlier rounds; noted here for visibility only, not as a new finding.

Gaps: no code execution in this sandbox (read-only), so findings are verified by reading the changed lines against the loop and tests that consume them; the author's measured outputs (38 passed, both mutations killed, anchor ratchet 445/445) are taken as reported evidence. Sub-agent count: 0 (4 files, 238 added lines, doc-dominant, reviewed in full directly).

Previous Review Summaries (7 snapshots, latest commit d39b11c)

Current summary above is authoritative. Previous snapshots are kept for context only.

Previous review (commit d39b11c)

Verdict: 2 Issues Found | Recommendation: Address before merge

Overview

Severity Count
🚨 critical 0
⚠️ warning 0
💡 suggestion 1
🤏 nitpick 1
Issue Details (click to expand)
File Line Roast
pmoves/tools/pytest_ratchet.py 463 The isolation pass's total budget is still the unchanged FALLBACK_BUDGET_SECONDS (600s) while a single file there can now legally cost 660s — a chunk that times out anyway can burn the pass budget before reaching the harness, and the fallback budget exhausted path re-declares the exact file this PR defends as BROKEN. The escape hatch has a trapdoor; make the pass budget allowance-aware too.
pmoves/tools/pytest_ratchet.py 223 An unparseable slow_files: entry (typo'd path, 600s) is silently dropped, so the file silently loses its allowance and CI re-reports it as broken with less signal than round 6 had. Emit a one-line stderr warning for in-block lines that fail to match.

🏆 Best part: Round 6's core fix is genuinely good — two pure budget functions, a config-driven allowance with a required reason, a negative-control test proving the budgets fall back to exactly 120s/60s without an entry, and wiring tests proving the widened timeout reaches the subprocess AND the isolation pass. Oh wait, budget models with negative controls — I need to sit down.

💀 Worst part: The new allowance raised the per-file ceiling above the static pass budget that bounds the isolation loop. Two budgets in the same function, one updated and one not — the classic sequel to exactly the defect this PR fixes, now living one loop iteration away.

📊 Overall: Like buying a bigger bathtub and keeping the same tiny water heater — the file now can run long, but the pass-level budget can still cut the lights on it mid-run.

Fix these issues in Kilo Cloud

Files Reviewed (incremental since aac9570, 7 files)
  • pmoves/tools/pytest_ratchet.py — 2 carried findings re-verified STILL PRESENT at HEAD (budget check :452, per-file timeout :463; silent parse-skip :223); both already covered by active inline comments — no duplicates re-posted
  • pmoves/tests/tools/test_pytest_ratchet.py — full read at HEAD of the 11 round-6 tests (wiring, negative control, isolation-pass allowance); no new issues
  • pmoves/configs/pytest_ratchet/_slow_files.yaml — config-only; verified against _SLOW_ENTRY_RE and the required-reason test
  • pmoves/tests/tools/test_mavis_ratchet_mutation_kill.py — SLEEP_SECONDS 20.0 → 12.0 trim only; all mutation anchors (FIXED_*/ORIGINAL_*) byte-match the live source; no issues
  • pmoves/tests/test_mavis_cli_timeout.py — unchanged in the incremental delta; prior threads re-verified fixed (exclude handling, POSIX lock deadline, locked clean-check, locked module load, mandatory pytest deadline, non-finite deadline guard, tree-kill + bounded drain, exact API-host match)
  • pmoves/docs/AGENTS/test_gap_ratchet_LEARNINGS.md — prose-only lessons feat(media-video): enable multimodal video intelligence #26–feat: orchestrate media audio pipeline #29 + round-6 tables; no code issues
  • pmoves/docs/AGENTS/AGNOTE4482PHI.t1.md — prose-only round-6 NOTE append; no code issues

Incremental-mode notes: the diff aac95700..HEAD initially surfaced 8 extra paths (hi-rag Dockerfiles, two hirag test files, three prose docs) — traced to base-side history (4d062d73c, PR #3382's merge) that predates the previous review head, NOT a content change by this PR; gh pr diff 3427 --name-only confirms the authoritative 7-file scope above, and the hirag files were excluded from this review per changed-lines-only. The round-6 code files are byte-identical between aac95700 and HEAD d39b11cab, so the two carried findings are re-verified rather than re-found.

Gaps: no Python interpreter execution in this sandbox (execution prohibited), so the budget-model findings are verified by reading the changed lines and the loop they sit in, not by a live run. Sub-agent count: 0 (round-6 delta is code-reviewed in full; the rebase introduced no new PR-diff content). Existing inline comments reconciled via paginated fetch: all threads carry line: null (outdated) except the two active round-6 threads at pytest_ratchet.py:463 and :223 (unanswered) and the round-5 defect-J thread at :926, which has the landing-fix reply — no active duplicates for any new finding.

Previous review (commit aac9570)

Verdict: 2 Issues Found | Recommendation: Address before merge

Overview

Severity Count
🚨 critical 0
⚠️ warning 0
💡 suggestion 1
🤏 nitpick 1
Issue Details (click to expand)
File Line Roast
pmoves/tools/pytest_ratchet.py 463 The isolation pass's total budget is still the unchanged FALLBACK_BUDGET_SECONDS (600s) while a single file there can now legally cost 660s — a chunk that times out anyway can burn the pass budget before reaching the harness, and the fallback budget exhausted path re-declares the exact file this PR defends as BROKEN. The escape hatch has a trapdoor; make the pass budget allowance-aware too.
pmoves/tools/pytest_ratchet.py 223 An unparseable slow_files: entry (typo'd path, 600s) is silently dropped, so the file silently loses its allowance and CI re-reports it as broken with less signal than round 6 had. Emit a one-line stderr warning for in-block lines that fail to match.

🏆 Best part: Round 6's core fix is genuinely good — two pure budget functions, a config-driven allowance with a required reason, a negative-control test proving the budgets fall back to exactly 120s/60s without an entry, and wiring tests proving the widened timeout reaches the subprocess AND the isolation pass. Oh wait, budget models with negative controls — I need to sit down.

💀 Worst part: The new allowance raised the per-file ceiling above the static pass budget that bounds the isolation loop. Two budgets in the same function, one updated and one not — the classic sequel to exactly the defect this PR fixes, now living one loop iteration away.

📊 Overall: Like buying a bigger bathtub and keeping the same tiny water heater — the file now can run long, but the pass-level budget can still cut the lights on it mid-run.

Fix these issues in Kilo Cloud

Files Reviewed (incremental since f9cec95, 6 files)
  • pmoves/tools/pytest_ratchet.py — 2 issues (the new declared-slow budget model; full file read)
  • pmoves/tests/tools/test_pytest_ratchet.py — full read of the 11 new tests; no issues
  • pmoves/configs/pytest_ratchet/_slow_files.yaml — config-only; parse verified against the regex
  • pmoves/tests/tools/test_mavis_ratchet_mutation_kill.py — SLEEP_SECONDS trim only; assertion set unchanged
  • pmoves/docs/AGENTS/test_gap_ratchet_LEARNINGS.md — prose-only lessons/tables; no code issues
  • pmoves/docs/AGENTS/AGNOTE4482PHI.t1.md — prose-only NOTE append; no code issues

Gaps: no Python interpreter execution in this sandbox (execution prohibited), so the budget-model findings are verified by reading the changed lines and the loop they sit in, not by a live run. Sub-agent count: 0 (incremental ~430 changed lines across 6 mostly-prose files). Existing inline comments reconciled: all fetched threads carry line: null (outdated) except the round-5 defect-J thread at :926, which has the landing-fix reply — no active duplicates.

Previous review (commit f9cec95)

Verdict: No Issues Found | Recommendation: Merge

Round 7, and the history got rewritten out from under me — force-push, SHAs moved, the whole dramatic rebase. So I did the paranoid thing and diffed the old review HEAD against the new one: zero bytes of difference in the reviewed mavis files. Same code, new addresses, same verdict.

📊 Overall: Round 7 re-verifies the round-6 state at the rewritten HEAD (f9cec9504) and finds the tree still welded: math.isfinite guards the deadline, the tree dies, the drain is bounded, and the byte-diff between the previously reviewed commits and this one is literally empty — the only thing this PR changed since the last review was its own commit IDs.

Details (click to expand)

Force-push handled per protocol: git diff 0905341c..HEAD over pmoves/tests/test_mavis_cli_timeout.py, pmoves/tests/tools/test_mavis_ratchet_mutation_kill.py, and pmoves/docs/AGENTS/test_gap_ratchet_LEARNINGS.md is empty — the branch was rebased onto the current base (99d6dc2db), and the file content is byte-identical to the round-6 verified pass. HEAD re-read immediately before publication: f9cec95043bb1cbeefa2db174ead76f7ac49ac1c, unchanged from analysis start.

Both round-5 findings re-verified as FIXED at HEAD by full-file read:

  • Defect I (nan/inf deadline override) — _validated_deadline() (pmoves/tests/tools/test_mavis_ratchet_mutation_kill.py:680, guard at :694) rejects non-finite and non-positive values and falls back to the 300s default; the dead AttributeError arm is gone. Pinned by test_nonfinite_timeout_override_falls_back_to_default (:1525), killed by test_mutation_nonfinite_timeout_override_is_killed (:1791).
  • Defect J (Windows unbounded post-kill drain / direct-child kill) — children start in their own session/group (_spawn_pytest_process, :750), the tree is killed on timeout (_kill_process_tree, :785: os.killpg on POSIX, taskkill /T /F + direct-child fallback on Windows), the drain is bounded (_drain_process_output, :834, 10s cap, tree-kill-bounded final reap), and PytestRunTimeout raises on every branch so the message contract holds on both platforms. Pinned by test_post_kill_drain_is_bounded_when_a_pipe_holder_survives (:1613) against _FakeWedgedChild (:1565), killed by test_mutation_unbounded_post_kill_drain_is_killed (:1814) and test_mutation_direct_child_kill_is_killed (:1836).

Fresh checks at HEAD, nothing found: every mutation anchor (FIXED_GATE, FIXED_EXCLUDE_HANDLING, FIXED_POSIX_BRANCH, FIXED_LOCKED_READ, FIXED_LOCKED_MODULE_LOAD, FIXED_PYTEST_RUN, FIXED_POST_KILL, FIXED_DRAIN, FIXED_DEADLINE_VALIDATION, FIXED_API_HOST_MATCH, FIXED_UPSTREAM_PIN) byte-matches the live source; the _mutation_case green→red→green contract holds with an exact-bytes restore inside the lock; the re-invoked communicate(timeout=…) in the drain retries safely; the fake child's dead pid keeps the monkeypatched tree-kill honest; the lock-release verification checks acquireability in a thread so a leak fails instead of deadlocking.

Existing inline comments reconciled: 34 threads fetched with pagination; all are on subject_type: "line" with line: null (outdated) except the round-5 defect-J thread (:926), which carries a landing fix reply — no active same-defect findings, nothing to carry or de-duplicate.

Files Reviewed (incremental since 0905341; content-identical, re-verified at HEAD):

  • pmoves/tests/test_mavis_cli_timeout.py — full re-read at HEAD; both prior findings closed; no new issues
  • pmoves/tests/tools/test_mavis_ratchet_mutation_kill.py — full re-read at HEAD; anchors verified against live source; no new issues
  • pmoves/docs/AGENTS/test_gap_ratchet_LEARNINGS.md — round-5 lesson rows + measurement tables, prose-only, no code issues
  • pmoves/docs/AGENTS/AGNOTE4482PHI.t1.md — prose-only NOTE append, no code issues

Gaps: no Python interpreter in this sandbox and execution is prohibited, so platform-specific paths (Windows taskkill, POSIX killpg, msvcrt locking) are verified by source reading of the changed lines plus documented CPython semantics, not by execution. Sub-agent count: 0 (byte-empty incremental, prose-only elsewhere).

Previous review (commit 0905341)

Verdict: No Issues Found | Recommendation: Merge

Oh wait, this PR is actually clean. I need to sit down. I had my flamethrower warmed up and everything.

📊 Overall: Round 6 reviews the fix for round 5's two findings and finds the barn doors not just closed but welded: math.isfinite guards the deadline, the tree dies, the drain is bounded, and three new mutants stand guard over all of it.

Details (click to expand)

Both previous findings re-verified as FIXED at HEAD (e00a052 + docs at 0905341):

  • Defect I (nan/inf deadline override) — _validated_deadline() (pmoves/tests/tools/test_mavis_ratchet_mutation_kill.py:680, guard at :694) rejects non-finite and non-positive values; the dead AttributeError arm is gone (:719). Pinned by test_nonfinite_timeout_override_falls_back_to_default (:1525), killed by test_mutation_nonfinite_timeout_override_is_killed (:1791).
  • Defect J (Windows unbounded post-kill drain / direct-child kill) — children now start in their own session/group (_spawn_pytest_process, :750), the tree is killed on timeout (_kill_process_tree, :785: os.killpg on POSIX, taskkill /T /F + direct-child fallback on Windows), and the drain is bounded (_drain_process_output, :834, 10s cap with a further-bounded final reap). PytestRunTimeout raises on every branch, so the message contract holds on both platforms. Pinned by test_post_kill_drain_is_bounded_when_a_pipe_holder_survives (:1613) against _FakeWedgedChild (:1565), killed by test_mutation_unbounded_post_kill_drain_is_killed (:1814) and test_mutation_direct_child_kill_is_killed (:1836).

Fresh code checked, nothing found: mutation anchors (FIXED_DRAIN, FIXED_POST_KILL, FIXED_PYTEST_RUN, FIXED_DEADLINE_VALIDATION) byte-match the live source; the re-invoked communicate(timeout=…) in the drain matches CPython's documented retry-safe semantics; the success path builds CompletedProcess after communicate has reaped the child; the fake child's dead pid keeps the monkeypatched tree-kill honest; the lock-release verification checks in a thread to fail instead of deadlock.

Files Reviewed (incremental since 43aaa49; 3 files changed, plus carried checks):

  • pmoves/tests/tools/test_mavis_ratchet_mutation_kill.py — both round-5 findings fixed at HEAD, no new issues; anchors verified against live source
  • pmoves/docs/AGENTS/test_gap_ratchet_LEARNINGS.md — prose-only round-5 lesson rows + measurement tables, no code issues
  • pmoves/docs/AGENTS/AGNOTE4482PHI.t1.md — prose-only round-5 NOTE append, no code issues
  • pmoves/tests/test_mavis_cli_timeout.py — not in the incremental diff; targeted check confirms all previously carried findings landed and closed (no code change since the last verified pass)

Gaps: no Python interpreter in this sandbox and execution is prohibited, so platform-specific paths (Windows taskkill, POSIX killpg) are verified by source reading of the changed lines plus documented CPython/CWD semantics, not by execution. Sub-agent count: 0 (single-file incremental change, prose-only elsewhere).

Previous review (commit 43aaa49)

Verdict: 2 Issues Found | Recommendation: Address before merge

Overview

Severity Count
🚨 critical 0
⚠️ warning 1
💡 suggestion 1
🤏 nitpick 0
Issue Details (click to expand)
File Line Roast
pmoves/tests/tools/test_mavis_ratchet_mutation_kill.py 676 The Windows timeout path can still hold the lock FOREVER: CPython's post-TimeoutExpired cleanup calls process.communicate() with no timeout, so a grandchild of the killed inner pytest (this harness designs in nested pytest subprocesses) inheriting the pipe wedges the drain, PytestRunTimeout never raises, and _mutation_case's with _mutation_lock(...) never exits. Kill the process tree (POSIX: new session + killpg; Windows: CREATE_NEW_PROCESS_GROUP + taskkill /T /F) and cap the post-kill drain.
pmoves/tests/tools/test_mavis_ratchet_mutation_kill.py 594 _pytest_timeout_seconds() accepts nan/inf overrides: NaN passes value <= 0 by comparing False, and subprocess.run(timeout=nan) never fires — the exact "typo switches the deadline off" defect the same docstring promises to prevent. Guard with math.isfinite(value) (and drop the unreachable AttributeError arm — os.environ values are always str).

🏆 Best part: The incremental delta since the last review is three prose register rows and zero new code — meaning five review rounds, nine confirmed defects, and nine landings, and the code is now quiet because it's actually fixed, not because anyone stopped looking. The mutation anchors still byte-match the live source. I keep sharpening the knife and keep finding the whetstone already used; it's disorienting.

💀 Worst part: The two survivors are both "the guarantee ends one layer below where you were looking." The lock holder's deadline still dies on Windows inside CPython's own unbounded post-kill pipe drain, and the deadline's override still can be set to a value that isn't a deadline. Round after round has pushed the same defect class one level down; this is where it stops moving.

📊 Overall: A ratchet with 180× headroom on its deadline and two ways a typo takes the headroom out — the last mile is made entirely of edge cases you already built test infrastructure to catch.

Fix these issues in Kilo Cloud

Files Reviewed (1 file changed since last review; 4 files verified)
  • pmoves/docs/AGENTS/AGNOTE4482PHI.t1.md - prose-only append (3 register rows: PR docs(register): land CRUSH-GLM52's five stranded RELEASE rows + baton-close the 5090 topology rows #3390 NOTE + two CRUSH-GLM52 claim/release rows), no code issues; ordering against the existing 00:19:47 row is by design (postdate-clean per repo tooling)
  • pmoves/tests/tools/test_mavis_ratchet_mutation_kill.py - 2 previous findings re-verified STILL PRESENT at current HEAD (no code change since c16bbd1): Windows unbounded post-kill communicate() wedge (:668-679) and missing math.isfinite guard (:590-595); both already covered by active inline comments — no duplicates re-posted
  • pmoves/tests/test_mavis_cli_timeout.py - unchanged since previous head; carried findings verified complete (exclude handling, POSIX flock deadline, locked clean-check, exact API-host match all landed)
  • pmoves/docs/AGENTS/test_gap_ratchet_LEARNINGS.md - unchanged since previous head; no issues

Gaps: no Python interpreter available in this sandbox (and execution is prohibited), so the Windows communicate() wedge and the NaN/inf deadline paths are verified by source reading of the current changed lines plus CPython's documented subprocess timeout semantics, not by execution.

Previous review (commit c16bbd1)

Verdict: 2 Issues Found | Recommendation: Address before merge

Overview

Severity Count
🚨 critical 0
⚠️ warning 1
💡 suggestion 1
🤏 nitpick 0
Issue Details (click to expand)
File Line Roast
pmoves/tests/tools/test_mavis_ratchet_mutation_kill.py 676 The Windows timeout path can still hold the lock FOREVER: CPython's post-TimeoutExpired cleanup calls process.communicate() with no timeout, so a grandchild of the killed inner pytest (this harness designs in nested pytest subprocesses) inheriting the pipe wedges the drain, PytestRunTimeout never raises, and _mutation_case's with _mutation_lock(...) never exits. Kill the process tree (POSIX: new session + killpg; Windows: CREATE_NEW_PROCESS_GROUP + taskkill /T /F) and cap the post-kill drain.
pmoves/tests/tools/test_mavis_ratchet_mutation_kill.py 594 _pytest_timeout_seconds() accepts nan/inf overrides: NaN passes value <= 0 by comparing False, and subprocess.run(timeout=nan) never fires — the exact "typo switches the deadline off" defect the same docstring promises to prevent. Guard with math.isfinite(value) (and drop the unreachable AttributeError arm — os.environ values are always str).

🏆 Best part: Both round-4 findings are now genuinely landed, not just replied-to — _load_ratchet_module(lock_path, target) takes the lock across the whole read+exec as one indivisible window, _run_pytest has a real deadline whose override fails safe to the default, and the timeout test checks lock re-acquirability in a thread so a leaked non-reentrant lock fails instead of deadlocking the suite. Nine threads, nine real fixes, zero suppressions over four rounds; the mutation anchors byte-match the live source. At this point the review process has its own review process.

💀 Worst part: The round dedicated to "the lock HOLDER must not be able to hang" left one platform where the holder still can — the unbounded post-kill pipe drain on Windows. Round three was "the lock's two halves must agree"; round four partially repeated it, just one layer down (process tree instead of OS branch).

📊 Overall: The ratchet can now say no, read whole declarations, and time out — it just needs to learn to raise a family that can also be put down.

Fix these issues in Kilo Cloud

Files Reviewed (4 files)
  • pmoves/tests/tools/test_mavis_ratchet_mutation_kill.py - 2 NEW issues (both round-4 findings verified fixed: locked read+exec at :706/#:726, mandatory deadline at :576/:621; mutation anchors byte-match source)
  • pmoves/tests/test_mavis_cli_timeout.py - no NEW issues (unchanged since previous head; all prior threads re-verified fixed, incl. CodeQL alert via _is_github_api_url)
  • pmoves/docs/AGENTS/test_gap_ratchet_LEARNINGS.md - prose-only append (lessons feat: enable media decoders in legacy hi-rag gateway #22-Remove demo SSE pipeline #23), no issues; measured numbers quoted are consistent with the code
  • pmoves/docs/AGENTS/AGNOTE4482PHI.t1.md - prose-only NOTE append, no issues

Gaps: no Python interpreter available in this sandbox (and execution is prohibited), so the Windows communicate() wedge and the NaN-timeout paths are verified by source reading of the changed lines plus CPython's documented subprocess.run timeout semantics, not by execution.

Previous review (commit 8af2663)

Verdict: 2 Issues Found | Recommendation: Address before merge

Overview

Severity Count
🚨 critical 0
⚠️ warning 0
💡 suggestion 2
🤏 nitpick 0
Issue Details (click to expand)
File Line Roast
pmoves/tests/tools/test_mavis_ratchet_mutation_kill.py 548 _load_ratchet_module() executes TARGET straight off disk with no _mutation_lock() — under xdist it can import the file mid-mutation and judge a kill verdict a

[Snapshot truncated.]

Additional previous summary content was truncated to keep this comment within platform limits.


Reviewed by glm-5.3-flash · Input: 48K · Output: 18.3K · Cached: 367K

@POWERFULMOVES
POWERFULMOVES force-pushed the fix/ratchet-upstream-matrix-and-shim-origin branch from 0aaba68 to ded8f21 Compare October 30, 2026 19:34
@github-actions

Copy link
Copy Markdown
Contributor

ORGSIM-MIRROR drift check (advisory, fail-soft)

vv3 / 7 files / VERIFIED 99 / UNDECIDED 61 / digest 7a6563644965

Zero-LLM deterministic audit - unreachable = UNDECIDED, never dead - scripts/runbook_drift.py

POWERFULMOVES pushed a commit that referenced this pull request Oct 30, 2026
… check can now say no

PR #3427 carried the A/B/C correction round into review. Seven threads came
back, and most of them were one defect wearing different clothes: a check
that cannot tell "I could not check" from "the answer is no", and a kill
signal that cannot tell "the mutation died" from "the run died".

Thread 1 (dbId 4427664896, P2) — a failed workflow download was reported as "ok"
  `_fetch_upstream_matrix()` caught a download failure with a bare `continue`
  and then returned status="ok" carrying whatever platforms it had managed to
  scrape from the other workflows. A rate-limited or timed-out download
  therefore published "upstream dropped Windows" when the truth was "GitHub
  throttled us" — an infrastructure failure reported as an upstream change.
  Every failure path now returns status="unavailable" plus a `reason`, and
  the cross-check SKIPS with that reason instead of blaming upstream. Pinned
  by test_mutation_upstream_download_failure_is_unavailable.

Thread 2 (dbId 4427664903, P2) — platform detection aggregated over every workflow
  The detector unioned runner labels found in the body of EVERY workflow under
  .github/workflows/. A label left behind in a release, compatibility or
  packaging workflow — or in a comment — still counted as test coverage, so
  removing Windows from the test matrix left the ratchet green while it named
  the wrong owner for the regression. Detection is now structural: the CI
  workflow (ci.yml) is selected explicitly, the job whose runs-on is driven by
  matrix.<key> is located, that job is confirmed to be the TEST job, and only
  that key's values (plus its include: overrides) are read. A workflow with no
  identifiable TEST job reports UNAVAILABLE rather than a confident platform
  set. Pinned by test_mutation_matrix_scoped_platform_detection.

Thread 3 (dbId 4427675919) — the runner-label version assumption
  The match tested a fixed suffix list (-latest / -22 / -24). GitHub-hosted
  runners appear as windows-2025, windows-2022, macos-15 and ubuntu-24.04 —
  none of them ends in one of those suffixes. One upstream rename emptied the
  platform set, the "windows" in platforms gate fired, and the ratchet rebuilt
  the inverted defect it exists to kill. The match is now the family followed
  by "latest" or ANY digit, which covers every version shape GitHub
  publishes. Pinned by test_mutation_runner_label_family_matching.

Thread 4 (dbId 4427675854) — infinite recursion inside the patched launcher
  broken_launcher was installed AS subprocess.run, and its fallback branch
  called subprocess.run again — resolving the patched attribute and re-entering
  itself with the same arguments, forever. real_run is now captured BEFORE
  monkeypatch.setattr and the fallback calls it, matching the sibling test
  that already had it right.

Thread 5 (dbId 4427675888) — the mutation-kill skipped whenever the CLI was absent
  test_mutation_broken_shim_fails_ratchet — and its sibling
  test_mutation_hang_fails_ratchet — skipped when mavis was not on PATH, i.e.
  on CI, so the load-bearing kill only bore load on the operator's laptop.
  Neither test ever runs the real CLI (the CompletedProcess is built by hand;
  the call is intercepted), so the guard bought nothing except a skip. The
  args are now constructed directly, the way
  test_mutation_error_banner_on_stdout_fails_ratchet already did. Verified:
  with mavis removed from PATH both files still pass and both kills still fire.

Thread 6 (dbId 4427675898) — the kill signal was "the run got sad"
  The signal was `proc.returncode != 0 and "failed" in output`, which a
  collection error caused by an unrelated import change, a timeout, or an
  environment failure also satisfies; the substring cannot tell "1 failed"
  from "failed to create endpoint". Each mutation now names the test that
  MUST fail (test_mutation_broken_shim_fails_ratchet for the version gate,
  test_mutation_wrong_upstream_repo_is_detectable for the upstream pin) and
  the harness reads pytest's own -rA short test summary for that name. A run
  that died for any other reason is no longer celebrated as a kill.

Thread 7 (dbId 4427675910) — the mutate/restore window raced
  Both mutations rewrote the same tracked source file and restored it in a
  finally, so a parallel runner could read a mutated "original" and resurrect
  a mutated file on restore. The window is now serialized by a threading.Lock
  plus a cross-process advisory file lock (the OS releases it if a worker
  dies, so a crashed run cannot leave it held), the restore writes back the
  exact pre-mutation bytes, and the restore is asserted.

Live probe after the repair (PMOVES_MAVIS_MATRIX_CHECK=1):
  {'status': 'ok', 'platforms': ['macos', 'ubuntu', 'windows'],
   'jobs': ['verify'], 'matrix_key': 'os',
   'labels': ['macos-latest', 'ubuntu-latest', 'windows-latest']}
Note what is NOT in that set: `linux`. The word "Linux" exists in upstream's
ci.yml only inside a COMMENT, and a comment is not a matrix entry — precisely
the distinction the old body scan could not make.

LEARNINGS: pmoves/docs/AGENTS/test_gap_ratchet_LEARNINGS.md gains lessons
#13–#17 (unavailable-vs-ok, matrix-scoped platform detection, runner-label
family matching, the named-test kill signal, and the harness's own
mutate/restore contract), a finding → lesson → code map for all seven
threads, and the live probe result.

Verified on this host:
  12 passed, 1 skipped  (the network-gated matrix check skips by default)
  13 passed, 0 skipped  (with PMOVES_MAVIS_MATRIX_CHECK=1)
  10 passed, 3 skipped  (with mavis removed from PATH — both kills still fire)
Comment thread pmoves/tests/test_mavis_cli_timeout.py Resolved
@POWERFULMOVES
POWERFULMOVES force-pushed the fix/ratchet-upstream-matrix-and-shim-origin branch from 7521765 to c457bf9 Compare October 30, 2026 22:20
POWERFULMOVES pushed a commit that referenced this pull request Oct 30, 2026
… check can now say no

PR #3427 carried the A/B/C correction round into review. Seven threads came
back, and most of them were one defect wearing different clothes: a check
that cannot tell "I could not check" from "the answer is no", and a kill
signal that cannot tell "the mutation died" from "the run died".

Thread 1 (dbId 4427664896, P2) — a failed workflow download was reported as "ok"
  `_fetch_upstream_matrix()` caught a download failure with a bare `continue`
  and then returned status="ok" carrying whatever platforms it had managed to
  scrape from the other workflows. A rate-limited or timed-out download
  therefore published "upstream dropped Windows" when the truth was "GitHub
  throttled us" — an infrastructure failure reported as an upstream change.
  Every failure path now returns status="unavailable" plus a `reason`, and
  the cross-check SKIPS with that reason instead of blaming upstream. Pinned
  by test_mutation_upstream_download_failure_is_unavailable.

Thread 2 (dbId 4427664903, P2) — platform detection aggregated over every workflow
  The detector unioned runner labels found in the body of EVERY workflow under
  .github/workflows/. A label left behind in a release, compatibility or
  packaging workflow — or in a comment — still counted as test coverage, so
  removing Windows from the test matrix left the ratchet green while it named
  the wrong owner for the regression. Detection is now structural: the CI
  workflow (ci.yml) is selected explicitly, the job whose runs-on is driven by
  matrix.<key> is located, that job is confirmed to be the TEST job, and only
  that key's values (plus its include: overrides) are read. A workflow with no
  identifiable TEST job reports UNAVAILABLE rather than a confident platform
  set. Pinned by test_mutation_matrix_scoped_platform_detection.

Thread 3 (dbId 4427675919) — the runner-label version assumption
  The match tested a fixed suffix list (-latest / -22 / -24). GitHub-hosted
  runners appear as windows-2025, windows-2022, macos-15 and ubuntu-24.04 —
  none of them ends in one of those suffixes. One upstream rename emptied the
  platform set, the "windows" in platforms gate fired, and the ratchet rebuilt
  the inverted defect it exists to kill. The match is now the family followed
  by "latest" or ANY digit, which covers every version shape GitHub
  publishes. Pinned by test_mutation_runner_label_family_matching.

Thread 4 (dbId 4427675854) — infinite recursion inside the patched launcher
  broken_launcher was installed AS subprocess.run, and its fallback branch
  called subprocess.run again — resolving the patched attribute and re-entering
  itself with the same arguments, forever. real_run is now captured BEFORE
  monkeypatch.setattr and the fallback calls it, matching the sibling test
  that already had it right.

Thread 5 (dbId 4427675888) — the mutation-kill skipped whenever the CLI was absent
  test_mutation_broken_shim_fails_ratchet — and its sibling
  test_mutation_hang_fails_ratchet — skipped when mavis was not on PATH, i.e.
  on CI, so the load-bearing kill only bore load on the operator's laptop.
  Neither test ever runs the real CLI (the CompletedProcess is built by hand;
  the call is intercepted), so the guard bought nothing except a skip. The
  args are now constructed directly, the way
  test_mutation_error_banner_on_stdout_fails_ratchet already did. Verified:
  with mavis removed from PATH both files still pass and both kills still fire.

Thread 6 (dbId 4427675898) — the kill signal was "the run got sad"
  The signal was `proc.returncode != 0 and "failed" in output`, which a
  collection error caused by an unrelated import change, a timeout, or an
  environment failure also satisfies; the substring cannot tell "1 failed"
  from "failed to create endpoint". Each mutation now names the test that
  MUST fail (test_mutation_broken_shim_fails_ratchet for the version gate,
  test_mutation_wrong_upstream_repo_is_detectable for the upstream pin) and
  the harness reads pytest's own -rA short test summary for that name. A run
  that died for any other reason is no longer celebrated as a kill.

Thread 7 (dbId 4427675910) — the mutate/restore window raced
  Both mutations rewrote the same tracked source file and restored it in a
  finally, so a parallel runner could read a mutated "original" and resurrect
  a mutated file on restore. The window is now serialized by a threading.Lock
  plus a cross-process advisory file lock (the OS releases it if a worker
  dies, so a crashed run cannot leave it held), the restore writes back the
  exact pre-mutation bytes, and the restore is asserted.

Live probe after the repair (PMOVES_MAVIS_MATRIX_CHECK=1):
  {'status': 'ok', 'platforms': ['macos', 'ubuntu', 'windows'],
   'jobs': ['verify'], 'matrix_key': 'os',
   'labels': ['macos-latest', 'ubuntu-latest', 'windows-latest']}
Note what is NOT in that set: `linux`. The word "Linux" exists in upstream's
ci.yml only inside a COMMENT, and a comment is not a matrix entry — precisely
the distinction the old body scan could not make.

LEARNINGS: pmoves/docs/AGENTS/test_gap_ratchet_LEARNINGS.md gains lessons
#13–#17 (unavailable-vs-ok, matrix-scoped platform detection, runner-label
family matching, the named-test kill signal, and the harness's own
mutate/restore contract), a finding → lesson → code map for all seven
threads, and the live probe result.

Verified on this host:
  12 passed, 1 skipped  (the network-gated matrix check skips by default)
  13 passed, 0 skipped  (with PMOVES_MAVIS_MATRIX_CHECK=1)
  10 passed, 3 skipped  (with mavis removed from PATH — both kills still fire)
@github-actions

Copy link
Copy Markdown
Contributor

ORGSIM-MIRROR drift check (advisory, fail-soft)

vv3 / 7 files / VERIFIED 99 / UNDECIDED 61 / digest 7298a8dec416

Zero-LLM deterministic audit - unreachable = UNDECIDED, never dead - scripts/runbook_drift.py

POWERFULMOVES pushed a commit that referenced this pull request Oct 30, 2026
…, and locked the wrong half

Four findings against PR #3427, all confirmed VALID and closed at source.

A. `exclude:` was never read. `_extract_matrix_platforms` collected
runner labels from the base dimension list plus `include:` entries and
never expanded or removed combinations, so a matrix that EXCLUDED
windows-latest still reported windows as covered -- the exact
inversion this ratchet exists to prevent, in the other direction.
New helpers `_matrix_axes` (:368), `_base_combinations` (:388),
`_combo_matches_exclude` (:405), `_apply_matrix_exclusions` (:422),
`_apply_matrix_inclusions` (:444); `_extract_matrix_platforms` (:499)
now expands base -> exclude -> include (GitHub's documented order) and
takes labels only from surviving combinations. An exclude that matches
nothing removes nothing -- not an error.

B. The POSIX lock could block forever. `_lock_file` enforced
`_LOCK_TIMEOUT_SECONDS` on the Windows branch only; POSIX used a bare
blocking `flock`, so a stuck holder wedged the suite with no timeout
and no diagnostic. Split into `_try_lock_windows` (:347) /
`_try_lock_posix` (:359, LOCK_EX|LOCK_NB) behind `_try_lock_nonblocking`
(:375), with ONE shared deadline loop in `_lock_file` (:382) that
raises `MutationLockTimeout` (:290) naming the lock file, the timeout
and the recorded holder. Both branches: same constant, same failure
mode, same message. A timeout always raises -- it never proceeds
unlocked.

C. The clean-check read the target without the lock.
`test_ratchet_file_is_left_clean_after_mutations` read TARGET outside
`_mutation_lock()`, so it could observe the file mid-mutation and
report a false pass. `_read_ratchet_file_under_lock` (:464) takes the
lock for the whole read; `_assert_ratchet_file_clean` (:475) holds the
content assertions.

D. CodeQL "Incomplete URL substring sanitization" (HIGH, the ratchet's
own test double). `fake_urlopen` matched the host with
`"api.github.com" in url`, which also accepts
`https://api.github.com.evil.example/` and
`https://evil.example/?x=api.github.com`. Fixed AT THE SOURCE:
`_is_github_api_url` (:305) parses with urllib.parse.urlsplit and
requires `parsed.hostname == "api.github.com"` -- host only, the netloc
is NOT compared because it carries userinfo and a port. A URL that is
not absolute or not parseable is not the API host and must not raise.
NO nosec, NO CodeQL config change -- the alert is fixed, not silenced.

New cases, each invoking the code under test rather than restating it:
- A: `test_mutation_excluded_platform_is_not_covered` (:1255) via
  `_assert_matrix_platforms` (:619); harness
  `test_mutation_exclude_handling_is_killed` (:686) mutates the ratchet
  back to ignoring exclude and requires that named test to fail.
- B: `test_posix_lock_path_times_out_and_raises` (:762) -- fake fcntl
  plus fake clock, proves the POSIX path raises instead of hanging;
  `test_held_lock_makes_the_next_holder_time_out` (:831) proves it
  end-to-end against a real holder process; harness
  `test_mutation_posix_blocking_flock_is_killed` (:912).
- C: `test_clean_check_is_serialized_against_concurrent_mutation`
  (:872) -- the reader thread must NOT complete while the lock is held;
  harness `test_mutation_unlocked_clean_check_is_killed` (:933).
- D: `test_mutation_github_api_host_match_is_exact` (:1394); harness
  `test_mutation_loose_api_host_match_is_killed` (:953).

Every mutation case runs GREEN-before -> RED-after (named test) ->
GREEN-after-restore, with a byte-exact restore inside the lock
(`_mutation_case`, :567).

Measured: ratchet 11 passed / 1 skipped (skip = the network-gated
matrix cross-check); harness 10 passed; 22 passed / 0 skipped with
PMOVES_MAVIS_MATRIX_CHECK=1 (the live probe ran and passed); 19 passed
/ 3 skipped with `mavis` off PATH (the two CLI probes plus the matrix
gate), with every mutation-kill still firing.
@github-actions

Copy link
Copy Markdown
Contributor

ORGSIM-MIRROR drift check (advisory, fail-soft)

vv3 / 7 files / VERIFIED 99 / UNDECIDED 61 / digest 546951bd4ea0

Zero-LLM deterministic audit - unreachable = UNDECIDED, never dead - scripts/runbook_drift.py

@POWERFULMOVES
POWERFULMOVES force-pushed the fix/ratchet-upstream-matrix-and-shim-origin branch from 8af2663 to c16bbd1 Compare October 30, 2026 23:52
POWERFULMOVES pushed a commit that referenced this pull request Oct 30, 2026
… check can now say no

PR #3427 carried the A/B/C correction round into review. Seven threads came
back, and most of them were one defect wearing different clothes: a check
that cannot tell "I could not check" from "the answer is no", and a kill
signal that cannot tell "the mutation died" from "the run died".

Thread 1 (dbId 4427664896, P2) — a failed workflow download was reported as "ok"
  `_fetch_upstream_matrix()` caught a download failure with a bare `continue`
  and then returned status="ok" carrying whatever platforms it had managed to
  scrape from the other workflows. A rate-limited or timed-out download
  therefore published "upstream dropped Windows" when the truth was "GitHub
  throttled us" — an infrastructure failure reported as an upstream change.
  Every failure path now returns status="unavailable" plus a `reason`, and
  the cross-check SKIPS with that reason instead of blaming upstream. Pinned
  by test_mutation_upstream_download_failure_is_unavailable.

Thread 2 (dbId 4427664903, P2) — platform detection aggregated over every workflow
  The detector unioned runner labels found in the body of EVERY workflow under
  .github/workflows/. A label left behind in a release, compatibility or
  packaging workflow — or in a comment — still counted as test coverage, so
  removing Windows from the test matrix left the ratchet green while it named
  the wrong owner for the regression. Detection is now structural: the CI
  workflow (ci.yml) is selected explicitly, the job whose runs-on is driven by
  matrix.<key> is located, that job is confirmed to be the TEST job, and only
  that key's values (plus its include: overrides) are read. A workflow with no
  identifiable TEST job reports UNAVAILABLE rather than a confident platform
  set. Pinned by test_mutation_matrix_scoped_platform_detection.

Thread 3 (dbId 4427675919) — the runner-label version assumption
  The match tested a fixed suffix list (-latest / -22 / -24). GitHub-hosted
  runners appear as windows-2025, windows-2022, macos-15 and ubuntu-24.04 —
  none of them ends in one of those suffixes. One upstream rename emptied the
  platform set, the "windows" in platforms gate fired, and the ratchet rebuilt
  the inverted defect it exists to kill. The match is now the family followed
  by "latest" or ANY digit, which covers every version shape GitHub
  publishes. Pinned by test_mutation_runner_label_family_matching.

Thread 4 (dbId 4427675854) — infinite recursion inside the patched launcher
  broken_launcher was installed AS subprocess.run, and its fallback branch
  called subprocess.run again — resolving the patched attribute and re-entering
  itself with the same arguments, forever. real_run is now captured BEFORE
  monkeypatch.setattr and the fallback calls it, matching the sibling test
  that already had it right.

Thread 5 (dbId 4427675888) — the mutation-kill skipped whenever the CLI was absent
  test_mutation_broken_shim_fails_ratchet — and its sibling
  test_mutation_hang_fails_ratchet — skipped when mavis was not on PATH, i.e.
  on CI, so the load-bearing kill only bore load on the operator's laptop.
  Neither test ever runs the real CLI (the CompletedProcess is built by hand;
  the call is intercepted), so the guard bought nothing except a skip. The
  args are now constructed directly, the way
  test_mutation_error_banner_on_stdout_fails_ratchet already did. Verified:
  with mavis removed from PATH both files still pass and both kills still fire.

Thread 6 (dbId 4427675898) — the kill signal was "the run got sad"
  The signal was `proc.returncode != 0 and "failed" in output`, which a
  collection error caused by an unrelated import change, a timeout, or an
  environment failure also satisfies; the substring cannot tell "1 failed"
  from "failed to create endpoint". Each mutation now names the test that
  MUST fail (test_mutation_broken_shim_fails_ratchet for the version gate,
  test_mutation_wrong_upstream_repo_is_detectable for the upstream pin) and
  the harness reads pytest's own -rA short test summary for that name. A run
  that died for any other reason is no longer celebrated as a kill.

Thread 7 (dbId 4427675910) — the mutate/restore window raced
  Both mutations rewrote the same tracked source file and restored it in a
  finally, so a parallel runner could read a mutated "original" and resurrect
  a mutated file on restore. The window is now serialized by a threading.Lock
  plus a cross-process advisory file lock (the OS releases it if a worker
  dies, so a crashed run cannot leave it held), the restore writes back the
  exact pre-mutation bytes, and the restore is asserted.

Live probe after the repair (PMOVES_MAVIS_MATRIX_CHECK=1):
  {'status': 'ok', 'platforms': ['macos', 'ubuntu', 'windows'],
   'jobs': ['verify'], 'matrix_key': 'os',
   'labels': ['macos-latest', 'ubuntu-latest', 'windows-latest']}
Note what is NOT in that set: `linux`. The word "Linux" exists in upstream's
ci.yml only inside a COMMENT, and a comment is not a matrix entry — precisely
the distinction the old body scan could not make.

LEARNINGS: pmoves/docs/AGENTS/test_gap_ratchet_LEARNINGS.md gains lessons
#13–#17 (unavailable-vs-ok, matrix-scoped platform detection, runner-label
family matching, the named-test kill signal, and the harness's own
mutate/restore contract), a finding → lesson → code map for all seven
threads, and the live probe result.

Verified on this host:
  12 passed, 1 skipped  (the network-gated matrix check skips by default)
  13 passed, 0 skipped  (with PMOVES_MAVIS_MATRIX_CHECK=1)
  10 passed, 3 skipped  (with mavis removed from PATH — both kills still fire)
POWERFULMOVES pushed a commit that referenced this pull request Oct 30, 2026
…, and locked the wrong half

Four findings against PR #3427, all confirmed VALID and closed at source.

A. `exclude:` was never read. `_extract_matrix_platforms` collected
runner labels from the base dimension list plus `include:` entries and
never expanded or removed combinations, so a matrix that EXCLUDED
windows-latest still reported windows as covered -- the exact
inversion this ratchet exists to prevent, in the other direction.
New helpers `_matrix_axes` (:368), `_base_combinations` (:388),
`_combo_matches_exclude` (:405), `_apply_matrix_exclusions` (:422),
`_apply_matrix_inclusions` (:444); `_extract_matrix_platforms` (:499)
now expands base -> exclude -> include (GitHub's documented order) and
takes labels only from surviving combinations. An exclude that matches
nothing removes nothing -- not an error.

B. The POSIX lock could block forever. `_lock_file` enforced
`_LOCK_TIMEOUT_SECONDS` on the Windows branch only; POSIX used a bare
blocking `flock`, so a stuck holder wedged the suite with no timeout
and no diagnostic. Split into `_try_lock_windows` (:347) /
`_try_lock_posix` (:359, LOCK_EX|LOCK_NB) behind `_try_lock_nonblocking`
(:375), with ONE shared deadline loop in `_lock_file` (:382) that
raises `MutationLockTimeout` (:290) naming the lock file, the timeout
and the recorded holder. Both branches: same constant, same failure
mode, same message. A timeout always raises -- it never proceeds
unlocked.

C. The clean-check read the target without the lock.
`test_ratchet_file_is_left_clean_after_mutations` read TARGET outside
`_mutation_lock()`, so it could observe the file mid-mutation and
report a false pass. `_read_ratchet_file_under_lock` (:464) takes the
lock for the whole read; `_assert_ratchet_file_clean` (:475) holds the
content assertions.

D. CodeQL "Incomplete URL substring sanitization" (HIGH, the ratchet's
own test double). `fake_urlopen` matched the host with
`"api.github.com" in url`, which also accepts
`https://api.github.com.evil.example/` and
`https://evil.example/?x=api.github.com`. Fixed AT THE SOURCE:
`_is_github_api_url` (:305) parses with urllib.parse.urlsplit and
requires `parsed.hostname == "api.github.com"` -- host only, the netloc
is NOT compared because it carries userinfo and a port. A URL that is
not absolute or not parseable is not the API host and must not raise.
NO nosec, NO CodeQL config change -- the alert is fixed, not silenced.

New cases, each invoking the code under test rather than restating it:
- A: `test_mutation_excluded_platform_is_not_covered` (:1255) via
  `_assert_matrix_platforms` (:619); harness
  `test_mutation_exclude_handling_is_killed` (:686) mutates the ratchet
  back to ignoring exclude and requires that named test to fail.
- B: `test_posix_lock_path_times_out_and_raises` (:762) -- fake fcntl
  plus fake clock, proves the POSIX path raises instead of hanging;
  `test_held_lock_makes_the_next_holder_time_out` (:831) proves it
  end-to-end against a real holder process; harness
  `test_mutation_posix_blocking_flock_is_killed` (:912).
- C: `test_clean_check_is_serialized_against_concurrent_mutation`
  (:872) -- the reader thread must NOT complete while the lock is held;
  harness `test_mutation_unlocked_clean_check_is_killed` (:933).
- D: `test_mutation_github_api_host_match_is_exact` (:1394); harness
  `test_mutation_loose_api_host_match_is_killed` (:953).

Every mutation case runs GREEN-before -> RED-after (named test) ->
GREEN-after-restore, with a byte-exact restore inside the lock
(`_mutation_case`, :567).

Measured: ratchet 11 passed / 1 skipped (skip = the network-gated
matrix cross-check); harness 10 passed; 22 passed / 0 skipped with
PMOVES_MAVIS_MATRIX_CHECK=1 (the live probe ran and passed); 19 passed
/ 3 skipped with `mavis` off PATH (the two CLI probes plus the matrix
gate), with every mutation-kill still firing.
@github-actions

Copy link
Copy Markdown
Contributor

ORGSIM-MIRROR drift check (advisory, fail-soft)

vv3 / 7 files / VERIFIED 99 / UNDECIDED 61 / digest 42778bc46e2e

Zero-LLM deterministic audit - unreachable = UNDECIDED, never dead - scripts/runbook_drift.py

@POWERFULMOVES
POWERFULMOVES force-pushed the fix/ratchet-upstream-matrix-and-shim-origin branch from c16bbd1 to 43aaa49 Compare October 31, 2026 00:15
POWERFULMOVES pushed a commit that referenced this pull request Oct 31, 2026
… check can now say no

PR #3427 carried the A/B/C correction round into review. Seven threads came
back, and most of them were one defect wearing different clothes: a check
that cannot tell "I could not check" from "the answer is no", and a kill
signal that cannot tell "the mutation died" from "the run died".

Thread 1 (dbId 4427664896, P2) — a failed workflow download was reported as "ok"
  `_fetch_upstream_matrix()` caught a download failure with a bare `continue`
  and then returned status="ok" carrying whatever platforms it had managed to
  scrape from the other workflows. A rate-limited or timed-out download
  therefore published "upstream dropped Windows" when the truth was "GitHub
  throttled us" — an infrastructure failure reported as an upstream change.
  Every failure path now returns status="unavailable" plus a `reason`, and
  the cross-check SKIPS with that reason instead of blaming upstream. Pinned
  by test_mutation_upstream_download_failure_is_unavailable.

Thread 2 (dbId 4427664903, P2) — platform detection aggregated over every workflow
  The detector unioned runner labels found in the body of EVERY workflow under
  .github/workflows/. A label left behind in a release, compatibility or
  packaging workflow — or in a comment — still counted as test coverage, so
  removing Windows from the test matrix left the ratchet green while it named
  the wrong owner for the regression. Detection is now structural: the CI
  workflow (ci.yml) is selected explicitly, the job whose runs-on is driven by
  matrix.<key> is located, that job is confirmed to be the TEST job, and only
  that key's values (plus its include: overrides) are read. A workflow with no
  identifiable TEST job reports UNAVAILABLE rather than a confident platform
  set. Pinned by test_mutation_matrix_scoped_platform_detection.

Thread 3 (dbId 4427675919) — the runner-label version assumption
  The match tested a fixed suffix list (-latest / -22 / -24). GitHub-hosted
  runners appear as windows-2025, windows-2022, macos-15 and ubuntu-24.04 —
  none of them ends in one of those suffixes. One upstream rename emptied the
  platform set, the "windows" in platforms gate fired, and the ratchet rebuilt
  the inverted defect it exists to kill. The match is now the family followed
  by "latest" or ANY digit, which covers every version shape GitHub
  publishes. Pinned by test_mutation_runner_label_family_matching.

Thread 4 (dbId 4427675854) — infinite recursion inside the patched launcher
  broken_launcher was installed AS subprocess.run, and its fallback branch
  called subprocess.run again — resolving the patched attribute and re-entering
  itself with the same arguments, forever. real_run is now captured BEFORE
  monkeypatch.setattr and the fallback calls it, matching the sibling test
  that already had it right.

Thread 5 (dbId 4427675888) — the mutation-kill skipped whenever the CLI was absent
  test_mutation_broken_shim_fails_ratchet — and its sibling
  test_mutation_hang_fails_ratchet — skipped when mavis was not on PATH, i.e.
  on CI, so the load-bearing kill only bore load on the operator's laptop.
  Neither test ever runs the real CLI (the CompletedProcess is built by hand;
  the call is intercepted), so the guard bought nothing except a skip. The
  args are now constructed directly, the way
  test_mutation_error_banner_on_stdout_fails_ratchet already did. Verified:
  with mavis removed from PATH both files still pass and both kills still fire.

Thread 6 (dbId 4427675898) — the kill signal was "the run got sad"
  The signal was `proc.returncode != 0 and "failed" in output`, which a
  collection error caused by an unrelated import change, a timeout, or an
  environment failure also satisfies; the substring cannot tell "1 failed"
  from "failed to create endpoint". Each mutation now names the test that
  MUST fail (test_mutation_broken_shim_fails_ratchet for the version gate,
  test_mutation_wrong_upstream_repo_is_detectable for the upstream pin) and
  the harness reads pytest's own -rA short test summary for that name. A run
  that died for any other reason is no longer celebrated as a kill.

Thread 7 (dbId 4427675910) — the mutate/restore window raced
  Both mutations rewrote the same tracked source file and restored it in a
  finally, so a parallel runner could read a mutated "original" and resurrect
  a mutated file on restore. The window is now serialized by a threading.Lock
  plus a cross-process advisory file lock (the OS releases it if a worker
  dies, so a crashed run cannot leave it held), the restore writes back the
  exact pre-mutation bytes, and the restore is asserted.

Live probe after the repair (PMOVES_MAVIS_MATRIX_CHECK=1):
  {'status': 'ok', 'platforms': ['macos', 'ubuntu', 'windows'],
   'jobs': ['verify'], 'matrix_key': 'os',
   'labels': ['macos-latest', 'ubuntu-latest', 'windows-latest']}
Note what is NOT in that set: `linux`. The word "Linux" exists in upstream's
ci.yml only inside a COMMENT, and a comment is not a matrix entry — precisely
the distinction the old body scan could not make.

LEARNINGS: pmoves/docs/AGENTS/test_gap_ratchet_LEARNINGS.md gains lessons
#13–#17 (unavailable-vs-ok, matrix-scoped platform detection, runner-label
family matching, the named-test kill signal, and the harness's own
mutate/restore contract), a finding → lesson → code map for all seven
threads, and the live probe result.

Verified on this host:
  12 passed, 1 skipped  (the network-gated matrix check skips by default)
  13 passed, 0 skipped  (with PMOVES_MAVIS_MATRIX_CHECK=1)
  10 passed, 3 skipped  (with mavis removed from PATH — both kills still fire)
POWERFULMOVES pushed a commit that referenced this pull request Oct 31, 2026
…, and locked the wrong half

Four findings against PR #3427, all confirmed VALID and closed at source.

A. `exclude:` was never read. `_extract_matrix_platforms` collected
runner labels from the base dimension list plus `include:` entries and
never expanded or removed combinations, so a matrix that EXCLUDED
windows-latest still reported windows as covered -- the exact
inversion this ratchet exists to prevent, in the other direction.
New helpers `_matrix_axes` (:368), `_base_combinations` (:388),
`_combo_matches_exclude` (:405), `_apply_matrix_exclusions` (:422),
`_apply_matrix_inclusions` (:444); `_extract_matrix_platforms` (:499)
now expands base -> exclude -> include (GitHub's documented order) and
takes labels only from surviving combinations. An exclude that matches
nothing removes nothing -- not an error.

B. The POSIX lock could block forever. `_lock_file` enforced
`_LOCK_TIMEOUT_SECONDS` on the Windows branch only; POSIX used a bare
blocking `flock`, so a stuck holder wedged the suite with no timeout
and no diagnostic. Split into `_try_lock_windows` (:347) /
`_try_lock_posix` (:359, LOCK_EX|LOCK_NB) behind `_try_lock_nonblocking`
(:375), with ONE shared deadline loop in `_lock_file` (:382) that
raises `MutationLockTimeout` (:290) naming the lock file, the timeout
and the recorded holder. Both branches: same constant, same failure
mode, same message. A timeout always raises -- it never proceeds
unlocked.

C. The clean-check read the target without the lock.
`test_ratchet_file_is_left_clean_after_mutations` read TARGET outside
`_mutation_lock()`, so it could observe the file mid-mutation and
report a false pass. `_read_ratchet_file_under_lock` (:464) takes the
lock for the whole read; `_assert_ratchet_file_clean` (:475) holds the
content assertions.

D. CodeQL "Incomplete URL substring sanitization" (HIGH, the ratchet's
own test double). `fake_urlopen` matched the host with
`"api.github.com" in url`, which also accepts
`https://api.github.com.evil.example/` and
`https://evil.example/?x=api.github.com`. Fixed AT THE SOURCE:
`_is_github_api_url` (:305) parses with urllib.parse.urlsplit and
requires `parsed.hostname == "api.github.com"` -- host only, the netloc
is NOT compared because it carries userinfo and a port. A URL that is
not absolute or not parseable is not the API host and must not raise.
NO nosec, NO CodeQL config change -- the alert is fixed, not silenced.

New cases, each invoking the code under test rather than restating it:
- A: `test_mutation_excluded_platform_is_not_covered` (:1255) via
  `_assert_matrix_platforms` (:619); harness
  `test_mutation_exclude_handling_is_killed` (:686) mutates the ratchet
  back to ignoring exclude and requires that named test to fail.
- B: `test_posix_lock_path_times_out_and_raises` (:762) -- fake fcntl
  plus fake clock, proves the POSIX path raises instead of hanging;
  `test_held_lock_makes_the_next_holder_time_out` (:831) proves it
  end-to-end against a real holder process; harness
  `test_mutation_posix_blocking_flock_is_killed` (:912).
- C: `test_clean_check_is_serialized_against_concurrent_mutation`
  (:872) -- the reader thread must NOT complete while the lock is held;
  harness `test_mutation_unlocked_clean_check_is_killed` (:933).
- D: `test_mutation_github_api_host_match_is_exact` (:1394); harness
  `test_mutation_loose_api_host_match_is_killed` (:953).

Every mutation case runs GREEN-before -> RED-after (named test) ->
GREEN-after-restore, with a byte-exact restore inside the lock
(`_mutation_case`, :567).

Measured: ratchet 11 passed / 1 skipped (skip = the network-gated
matrix cross-check); harness 10 passed; 22 passed / 0 skipped with
PMOVES_MAVIS_MATRIX_CHECK=1 (the live probe ran and passed); 19 passed
/ 3 skipped with `mavis` off PATH (the two CLI probes plus the matrix
gate), with every mutation-kill still firing.
@github-actions

Copy link
Copy Markdown
Contributor

ORGSIM-MIRROR drift check (advisory, fail-soft)

vv3 / 7 files / VERIFIED 99 / UNDECIDED 61 / digest f397dc54ce60

Zero-LLM deterministic audit - unreachable = UNDECIDED, never dead - scripts/runbook_drift.py

@github-actions

Copy link
Copy Markdown
Contributor

ORGSIM-MIRROR drift check (advisory, fail-soft)

vv3 / 7 files / VERIFIED 99 / UNDECIDED 61 / digest d6eeba3cea17

Zero-LLM deterministic audit - unreachable = UNDECIDED, never dead - scripts/runbook_drift.py

POWERFULMOVES pushed a commit that referenced this pull request Oct 31, 2026
… check can now say no

PR #3427 carried the A/B/C correction round into review. Seven threads came
back, and most of them were one defect wearing different clothes: a check
that cannot tell "I could not check" from "the answer is no", and a kill
signal that cannot tell "the mutation died" from "the run died".

Thread 1 (dbId 4427664896, P2) — a failed workflow download was reported as "ok"
  `_fetch_upstream_matrix()` caught a download failure with a bare `continue`
  and then returned status="ok" carrying whatever platforms it had managed to
  scrape from the other workflows. A rate-limited or timed-out download
  therefore published "upstream dropped Windows" when the truth was "GitHub
  throttled us" — an infrastructure failure reported as an upstream change.
  Every failure path now returns status="unavailable" plus a `reason`, and
  the cross-check SKIPS with that reason instead of blaming upstream. Pinned
  by test_mutation_upstream_download_failure_is_unavailable.

Thread 2 (dbId 4427664903, P2) — platform detection aggregated over every workflow
  The detector unioned runner labels found in the body of EVERY workflow under
  .github/workflows/. A label left behind in a release, compatibility or
  packaging workflow — or in a comment — still counted as test coverage, so
  removing Windows from the test matrix left the ratchet green while it named
  the wrong owner for the regression. Detection is now structural: the CI
  workflow (ci.yml) is selected explicitly, the job whose runs-on is driven by
  matrix.<key> is located, that job is confirmed to be the TEST job, and only
  that key's values (plus its include: overrides) are read. A workflow with no
  identifiable TEST job reports UNAVAILABLE rather than a confident platform
  set. Pinned by test_mutation_matrix_scoped_platform_detection.

Thread 3 (dbId 4427675919) — the runner-label version assumption
  The match tested a fixed suffix list (-latest / -22 / -24). GitHub-hosted
  runners appear as windows-2025, windows-2022, macos-15 and ubuntu-24.04 —
  none of them ends in one of those suffixes. One upstream rename emptied the
  platform set, the "windows" in platforms gate fired, and the ratchet rebuilt
  the inverted defect it exists to kill. The match is now the family followed
  by "latest" or ANY digit, which covers every version shape GitHub
  publishes. Pinned by test_mutation_runner_label_family_matching.

Thread 4 (dbId 4427675854) — infinite recursion inside the patched launcher
  broken_launcher was installed AS subprocess.run, and its fallback branch
  called subprocess.run again — resolving the patched attribute and re-entering
  itself with the same arguments, forever. real_run is now captured BEFORE
  monkeypatch.setattr and the fallback calls it, matching the sibling test
  that already had it right.

Thread 5 (dbId 4427675888) — the mutation-kill skipped whenever the CLI was absent
  test_mutation_broken_shim_fails_ratchet — and its sibling
  test_mutation_hang_fails_ratchet — skipped when mavis was not on PATH, i.e.
  on CI, so the load-bearing kill only bore load on the operator's laptop.
  Neither test ever runs the real CLI (the CompletedProcess is built by hand;
  the call is intercepted), so the guard bought nothing except a skip. The
  args are now constructed directly, the way
  test_mutation_error_banner_on_stdout_fails_ratchet already did. Verified:
  with mavis removed from PATH both files still pass and both kills still fire.

Thread 6 (dbId 4427675898) — the kill signal was "the run got sad"
  The signal was `proc.returncode != 0 and "failed" in output`, which a
  collection error caused by an unrelated import change, a timeout, or an
  environment failure also satisfies; the substring cannot tell "1 failed"
  from "failed to create endpoint". Each mutation now names the test that
  MUST fail (test_mutation_broken_shim_fails_ratchet for the version gate,
  test_mutation_wrong_upstream_repo_is_detectable for the upstream pin) and
  the harness reads pytest's own -rA short test summary for that name. A run
  that died for any other reason is no longer celebrated as a kill.

Thread 7 (dbId 4427675910) — the mutate/restore window raced
  Both mutations rewrote the same tracked source file and restored it in a
  finally, so a parallel runner could read a mutated "original" and resurrect
  a mutated file on restore. The window is now serialized by a threading.Lock
  plus a cross-process advisory file lock (the OS releases it if a worker
  dies, so a crashed run cannot leave it held), the restore writes back the
  exact pre-mutation bytes, and the restore is asserted.

Live probe after the repair (PMOVES_MAVIS_MATRIX_CHECK=1):
  {'status': 'ok', 'platforms': ['macos', 'ubuntu', 'windows'],
   'jobs': ['verify'], 'matrix_key': 'os',
   'labels': ['macos-latest', 'ubuntu-latest', 'windows-latest']}
Note what is NOT in that set: `linux`. The word "Linux" exists in upstream's
ci.yml only inside a COMMENT, and a comment is not a matrix entry — precisely
the distinction the old body scan could not make.

LEARNINGS: pmoves/docs/AGENTS/test_gap_ratchet_LEARNINGS.md gains lessons
#13–#17 (unavailable-vs-ok, matrix-scoped platform detection, runner-label
family matching, the named-test kill signal, and the harness's own
mutate/restore contract), a finding → lesson → code map for all seven
threads, and the live probe result.

Verified on this host:
  12 passed, 1 skipped  (the network-gated matrix check skips by default)
  13 passed, 0 skipped  (with PMOVES_MAVIS_MATRIX_CHECK=1)
  10 passed, 3 skipped  (with mavis removed from PATH — both kills still fire)
@POWERFULMOVES
POWERFULMOVES force-pushed the fix/ratchet-upstream-matrix-and-shim-origin branch from 0905341 to f9cec95 Compare October 31, 2026 01:11
POWERFULMOVES pushed a commit that referenced this pull request Oct 31, 2026
…, and locked the wrong half

Four findings against PR #3427, all confirmed VALID and closed at source.

A. `exclude:` was never read. `_extract_matrix_platforms` collected
runner labels from the base dimension list plus `include:` entries and
never expanded or removed combinations, so a matrix that EXCLUDED
windows-latest still reported windows as covered -- the exact
inversion this ratchet exists to prevent, in the other direction.
New helpers `_matrix_axes` (:368), `_base_combinations` (:388),
`_combo_matches_exclude` (:405), `_apply_matrix_exclusions` (:422),
`_apply_matrix_inclusions` (:444); `_extract_matrix_platforms` (:499)
now expands base -> exclude -> include (GitHub's documented order) and
takes labels only from surviving combinations. An exclude that matches
nothing removes nothing -- not an error.

B. The POSIX lock could block forever. `_lock_file` enforced
`_LOCK_TIMEOUT_SECONDS` on the Windows branch only; POSIX used a bare
blocking `flock`, so a stuck holder wedged the suite with no timeout
and no diagnostic. Split into `_try_lock_windows` (:347) /
`_try_lock_posix` (:359, LOCK_EX|LOCK_NB) behind `_try_lock_nonblocking`
(:375), with ONE shared deadline loop in `_lock_file` (:382) that
raises `MutationLockTimeout` (:290) naming the lock file, the timeout
and the recorded holder. Both branches: same constant, same failure
mode, same message. A timeout always raises -- it never proceeds
unlocked.

C. The clean-check read the target without the lock.
`test_ratchet_file_is_left_clean_after_mutations` read TARGET outside
`_mutation_lock()`, so it could observe the file mid-mutation and
report a false pass. `_read_ratchet_file_under_lock` (:464) takes the
lock for the whole read; `_assert_ratchet_file_clean` (:475) holds the
content assertions.

D. CodeQL "Incomplete URL substring sanitization" (HIGH, the ratchet's
own test double). `fake_urlopen` matched the host with
`"api.github.com" in url`, which also accepts
`https://api.github.com.evil.example/` and
`https://evil.example/?x=api.github.com`. Fixed AT THE SOURCE:
`_is_github_api_url` (:305) parses with urllib.parse.urlsplit and
requires `parsed.hostname == "api.github.com"` -- host only, the netloc
is NOT compared because it carries userinfo and a port. A URL that is
not absolute or not parseable is not the API host and must not raise.
NO nosec, NO CodeQL config change -- the alert is fixed, not silenced.

New cases, each invoking the code under test rather than restating it:
- A: `test_mutation_excluded_platform_is_not_covered` (:1255) via
  `_assert_matrix_platforms` (:619); harness
  `test_mutation_exclude_handling_is_killed` (:686) mutates the ratchet
  back to ignoring exclude and requires that named test to fail.
- B: `test_posix_lock_path_times_out_and_raises` (:762) -- fake fcntl
  plus fake clock, proves the POSIX path raises instead of hanging;
  `test_held_lock_makes_the_next_holder_time_out` (:831) proves it
  end-to-end against a real holder process; harness
  `test_mutation_posix_blocking_flock_is_killed` (:912).
- C: `test_clean_check_is_serialized_against_concurrent_mutation`
  (:872) -- the reader thread must NOT complete while the lock is held;
  harness `test_mutation_unlocked_clean_check_is_killed` (:933).
- D: `test_mutation_github_api_host_match_is_exact` (:1394); harness
  `test_mutation_loose_api_host_match_is_killed` (:953).

Every mutation case runs GREEN-before -> RED-after (named test) ->
GREEN-after-restore, with a byte-exact restore inside the lock
(`_mutation_case`, :567).

Measured: ratchet 11 passed / 1 skipped (skip = the network-gated
matrix cross-check); harness 10 passed; 22 passed / 0 skipped with
PMOVES_MAVIS_MATRIX_CHECK=1 (the live probe ran and passed); 19 passed
/ 3 skipped with `mavis` off PATH (the two CLI probes plus the matrix
gate), with every mutation-kill still firing.
@github-actions

Copy link
Copy Markdown
Contributor

ORGSIM-MIRROR drift check (advisory, fail-soft)

vv3 / 7 files / VERIFIED 99 / UNDECIDED 61 / digest 3a13000d1553

Zero-LLM deterministic audit - unreachable = UNDECIDED, never dead - scripts/runbook_drift.py

POWERFULMOVES pushed a commit that referenced this pull request Oct 31, 2026
@github-actions github-actions Bot added the config pmoves/config(s)/ changes label Oct 31, 2026
Comment thread pmoves/tools/pytest_ratchet.py Resolved
Comment thread pmoves/tools/pytest_ratchet.py Resolved
POWERFULMOVES and others added 11 commits October 30, 2026 22:27
… load-bearingly

The test-gap ratchet slice shipped in PR #3095. A follow-up audit on
2026-10-30 found that the ratchet itself had two defects, plus a third
surfaced while repairing them. All three are the exact failure mode this
lane exists to prevent: a ratchet that reports GREEN while the thing it
guards is broken.

Defect A — stderr accepted as a version string
  The shipped `mavis --version` gate was:

      version = (proc.stdout or proc.stderr or "").strip()
      assert version

  Node's module loader writes "Error: Cannot find module '<path>'" to
  STDERR and exits 1. A 100%-broken launcher therefore satisfied the
  non-empty assertion. Measured on the operator's host before this fix:

      $ mavis --version
      rc=1  stdout=''  stderr="Error: Cannot find module '...daemon/cli.js'"
      test_mavis_cli_version_completes_within_timeout ... PASSED

  The gate is extracted to `_assert_healthy_version_output()` and now
  asserts what a working CLI has and a broken one cannot fake: rc == 0,
  non-empty STDOUT (stderr is never a fallback), and stdout that is not
  an error banner. `--help` gets the same treatment.

Defect B — the upstream pin pointed at a 404
  The matrix cross-check pinned `MiniMaxInc/MiniMax-Code`, which does not
  exist. The real upstream is `MiniMax-AI/minimax-code`. A 404 body is a
  JSON object where the helper expected a list, so the fetch returned
  None and the cross-check degraded to a permanent SKIP — it could never
  report green or red. The pin is corrected and is now itself assertable.

Defect C — filename-derived platform set (found while repairing B)
  The platform detector scanned workflow FILENAMES. Upstream's workflows
  are ci.yml, cli-release.yml, compatibility.yml, … — not one carries an
  OS name; the matrix is declared inside ci.yml's BODY as
  `os: [ubuntu-latest, macos-latest, windows-latest]`. The filename scan
  returned an empty set, so the gate would have FAILED once enabled,
  reporting "upstream does not cover Windows" for an upstream that DOES.
  The detector now reads each workflow's content via its download_url.

Upstream matrix answer (the operator's actual question): upstream's Linux
matrix is GREEN and upstream DOES cover Windows (`profile: full` on
Ubuntu, a focused `profile: windows` on Windows). Live probe:
{'platforms': ['macos', 'ubuntu', 'windows'], 'status': 'ok'}. So the
240s timeout is the platform-specific Windows case, not a known-broken
upstream.

Mutation-kills (the load-bearing proof)
  pmoves/tests/tools/test_mavis_ratchet_mutation_kill.py rewrites the
  gate and the upstream pin back to their original defective forms and
  asserts the ratchet module then FAILS. Both mutations are killed.

  The first attempt at this harness re-implemented the gate inline
  instead of invoking it, and restoring the defective gate left the suite
  at 7 passed — the mutation SURVIVED. The gate is now shared between
  the ratchet and the mutation-kill, so the two are genuinely coupled.
  That is recorded as lesson #12 in the LEARNINGS taxonomy.

Host shim
  ~/.minimax/bin/{mavis,minimax}.cmd pointed at
  `...\MiniMax Code\resources\resources\daemon\cli.js`, which no longer
  exists (the daemon now ships inside app.asar). Per the operator's
  direction that the CLI runs from our fork, both shims now exec the fork
  build at C:\Users\russe\pmoves-fork-minimax-code\dist\cli.js under
  Node 22.22.1. `mavis --version` → 0.6.5, rc=0, 0.47s.

Tests
  pmoves/tests/test_mavis_cli_timeout.py   7 passed, 1 skipped
                                         (8 passed with PMOVES_MAVIS_MATRIX_CHECK=1)
  pmoves/tests/tools/test_mavis_ratchet_mutation_kill.py   3 passed
  pmoves/tests/test_kilo_binary_path.py     6 passed (no regression)

Docs
  pmoves/docs/AGENTS/test_gap_ratchet_LEARNINGS.md — lessons #9–#12
  added to the 4-bucket x 5-class taxonomy, cross-check re-tallied,
  post-merge correction table + the upstream-matrix answer recorded.
  pmoves/docs/AGENTS/AGNOTE4482PHI.t1.md — CLAIM row 2026-10-30T23:00:00Z
  (5090-CLAUDE, unsigned-local) with full SDK provenance.

Co-Authored-By: Mavis <mavis@pmoves.ai>
… check can now say no

PR #3427 carried the A/B/C correction round into review. Seven threads came
back, and most of them were one defect wearing different clothes: a check
that cannot tell "I could not check" from "the answer is no", and a kill
signal that cannot tell "the mutation died" from "the run died".

Thread 1 (dbId 4427664896, P2) — a failed workflow download was reported as "ok"
  `_fetch_upstream_matrix()` caught a download failure with a bare `continue`
  and then returned status="ok" carrying whatever platforms it had managed to
  scrape from the other workflows. A rate-limited or timed-out download
  therefore published "upstream dropped Windows" when the truth was "GitHub
  throttled us" — an infrastructure failure reported as an upstream change.
  Every failure path now returns status="unavailable" plus a `reason`, and
  the cross-check SKIPS with that reason instead of blaming upstream. Pinned
  by test_mutation_upstream_download_failure_is_unavailable.

Thread 2 (dbId 4427664903, P2) — platform detection aggregated over every workflow
  The detector unioned runner labels found in the body of EVERY workflow under
  .github/workflows/. A label left behind in a release, compatibility or
  packaging workflow — or in a comment — still counted as test coverage, so
  removing Windows from the test matrix left the ratchet green while it named
  the wrong owner for the regression. Detection is now structural: the CI
  workflow (ci.yml) is selected explicitly, the job whose runs-on is driven by
  matrix.<key> is located, that job is confirmed to be the TEST job, and only
  that key's values (plus its include: overrides) are read. A workflow with no
  identifiable TEST job reports UNAVAILABLE rather than a confident platform
  set. Pinned by test_mutation_matrix_scoped_platform_detection.

Thread 3 (dbId 4427675919) — the runner-label version assumption
  The match tested a fixed suffix list (-latest / -22 / -24). GitHub-hosted
  runners appear as windows-2025, windows-2022, macos-15 and ubuntu-24.04 —
  none of them ends in one of those suffixes. One upstream rename emptied the
  platform set, the "windows" in platforms gate fired, and the ratchet rebuilt
  the inverted defect it exists to kill. The match is now the family followed
  by "latest" or ANY digit, which covers every version shape GitHub
  publishes. Pinned by test_mutation_runner_label_family_matching.

Thread 4 (dbId 4427675854) — infinite recursion inside the patched launcher
  broken_launcher was installed AS subprocess.run, and its fallback branch
  called subprocess.run again — resolving the patched attribute and re-entering
  itself with the same arguments, forever. real_run is now captured BEFORE
  monkeypatch.setattr and the fallback calls it, matching the sibling test
  that already had it right.

Thread 5 (dbId 4427675888) — the mutation-kill skipped whenever the CLI was absent
  test_mutation_broken_shim_fails_ratchet — and its sibling
  test_mutation_hang_fails_ratchet — skipped when mavis was not on PATH, i.e.
  on CI, so the load-bearing kill only bore load on the operator's laptop.
  Neither test ever runs the real CLI (the CompletedProcess is built by hand;
  the call is intercepted), so the guard bought nothing except a skip. The
  args are now constructed directly, the way
  test_mutation_error_banner_on_stdout_fails_ratchet already did. Verified:
  with mavis removed from PATH both files still pass and both kills still fire.

Thread 6 (dbId 4427675898) — the kill signal was "the run got sad"
  The signal was `proc.returncode != 0 and "failed" in output`, which a
  collection error caused by an unrelated import change, a timeout, or an
  environment failure also satisfies; the substring cannot tell "1 failed"
  from "failed to create endpoint". Each mutation now names the test that
  MUST fail (test_mutation_broken_shim_fails_ratchet for the version gate,
  test_mutation_wrong_upstream_repo_is_detectable for the upstream pin) and
  the harness reads pytest's own -rA short test summary for that name. A run
  that died for any other reason is no longer celebrated as a kill.

Thread 7 (dbId 4427675910) — the mutate/restore window raced
  Both mutations rewrote the same tracked source file and restored it in a
  finally, so a parallel runner could read a mutated "original" and resurrect
  a mutated file on restore. The window is now serialized by a threading.Lock
  plus a cross-process advisory file lock (the OS releases it if a worker
  dies, so a crashed run cannot leave it held), the restore writes back the
  exact pre-mutation bytes, and the restore is asserted.

Live probe after the repair (PMOVES_MAVIS_MATRIX_CHECK=1):
  {'status': 'ok', 'platforms': ['macos', 'ubuntu', 'windows'],
   'jobs': ['verify'], 'matrix_key': 'os',
   'labels': ['macos-latest', 'ubuntu-latest', 'windows-latest']}
Note what is NOT in that set: `linux`. The word "Linux" exists in upstream's
ci.yml only inside a COMMENT, and a comment is not a matrix entry — precisely
the distinction the old body scan could not make.

LEARNINGS: pmoves/docs/AGENTS/test_gap_ratchet_LEARNINGS.md gains lessons
#13–#17 (unavailable-vs-ok, matrix-scoped platform detection, runner-label
family matching, the named-test kill signal, and the harness's own
mutate/restore contract), a finding → lesson → code map for all seven
threads, and the live probe result.

Verified on this host:
  12 passed, 1 skipped  (the network-gated matrix check skips by default)
  13 passed, 0 skipped  (with PMOVES_MAVIS_MATRIX_CHECK=1)
  10 passed, 3 skipped  (with mavis removed from PATH — both kills still fire)
…, and locked the wrong half

Four findings against PR #3427, all confirmed VALID and closed at source.

A. `exclude:` was never read. `_extract_matrix_platforms` collected
runner labels from the base dimension list plus `include:` entries and
never expanded or removed combinations, so a matrix that EXCLUDED
windows-latest still reported windows as covered -- the exact
inversion this ratchet exists to prevent, in the other direction.
New helpers `_matrix_axes` (:368), `_base_combinations` (:388),
`_combo_matches_exclude` (:405), `_apply_matrix_exclusions` (:422),
`_apply_matrix_inclusions` (:444); `_extract_matrix_platforms` (:499)
now expands base -> exclude -> include (GitHub's documented order) and
takes labels only from surviving combinations. An exclude that matches
nothing removes nothing -- not an error.

B. The POSIX lock could block forever. `_lock_file` enforced
`_LOCK_TIMEOUT_SECONDS` on the Windows branch only; POSIX used a bare
blocking `flock`, so a stuck holder wedged the suite with no timeout
and no diagnostic. Split into `_try_lock_windows` (:347) /
`_try_lock_posix` (:359, LOCK_EX|LOCK_NB) behind `_try_lock_nonblocking`
(:375), with ONE shared deadline loop in `_lock_file` (:382) that
raises `MutationLockTimeout` (:290) naming the lock file, the timeout
and the recorded holder. Both branches: same constant, same failure
mode, same message. A timeout always raises -- it never proceeds
unlocked.

C. The clean-check read the target without the lock.
`test_ratchet_file_is_left_clean_after_mutations` read TARGET outside
`_mutation_lock()`, so it could observe the file mid-mutation and
report a false pass. `_read_ratchet_file_under_lock` (:464) takes the
lock for the whole read; `_assert_ratchet_file_clean` (:475) holds the
content assertions.

D. CodeQL "Incomplete URL substring sanitization" (HIGH, the ratchet's
own test double). `fake_urlopen` matched the host with
`"api.github.com" in url`, which also accepts
`https://api.github.com.evil.example/` and
`https://evil.example/?x=api.github.com`. Fixed AT THE SOURCE:
`_is_github_api_url` (:305) parses with urllib.parse.urlsplit and
requires `parsed.hostname == "api.github.com"` -- host only, the netloc
is NOT compared because it carries userinfo and a port. A URL that is
not absolute or not parseable is not the API host and must not raise.
NO nosec, NO CodeQL config change -- the alert is fixed, not silenced.

New cases, each invoking the code under test rather than restating it:
- A: `test_mutation_excluded_platform_is_not_covered` (:1255) via
  `_assert_matrix_platforms` (:619); harness
  `test_mutation_exclude_handling_is_killed` (:686) mutates the ratchet
  back to ignoring exclude and requires that named test to fail.
- B: `test_posix_lock_path_times_out_and_raises` (:762) -- fake fcntl
  plus fake clock, proves the POSIX path raises instead of hanging;
  `test_held_lock_makes_the_next_holder_time_out` (:831) proves it
  end-to-end against a real holder process; harness
  `test_mutation_posix_blocking_flock_is_killed` (:912).
- C: `test_clean_check_is_serialized_against_concurrent_mutation`
  (:872) -- the reader thread must NOT complete while the lock is held;
  harness `test_mutation_unlocked_clean_check_is_killed` (:933).
- D: `test_mutation_github_api_host_match_is_exact` (:1394); harness
  `test_mutation_loose_api_host_match_is_killed` (:953).

Every mutation case runs GREEN-before -> RED-after (named test) ->
GREEN-after-restore, with a byte-exact restore inside the lock
(`_mutation_case`, :567).

Measured: ratchet 11 passed / 1 skipped (skip = the network-gated
matrix cross-check); harness 10 passed; 22 passed / 0 skipped with
PMOVES_MAVIS_MATRIX_CHECK=1 (the live probe ran and passed); 19 passed
/ 3 skipped with `mavis` off PATH (the two CLI probes plus the matrix
gate), with every mutation-kill still firing.
…ld hang holding the lock

Two more findings against the round-3 code, both confirmed valid. They close
the loop round 3 had half-closed: round 3 taught that the lock's two halves
must agree (the timeout must exist on BOTH platforms) and that the
VERIFICATION must hold the lock the writer holds. Round 4 finds the
remaining two gaps -- the lock must cover THE SUBJECT UNDER TEST, and the
LOCK HOLDER must not be able to hang.

(A) THE LOCK MUST COVER THE SUBJECT, NOT JUST THE MUTATION.
`_load_ratchet_module()` read AND executed the ratchet file with NO lock
held, so a load landing while another case held the lock and had the file
mutated measured a DIFFERENT ratchet than the one it thought it was
measuring. Same class as the round-3 clean-check finding, one level
earlier: there the VERIFICATION was unlocked, here the SUBJECT is.

`_load_ratchet_module(lock_path, target)` (:726) now takes
`_mutation_lock(lock_path)` around the whole read+exec. The read+exec
moved into `_read_and_exec_ratchet_module()` (:706) so the lock covers
BOTH halves as one indivisible window -- a mutation landing between the
read and the exec would be just as wrong. `target` is an optional
override so the check can point the loader at a scratch file.

Pinned by `test_module_load_is_serialized_against_concurrent_mutation`
(:1112) -- mutates a marker file under the lock in one thread while a
loader thread runs, and asserts the loader CANNOT finish while the
mutation is in effect. Killed by
`test_mutation_unlocked_module_load_is_killed` (:1311), which rewrites
the harness's own loader back to the unlocked form.

(B) THE LOCK HOLDER MUST NOT BE ABLE TO HANG.
`_run_pytest()` called `subprocess.run` with NO `timeout=`, and it runs
INSIDE the mutation lock -- so a hung child held the lock forever and
every other case blocked behind it. This is the round-3 POSIX-lock
finding turned on its owner: a lock whose HOLDER can hang has no
deadline at all, whichever platform it runs on.

`_run_pytest()` (:621) passes a real `timeout=` and converts
`subprocess.TimeoutExpired` into `PytestRunTimeout` (:373), whose message
(:599) names the deadline, the argv/`select` (the test being run), and
states that the lock is about to be released and the mutated file
restored. The deadline comes from `_pytest_timeout_seconds()` (:576) and
is overridable via PMOVES_MAVIS_RATCHET_PYTEST_TIMEOUT; a bad or
non-positive override falls back to the DEFAULT rather than disabling
the deadline.

Lock release was already structural: `_mutation_case()` (:754) holds the
lock via `with _mutation_lock(...)` across all three phases and the
byte-exact restore is in a `finally` INSIDE that block, so the timeout
path restores the file BEFORE releasing the lock. `_mutation_case` gained
an optional `lock_path` so a case running inside a child pytest does not
contend for the shared lock.

Pinned by `test_pytest_run_timeout_fires_and_releases_the_lock` (:1182) --
drives a genuinely hanging module through `_mutation_case` with an 8s
override, then asserts the timeout fired with a message naming
`8s`/`test_slow`/the lock, that the lock is acquirable again (checked in
a thread, so a leaked non-reentrant lock fails rather than deadlocks),
and that the mutated file is back to its original bytes. Killed by
`test_mutation_pytest_run_without_timeout_is_killed` (:1333).

TIMEOUT 300s, chosen from measurement: the slowest LEGITIMATE single
pytest subprocess run is 1.6s including interpreter and pytest startup,
so the deadline carries ~180x headroom. The deadline is PER-SUBPROCESS,
not per-case, so the 48s mutation case is unaffected.

Measured: harness -v (14 cases) -> 14 passed in 106.7s; ratchet -> 11
passed / 1 skipped (the network-gated matrix cross-check); the pair with
PMOVES_MAVIS_MATRIX_CHECK=1 -> 26 passed (the live probe ran and
passed); the pair with `mavis` off PATH -> 23 passed / 3 skipped, every
mutation-kill still firing.

pmoves/tests/test_mavis_cli_timeout.py was NOT touched by this round.
…died with the child

Defect I -- a deadline that a typo can switch off is not a deadline. _pytest_timeout_seconds() guarded the PMOVES_MAVIS_RATCHET_PYTEST_TIMEOUT override with 'value <= 0'. But float('nan') compares False against EVERYTHING, so a 'nan' override sailed past the guard and BECAME the deadline -- and a nan deadline never fires, so the run it was meant to bound was unbounded and the mutation lock could be held forever. 'inf' is the same hole with a slower fuse. FIX: _validated_deadline() rejects anything that is not FINITE and POSITIVE and falls back to the default. Pinned by test_nonfinite_timeout_override_falls_back_to_default; killed by test_mutation_nonfinite_timeout_override_is_killed.

Defect J -- the deadline must survive the KILL. On POSIX, CPython's timed-out subprocess.run path kills the child and calls process.wait() -- bounded. On WINDOWS the same path calls process.communicate() with NO timeout after the kill: an UNBOUNDED read. This harness spawns nested pytest subprocesses BY DESIGN, so a killed inner pytest can leave GRANDCHILDREN behind, and a surviving grandchild holds the stdout pipe open. The unbounded post-kill read then blocks FOREVER, PytestRunTimeout never raises, and the mutation lock is never released -- on the one platform where the guarantee was supposed to be airtight. FIX: the child starts in its OWN process group (start_new_session=True / CREATE_NEW_PROCESS_GROUP); _kill_process_tree() kills the whole GROUP (os.killpg) on POSIX and the whole TREE (taskkill /T /F) on Windows; _drain_process_output() drains the pipes with its OWN bounded communicate(timeout=) and closes them if a survivor still holds them open. PytestRunTimeout is raised on every branch, so the message contract holds on both platforms. Pinned by test_post_kill_drain_is_bounded_when_a_pipe_holder_survives against a fake child whose pipe is held open by a survivor; killed by test_mutation_unbounded_post_kill_drain_is_killed and test_mutation_direct_child_kill_is_killed.

MEASURED: harness 19 passed (128.7s); ratchet 11 passed / 1 skipped (the network-gated matrix cross-check). LEARNINGS lessons #24-#25.
The merge gate's python-tests job failed on this branch at head f9cec95
with a finding that was not a defect:

    --- pmoves/tests/tools [2] timed out; isolating 20 files (budget 600s) ---
    ---   no report for pmoves/tests/tools/test_mavis_ratchet_mutation_kill.py (exit -1) ---

The mutation-kill harness is healthy and SLOW. Its 19 cases each run three
phases (GREEN before -> RED under mutation -> GREEN after restore) and each
phase spawns a full child pytest: 19 x 3 = 57 startups at ~1.7s each, so
~97s is the floor before any deliberate timeout wait. The runner had no way
to say "this file is legitimately expensive" -- chunks were built by FILE
COUNT as a proxy for cost -- so the chunk was killed at 120s, the 60s
per-file isolation killed the same file AGAIN, and the file's real result was
replaced by a false "no report" ERROR.

The fix is the budget model, not a suppression. A new sibling config,
pmoves/configs/pytest_ratchet/_slow_files.yaml, declares a slow file and the
extra seconds it gets; the runner hand-parses it (no new dependency, same
style as _known_failures.yaml) and a missing file is an empty allowance
rather than an error.

  * chunk_timeout_seconds(files) = GROUP_TIMEOUT_SECONDS + the sum of the
    chunk's allowances, so the chunk holding the harness is not killed before
    the harness can report.
  * file_timeout_seconds(file) = FALLBACK_FILE_TIMEOUT + that file's own
    allowance, so the file is still MEASURED if some other reason times the
    chunk out.

Both are pure, and both apply the allowance in BOTH places the budget
applies. Every file with no allowance gets EXACTLY the old
GROUP_TIMEOUT_SECONDS / FALLBACK_FILE_TIMEOUT, so hang detection is not
weakened anywhere else. The negative control
(test_the_allowance_is_driven_by_the_config_not_by_the_code) proves the
extra time is driven by the config and can be taken back.

Measured (Windows, Python 3.12.10, pytest 9.1.1):
  * pmoves/tests/tools/test_pytest_ratchet.py  31 passed (20 + 11 new)
  * pmoves/tests/tools/test_mavis_ratchet_mutation_kill.py  19 passed in
    116.29s (121.3s before the trim)
  * pmoves/tests/test_mavis_cli_timeout.py  11 passed, 1 skipped
  * the harness run UNDER THE NEW CHUNK BUDGET: rc=0, JUnit report written,
    0 findings, 118.5s -- MEASURED, where the old budgets lost it

The harness's own deliberate waste is trimmed too: the mutated slow module
now sleeps 12s instead of 20s, still comfortably longer than the 8s
override, so the timeout still fires first and the mutated run still
finishes. No assertion was changed and no case was dropped.
…chet round 6

Round 6 is the first round in this lane whose subject is the GATE rather than
the ratchet it gates: the gate could not tell "broken" from "slow", and
reported a healthy file as broken.

  #26 contract-correctness   a budget measured in FILE COUNT is not a budget
                              measured in COST
  #27 reasoning-gap          "no report" conflates "hung" with "out of
                              budget", and a false BROKEN is worse than a
                              missing result
  #28 defense-in-depth       an allowance must be REMOVABLE: with the entry
                              gone the budgets fall back to exactly the old
                              values
  #29 pattern-conformance    a declared cost belongs in a reviewable config
                              beside the baseline, parsed without a new
                              dependency

Adds the CI evidence verbatim, the round-6 measurement table, and the SDK
provenance table (file -> symbol anchor -> what it does). The AGNOTE row for
this round is filed by the register owner.
@POWERFULMOVES
POWERFULMOVES force-pushed the fix/ratchet-upstream-matrix-and-shim-origin branch from aac9570 to d39b11c Compare October 31, 2026 02:28
@github-actions

Copy link
Copy Markdown
Contributor

ORGSIM-MIRROR drift check (advisory, fail-soft)

vv3 / 7 files / VERIFIED 99 / UNDECIDED 61 / digest 8ce0d3f4f3a4

Zero-LLM deterministic audit - unreachable = UNDECIDED, never dead - scripts/runbook_drift.py

POWERFULMOVES added 2 commits October 30, 2026 22:52
…ithout a sound

Two holes in round 6's own fix, both found by the review of that change. (1) THE ESCAPE HATCH HAD A TRAPDOOR -- round 6 widened the CHUNK budget (120 -> 720s) and the PER-FILE budget (60 -> 660s), but left FALLBACK_BUDGET_SECONDS (600s) still bounding the whole isolation pass. Since the per-file budget can now hand ONE file 660s, a chunk that timed out anyway could exhaust the flat pass budget BEFORE reaching the harness -- and the '--- fallback budget exhausted; N files unmeasured ---' path would re-declare the very file the allowance exists to defend as BROKEN, with less signal than round 6 had. The allowance admitted the file at the door and priced it out at the window. FIX: fallback_budget_seconds() = FALLBACK_BUDGET_SECONDS + the sum of the chunk's allowances, and the isolation loop compares spent against it. A chunk with no declared-slow file gets EXACTLY 600s -- the default path is numerically unchanged. (2) A BUDGET-OWNING LINE THAT FAILED TO PARSE VANISHED WITHOUT A SOUND -- load_slow_file_entries() skipped any unmatched line inside the slow_files: block, so a typo'd path, '600s' instead of '600', or a mis-nested line silently stripped the file's allowance and CI then re-reported it as BROKEN with LESS signal than before. Silence is fine for prose; this parser is the single source of a budget. FIX: a one-line stderr warning quoting the raw line. A line OUTSIDE the block stays quiet -- only a budget-owning line is worth a sound. (3) FOUND BY THE MUTATION CHECK, NOT BY A REVIEWER -- the first version of the fix for (1) shipped a test that called fallback_budget_seconds() and compared the result. That test SURVIVED the mutation reverting the CALL SITE to the flat budget: the helper was intact and correct while the runner kept using the old currency. A green test, a correct helper, a broken runner. The test now drives run_chunk_with_fallback() itself with the pass budget exhausted and requires the declared-slow file to still be MEASURED rather than declared dead -- with the flat budget the loop breaks on its first check and the file lands in dead, which the runner reports as BROKEN. MEASURED: pmoves/tests/tools/test_pytest_ratchet.py -> 38 passed (31 after round 6 + 7 new); the anchor ratchet -> 445 total, 445 baselined, 0 new -- PASS; the register postdate check -> clean. MUTATION PROOF: M1 (the pass budget reverts to the flat default) and M2 (the unparseable-entry warning is removed) are both KILLED, and the restore is byte-exact with the suite green again. LEARNINGS lessons #30-#32 added to the 4-bucket x 5-class taxonomy (contract-correctness now leads with 15 of 32).
…oor and a typo vanished without a sound
@github-actions

Copy link
Copy Markdown
Contributor

ORGSIM-MIRROR drift check (advisory, fail-soft)

vv3 / 7 files / VERIFIED 99 / UNDECIDED 61 / digest 47f5dbaf66d1

Zero-LLM deterministic audit - unreachable = UNDECIDED, never dead - scripts/runbook_drift.py

@POWERFULMOVES
POWERFULMOVES merged commit 9746c27 into main Oct 31, 2026
44 checks passed
@POWERFULMOVES
POWERFULMOVES deleted the fix/ratchet-upstream-matrix-and-shim-origin branch October 31, 2026 03:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

config pmoves/config(s)/ changes docs Documentation governance AGNOTE register / agent definitions / damage-control hooks

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants