Repository navigation
The repo gate stops when ttok counts nothing, instead of passing every file - #1283
Conversation
…y file ttok() read ttok's stdout as a number, so a ttok that printed nothing read as 0 tokens and every capped file passed; a missing ttok threw on a null stdout only by accident. Main has been over comp.ts's 64000 cap since bendlang#1269 (64250 at fb6f32a, 64251 now) with the gate reporting 49/49 on a machine whose ttok printed nothing. A ttok that is missing, exits nonzero or prints no positive count now stops the gate with its file and how to install ttok. With a working ttok, main gives 48/49 (bend2/comp.ts: 64251 > 64000); with a ttok that prints nothing, exits 3, or is not on the PATH, the gate exits 1 naming the first capped file it could not count.
|
This closes the fail-open hole, but the overshoot itself came from #1269 being checked against a stale base. Today the gate runs on whatever branch the author has locally, and nothing reruns it on what main becomes after the merge: #1269 passed at 63,821 on its branch, five other merges had added 429 tokens to main in the meantime, and the squash-merge landed at 64,250 with no check in between. The fix is to check each PR combined with current main right before it lands, not just its own branch. GitHub can do that if the gate runs there instead of on someone's machine. The repo gate only needs git, bun and ttok, so unlike the test and perf gates (which need Metal and the minis) it can run on GitHub's own Linux machines. It takes two pieces:
# .github/workflows/repo-gate.yml
name: repo-gate
on:
pull_request:
merge_group:
jobs:
repo-gate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v2
- run: pipx install ttok
- run: bun gates/repo.ts
With the queue on, nobody merges directly. "Merge when ready" puts the PR in the queue, GitHub builds a temporary branch of current main plus every PR queued ahead plus this one, and runs the check on that. If it passes, the PR merges; if not, it's dropped from the queue and main is untouched. For #1269 that branch would have been main with the five newer merges plus #1269, at 64,250 tokens, so it would have failed instead of landing. The simpler setting is "Require branches to be up to date before merging" instead of the queue: a PR that's behind main has to be updated and rechecked before it can merge. That gives the same guarantee, but with 10+ merges a day everyone keeps rebasing and waiting on reruns, which the queue does for them. Bend had exactly this kind of setup (a checks workflow with a |
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
|
I will set up the workflow for us running on the cluster, probably tomorrow. This way non-mergeable PRs wont even be able to merge as you suggested. The rhythm is very fast. Thanks for pointing and for the PRs @wakamex |
gates/repo.tsreadsttok's stdout withNumber(...), so attokthat prints nothing counts as 0 tokens and every capped file passes. That's how main went over thecomp.tscap without anyone seeing it: #1269 measured 63,821 on its branch, but five merges had grown main by 429 tokens in the meantime, and the squash-merge putcomp.tsat 64,250. It's 64,251 today, and the gate still reported 49/49 on main.ttokon the machine runninggates/repo.tspipx install ttok)bend2/comp.ts: 64251 > 64000 ttokttok counted nothing for README.md (pipx install ttok), exit 1Token counts are
ttokoverbend2/comp.tsat each merge commit; it gives 64,172 at d7af6bf, the figure recorded there.The change only touches
ttok(): it throws whenttokis missing, exits nonzero, or prints anything but a positive count. Caps and the allow list are untouched.Heads-up: once this lands, the repo gate fails on main until
comp.tsloses about 250 tokens, so that's the next thing.