Repository navigation
CI: a ledger or allowlist count that rises above the base branch's fails the PR - #1135
Merged
Merged
Conversation
The allowlists and ledgers under ci/allow/ are meant to only shrink, but every check on them compared a number with another number in the SAME tree: check-deps.sh tested a file's `# count:` header against its lines, and tests/test_harness.py tested the headers against PINNED_LEDGER_TOTALS / PINNED_ALLOWLIST_COUNTS with assertLessEqual. One diff could add an entry, raise the header and raise the pin, and stay green. ci/check-ledger-ratchet.py compares with the base instead. It counts real entry lines (check-deps.sh's own rule: not blank, not a comment; the header is never read), one total per family directory (workers/, globals/, forks/, fxlanes/, so an entry may move between a family's area files) and one per top-level ci/allow/*.txt, and it reads both pin tables of tests/test_harness.py with ast. A file, family or pin key that is new counts up from 0. Any count above the base's fails, naming `name: base -> head`; a lower or equal count passes, so a one-for-one rename such as #1116's still lands. The base is PLX_LEDGER_BASE (the tests' override), else the merge-base of HEAD and origin/$GITHUB_BASE_REF (an error, not a skip, when that ref is missing), else of HEAD and origin/main, else the check skips and says so. The head is the working tree; the base is read with git ls-tree and git show. ci.yml's host-python job, which runs the step, already checks out with fetch-depth: 0, and the new test pins that. An exception is the owner's call, made by merging past the check; the message tells an agent to stop and explain in the PR instead. ci/test_ledger_ratchet.py runs the script against fixture repositories: a family count rising, falling, a same-count rename, an entry moving inside a family, a new file, a header bumped over unchanged entries, header and pin raised with a new entry, a pin rising, falling and new, and no base; plus the base resolution (merge-base, not the tip of main) and the real pin tables. Replayed over the last 120 first-parent commits of main it flags only #971, the commit that created the ledgers. AGENTS.md, docs/sans-io.md and docs/sans-io-guide.md say so, and the sentence in docs/sans-io.md that presented the pins as the guard against a ledger and its count growing together now names the ratchet. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
… that fits every list A review of the ratchet found three faults. A counter the base does not have was counted up from 0. A top-level ci/allow/*.txt file, a family directory or a pin key that is new is a NEW gate's own list, not an exception added to an existing rule: no existing gate reads a file name that did not exist (check-deps.sh's allowed() keys by file name, its ledger engine globs the four families by name, and the Python gates read fixed paths), so a new list cannot excuse a site of an existing rule, and failing it would fail every PR that adds a gate. Such counters are now skipped and named in the ok line (`; new, not compared: ci/allow/foo.txt (3)`). A new AREA file inside a family the base has still counts toward that family's total, a list that exists at the base with zero entries still fails on its first entry, and a pin table the base has and the head lost is still exit 2. The failure message told every list to "move the work behind an effect", which is wrong for wall.txt, statics.txt, dump.txt and the like. It now says to remove the entry by fixing the site so the rule passes (for a Sans-IO ledger, move the work behind an effect, docs/sans-io-guide.md "The ledgers"), and keeps the owner-exception and agent-stops sentences. Prose that described growth as the routine path now says the ratchet fails a PR that grows the list, so a new entry is the owner's call: the lead-in comments above PINNED_ALLOWLIST_COUNTS and PINNED_LEDGER_TOTALS and the assertion message of test_allowlist_counts_match_the_pinned_table (which said to raise the pin), docs/module-layers.md items 5 and the split paragraph, check-dump-consumers.py, ci/allow/dump.txt's header comment (its `# count:` is unchanged), gfx/src/dump.rs, and check-statics.sh with its failure message. The module docstring and the check-python-steps.txt comment no longer say a new file counts from 0. ci/test_ledger_ratchet.py: a new top-level file, a new family directory and a new pin key now pass and are named; a new area file in an existing family that raises its total, an entry added to a list that was empty, and a raised count that arrives with a new list all still fail. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The allowlists and Sans-IO ledgers under
ci/allow/are meant to only shrink, but every existing guard compared numbers inside the same tree. A PR could add an entry, bump the file's# count:header and raise its pin intests/test_harness.pyin one diff, and every check stayed green. This PR adds the comparison with the base branch.ci/check-ledger-ratchet.py(a new step inci/check-python-steps.txt, so it runs inmake checkand in CI'shost-pythonjob):origin/$GITHUB_BASE_REFon a pull request, else withorigin/main.PLX_LEDGER_BASE=<rev>overrides. With no base at all it prints one skip line. AGITHUB_BASE_REFwhose branch is missing is an error (exit 2), not a skip, so the check cannot skip on the runs it exists for.host-pythonchecks out withfetch-depth: 0(.github/workflows/ci.yml:415), and a test asserts it.#), never the# count:header. Each family directory (ci/allow/{workers,globals,forks,fxlanes}/) is one total, so an entry may move between area files. Each top-levelci/allow/*.txtcounts on its own. Both pin tables,PINNED_LEDGER_TOTALSandPINNED_ALLOWLIST_COUNTS, are read withast, never imported. A table that vanishes or stops being a literal is exit 2.name: base → head. A lower or equal count passes, so a one-for-one rename (like Playback: a new play never blocks the UI on the previous player's Unload; a hung Unload fails typed after 10 s #1116'smod.rs::sink→mod.rs::raw_sink) passes.What it would have caught. The review replayed the 164 first-parent commits on main since 2026-09-07 that touched
ci/allowor the harness. Six were new gates seeding their own list from zero, and they pass under the new-list rule. Four were single entries added to an existing list: #121 (statics.txt7 → 9), #178 (statics.txt9 → 10), #182 (wall.txt2 → 3) and #260 (libm.txt5 → 6). Those are what this check now stops unless the owner merges past it. Run against #1134's own base, it fails on #1134's one-time coverage expansion, as it should:Prose that described growth as the routine path now says the ratchet fails it:
test_allowlist_counts_match_the_pinned_tableassertion message, which told an agent to "raise the number in PINNED_ALLOWLIST_COUNTS in the same change";docs/module-layers.md's re-layering steps;ci/check-dump-consumers.py,ci/allow/dump.txtandgfx/src/dump.rs;ci/check-statics.shand its failure message.AGENTS.md,
docs/sans-io.mdanddocs/sans-io-guide.mdeach gain the one fact.Tests:
ci/test_ledger_ratchet.pybuilds fixture repositories. It covers a rise, a fall, a rename, a move inside a family, a move across families, a header bump, pin rises and falls, new lists, a new area file in an existing family, base resolution (override,GITHUB_BASE_REF,origin/main, merge-base rather than the tip) and the exit-2 paths. It also checks the real tree: the entry counts agree with every headercheck-deps.shenforces, and the CI job has full history.On the committed tree, merged with main decb0aa:
Not covered:
ci/module-cycle-baseline.jsonandtests/demo_library/pending.json, which are shrink-only through their own checks. No workflow file changes, so nomake build-benchtable.No issue: the owner asked for this enforcement directly.
🤖 Generated with Claude Code