fix(ratchet): exempt a ruled ceiling from opportunistic tightening - #1612
Merged
os-steve merged 1 commit intoSep 5, 2026
Merged
Conversation
The gate's opportunistic-tightening advisory offers to re-derive a ceiling from the current reading, which only means something for an ANCHORED ceiling — one derived as `anchor(reading)` in the first place. A RULED ceiling is a maintainer grant no reading derives, so on `business semantics` the advisory printed, on every run, an instruction to hand back the 15,421 tokens of headroom the ruling had just been made to create. An agent following it in good faith would have undone a ruling and no check would have objected, because the resulting ceiling would be a perfectly valid anchored one. The ruled/anchored distinction existed only in the header's prose, where the code could not act on it. Lift it into the code beside each committed ceiling: `COMMITTED` declares the number and the kind, `CEILINGS` and `CEILING_KINDS` derive from that one table, and the advisory asks `isAnchored(label)` at the single place it fires. A ceiling declaring an unrecognised kind is a hard error rather than a default, because neither default is safe — one drops the advisory for a layer that owes it, the other restores this hazard on the next grant. The advisory is unchanged for anchored ceilings. The ruled row prints what it is instead of a nag, so the exemption is visible where a reader meets it. The header's interim prose is updated to describe the mechanism rather than to stand in for it, and the raise guard gains its symmetric half: lowering a ruled ceiling needs a ruling too. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018xtjdpZFjgWh4Ad9Wcx68J
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
os-steve
marked this pull request as ready for review
September 5, 2026 23:59
This was referenced Sep 6, 2026
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.
Fixes #1607
The opportunistic-tightening advisory offers to re-derive a ceiling from the current reading. That only means something for an anchored ceiling — one derived as
anchor(reading)in the first place. A ruled ceiling is a maintainer grant no reading derives, so onbusiness semanticsthe advisory was printing, on every run, an instruction to hand back the 15,421 tokens of headroom the ruling had just been made to create.The finding, first — the distinction was not in the code
RULED_ROWparsing of that prose. At runtimeCEILINGSwas a bareMap<label, number>; nothing the gate executes could tell the two kinds apart. So this card could not simply "key the exemption on the existing distinction" — the distinction had to be lifted into the code first, which is the bulk of this diff.COMMITTEDnow declares each ceiling's number and its kind, andCEILINGS/CEILING_KINDSboth derive from that one table, so a ceiling cannot carry its number in one place and its kind in another that disagrees. The advisory asksisAnchored(label)at the single place it fires. A ceiling declaring an unrecognised kind is a hard error rather than a default, because neither default is safe: one silently drops the advisory for a layer that owes it (a weakened ratchet), the other silently restores this hazard on the next grant.Evidence — three runs of the gate, not three greens
1 — Before (
origin/main@57ce7204, exit 0). Reproduces the card's reading exactly:2 — After (this branch, exit 0). The nag is gone; the ceiling and the headroom are still reported, so the row is exempt, not hidden:
3 — Control: an anchored layer still gets the advisory when it qualifies. Neither anchored layer qualifies naturally today (headroom 2,553 and 3,634), so the condition was constructed:
interaction layerceiling temporarily 40,000 → 50,000. Mutation proved on disk before the run ('ceiling: 40000'occurrences 1 → 0,'ceiling: 50000'now 1), gate exit 0:3b — Control: the key is the KIND, not the label. Same label, same 100,000 ceiling, kind flipped
RULED→ANCHORED. The original advisory returns verbatim,~89,000included — which is what rules out a label hard-code:Both mutations ran under a
trap … EXIT INT TERM, restored withgit checkout HEAD -- <path>, and each restore is proved by blob hash — restoredb5a5fdb981218cd28f8c473a8ef69a6c0299a143on both legs, identical toHEAD:scripts/check-source-token-ratchet.mjs.git statusis clean.What the test suite establishes
test/source-token-ratchet.test.tsgains two cases (22 → 24, all green). They are what judges this change;hygiene:tokensgreen says only that the gate still runs.exempts a RULED ceiling from that nag, and exempts only the ruled kind— spawns the real gate in the sandbox against fixtures tiny enough that every committed ceiling is past the advisory's trigger (asserted first, so "no nag" cannot be a quiet run). Which rows are expected to nag is derived fromCEILING_KINDS, never listed: a case namingbusiness semanticswould pass for the wrong reason. The anchored branch asserts the advisory is unchanged, down to theanchor()figure it names — that branch is the control that stops this card being satisfied by silencing the advisory generally.declares in code the same kinds the header states in prose— the header's ruled/anchored rows must matchCEILING_KINDS. Both ways of disagreeing are silent: a row rewritten as ruled while the constant stays anchored documents an exemption that never fires; the reverse drops the advisory for a layer that owes it.Scope and the guards left standing
src/. Two files plus the changeset;test/**touched only intest/source-token-ratchet.test.ts, additively, no deletions..changeset/ratchet-footer-names-the-stripper-importer.mdalready onmain. This PR is repository tooling — nothing undersrc/changed and nothing ships to HotCRM users. No links in it, solink-checkhas nothing site-absolute to resolve.Gates
pnpm verify(validate · typecheck · lint · lint:i18n-gate · hygiene · hygiene:tokens · build · test) — exit 0, 160 test files, 3394 passed / 1 skipped. Re-run after the final commit: the three suites that import from this gate, 67 passed, exit 0.⛔ Draft on purpose — not marked ready, not enqueued, no auto-merge; the seat lands it.
🤖 Generated with Claude Code
https://claude.ai/code/session_018xtjdpZFjgWh4Ad9Wcx68J
Generated by Claude Code