test(ratchet): wire both hand-calibrated copies to the ceilings that produce them - #1334
Merged
Merged
Conversation
…ceilings `scripts/check-source-token-ratchet.mjs` computes every figure it needs — `CEILINGS`, `BUFFER`, `anchor()` and the readings it prints. Two artefacts restated those figures by hand with nothing comparing the copies to the producer, so each sat in permanent tension with the ratchet it describes: a shrink-only ceiling is meant to be tightened opportunistically, and every legitimate tightening falsified a copy. The test fixtures now import `CEILINGS`, `BUFFER`, `anchor()` and `fmt()` from the gate the suite already runs. The in-buffer case sizes its scope as `ceiling / (1 + BUFFER)` — the reading whose `anchor()` is that ceiling, which is what "inside the buffer" means — and asserts headroom relatively. The over-ceiling case sizes itself from the committed ceiling and reads its over-by figures back off the measurement. Both pin exactly what they pinned before. The docstring's worked table gains the producer-side pin it never had: the rows are parsed out of the script source and asserted per row against the committed constant, `anchor(reading)`, `Math.round(reading * (1 + BUFFER))`, and the headroom and percentage that row derives — plus one row per ceiling in order, and each row's date naming the anchoring run its reading came from. Those assertions are internal to the row and the constant: a row's headroom is the headroom at anchor time, so comparing it against a live run would be wrong by design and the pin does not do it. `BUFFER` and `fmt` are newly exported; no value moved and no ceiling changed. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016ED4cusQ7pxZ7d7TCLKrZb
The reverse verification for the previous commit caught this: with the ceiling moved to 39,000 in a sandbox, `Math.round(ceiling / (1 + BUFFER))` gives 37,143, whose `reading × 1.05` is 39,000.15 — over the ceiling, so `anchor()` rounds it past the next 1k boundary and returns 40,000. The fixture was then NOT the reading that ceiling was anchored from, which is the one thing the case is about. `Math.floor` is exact at every ceiling: the product lands at or just under the ceiling and `anchor()` returns it. The two agree at the committed 40,000 (both 38,095) and disagree at 39,000 and 41,000, so today's suite is green either way and only a re-anchoring would have exposed it — precisely the failure mode this card exists to close, one level up. The card suggested `Math.round`; the dispatch marked the formula a suggestion and asked for what actually reproduces the case's intent. This is that. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016ED4cusQ7pxZ7d7TCLKrZb
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
os-trump
marked this pull request as ready for review
August 26, 2026 08:06
This was referenced Aug 26, 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 #1321
scripts/check-source-token-ratchet.mjscomputes every figure it needs —CEILINGS,BUFFER,anchor(), and the readings it prints. Two artefactsrestated those figures by hand with nothing comparing the copies to the
producer, so each sat in permanent tension with the ratchet it describes: a
shrink-only ceiling is meant to be tightened opportunistically, and every
legitimate tightening falsified a copy. Both copies now read the producer.
Half 1 — the fixtures are sized from the committed ceilings
test/source-token-ratchet.test.tsimportsCEILINGS,BUFFER,anchor()and
fmt()from the gate it already runs in a sandbox.The in-buffer case sizes its scope as
Math.floor(ceiling / (1 + BUFFER))—the largest reading whose
anchor()is that ceiling, which is what "insidethe buffer" means — fills to exactly that many tokens by subtracting what the
layer already holds and the wrapper the stripper keeps, and asserts headroom
relatively as
ceiling - readingin the gate's own formatting. What thecase pins is unchanged and now stated as the property itself: under the
ceiling, and clear of the advisory's
2 × BUFFERtrigger.Floor, not round. The card suggested
Math.round; the dispatch marked theformula a suggestion and asked for what actually reproduces the case's intent.
Math.rounddoes not. Rounding up makesreading × (1 + BUFFER)exceed theceiling,
anchor()then carries it past the next 1k boundary and returnsceiling + 1000, so the fixture is not the reading that ceiling was anchoredfrom:
The two agree at the committed 40,000, so the suite is green either way today
and only a re-anchoring exposes it — the same failure mode this card closes,
one level up. Caught by the reverse verification below, in
027bd73.Half 2 — the docstring's worked table gets the pin it never had
A new
describeparses the three rows out of the script source and asserts,per row:
anchor(reading)1 + BUFFER)Math.round(reading × (1 + BUFFER))ceiling - readingand the percentage is its one-decimal formEvery assertion is internal to the row plus the committed constant. A row's
headroomis the headroom at anchor time — since #1320 the three rows donot even come from one run, which is why the date column exists — so comparing
it against what the gate prints today would be wrong by design, and the pin
does not do it. (Live interaction reading today is 37,428; the row's is 37,424,
from the 2026-08-26 run. The pin is indifferent to that gap, correctly.)
Reverse verification — the acceptance criterion
Every mutation proved on disk by blob hash before any verdict was read
(anchor hit count 1, removed-text count 0, injected-text count 1, blob differs
from the
HEADblob); every restore viagit checkout HEAD -- PATHand provedby an empty
git diff HEADplus a disk blob equal to theHEADblob. No legmatched zero times, so no reading here is void.
Mutation A — move a ceiling constant (
interaction layer40000 to 39000,blob
ddf39cctoac26097):a76b69f(control, same mutated tree)The control leg is the card's thesis, reproduced on demand: the old literal
stays pinned at 38,095 tokens while the ceiling moves beneath it. The wired
fixture re-derived itself to 37,142 and stayed quiet and clean.
Mutation B — falsify one docstring row, three separate legs, each naming
its own row:
Gates
pnpm verifygreen on the final commit027bd73:The ratchet suite itself goes 15 tests to 19.
Two changes outside the dispatched file surface, declared
1.
tsconfig.jsongainsallowJs: true(commented in place).tscresolves the relative
.mjseither way, but without it there are no types forthe module and
strictturns that intoTS7016at the import site — measured,not assumed. Inferring the types from the producer is the point: the
alternative, a hand-written
.d.mtsbeside the script, is one morehand-maintained copy of exactly the kind this card deletes.
checkJsstaysoff, and no
.js/.mjsfile lives undersrc/ore2e/for the includeglobs to newly sweep in.
2. A third hand-calibrated ceiling copy in the same file, folded in. Scan
that found it, on
a76b69f:The over-ceiling case restated
CEILINGS.get('business semantics')as a literaland quoted two absolute figures derived from it — the identical defect, in the
same case block, and it goes red on the next re-anchoring of business semantics
for exactly the same reason. It now sizes itself from the committed ceiling and
reads its over-by figures back off the measurement, and gains an assertion on
the
over by ~Nfigure it previously ignored. Nothing it pinned was weakened.Not done, deliberately
No ceiling value moved — not
40000, not85000, not140000.BUFFERisuntouched at
0.05; it is only newly exported, along withfmt.scripts/check-source-hygiene.mjsis not touched. No existing assertion wasweakened, skipped or deleted.
src/metadata is unchanged, so the app bundleis byte-identical and the ratchet's own readings do not move.
Sibling read-coupling with #1325 checked and irrelevant by construction: it
moves the interaction layer's live reading; everything here derives from the
constant, which is why Mutation A had to move the constant to have any
effect at all.
Generated by Claude Code
Generated by Claude Code