Skip to content

Commit cac93cc

Browse files
fix(scripts): the skills token ratchet reds a row whose ceiling sits above its measurement (#37747)
<!-- claude-projects-attribution: {"github_login":"os-elon-musk"} --> _Requested by **Elon** · [project thread](https://claude.ai/code/project/chan_01WedDzV26nniwxv7jC88B9D?thread=cmsg_01WedDzV26nniwxv7jC88B9DG44bgtJm8kWx4oK68re6GX)_ Fixes #37630 Clause-②: no Metadata-protocol: none ## 维护者速读 - 用户无感:这是仓库内部的技能长度检查,发布给客户的技能文字一个字都没改。 - 为什么做:属于技能长度管控。以前文件变短后上限还停在原处,多出来的额度没人发现,后来的改动可以悄悄用掉;现在会直接报错,并给出该降到的数字。 - 出错会怎样:最坏是技能相关的 PR 被误拦,作者照提示把上限降到实测值即可;整个改动可直接撤回。 - 要你做的:无。 ## What changes `scripts/check-skills-token-ratchet.mjs` used to fail a row only when the measured tokens were over its ceiling. A row whose file later shrank passed and printed its headroom. On PR #37442 that left a row 1 token above the merged measurement, and only the reviewer's arithmetic caught it. - **The per-row check** (`verdict()`) now fails a row whose ceiling is above its measurement. The message names the row, the measurement, the ceiling and the gap, and tells the author to lower the row to the measurement in the same PR. Lowering is the author's own act, so this message carries no `⛔ MAINTAINER-ONLY` token. The over-ceiling refusal is byte-for-byte unchanged. - **The header's shrink-only bullet** now says the PR that shrinks a file lowers its row to the new measurement in that PR. A row left above its measurement is red. - **37 CEILINGS rows are lowered to their measurement.** On `origin/main` ce4d8c7, 37 of the 61 authored rows sat above their measurement, 4813 tokens in all. The largest gaps were `objectstack-api/SKILL.md` (981), `objectstack-query/SKILL.md` (940) and `objectstack-data/rules/indexing.md` (746). Each row's number changes and gains a `-N to the measurement (was C)` note, and one block comment sits on the prose side of the CEILINGS doc comment (the placement note says to keep new prose there). No `skills/**` text changes and no ceiling is raised. ### Failure or warning **I chose failure.** Reasons: 1. With the 37 stale rows lowered, every row on main sits at its measurement, so a failure reds nothing that exists today. 2. A warning would be one more line in a log of 100-plus lines. A log line is how the 1-token gap on PR #37442 got through. The card's failure mode is a reading nobody looks at, and a warning is still a reading nobody looks at. 3. The header already has the gate's rule: every path that moves a row pins it AT the measurement. Headroom left by a shrink is not budget. Failing on it makes that rule hold mechanically, just as failing over the ceiling does. 4. No header-documented reservation exists today. The header's one reservation is `pending10402` (headroom held for an approved PR), and its own record says it is spent ("`objectstack-data` measured 13817 against a 13817 ceiling … exactly zero"). So nothing needs an exemption. A future reservation of that kind would need this gate changed, and the header now says so. **How unchanged rows on main are treated:** they are lowered in this PR, not given a warning tier. Lowering is always legitimate under the header. Header lines that bound this change, quoted for the skills-lane reviewer: - Record 6139629628 item 2 (the A2′ stamp exclusion), as the header quotes it: "counts authored content only: the frontmatter `version:` line that the release bot rewrites is excluded from the count … ceilings stay shrink-only and the current headroom (0 and 1 tokens) stays as it is." I read this as bounding the A2′ re-pin, which lowered every stamped row by exactly 5 so that no file's headroom moved. I do not read it as protecting headroom against a later lowering. - The `strippedInternalIds` note in `CEILING_BASIS`: "That is the ratchet working as designed: shrink-only means a ceiling may be lowered to the measurement whenever one is taken, not merely by the size of the day's deletion." This is the authority for lowering all 37 rows in one PR. - The raise paths, all pinned at the measurement: ruling record 6513306068 ("may move the row by the measured remainder, pinned AT the measurement"), and ruling A on record 6819475461, made standing by record 6840575378 ("may raise that file's row by the row's own measured delta and by no more"). **Side effect for the reviewer:** in failure mode every count change to a skills file must edit its row. So two skills PRs that change one file's count now always conflict on that row; before, only raises did. This is the intended serialisation, because the merged measurement differs from both branches. It is still new load on skills PRs. **Overlap:** open draft PR #36158 rewrites five of the lowered rows: `objectstack-data` `SKILL.md`, `rules/field-types.md` (together with the adjacent `rules/indexing.md`), `rules/relationships.md`, `rules/validation.md` and `references/examples-objects.md`. That PR already conflicts with main on its own skills files and re-measures those rows when it rebases. overlap-check: origin/main, #37676 and #37422 merge cleanly. ## Tests <details><summary>Self-test, gate, ablation and reverse reading (head d1295a6)</summary> - `node scripts/check-skills-token-ratchet.mjs --self-test`: exit 0, `✓ check-skills-token-ratchet self-test: 111 cases pass.` The roster grew 104 to 111, and the floor was raised to match. `under the ceiling -> green` became `under the ceiling -> red (a ceiling above its measurement)`, and the shrink-direction row now pins red-until-lowered. Seven new batteries: the red names the row, the measured count, the ceiling and the gap; it tells the author to lower the row; it is not the over-ceiling red (no `over by`, no authority token); one token above the measurement is red. Each new case reads the verdict and its text together. - `node scripts/check-skills-token-ratchet.mjs`: exit 0, `61 authored bundle file(s) within their ceilings`, and `ratcheted (authored) 199660 / 199660 (+0)`. On main it read `199660 / 204473 (-4813)`. - Ablation (`scripts/ablation-replace.mjs`, the new branch's `if` disabled, anchor x1 to x0): self-test exit 1, `9 failure(s)`, which is exactly the nine above-measurement batteries. After restore the blob matched HEAD and `git diff HEAD` was empty. - Reverse reading: main's CEILINGS judged by the new verdict, 37 of 61 rows red, gap 4813. </details> ## Acceptance notes - The card's acceptance asks the gate to report a row whose ceiling exceeds its measured tokens, naming the row, the measurement and the ceiling. It does that, as a failure; the choice is argued above for the reviewer. A test pins the new reading. The existing over-ceiling refusals are unchanged. - `skip-changeset`: the only file changed is a root `scripts/` gate in the private monorepo root package, so nothing ships. ## Verification <details><summary>Local gates (head d1295a6)</summary> - All 34 commands from `node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack` exited 0. Each exit code was captured before any pipe. They include `check-skills-token-ratchet` with its `--self-test`, `check:ratchet-remedy-authority`, `check:doc-authoring` and `check:nul-bytes`. - `--ran` reconciliation: `34 derived, 34 run, 0 NOT-MEASURED, 0 UNRUN`. - `check:pm-dispatch-gates` exited 0 on the previous head, ebc8fae. The last commit touches only ratchet self-test lines. - `check-published-list-mirrors` exited 0. - The control-byte self-scan found 0. </details> **Read first:** `verdict()`, the new below-ceiling branch (the one behaviour change). Then the header's "ratchet discipline" bullet. Then a sample of the lowered rows against the gate's printed counts. **Two-minute check:** run `node scripts/check-skills-token-ratchet.mjs`. Expect exit 0 and the line `ratcheted (authored) 199660 / 199660 (+0)`. Then raise any row by 1 locally and re-run. Expect a red that names that row, its measurement and the ceiling, ending in `Lower the row to N`. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_016WV4cwPhGV4g9p1BGQaZbP --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent f4d6bc5 commit cac93cc

1 file changed

Lines changed: 111 additions & 51 deletions

File tree

0 commit comments

Comments
 (0)