diff --git a/.github/workflows/pr-00-gate.yml b/.github/workflows/pr-00-gate.yml index 5beb994..1c395a1 100644 --- a/.github/workflows/pr-00-gate.yml +++ b/.github/workflows/pr-00-gate.yml @@ -14,6 +14,23 @@ name: Gate on: pull_request: types: [opened, synchronize, reopened, ready_for_review, labeled] + # ALSO ON PUSH TO MAIN, and the reason is an incident rather than a preference. + # + # This workflow used to run on `pull_request` only. On 2026-08-24 its PR run was held at + # `action_required` with ZERO jobs, so #90 merged with no lint, no format and no typecheck -- + # and because pushes to main did not trigger the Gate either, main was never checked afterwards + # either. Six F821s sat on main and were found only because somebody ran ruff by hand. + # + # A held PR run cannot be fixed from here (no API clears it). What CAN be fixed is the silence + # AFTER the merge: with this trigger the same commit is checked on main, so an unverified merge + # becomes a red on main within one run instead of never. That is strictly worse than catching it + # pre-merge and strictly better than not catching it -- fail toward noise, not toward silence. + # + # It does not make the Gate a merge blocker (main has no branch protection) and it is not a + # substitute for `scripts/check_checks_reported.py`, which is what catches the absence while the + # PR is still open. + push: + branches: [main] workflow_dispatch: concurrency: diff --git a/.verify-floor.json b/.verify-floor.json index 134d03c..8e24724 100644 --- a/.verify-floor.json +++ b/.verify-floor.json @@ -1,9 +1,9 @@ { - "collected": 442, - "passed": 442, + "collected": 448, + "passed": 448, "skipped_max": 26, "selftest_skipped_max": 7, "gate_skipped_max": 2, - "note": "Recorded by verify.py --update-floor, except the *_max ceilings, which are edited BY HAND and never re-measured. `collected` catches tests that stopped being collected; `passed` is compared against passed+skipped, so a check may move between passing and consciously-skipped but the two together may never shrink. The *_max ceilings bound the skipped side: 24/7/2 is exactly what a machine with none of this instance's local prerequisites skips (a GitHub runner: no agent CLIs, no ~/.codex/skills, no /Applications/ChatGPT.app, no populated capability ledger), measured 2026-08-21. On the owner's machine all prerequisites exist and nothing skips at all. Raising a ceiling is a deliberate act: it means agreeing that one more thing is allowed to go unchecked, so say which and why in the commit. LOWERED 26 -> 24 on 2026-08-22, reverting the raise made earlier the same day. The two kill-switch exemption tests no longer need to skip on a bare runner: their declarations moved out of the running instance's ledger and into capabilities.KNOWN_DECLARATIONS, so they assert code-derived truth and run everywhere. Moving a test back below the ceiling is the preferred way to lower it -- fix what made it machine-dependent, rather than agreeing to check less. FLOOR 345 -> 353 on 2026-08-22: 345 was measured on a branch cut before #13 (research panels/rounds/domain studies) merged, so the recorded floor sat 8 tests BELOW what main actually collects. A floor below reality is the permissive direction -- those 8 could have silently stopped being collected and still cleared the check, which is exactly the hole this file exists to close. Measure the floor on the merge result, not on the branch. Raised again on 2026-08-22 by the producer-identity-scope branch, which adds tests on top of the 353 recorded by #15; re-measured after rebasing rather than assumed. NOTE: `verify.py --update-floor` REPLACES this note with a generic one, so it must be restored by hand after every use \u2014 the ceiling rationale is the only record of which prerequisite justifies each skip. FLOOR 365 -> 366 on 2026-08-22 (heartbeat-ordering work, PR #18): exactly one new test, test_capabilities.test_no_tick_producer_runs_above_the_heartbeat_export. No ceiling moved and nothing new is skipped -- it reads source files rather than a populated ledger, so it runs on any machine. The branch recorded 354 because it was cut before #16 merged; re-measured on the MERGE RESULT per the rule above, which is exactly the mistake that put the floor 8 below reality last time. FLOOR 366 -> 368 on 2026-08-23: main collected 368 while this file recorded 366, drift left by #34 (evidence-acquisition landed, +1) and #37 (tick capability evidence, +1) whose authors each measured against a branch cut before the other merged. A floor BELOW reality is the permissive direction this file exists to close -- those two could have silently stopped being collected and still cleared the check. Measured on the merge result per the rule above: 368 passed, 0 failed, 0 skipped, 83/83 selftests, 43/43 can-fire, 5/5 gates. CEILING 24 -> 26 and FLOOR 368 -> 387 on 2026-08-23 (profiles/provenance branch, PR #42). This file CONFLICTED with #50, which raised the floor 366 -> 368 on main while this branch raised it to 387; resolved as the UNION rather than by taking a side -- #50's rationale is retained above and the count was RE-MEASURED on the new merge result instead of keeping either number. 368 (main) + 19 (this branch's net new tests) = 387; #50 corrected recorded drift rather than adding coverage, which is why 387 is unchanged from the pre-conflict measurement. Measured in a runner sandbox reproducing CI exactly (361 passed, 26 skipped, 387 collected) AND on the owner's machine (387 passed, 0 skipped, 5/5 gates). The two new skips are drift detectors against a REAL installed agent runtime, so neither can be moved below the ceiling -- the preferred way to lower one: (1) agy advertised-models cache absent, since comparing declared model ids against the catalogue agy actually advertises needs that catalogue, and a fixture would exercise the comparison while detecting no real drift; (2) vibe config absent (~/.vibe/config.toml), since active_model cannot be read to check for drift when there is no config to read. Both name their missing prerequisite, so a green run still states what it did not check. A third candidate skip was REFUSED: dispatcher's per-run agy-log assertion failed on a bare runner because adapters.advertised_models shells out to `agy models` when its disk cache is cold, and that probe landed inside a monkeypatched subprocess.run and overwrote the captured command. That is a stub leak, so it was fixed by ISOLATING the double rather than by skipping -- which makes CI run MORE. FLOOR 387 -> 391 on 2026-08-23 (improvement-log accessor, PR #59): exactly four new tests, all in test_improvement_log.py -- three read tracked files in the tree (the pointer's size and content, and that CLAUDE.md 0 step 3 and 5 name the accessor rather than a bare path) and one runs the accessor as a subprocess against a path that cannot exist. None reads a populated ledger, an agent CLI or ~/.codex, so all four RUN on a bare runner and NO ceiling moved: nothing new is skipped. Measured on the MERGE RESULT after rebasing onto origin/main af6654d, which collected 387 -- not on the branch base, per the rule above. FLOOR 391 -> 402 on 2026-08-23 (Gate python-ci configuration, the PR that adds the missing .github/workflows/autofix-versions.env): exactly 11 new tests, all in test_ci_gate_config.py, which read committed files only -- the pin file, ruff.toml, mypy.ini, pr-00-gate.yml's toggle annotations and docs/CI_LINT_BASELINE.md. NO ceiling moved. On any CHECKOUT -- CI, the owner's tree, a second instance -- all 11 run: they need no installed linter and no populated ledger. In the EXEC-MIRROR layout all 11 skip with one named reason, because orch-sync-mirror.sh copies root-level *.py only, so .github/workflows, docs/ and scripts/ are genuinely absent there (env_prereq.repo_files_absent). That lands at 11/26 on a machine that otherwise skips nothing, and CI stays at 26/26, so no ceiling needed raising. The skip gate is the presence of those DIRECTORIES, never of the pin file itself -- gating on the file would have made the test that checks for it unable to fail. Measured on the merge result, twice: the branch was rebuilt on origin/main after #42 and #59 merged, and re-measured after #61 merged and was merged in -- 393 passed + 9 skipped = 402 collected both times, so #61 added no collected tests and this floor is not sitting below reality. #61 itself left main's floor at 391, which is exactly main-without-these-11, so there is no inherited drift to correct. RULE CHANGE 2026-08-23: `collected` is now an EQUALITY, not a minimum. Every floor entry above this one records the number being found BELOW reality and hand-raised after the fact -- 21 low at the worst, then 8, then 1, then 2 -- because nothing ever required a test-adding PR to touch this file, so the permissive direction was silent by construction and the rule 'measure on the merge result' had to be restated three times with nothing enforcing it. verify.py now FAILS when collected exceeds the floor, printing the two integers to write. That also makes the concurrency case self-enforcing: once every test-adding branch must edit these same two lines, two concurrent branches CONFLICT IN GIT, so the second cannot merge without rebasing onto the first and re-measuring on the actual merge result. Demonstrated repeatedly on the change itself: six merges landed on main in the two hours it took to write, moving this file 368 -> 387 -> 391 -> 402, and every one would have left the floor below reality under the old one-directional rule. `passed` deliberately stays a MINIMUM on passed+skipped: only collection is machine-invariant (a skipped test is still collected), measured across machines at 391 collected on both, with pass/skip splits of 365/26 on CI against 391/0 locally. The *_max ceilings are untouched by this change and nothing new is skipped. `--update-floor` also stops REPLACING this note -- it appends -- so the warning above about restoring it by hand no longer applies; and drift does NOT block --update-floor, since a gate that forbade its own only remedy would be a deadlock (the first draft was exactly that). FLOOR 402 -> 407 on 2026-08-23 (findability admission requirement). (findability admission requirement). (findability admission requirement). (findability admission requirement). Exactly five new pytest tests, all in test_capability_admission.py: test_findability_distinguishes_its_three_sub_causes, test_findability_blocks_new_capabilities_and_reports_older_ones_as_debt, test_unreadable_reach_is_not_evaluated_and_never_a_failure, test_findability_exemption_is_declared_in_code_not_in_a_live_ledger, test_consult_sites_are_falsifiable_claims_about_real_callers. NO CEILING MOVED and nothing new skips: all five build synthetic ledgers in a tempdir or read committed tables, so none needs a populated capability ledger, an agent CLI or ~/.claude/skills. The one machine-dependent thing they touch -- an external consult site declared in capability_advisor.CONSULT_SITES whose skill prompt is not on this machine -- is reported as UNVERIFIED rather than skipped, because absence of the caller is not refutation of the claim; the in-tree site (tick) is asserted verified on every machine so the check can never degrade into 'everything unverified, nothing tested'. Measured on the merge result per the rule above: this file CONFLICTED three times while the branch was open, as main went 387 -> 391 -> 402 (#61, #64, #65, #60). Each time it was resolved as the UNION rather than by taking a side, and the count was RE-MEASURED on the new merge result rather than either number being carried forward: 402 (main at bd6da2e) + 5 (this branch's new tests) = 407. That is the rule this file already states -- measure the floor on the merge result, not on the branch -- and it mattered here, because #60 both deleted test_ci_gate_config.py and added more than it removed, so guessing in either direction would have been wrong. -> re-measured on 2026-08-23 (PR #62, the four deferred #42 review findings): three new tests, all machine-independent (each builds its own tmp_path Brain and manifests), so NO CEILING MOVED and nothing new is skipped. Fourth conflict for this branch, and the first one under the EQUALITY -- which is the point: the equality's own rationale says git conflict detection is what enforces 'measure on the merge result', and that is exactly what happened here. Under the old minimum the three earlier conflicts could each have been resolved by keeping the larger number; under the equality the count MUST be measured, and it was. RESOLVED AGAINST #68 (findability admission requirement) on 2026-08-23: taken as the UNION per the rule this file states -- #68's five-test entry is retained above and this branch's three-test entry beside it -- and the count RE-MEASURED on the merge result rather than keeping either side's number. main fc1fd42 collects 407; this branch adds 3; 410 measured with `pytest --collect-only -q` on the merge result, not assumed. Ceilings untouched at 26/7/2 and nothing new is skipped. Also resolved in the same merge: langsmith-fleet-worker-attempt.json, a CI-emitted `langsmith-fleet/v1` worker-attempt record whose two sides differed only in `emitted_at` and `pr_number` (62 here, 68 on main). Main's NEWER record was kept rather than this branch's older one -- discarding a newer provenance observation to win a merge would corrupt exactly the causal-provenance evidence CLAUDE.md 2 protects, and this branch's own run re-emits its record anyway. FLOOR 410 -> 411 on 2026-08-23 (CodeRabbit follow-up on PR #42, thread 3837879039; re-measured again after #56 made `collected` an EQUALITY, which makes an assumed number a hard RED rather than a quiet pass -- main stayed at 402 across #56, and the merge result measures 403, so #56 added no collected tests and this is main's 402 plus this branch's one): exactly one new test, test_feedback_model_provenance.test_late_sweep_completes_terminal_attempts_never_one_in_flight, which pins that ledger_reconcile.resolve_unresolved_worker_attempts completes only TERMINAL unresolved worker attempts and never one still in flight. No ceiling moved and nothing new is skipped -- the test builds its own tmp ledger and codex rollout fixture and monkeypatches adapters.CODEX_SESSIONS, so it needs no agent CLI and no populated capability ledger and runs on a bare runner. RESOLVED AGAINST #59 (improvement-log accessor), which raised the floor 387 -> 391 on main while this branch raised it to 388: taken as the UNION -- #59's rationale is retained above and the count was RE-MEASURED on the new merge result rather than keeping either number, which is the rule this file states and the mistake that once put the floor 8 below reality. 391 (main, incl. #59's four tests) + 1 (this branch's one new test) = 392 measured, not assumed: 392 passed, 0 failed, 0 skipped, 83/83 selftests, 43/43 can-fire, 5/5 gates. Three sibling follow-up branches are in flight against this same main (CI/ruff config, arm-attribution + durability, adapters label->ID); if this file conflicts with one of them, resolve as the UNION and RE-MEASURE on the new merge result rather than taking either number -- that is what #42 and #50 did, and taking a side is what put the floor 8 below reality earlier. RESOLVED AGAINST #68 (findability admission requirement) on 2026-08-23: taken as the UNION per the rule this file states -- #68's five-test entry is retained above and this branch's one-test entry beside it -- and the count RE-MEASURED on the merge result. main fc1fd42 collects 407; this branch adds 1; 408 measured with `pytest --collect-only -q` on the merge result, not assumed. Ceilings untouched at 26/7/2 and nothing new is skipped -- the one new test builds its own tmp ledger and codex rollout fixture, so it runs on a bare runner. Also resolved in the same merge: langsmith-fleet-worker-attempt.json, a CI-emitted `langsmith-fleet/v1` worker-attempt record differing only in `emitted_at` and `pr_number`; main's NEWER record was kept, since discarding a newer provenance observation to win a merge would corrupt the causal-provenance evidence CLAUDE.md 2 protects. FLOOR 411 -> 415 on 2026-08-23 (PR #70 diagnostics salvage): four new collected tests in test_capability_set_coverage.py from the PR #43 salvage plus CodeRabbit follow-ups on PR #51/#70 \u2014 union/missing-candidate fetch command, truncation after six modules, AST-scoped gate-call audit, and entrypoint-diagnosis coverage. NO CEILING MOVED and nothing new is skipped; all inject synthetic ledgers or read committed source. Measured on the merge result at 91d37fa: 389 passed + 26 skipped = 415 collected on CI, not assumed. FLOOR 415 -> 416 on 2026-08-23 (the dangling-citation follow-up, PR #74): exactly ONE new test, test_ci_gate_config.test_every_cited_repo_path_resolves, which reads the two committed config files this repo OWNS (the pin file and ruff.toml) and asserts every repo-relative path they cite exists. It exists because the pin file shipped citing docs/ci/LINT_BASELINE.md when the real path was docs/CI_LINT_BASELINE.md: the sibling checks read that file's CONTENTS thoroughly and its PROSE not at all, and the prose is the only pointer telling a reader where to re-measure before bumping a pin. Scoped to the two owned files deliberately -- scanning pr-00-gate.yml yields six findings that are all correct as written (guarded by hashFiles or a .agents check, or upstream paths), and a test that cries wolf gets waived. NO ceiling moved. RE-MEASURED SIX TIMES as the base moved under this ONE-LINE change: bd6da2e 402 -> ddb0928 402 -> fc1fd42 407 -> 0d661e3 407 -> 0593eeb 411 -> 6fed4ad 415, each +1 with this test, and the branch was rebuilt on each rather than the number carried forward. THIS BRANCH IS THE WORKED EXAMPLE of the equality's concurrency cost, so record it rather than rediscover it: main moved EIGHT times in the ~2.5 hours a one-line comment fix was open (#56, #68, #73, #69, #62, #70 and two direct commits), the floor line conflicted THREE separate times, and two merges overlapped the change directly -- #73 landed a byte-identical copy of the backplane-conformance.yml guard this branch also carried (dropped as redundant), and #69 edited this very test file in a neighbouring region. The equality is still the right call and should stay: every entry above this one records the floor being found BELOW reality, which is the permissive direction. But no amount of author care wins this race, because the correct value is only knowable on the merge result. The durable fix is CI running `verify.py --update-floor` on the merge commit, which keeps the equality and removes the race; until then a test-adding PR must be merged promptly after going green, because it re-conflicts on roughly every subsequent merge. FLOOR 416 -> 427 on 2026-08-23 (PR #72 hygiene untrack, rebased after #71 merged): exactly 11 new tests from test_repo_artifact_hygiene.py with root-anchored gitignore patterns. NO ceiling moved. Measured on merge result after #71 landed on main: 416 (main) + 11 = 427 collected via pytest --collect-only -q, not assumed. #71's simpler untrack landed first; this branch carries the full hygiene test suite and corrected root-anchored patterns. FLOOR 427 -> 428 on 2026-08-23 (PR salvaging #34/#42 remnants): exactly one new test, test_feedback_model_provenance.test_gemini_provenance_reads_the_per_run_log_before_the_conversation_store, recovered from #42's post-merge commit 4e0d6ae along with the adapters catalog work it exercises. No ceiling moved and nothing new is skipped -- it seeds adapters._ADVERTISED_MEMO instead of letting the catalog probe shell out, so it runs on any machine and adds no prerequisite. `passed` is 428 rather than the 426 verify.py suggested on this machine: two test_capabilities liveness tests (test_gate_blocks_execution_is_opt_in_and_narrow, test_evidence_gate_kind_is_not_blanket_observer) currently fail HERE on pristine main as well, because the hourly fleet tick mutated the machine-local ledger and range-lane-rollout now classifies matched_not_invoked rather than deliberately_gated. That is ledger STATE, not this branch and not the code -- CI bootstraps an empty ledger and counts 428/428. Recording 426 would have baked a local environment failure into the floor as though it were the expected result. FLOOR 428 -> 441 on 2026-08-23 (coverage measures what actually runs): exactly 12 new tests, all in test_verify_coverage_mode.py. They read committed files and verify.py's own source, and monkeypatch verify.COVERAGE in-process -- no populated ledger, no agent CLI, no ~/.codex, and no coverage RUN -- so all 12 execute on any machine and NO ceiling moved. The change itself is a measurement fix, not a gate: `verify.py --coverage` wraps each child in `coverage run --parallel-mode` and combines, because the per-module --selftest is a SUBPROCESS and a pytest-only coverage run cannot see it. That blind spot was most of the codebase -- 78 modules have no test_*.py at all, ~85,500 lines, 79.6% of non-test root Python -- so the reported 48.45% was measuring the gap in the instrument, not a gap in the tests. Combined: 76.1% (45,049 statements, 10,774 missed). Twelve of the twelve modules the old report named as worst were selftest-only; outcomes.py reported 9.0% and measures 61.9%, watch.py 9.6% -> 86.9%. Coverage is OFF by default and deliberately never touches the exit code -- one of the 12 tests pins that, because enforcing a threshold here would reward pytest wrappers around already-tested modules: metric up, assurance flat. Measured on the MERGE RESULT: branched from origin/main bcc68cd (floor 427), then REBASED onto f5f1c39 when it landed underneath and re-measured on the new merge result rather than carrying the old number: 428 + 13 = 441. +1 on 2026-08-23 (440 -> 441 after the rebase), same branch: test_the_cli_help_actually_renders. It exists because this branch BROKE `verify.py --help` and its own twelve tests did not notice. argparse interpolates help strings with `% params`, so the literal `~80%` in the --coverage help was read as an `%o` octal conversion and --help died with 'badly formed help string'. All twelve original tests passed: every one inspected source text or monkeypatched a flag, and not one RENDERED the help -- a construction-time test suite that never exercised the constructed thing, which is this repo's founding defect one layer up. CI's verify.py gate caught it, which is the check of last resort working as intended. The new test runs `verify.py --help` as a subprocess and asserts it exits 0, so it runs anywhere and NO ceiling moved. Rendering rather than grepping for `%` is deliberate: a grep would flag the legitimate `%(default)s`. FLOOR 441 -> 442 on 2026-08-23 (matched_not_invoked yields to observers and declared gates): exactly one new test, test_capabilities.test_matched_not_invoked_yields_to_observers_and_declared_gates. It is SYNTHETIC on purpose and that is the point of it: the two tests that caught this bug in the wild read the LIVE ledger, so they skipped with a named reason on the empty ledger ci.yml bootstraps -- the defect was red on every populated machine and green on CI for as long as it existed. A synthetic row asks the same question everywhere, so this one RUNS on a bare runner and NO ceiling moved. The fix itself moves matched_not_invoked below `observing` and below the DECLARED deliberately_gated check in classify_liveness: it was the first check, which made it the fourth instance of the unescapable label the comments in that function exist to fix. Audited before committing -- 12 of 43 live rows reclassify (ten observers to observing, two declared gates to deliberately_gated) and ZERO move for any other reason, so nothing is reclassified by inference and the weaker gate_reason-only branch is untouched. Measured on origin/main 0d9c3a7, whose recorded floor is 441, so 441 + 1 = 442. FLOOR RECORDED by verify.py --update-floor on 2026-08-23: collected=442, passed=442. Ceilings preserved, never re-measured \u2014 they are edited by hand. FLOOR RECORDED by verify.py --update-floor on 2026-08-24: collected=442, passed=442. Ceilings preserved, never re-measured \u2014 they are edited by hand. FLOOR RECORDED by verify.py --update-floor on 2026-08-24: collected=442, passed=442. Ceilings preserved, never re-measured \u2014 they are edited by hand. MYPY_EXEMPT_MAX introduced at 64 on 2026-08-23, the same change that flipped `typecheck` ON in pr-00-gate.yml. It was OFF because 608 whole-tree errors were drainable 0 per PR -- a gate whose clear path is blocked by the thing it measures. Two real changes opened it: the src/ move scoped the Gate's `target=src` to the 99 modules (608 -> 467), and pyproject.toml's [[tool.mypy.overrides]] exempts the modules that still have findings BY NAME so the 35 already-clean ones are checked today. 12 var-annotated findings were then drained (467 -> 455, 66 -> 64 modules) to prove the drain works rather than promise it. This ceiling may only ever be LOWERED, by typing a module and deleting its line -- raising it means agreeing one more module goes unchecked, so say which and why. NOT a suppression: no error code is disabled anywhere and the 455 stay visible via `python3 scripts/ci_lint_baseline.py`. Edited BY HAND like the other *_max values; --update-floor never re-measures it. MYPY_EXEMPT_MAX LOWERED 64 -> 43 on 2026-08-24, the ratchet's first real drain: 21 modules typed clean and removed from the exempt list, 455 -> 430 findings. Targeted the modules with 1-3 errors on purpose -- fixing 50 errors spread across the big modules would move this number by ZERO, and this number is what the gate reads. Lowering it is the drain; it may never be raised without naming the module and why. MYPY_EXEMPT_MAX LOWERED 43 -> 33 on 2026-08-24 (batch 2 of the drain): the whole <=5-finding tail typed clean. 66 of 99 modules now checked. What remains is five per-module campaigns (capability_advisor, dispatcher, capability_propensity, runtime_ac_gate, capabilities hold most of it), so future batches take ONE big module at a time rather than skimming. (batch 2 detail: 43 -> 26, 430 -> 374 findings, 73 of 99 modules checked. `mypy_path` gained `tests` so mypy can RESOLVE the recurrence-fixture roster capability_admission legitimately imports; the target stays `src`, but mypy then follows into that one test file, whose two findings were fixed rather than configured around.) MYPY_EXEMPT_MAX LOWERED 26 -> 20 on 2026-08-24 (batch 3): 79 of 99 modules checked.", + "note": "Recorded by verify.py --update-floor, except the *_max ceilings, which are edited BY HAND and never re-measured. `collected` catches tests that stopped being collected; `passed` is compared against passed+skipped, so a check may move between passing and consciously-skipped but the two together may never shrink. The *_max ceilings bound the skipped side: 24/7/2 is exactly what a machine with none of this instance's local prerequisites skips (a GitHub runner: no agent CLIs, no ~/.codex/skills, no /Applications/ChatGPT.app, no populated capability ledger), measured 2026-08-21. On the owner's machine all prerequisites exist and nothing skips at all. Raising a ceiling is a deliberate act: it means agreeing that one more thing is allowed to go unchecked, so say which and why in the commit. LOWERED 26 -> 24 on 2026-08-22, reverting the raise made earlier the same day. The two kill-switch exemption tests no longer need to skip on a bare runner: their declarations moved out of the running instance's ledger and into capabilities.KNOWN_DECLARATIONS, so they assert code-derived truth and run everywhere. Moving a test back below the ceiling is the preferred way to lower it -- fix what made it machine-dependent, rather than agreeing to check less. FLOOR 345 -> 353 on 2026-08-22: 345 was measured on a branch cut before #13 (research panels/rounds/domain studies) merged, so the recorded floor sat 8 tests BELOW what main actually collects. A floor below reality is the permissive direction -- those 8 could have silently stopped being collected and still cleared the check, which is exactly the hole this file exists to close. Measure the floor on the merge result, not on the branch. Raised again on 2026-08-22 by the producer-identity-scope branch, which adds tests on top of the 353 recorded by #15; re-measured after rebasing rather than assumed. NOTE: `verify.py --update-floor` REPLACES this note with a generic one, so it must be restored by hand after every use \u2014 the ceiling rationale is the only record of which prerequisite justifies each skip. FLOOR 365 -> 366 on 2026-08-22 (heartbeat-ordering work, PR #18): exactly one new test, test_capabilities.test_no_tick_producer_runs_above_the_heartbeat_export. No ceiling moved and nothing new is skipped -- it reads source files rather than a populated ledger, so it runs on any machine. The branch recorded 354 because it was cut before #16 merged; re-measured on the MERGE RESULT per the rule above, which is exactly the mistake that put the floor 8 below reality last time. FLOOR 366 -> 368 on 2026-08-23: main collected 368 while this file recorded 366, drift left by #34 (evidence-acquisition landed, +1) and #37 (tick capability evidence, +1) whose authors each measured against a branch cut before the other merged. A floor BELOW reality is the permissive direction this file exists to close -- those two could have silently stopped being collected and still cleared the check. Measured on the merge result per the rule above: 368 passed, 0 failed, 0 skipped, 83/83 selftests, 43/43 can-fire, 5/5 gates. CEILING 24 -> 26 and FLOOR 368 -> 387 on 2026-08-23 (profiles/provenance branch, PR #42). This file CONFLICTED with #50, which raised the floor 366 -> 368 on main while this branch raised it to 387; resolved as the UNION rather than by taking a side -- #50's rationale is retained above and the count was RE-MEASURED on the new merge result instead of keeping either number. 368 (main) + 19 (this branch's net new tests) = 387; #50 corrected recorded drift rather than adding coverage, which is why 387 is unchanged from the pre-conflict measurement. Measured in a runner sandbox reproducing CI exactly (361 passed, 26 skipped, 387 collected) AND on the owner's machine (387 passed, 0 skipped, 5/5 gates). The two new skips are drift detectors against a REAL installed agent runtime, so neither can be moved below the ceiling -- the preferred way to lower one: (1) agy advertised-models cache absent, since comparing declared model ids against the catalogue agy actually advertises needs that catalogue, and a fixture would exercise the comparison while detecting no real drift; (2) vibe config absent (~/.vibe/config.toml), since active_model cannot be read to check for drift when there is no config to read. Both name their missing prerequisite, so a green run still states what it did not check. A third candidate skip was REFUSED: dispatcher's per-run agy-log assertion failed on a bare runner because adapters.advertised_models shells out to `agy models` when its disk cache is cold, and that probe landed inside a monkeypatched subprocess.run and overwrote the captured command. That is a stub leak, so it was fixed by ISOLATING the double rather than by skipping -- which makes CI run MORE. FLOOR 387 -> 391 on 2026-08-23 (improvement-log accessor, PR #59): exactly four new tests, all in test_improvement_log.py -- three read tracked files in the tree (the pointer's size and content, and that CLAUDE.md 0 step 3 and 5 name the accessor rather than a bare path) and one runs the accessor as a subprocess against a path that cannot exist. None reads a populated ledger, an agent CLI or ~/.codex, so all four RUN on a bare runner and NO ceiling moved: nothing new is skipped. Measured on the MERGE RESULT after rebasing onto origin/main af6654d, which collected 387 -- not on the branch base, per the rule above. FLOOR 391 -> 402 on 2026-08-23 (Gate python-ci configuration, the PR that adds the missing .github/workflows/autofix-versions.env): exactly 11 new tests, all in test_ci_gate_config.py, which read committed files only -- the pin file, ruff.toml, mypy.ini, pr-00-gate.yml's toggle annotations and docs/CI_LINT_BASELINE.md. NO ceiling moved. On any CHECKOUT -- CI, the owner's tree, a second instance -- all 11 run: they need no installed linter and no populated ledger. In the EXEC-MIRROR layout all 11 skip with one named reason, because orch-sync-mirror.sh copies root-level *.py only, so .github/workflows, docs/ and scripts/ are genuinely absent there (env_prereq.repo_files_absent). That lands at 11/26 on a machine that otherwise skips nothing, and CI stays at 26/26, so no ceiling needed raising. The skip gate is the presence of those DIRECTORIES, never of the pin file itself -- gating on the file would have made the test that checks for it unable to fail. Measured on the merge result, twice: the branch was rebuilt on origin/main after #42 and #59 merged, and re-measured after #61 merged and was merged in -- 393 passed + 9 skipped = 402 collected both times, so #61 added no collected tests and this floor is not sitting below reality. #61 itself left main's floor at 391, which is exactly main-without-these-11, so there is no inherited drift to correct. RULE CHANGE 2026-08-23: `collected` is now an EQUALITY, not a minimum. Every floor entry above this one records the number being found BELOW reality and hand-raised after the fact -- 21 low at the worst, then 8, then 1, then 2 -- because nothing ever required a test-adding PR to touch this file, so the permissive direction was silent by construction and the rule 'measure on the merge result' had to be restated three times with nothing enforcing it. verify.py now FAILS when collected exceeds the floor, printing the two integers to write. That also makes the concurrency case self-enforcing: once every test-adding branch must edit these same two lines, two concurrent branches CONFLICT IN GIT, so the second cannot merge without rebasing onto the first and re-measuring on the actual merge result. Demonstrated repeatedly on the change itself: six merges landed on main in the two hours it took to write, moving this file 368 -> 387 -> 391 -> 402, and every one would have left the floor below reality under the old one-directional rule. `passed` deliberately stays a MINIMUM on passed+skipped: only collection is machine-invariant (a skipped test is still collected), measured across machines at 391 collected on both, with pass/skip splits of 365/26 on CI against 391/0 locally. The *_max ceilings are untouched by this change and nothing new is skipped. `--update-floor` also stops REPLACING this note -- it appends -- so the warning above about restoring it by hand no longer applies; and drift does NOT block --update-floor, since a gate that forbade its own only remedy would be a deadlock (the first draft was exactly that). FLOOR 402 -> 407 on 2026-08-23 (findability admission requirement). (findability admission requirement). (findability admission requirement). (findability admission requirement). Exactly five new pytest tests, all in test_capability_admission.py: test_findability_distinguishes_its_three_sub_causes, test_findability_blocks_new_capabilities_and_reports_older_ones_as_debt, test_unreadable_reach_is_not_evaluated_and_never_a_failure, test_findability_exemption_is_declared_in_code_not_in_a_live_ledger, test_consult_sites_are_falsifiable_claims_about_real_callers. NO CEILING MOVED and nothing new skips: all five build synthetic ledgers in a tempdir or read committed tables, so none needs a populated capability ledger, an agent CLI or ~/.claude/skills. The one machine-dependent thing they touch -- an external consult site declared in capability_advisor.CONSULT_SITES whose skill prompt is not on this machine -- is reported as UNVERIFIED rather than skipped, because absence of the caller is not refutation of the claim; the in-tree site (tick) is asserted verified on every machine so the check can never degrade into 'everything unverified, nothing tested'. Measured on the merge result per the rule above: this file CONFLICTED three times while the branch was open, as main went 387 -> 391 -> 402 (#61, #64, #65, #60). Each time it was resolved as the UNION rather than by taking a side, and the count was RE-MEASURED on the new merge result rather than either number being carried forward: 402 (main at bd6da2e) + 5 (this branch's new tests) = 407. That is the rule this file already states -- measure the floor on the merge result, not on the branch -- and it mattered here, because #60 both deleted test_ci_gate_config.py and added more than it removed, so guessing in either direction would have been wrong. -> re-measured on 2026-08-23 (PR #62, the four deferred #42 review findings): three new tests, all machine-independent (each builds its own tmp_path Brain and manifests), so NO CEILING MOVED and nothing new is skipped. Fourth conflict for this branch, and the first one under the EQUALITY -- which is the point: the equality's own rationale says git conflict detection is what enforces 'measure on the merge result', and that is exactly what happened here. Under the old minimum the three earlier conflicts could each have been resolved by keeping the larger number; under the equality the count MUST be measured, and it was. RESOLVED AGAINST #68 (findability admission requirement) on 2026-08-23: taken as the UNION per the rule this file states -- #68's five-test entry is retained above and this branch's three-test entry beside it -- and the count RE-MEASURED on the merge result rather than keeping either side's number. main fc1fd42 collects 407; this branch adds 3; 410 measured with `pytest --collect-only -q` on the merge result, not assumed. Ceilings untouched at 26/7/2 and nothing new is skipped. Also resolved in the same merge: langsmith-fleet-worker-attempt.json, a CI-emitted `langsmith-fleet/v1` worker-attempt record whose two sides differed only in `emitted_at` and `pr_number` (62 here, 68 on main). Main's NEWER record was kept rather than this branch's older one -- discarding a newer provenance observation to win a merge would corrupt exactly the causal-provenance evidence CLAUDE.md 2 protects, and this branch's own run re-emits its record anyway. FLOOR 410 -> 411 on 2026-08-23 (CodeRabbit follow-up on PR #42, thread 3837879039; re-measured again after #56 made `collected` an EQUALITY, which makes an assumed number a hard RED rather than a quiet pass -- main stayed at 402 across #56, and the merge result measures 403, so #56 added no collected tests and this is main's 402 plus this branch's one): exactly one new test, test_feedback_model_provenance.test_late_sweep_completes_terminal_attempts_never_one_in_flight, which pins that ledger_reconcile.resolve_unresolved_worker_attempts completes only TERMINAL unresolved worker attempts and never one still in flight. No ceiling moved and nothing new is skipped -- the test builds its own tmp ledger and codex rollout fixture and monkeypatches adapters.CODEX_SESSIONS, so it needs no agent CLI and no populated capability ledger and runs on a bare runner. RESOLVED AGAINST #59 (improvement-log accessor), which raised the floor 387 -> 391 on main while this branch raised it to 388: taken as the UNION -- #59's rationale is retained above and the count was RE-MEASURED on the new merge result rather than keeping either number, which is the rule this file states and the mistake that once put the floor 8 below reality. 391 (main, incl. #59's four tests) + 1 (this branch's one new test) = 392 measured, not assumed: 392 passed, 0 failed, 0 skipped, 83/83 selftests, 43/43 can-fire, 5/5 gates. Three sibling follow-up branches are in flight against this same main (CI/ruff config, arm-attribution + durability, adapters label->ID); if this file conflicts with one of them, resolve as the UNION and RE-MEASURE on the new merge result rather than taking either number -- that is what #42 and #50 did, and taking a side is what put the floor 8 below reality earlier. RESOLVED AGAINST #68 (findability admission requirement) on 2026-08-23: taken as the UNION per the rule this file states -- #68's five-test entry is retained above and this branch's one-test entry beside it -- and the count RE-MEASURED on the merge result. main fc1fd42 collects 407; this branch adds 1; 408 measured with `pytest --collect-only -q` on the merge result, not assumed. Ceilings untouched at 26/7/2 and nothing new is skipped -- the one new test builds its own tmp ledger and codex rollout fixture, so it runs on a bare runner. Also resolved in the same merge: langsmith-fleet-worker-attempt.json, a CI-emitted `langsmith-fleet/v1` worker-attempt record differing only in `emitted_at` and `pr_number`; main's NEWER record was kept, since discarding a newer provenance observation to win a merge would corrupt the causal-provenance evidence CLAUDE.md 2 protects. FLOOR 411 -> 415 on 2026-08-23 (PR #70 diagnostics salvage): four new collected tests in test_capability_set_coverage.py from the PR #43 salvage plus CodeRabbit follow-ups on PR #51/#70 \u2014 union/missing-candidate fetch command, truncation after six modules, AST-scoped gate-call audit, and entrypoint-diagnosis coverage. NO CEILING MOVED and nothing new is skipped; all inject synthetic ledgers or read committed source. Measured on the merge result at 91d37fa: 389 passed + 26 skipped = 415 collected on CI, not assumed. FLOOR 415 -> 416 on 2026-08-23 (the dangling-citation follow-up, PR #74): exactly ONE new test, test_ci_gate_config.test_every_cited_repo_path_resolves, which reads the two committed config files this repo OWNS (the pin file and ruff.toml) and asserts every repo-relative path they cite exists. It exists because the pin file shipped citing docs/ci/LINT_BASELINE.md when the real path was docs/CI_LINT_BASELINE.md: the sibling checks read that file's CONTENTS thoroughly and its PROSE not at all, and the prose is the only pointer telling a reader where to re-measure before bumping a pin. Scoped to the two owned files deliberately -- scanning pr-00-gate.yml yields six findings that are all correct as written (guarded by hashFiles or a .agents check, or upstream paths), and a test that cries wolf gets waived. NO ceiling moved. RE-MEASURED SIX TIMES as the base moved under this ONE-LINE change: bd6da2e 402 -> ddb0928 402 -> fc1fd42 407 -> 0d661e3 407 -> 0593eeb 411 -> 6fed4ad 415, each +1 with this test, and the branch was rebuilt on each rather than the number carried forward. THIS BRANCH IS THE WORKED EXAMPLE of the equality's concurrency cost, so record it rather than rediscover it: main moved EIGHT times in the ~2.5 hours a one-line comment fix was open (#56, #68, #73, #69, #62, #70 and two direct commits), the floor line conflicted THREE separate times, and two merges overlapped the change directly -- #73 landed a byte-identical copy of the backplane-conformance.yml guard this branch also carried (dropped as redundant), and #69 edited this very test file in a neighbouring region. The equality is still the right call and should stay: every entry above this one records the floor being found BELOW reality, which is the permissive direction. But no amount of author care wins this race, because the correct value is only knowable on the merge result. The durable fix is CI running `verify.py --update-floor` on the merge commit, which keeps the equality and removes the race; until then a test-adding PR must be merged promptly after going green, because it re-conflicts on roughly every subsequent merge. FLOOR 416 -> 427 on 2026-08-23 (PR #72 hygiene untrack, rebased after #71 merged): exactly 11 new tests from test_repo_artifact_hygiene.py with root-anchored gitignore patterns. NO ceiling moved. Measured on merge result after #71 landed on main: 416 (main) + 11 = 427 collected via pytest --collect-only -q, not assumed. #71's simpler untrack landed first; this branch carries the full hygiene test suite and corrected root-anchored patterns. FLOOR 427 -> 428 on 2026-08-23 (PR salvaging #34/#42 remnants): exactly one new test, test_feedback_model_provenance.test_gemini_provenance_reads_the_per_run_log_before_the_conversation_store, recovered from #42's post-merge commit 4e0d6ae along with the adapters catalog work it exercises. No ceiling moved and nothing new is skipped -- it seeds adapters._ADVERTISED_MEMO instead of letting the catalog probe shell out, so it runs on any machine and adds no prerequisite. `passed` is 428 rather than the 426 verify.py suggested on this machine: two test_capabilities liveness tests (test_gate_blocks_execution_is_opt_in_and_narrow, test_evidence_gate_kind_is_not_blanket_observer) currently fail HERE on pristine main as well, because the hourly fleet tick mutated the machine-local ledger and range-lane-rollout now classifies matched_not_invoked rather than deliberately_gated. That is ledger STATE, not this branch and not the code -- CI bootstraps an empty ledger and counts 428/428. Recording 426 would have baked a local environment failure into the floor as though it were the expected result. FLOOR 428 -> 441 on 2026-08-23 (coverage measures what actually runs): exactly 12 new tests, all in test_verify_coverage_mode.py. They read committed files and verify.py's own source, and monkeypatch verify.COVERAGE in-process -- no populated ledger, no agent CLI, no ~/.codex, and no coverage RUN -- so all 12 execute on any machine and NO ceiling moved. The change itself is a measurement fix, not a gate: `verify.py --coverage` wraps each child in `coverage run --parallel-mode` and combines, because the per-module --selftest is a SUBPROCESS and a pytest-only coverage run cannot see it. That blind spot was most of the codebase -- 78 modules have no test_*.py at all, ~85,500 lines, 79.6% of non-test root Python -- so the reported 48.45% was measuring the gap in the instrument, not a gap in the tests. Combined: 76.1% (45,049 statements, 10,774 missed). Twelve of the twelve modules the old report named as worst were selftest-only; outcomes.py reported 9.0% and measures 61.9%, watch.py 9.6% -> 86.9%. Coverage is OFF by default and deliberately never touches the exit code -- one of the 12 tests pins that, because enforcing a threshold here would reward pytest wrappers around already-tested modules: metric up, assurance flat. Measured on the MERGE RESULT: branched from origin/main bcc68cd (floor 427), then REBASED onto f5f1c39 when it landed underneath and re-measured on the new merge result rather than carrying the old number: 428 + 13 = 441. +1 on 2026-08-23 (440 -> 441 after the rebase), same branch: test_the_cli_help_actually_renders. It exists because this branch BROKE `verify.py --help` and its own twelve tests did not notice. argparse interpolates help strings with `% params`, so the literal `~80%` in the --coverage help was read as an `%o` octal conversion and --help died with 'badly formed help string'. All twelve original tests passed: every one inspected source text or monkeypatched a flag, and not one RENDERED the help -- a construction-time test suite that never exercised the constructed thing, which is this repo's founding defect one layer up. CI's verify.py gate caught it, which is the check of last resort working as intended. The new test runs `verify.py --help` as a subprocess and asserts it exits 0, so it runs anywhere and NO ceiling moved. Rendering rather than grepping for `%` is deliberate: a grep would flag the legitimate `%(default)s`. FLOOR 441 -> 442 on 2026-08-23 (matched_not_invoked yields to observers and declared gates): exactly one new test, test_capabilities.test_matched_not_invoked_yields_to_observers_and_declared_gates. It is SYNTHETIC on purpose and that is the point of it: the two tests that caught this bug in the wild read the LIVE ledger, so they skipped with a named reason on the empty ledger ci.yml bootstraps -- the defect was red on every populated machine and green on CI for as long as it existed. A synthetic row asks the same question everywhere, so this one RUNS on a bare runner and NO ceiling moved. The fix itself moves matched_not_invoked below `observing` and below the DECLARED deliberately_gated check in classify_liveness: it was the first check, which made it the fourth instance of the unescapable label the comments in that function exist to fix. Audited before committing -- 12 of 43 live rows reclassify (ten observers to observing, two declared gates to deliberately_gated) and ZERO move for any other reason, so nothing is reclassified by inference and the weaker gate_reason-only branch is untouched. Measured on origin/main 0d9c3a7, whose recorded floor is 441, so 441 + 1 = 442. FLOOR RECORDED by verify.py --update-floor on 2026-08-23: collected=442, passed=442. Ceilings preserved, never re-measured \u2014 they are edited by hand. FLOOR RECORDED by verify.py --update-floor on 2026-08-24: collected=442, passed=442. Ceilings preserved, never re-measured \u2014 they are edited by hand. FLOOR RECORDED by verify.py --update-floor on 2026-08-24: collected=442, passed=442. Ceilings preserved, never re-measured \u2014 they are edited by hand. MYPY_EXEMPT_MAX introduced at 64 on 2026-08-23, the same change that flipped `typecheck` ON in pr-00-gate.yml. It was OFF because 608 whole-tree errors were drainable 0 per PR -- a gate whose clear path is blocked by the thing it measures. Two real changes opened it: the src/ move scoped the Gate's `target=src` to the 99 modules (608 -> 467), and pyproject.toml's [[tool.mypy.overrides]] exempts the modules that still have findings BY NAME so the 35 already-clean ones are checked today. 12 var-annotated findings were then drained (467 -> 455, 66 -> 64 modules) to prove the drain works rather than promise it. This ceiling may only ever be LOWERED, by typing a module and deleting its line -- raising it means agreeing one more module goes unchecked, so say which and why. NOT a suppression: no error code is disabled anywhere and the 455 stay visible via `python3 scripts/ci_lint_baseline.py`. Edited BY HAND like the other *_max values; --update-floor never re-measures it. MYPY_EXEMPT_MAX LOWERED 64 -> 43 on 2026-08-24, the ratchet's first real drain: 21 modules typed clean and removed from the exempt list, 455 -> 430 findings. Targeted the modules with 1-3 errors on purpose -- fixing 50 errors spread across the big modules would move this number by ZERO, and this number is what the gate reads. Lowering it is the drain; it may never be raised without naming the module and why. MYPY_EXEMPT_MAX LOWERED 43 -> 33 on 2026-08-24 (batch 2 of the drain): the whole <=5-finding tail typed clean. 66 of 99 modules now checked. What remains is five per-module campaigns (capability_advisor, dispatcher, capability_propensity, runtime_ac_gate, capabilities hold most of it), so future batches take ONE big module at a time rather than skimming. (batch 2 detail: 43 -> 26, 430 -> 374 findings, 73 of 99 modules checked. `mypy_path` gained `tests` so mypy can RESOLVE the recurrence-fixture roster capability_admission legitimately imports; the target stays `src`, but mypy then follows into that one test file, whose two findings were fixed rather than configured around.) MYPY_EXEMPT_MAX LOWERED 26 -> 20 on 2026-08-24 (batch 3): 79 of 99 modules checked. FLOOR 442 -> 448 on 2026-08-24 (absent-check detector + its ratchet): SIX new tests in tests/test_checks_reported.py holding the frequency rule and the expected-check ratchet. NO ceiling moved -- they call pure functions and read one committed JSON file, so they run on any machine. The ratchet exists because dogfooding the detector caught it DISARMING ITSELF: while pr-00-gate.yml sat held, every merged PR merged without the Gate, so after twelve such merges the Gate's checks fell below the 75% frequency threshold, the expected set eroded 23 -> 14, and PR #91 was pronounced clean by the tool written to catch exactly that. config/expected-checks.json is the high-water mark, seeded from PRs #87/#89 whose Gate demonstrably ran, and it only comes down when somebody deletes a line.", "mypy_exempt_max": 20 } diff --git a/config/expected-checks.json b/config/expected-checks.json new file mode 100644 index 0000000..45dc12b --- /dev/null +++ b/config/expected-checks.json @@ -0,0 +1,37 @@ +{ + "expected": [ + "Bot comment handler", + "Cleanup bot comment label", + "Create issue from verification (enhanced)", + "Fetch PR context / Fetch PR Context", + "PR meta handler / Detect keepalive comments", + "PR meta handler / Dispatch keepalive orchestrator", + "PR meta handler / Resume keepalive after Gate", + "PR meta handler / Update PR body sections", + "Resolve event context", + "contract", + "cross-repo smoke", + "detect changed files", + "docker smoke", + "docs guard", + "generated delivery seal", + "github scripts tests", + "guard", + "issue consistency", + "ledger validation", + "privilege environment gate", + "python ci / Validate inputs", + "python ci / lint-format", + "python ci / lint-ruff", + "python ci / logs summary", + "python ci / python 3.12", + "python ci / python 3.13", + "python ci / select reusable CI scope", + "python ci / typecheck-mypy", + "reconcile the collection floor (main only)", + "summary", + "test-quality", + "unauthorized-promotion-marker", + "verify.py (real pytest counts + selftests + capability gates)" + ] +} diff --git a/docs/ABSENT_CHECK_LANE_WIRING.md b/docs/ABSENT_CHECK_LANE_WIRING.md new file mode 100644 index 0000000..3d17816 --- /dev/null +++ b/docs/ABSENT_CHECK_LANE_WIRING.md @@ -0,0 +1,77 @@ +# An absent check must reach the lanes — the one wiring step this repo cannot land + +`scripts/check_checks_reported.py` is in-repo, tested and callable. The lanes that actually **merge** +are not: `~/.codex/automations/{imi-merge-verify-closer,pd-workloop-resume}/automation.toml` and +`~/.codex/bin/handoff-prerun.sh` are the owner's files, outside any repository. So this doc is the +handoff, in the same shape as `docs/MIRROR_SYNC_PATCH.md`. + +## Why the merge point is the right home, and CI is not + +The defect is that **an absent check is indistinguishable from a passing one.** `gh pr checks` lists +what reported; a check that never started is simply not in the list, so a PR with no Gate reads +exactly like a PR whose Gate passed. + +That cannot be fixed from inside GitHub Actions, for two reasons: + +1. **A workflow can be held.** Six of this repo's workflows currently sit at `action_required` with + zero jobs, `pr-00-gate.yml` among them. A detector implemented as a workflow can be held by the + same mechanism it is watching. +2. **Ordering.** Any in-CI check runs *concurrently* with the Gate, so it cannot know whether the + Gate is absent or merely slower. + +The merge decision is the one place where "did everything report?" is both answerable and +actionable. In this fleet that decision is the closer lane's. + +## Why not branch protection + +Because it converts this defect into a worse one. A required status check that is **held** never +reports, so the PR can never merge — the clear path blocked by the very thing the gate measures, +which is this workspace's most-repeated defect. On a solo-maintained repo, "unverified but movable" +beats "permanently stuck". `main` is deliberately unprotected; this tool is what replaces the +protection, at the point where a human or a lane can still exercise judgement. + +## The closer wiring (pre-merge assertion) + +The closer already parses `action_required`, but frames it as *"may need human approval"*. That is +the wrong frame: the question is not whether someone should approve a workflow, it is whether **this +PR was verified at all.** Before merging any PR, run: + +```bash +python3 ~/Library/CloudStorage/Dropbox/Learning/Code/Orchestrator/scripts/check_checks_reported.py --pr +``` + +* **exit 0** — every check that normally reports also reported here. Proceed on the usual criteria. +* **exit 1** — one or more checks NEVER reported. Do not merge on the strength of a green list. + Post one inbox item naming the absent checks, and either wait for them or record explicitly why + the absence is acceptable (a workflow genuinely removed) before merging. + +This adds no queue: it is evaluated per merge attempt from live state, so there is nothing to drain +and nothing to mark as read. + +## The prerun surfacing (FYI, never blocking) + +Add to `handoff-prerun.sh`, in the section that already prints lane state: + +```bash +python3 "$ORCH/scripts/check_checks_reported.py" --sweep 2>/dev/null || true +``` + +`--sweep` reports every open PR with an absent check and every currently-held workflow. It is +report-only by construction — it takes no action, has no state, and cannot accumulate. `|| true` +because a lane round must never fail on the health reporter. + +## Attention cost + +Six workflows are held today; approving each in the Actions UI is a one-off of a couple of minutes +in total. Ongoing, an approval is needed each time an edit re-arms a workflow — a few times a week +at this repo's rate, so low single-digit minutes per week. The sweep makes those visible without +queuing them, and the closer assertion makes the dangerous case (merging unverified) impossible to +reach by accident rather than adding a step to remember. + +## What this deliberately does not do + +It does not model **why** a check is absent. A check can vanish to a held workflow, a cancellation, +a deleted or renamed workflow, a rate limit, a mistaken path filter, or a GitHub incident. Those +present identically to whoever is merging, and they are the same bug: something that was being +checked stopped being checked, quietly. The next cause will be one not listed here, which is exactly +why the tool asks only "did it report?". diff --git a/scripts/check_checks_reported.py b/scripts/check_checks_reported.py new file mode 100755 index 0000000..2759fb7 --- /dev/null +++ b/scripts/check_checks_reported.py @@ -0,0 +1,276 @@ +#!/usr/bin/env python3 +"""An ABSENT check must not read like a passing one. + +THE STRUCTURAL DEFECT THIS CLOSES, and the specific cause is deliberately not modelled. + +`main` has no branch protection, so nothing structurally blocks a merge whose checks never +reported. And `gh pr checks` lists what DID report: a check that never started is not "red", it is +missing from the list, so a PR with no Gate at all reads exactly like a PR whose Gate passed. That +is this repository's founding defect -- silence indistinguishable from success -- and it has now +produced two separate incidents: + + * 2026-08-23: five python-ci jobs died at a shared install step for want of + `.github/workflows/autofix-versions.env`. PRs #61/#64/#65 merged with all five red. + * 2026-08-24: PR #90's Gate run was held at `action_required` with ZERO jobs, so the Gate never + ran at all. It merged with no lint, no format and no typecheck, landing six F821s that were + found only because somebody happened to run ruff by hand. + +THE CAUSE WILL BE DIFFERENT NEXT TIME, so this tool does not look for holds. A check can go absent +because a workflow was held for review, cancelled, deleted, renamed, rate-limited, path-filtered by +mistake, or lost to a GitHub incident. All of those present identically to the merger, and all of +them are the same bug: something that was being checked stopped being checked, quietly. This tool +answers only "did every check that reports on a comparable PR also report here", which is true of +every one of those causes and needs no taxonomy. + +WHY THE EXPECTED SET IS DERIVED, NOT LISTED. A hardcoded list of required check names is a second +copy of the CI topology, and this repo has an unbroken record of paired literals drifting apart. +The reference set is taken from a recently MERGED pull request instead, so it tracks reality on its +own and needs no maintenance. Path filters are not a false-positive source: a job skipped by a path +filter still REPORTS, with conclusion `skipped`. This compares which check NAMES reported at all, +never their conclusions -- conclusions are the Gate's business, presence is this tool's. + +The safe direction is noise. A workflow that was deliberately deleted will be flagged until the +reference PR rotates past it; that is a one-line acknowledgement, whereas the opposite error ships +an unverified merge. +""" + +from __future__ import annotations + +import argparse +import json +import subprocess +from pathlib import Path + +REPO = "stranske/Orchestrator" +# Bot/advisory checks whose absence means nothing: they are opt-in, rate-limited, or driven by +# events unrelated to the head commit. Named individually -- never a prefix wildcard, which would +# quietly swallow a real check that happened to share a word. +IGNORED = frozenset( + { + "CodeRabbit", + "claude-review", + } +) + + +def _gh_json(path: str) -> object: + proc = subprocess.run( + ["gh", "api", path, "--paginate"], capture_output=True, text=True, check=False + ) + if proc.returncode != 0: + err = proc.stderr.strip() + # A rate limit is the expected degraded case, not a bug, and this runs every lane round -- + # dumping GitHub's full paragraph hourly would train the reader to skip the whole section. + # One line, and it says plainly that absence is now UNKNOWN rather than absent-of-problems: + # a reporter that cannot report must not read as a clean bill of health. + if "rate limit" in err.lower(): + raise SystemExit( + "GitHub rate limit reached — absent-check status is UNKNOWN this round, " + "which is not the same as clean. Re-run after the limit resets." + ) + raise SystemExit(f"gh api {path} failed: {err}") + # --paginate concatenates JSON documents; take the objects in order. + out, decoder, idx = [], json.JSONDecoder(), 0 + text = proc.stdout.strip() + while idx < len(text): + obj, end = decoder.raw_decode(text, idx) + out.append(obj) + idx = end + while idx < len(text) and text[idx] in " \n\r\t": + idx += 1 + return out + + +def reported_names(sha: str) -> set[str]: + """Which check NAMES reported on this commit, at any conclusion including skipped.""" + names: set[str] = set() + for page in _gh_json(f"repos/{REPO}/commits/{sha}/check-runs?per_page=100"): + for run in page.get("check_runs", []): # type: ignore[union-attr] + names.add(run["name"]) + return {n for n in names if n not in IGNORED} + + +# The reference is built from FREQUENCY across recent merged PRs, and both simpler designs were +# tried against the real incident first and rejected by it: +# +# * ONE reference PR. Failed outright. PR #90 merged with no Gate, and the newest merged PR at +# the time (#93) had no Gate checks either -- the hold had already swallowed the yardstick, so +# #90 was declared healthy. No "is this reference substantial" guard rescues it: any single PR +# can be holed. +# * The UNION across recent merged PRs. Caught #90 correctly (21 absent) but reported 25-26 +# absences on PRs that were entirely healthy, because the union sweeps in event-driven checks +# -- keepalive rounds, Claude-token detection, label-gated jobs -- which legitimately do not +# run on every PR. A check that cries wolf 25 times gets waived, which would have made this +# tool worse than nothing. +# +# So a check is EXPECTED when it reported on at least `EXPECTED_FRACTION` of the reference PRs. +# That is the property actually wanted: not "has this ever run" but "does this normally run". +# Structural checks (the Gate's jobs) appear on nearly every PR; event-driven ones appear on few. +# No hardcoded list of check names anywhere -- that would be a second copy of the CI topology, and +# paired literals in this repo have an unbroken record of drifting apart. +REFERENCE_PRS = 12 +EXPECTED_FRACTION = 0.75 + +# THE RATCHET, and it exists because dogfooding this tool caught it disarming itself. +# +# Frequency alone erodes. While `pr-00-gate.yml` sat held, every newly merged PR merged WITHOUT the +# Gate -- so after twelve such merges the Gate's checks no longer appeared on 75% of the reference +# window, stopped counting as "normally reporting", and their absence stopped being flagged. The +# expected set fell from 23 names to 14 and PR #91 was pronounced clean by a tool written to catch +# exactly that. A sustained outage is the case that matters most, and it was the one case the +# frequency rule could not see. +# +# `expected-checks.json` is the high-water mark: a name that has ever been expected stays expected +# until somebody DELETES ITS LINE, which is a visible act in a diff. Same shape as the mypy exempt +# ratchet in pyproject.toml -- a ceiling that can only come down deliberately -- and the same +# reason: an automatic downward move is indistinguishable from the defect. +RATCHET = Path(__file__).resolve().parent.parent / "config" / "expected-checks.json" + + +def reference_set(exclude_pr: int | None = None) -> tuple[set[str], list[int]]: + """Check names that report on at least EXPECTED_FRACTION of recent merged PRs.""" + counts: dict[str, int] = {} + contributors: list[int] = [] + for page in _gh_json(f"repos/{REPO}/pulls?state=closed&per_page=40"): + for pr in page: # type: ignore[union-attr] + if not pr.get("merged_at") or pr["number"] == exclude_pr: + continue + if len(contributors) >= REFERENCE_PRS: + break + seen = reported_names(pr["head"]["sha"]) + if not seen: + # A merged PR that reported nothing at all is itself an instance of the defect. + # It must not dilute the denominator, or a run of holed PRs would erode the + # expected set until nothing is expected -- the gate quietly disarming itself. + continue + contributors.append(pr["number"]) + for name in seen: + counts[name] = counts.get(name, 0) + 1 + if not contributors: + raise SystemExit("no merged PR in the last 40 closed PRs reported any check") + observed = expected_from_counts(counts, len(contributors)) + return observed | ratchet_names(), contributors + + +def ratchet_names() -> set[str]: + """Names that have ever been expected. Missing file means "nothing ratcheted yet", not zero.""" + if not RATCHET.is_file(): + return set() + return set(json.loads(RATCHET.read_text(encoding="utf-8")).get("expected", [])) + + +def expected_from_counts(counts: dict[str, int], contributors: int) -> set[str]: + """Which names are EXPECTED, given how often each was seen. Pure, so a test holds the rule. + + The `max(2, ...)` floor matters: with a small sample a fractional threshold can fall to 1, + which would promote every one-off event-driven check into the expected set and bury a real + absence under noise. Two sightings is the least that can distinguish "normally runs" from + "ran once". + """ + threshold = max(2, int(contributors * EXPECTED_FRACTION)) + return {n for n, c in counts.items() if c >= threshold} + + +def check_pr(number: int) -> int: + pr = _gh_json(f"repos/{REPO}/pulls/{number}")[0] + head = pr["head"]["sha"] # type: ignore[index] + here = reported_names(head) + expected, contributors = reference_set(exclude_pr=number) + missing = sorted(expected - here) + print(f"PR #{number} head {head[:8]}: {len(here)} check(s) reported") + print( + f" reference: {len(expected)} check(s) seen on >={int(EXPECTED_FRACTION*100)}% of {len(contributors)} merged PR(s)" + ) + if not missing: + print(" every check that reports on the reference also reported here.") + return 0 + print(f"\n {len(missing)} CHECK(S) NEVER REPORTED on this head:") + for name in missing: + print(f" - {name}") + print( + "\n These are not failures — they are ABSENCES, which `gh pr checks` cannot show you and\n" + " which read exactly like success. Do not merge on the strength of a green list until each\n" + " is explained. A workflow held for review, cancelled, deleted or renamed all land here.\n" + " If an absence is deliberate (a workflow really was removed), say so in the PR and merge;\n" + " the reference set will rotate past it on its own." + ) + return 1 + + +def sweep() -> int: + """FYI for the lane prerun: every open PR with an absent check, and every held run. + + Reports only. It never blocks and never accumulates: the output is recomputed each run from + live state, so there is no queue to drain and nothing to mark as read. + """ + expected, contributors = reference_set() + print( + f" reference: {len(expected)} check(s) seen on >={int(EXPECTED_FRACTION*100)}% of {len(contributors)} merged PR(s)" + ) + findings = 0 + for page in _gh_json(f"repos/{REPO}/pulls?state=open&per_page=50"): + for pr in page: # type: ignore[union-attr] + missing = sorted(expected - reported_names(pr["head"]["sha"])) + if missing: + findings += 1 + print(f" PR #{pr['number']}: {len(missing)} absent — {', '.join(missing[:4])}") + for page in _gh_json(f"repos/{REPO}/actions/runs?per_page=100"): + held = sorted( + { + r["path"] + for r in page.get("workflow_runs", []) # type: ignore[union-attr] + if r.get("conclusion") == "action_required" + } + ) + for path in held: + findings += 1 + print(f" HELD: {path} — a run reached `action_required` and executed no jobs") + break + if not findings: + print(" no absent checks and no held runs.") + return 0 + + +def update_ratchet() -> int: + """Raise the high-water mark. Never lowers it — see RATCHET.""" + observed, contributors = reference_set() + before = ratchet_names() + after = before | observed + RATCHET.parent.mkdir(parents=True, exist_ok=True) + RATCHET.write_text(json.dumps({"expected": sorted(after)}, indent=1) + "\n", encoding="utf-8") + added = sorted(after - before) + print(f"ratchet: {len(before)} -> {len(after)} name(s) over {len(contributors)} merged PR(s)") + for name in added: + print(f" + {name}") + if not added: + print(" (no new names; nothing removed — this command never removes)") + return 0 + + +def main() -> int: + ap = argparse.ArgumentParser(description=__doc__.splitlines()[0]) + g = ap.add_mutually_exclusive_group(required=True) + g.add_argument("--pr", type=int, help="assert every expected check REPORTED on this PR's head") + g.add_argument( + "--update-ratchet", + action="store_true", + help=( + "add currently-observed check names to config/expected-checks.json. RAISES ONLY -- it " + "never removes a name, because an automatic downward move is indistinguishable from " + "the defect this tool exists to find. To drop a name, delete its line by hand." + ), + ) + g.add_argument( + "--sweep", + action="store_true", + help="report absent checks across open PRs and any held runs (FYI, never blocking)", + ) + ap.add_argument("--selftest", action="store_true", help=argparse.SUPPRESS) + args = ap.parse_args() + if args.update_ratchet: + return update_ratchet() + return sweep() if args.sweep else check_pr(args.pr) + + +if __name__ == "__main__": + raise SystemExit(main()) diff --git a/tests/test_checks_reported.py b/tests/test_checks_reported.py new file mode 100644 index 0000000..b3ff857 --- /dev/null +++ b/tests/test_checks_reported.py @@ -0,0 +1,97 @@ +"""An absent check must not read like a passing one — the rule, held as a test. + +Only the PURE part is exercised here. The rest of `check_checks_reported.py` is GitHub API calls, +and a test that mocked them would assert my idea of the API rather than the threshold rule, which +is the part with a decision in it. +""" + +from __future__ import annotations + +import importlib.util +from pathlib import Path + +_SPEC = importlib.util.spec_from_file_location( + "check_checks_reported", + Path(__file__).resolve().parent.parent / "scripts" / "check_checks_reported.py", +) +assert _SPEC and _SPEC.loader +mod = importlib.util.module_from_spec(_SPEC) +_SPEC.loader.exec_module(mod) + + +def test_a_check_that_normally_runs_is_expected(): + """Seen on 12 of 12 merged PRs: structural, so its absence is a finding.""" + assert "python ci / lint-ruff" in mod.expected_from_counts({"python ci / lint-ruff": 12}, 12) + + +def test_an_event_driven_check_is_not_expected(): + """Seen once in 12: a keepalive round or label-gated job. Demanding it would cry wolf. + + This is the case that killed the union design: it reported 25-26 absences on entirely healthy + PRs, and a check that cries wolf 25 times gets waived. + """ + assert mod.expected_from_counts({"Keepalive next task (Claude)": 1}, 12) == set() + + +def test_the_threshold_never_falls_to_one(): + """With a tiny sample the fraction rounds toward 1, which would expect every one-off. + + DELIBERATE BREAK -> REVERT: drop the `max(2, ...)` floor and this fails at 1 sighting of 2, + because int(2 * 0.75) == 1. The floor is load-bearing, not decorative. + """ + assert mod.expected_from_counts({"ran-once": 1}, 2) == set() + assert mod.expected_from_counts({"ran-twice": 2}, 2) == {"ran-twice"} + + +def test_a_holed_pr_cannot_erode_the_expected_set(): + """A merged PR that reported NOTHING must not dilute the denominator. + + Otherwise a run of held PRs erodes the expected set until nothing is expected — the check + quietly disarming itself, which is the defect it exists to catch wearing the other hat. The + caller enforces this by never appending such a PR to `contributors`; asserted here on the + arithmetic it protects. + """ + # 8 real contributors, a check seen on 6 of them: expected (6 >= int(8*0.75) == 6). + assert mod.expected_from_counts({"summary": 6}, 8) == {"summary"} + # Had two holed PRs been counted, the threshold would rise to 7 and the check would vanish + # from the expected set — the erosion this guards against. + assert mod.expected_from_counts({"summary": 6}, 10) == set() + + +def test_the_ratchet_only_raises(tmp_path, monkeypatch): + """A name that has ever been expected stays expected until a human deletes its line. + + THE CASE THIS EXISTS FOR, found by dogfooding rather than by review: while `pr-00-gate.yml` sat + held, every newly merged PR merged WITHOUT the Gate, so after twelve such merges the Gate's + checks no longer appeared on 75% of the reference window and stopped counting as "normally + reporting". The expected set fell 23 -> 14 and PR #91 was pronounced clean by the very tool + written to catch that. A sustained outage is the case that matters most and it was the one the + frequency rule could not see. + + DELIBERATE BREAK -> REVERT: make `reference_set` return `observed` instead of + `observed | ratchet_names()` and this fails — the ratchet is present but unconsulted, which is + this repo's founding defect (built and not wired). + """ + ratchet = tmp_path / "expected-checks.json" + ratchet.write_text('{"expected": ["python ci / lint-ruff", "summary"]}', encoding="utf-8") + monkeypatch.setattr(mod, "RATCHET", ratchet) + assert mod.ratchet_names() == {"python ci / lint-ruff", "summary"} + + # An absent file means "nothing ratcheted yet", never zero-expected: reading a missing ratchet + # as an empty expectation would silently disable the check on a fresh checkout. + monkeypatch.setattr(mod, "RATCHET", tmp_path / "does-not-exist.json") + assert mod.ratchet_names() == set() + + +def test_the_ratchet_is_wired_into_the_expected_set(): + """The union with the ratchet must happen in `reference_set`, not merely be available.""" + src = ( + Path(__file__).resolve().parent.parent / "scripts" / "check_checks_reported.py" + ).read_text(encoding="utf-8") + # Split so the needle cannot match this line, and pinned to the FRAGMENT that carries the + # meaning rather than the whole statement — CLAUDE.md's wiring-pin rule. + needle = "observed | " + "ratchet_names()" + assert needle in src, ( + "reference_set no longer unions the ratchet — the expected set can erode to nothing " + "during a sustained outage, which is exactly when this check matters" + )