Skip to content

fix(gate): count the caps with one tokenizer - #1748

Merged
Lorenzobattistela merged 1 commit into
bendlang:mainfrom
adeerkhan:fix/gate-ttok-model
Oct 19, 2026
Merged

Lorenzobattistela merged 1 commit into
bendlang:mainfrom
adeerkhan:fix/gate-ttok-model

Conversation

@adeerkhan

Copy link
Copy Markdown
Contributor

The gate measured the permanent caps with whatever tokenizer the installed ttok defaults to. ttok changed that default in 1.0 — gpt-5 (o200k_base) there, gpt-3.5-turbo (cl100k_base) in 0.3, which the CI workflow pins — and on Lean the second counts 4.5% less. The same tree then gets two verdicts:

ttok 0.3 (CI's pin) ttok 1.0
before this PR PASS: 54 / 54 FAIL bend2/bendtt.lean: 64885 > 64000 ttok
after this PR PASS: 54 / 54 PASS: 54 / 54

bend2/bendtt.lean is 62,092 tokens under cl100k_base and 64,885 under o200k_base, against a cap of 64,000. It is over by 885 tokens under one tokenizer and not at all under the other.

Why this matters. The caps are permanent, and the only sanctioned response to a file over its cap is to make it smaller: "A file over its cap is made smaller by simplification, never by moving code out." A contributor who installs the current ttok — which the gate's own error message tells them to do — runs the gate locally, sees bend2/bendtt.lean over the cap, and deletes Lean proofs from the machine-checked kernel to satisfy a budget that was never exceeded. Nothing but the CI workflow pinned the tokenizer, so a local verdict and the CI verdict could disagree.

The fix names the model rather than the tool version, so the count the caps mean is the same on every machine and under every ttok, present or future. The CI pin stays valid: 0.3 takes -m gpt-3.5-turbo, which is its own default. The existing error path already covers an unsupported model, so there is nothing else to add.

Check — 0.3 and 1.0 now agree exactly on all seven capped files:

file cap tokens
bend2/bend.ts 48000 43767
bend2/comp.ts 66000 65625
bend2/main.ts 16000 11625
bend2/safe.ts 24000 23992
bend2/bendtt.lean 64000 62092
README.md 4000 3071
guide/GUIDE.md 8000 7998

Gates on main: repo 54/54.

Not part of this PR, but worth a decision: guide/GUIDE.md is at 7,998 of 8,000 and bend2/safe.ts at 23,992 of 24,000, so the next edit to either turns the gate red, and the only sanctioned response is to delete from them. The core library bend2/base.bend is uncapped, which is the shape of answer the caps already have for a file that grows.

The gate measured the permanent caps with whatever tokenizer the installed
ttok defaults to, and ttok changed that default in 1.0: gpt-5 (o200k_base)
there, gpt-3.5-turbo (cl100k_base) in 0.3, which CI pins. On Lean the second
counts 4.5% less, so the same tree passes the caps under one and fails under
the other: 62,092 vs 64,885 on bend2/bendtt.lean, over the 64,000 cap.

The fix names the model, so the count the caps mean is the same on every
machine and under every ttok, and the CI pin stays valid: 0.3 and 1.0 now
agree on all seven capped files.
@Lorenzobattistela
Lorenzobattistela merged commit 979bc5c into bendlang:main Oct 19, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants