Skip to content

fix(scripts): the skills token ratchet reds a row whose ceiling sits above its measurement - #37747

Merged
objectstack-fleet[bot] merged 9 commits into
mainfrom
claude/area-o1C-37630
Nov 27, 2026
Merged

objectstack-fleet[bot] merged 9 commits into
mainfrom
claude/area-o1C-37630

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Requested by Elon · project thread

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 feat(core): requires knowledge mounts the knowledge service and one vector store #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

Self-test, gate, ablation and reverse reading (head d1295a6)
  • 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.

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

Local gates (head d1295a6)
  • 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.

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.ai/code/session_016WV4cwPhGV4g9p1BGQaZbP

A row a later shrink left standing above its file used to pass and print
its headroom, so the freed tokens sat in the row as budget a later raise
could spend with no deletion shown. The per-row check now reds it, naming
the row, the measurement, the ceiling and the gap, and tells the author to
lower the row to the measurement. The over-ceiling refusal is unchanged.

The 37 rows that sat above their measurement on main are lowered to it,
4813 tokens in all; no skills text moves.

Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016WV4cwPhGV4g9p1BGQaZbP
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#1 · os-elon-musk · session_016WV4czzx9dtSEm3jWWL9c3

L1 verdict (L1-a): ACCEPT at head d1295a6cd5b3e5030421c0e0015d756f14994a12 (Fixes #37630). Full read · 2026-11-27T01:51Z

席位核对

Shape and gates. l1-face --pr 37747: clean. Check-runs at d1295a6: 26 success, 23 expected skip, 0 failed, 0 pending; mergeable_state clean. Draft, base main, first line after the attribution lines Fixes #37630. 2 files, +103/-50. Not governed (scripts/check-skills-token-ratchet.mjs and its test, no workflow, skill, ADR or .claude path). Clause-②: no · Metadata-protocol: none.

Fixes is right. The card asks that a ceiling sitting above its measurement fail the ratchet, naming the row, the measurement and the ceiling. verdict() now fails such a row and its message names all three. The 37 of 61 CEILINGS rows that sat above their measurement are lowered to it (4,813 tokens of slack removed), so the gate is green on its own data. The new behaviour is pinned in the test file, and the ablation (the slack check disabled) turns 9 cases red.

Re-measured against today's main. I merged the head onto origin/main in a scratch worktree and ran the ratchet there: green, ratcheted (authored) 199660 / 199660 (+0). So no skill that landed since the branch point is over or under its new ceiling.

Failure mode, judged. This makes an existing gate stricter. Its cost is that a PR which shrinks a skill must also lower that skill's ceiling in the same PR, which serialises edits to the ceilings table. That is the purpose of a ratchet, and it is the not-escalate class (a gate tightened, nothing refused that an author could write before). The overlap with #36158 was ruled by the seat (7207185962) and this PR follows that ruling.

Changeset. None, and none is owed: both files belong to the private root package, nothing published moves. The skip-changeset label is on, with both premises (root-only, no shipped file) true.

Contract review. None owed. No packages/spec/src/**, no governed path, no Clause-②: yes, no narrowing.

Out of scope. Nothing filed.

Landing: not governed, ≤3000 lines, no narrowing. The area lands it. Fixes closes the card.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#1 · os-elon-musk · session_016WV4cwPhGV4g9p1BGQaZbP

Landing · area o1-C · head d1295a6cd5 · 2026-11-27T01:52Z · ACCEPT → PR #37747 comment 7207645559 (L1-a)

Probe Reading
check-runs at d1295a6cd5 26 success · 23 expected skip · 0 failed · 0 pending · mergeable_state clean
check-governed-merges.mjs --pr 37747 NOT governed · +103 / −50
landing-k.mjs --pr 37747 K = 9 < 15 · no shared book moved under this PR's

State: ready + auto-merge; #37630 closes on merge via Fixes.

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review November 27, 2026 01:53
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 27, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 27, 2026
…rement after the main merge

The automation skill's state-machines reference shrank 9 tokens on main
with its row left standing, which the new above-measurement red caught in
the merge queue. The row follows the measurement down to 5927.

Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016WV4cwPhGV4g9p1BGQaZbP
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#1 · os-elon-musk · session_016WV4czzx9dtSEm3jWWL9c3

L1 verdict (L1-a): REWORK (mechanical, one row) at head 00112a68423857659496972ff5dab8603d070f23 (Fixes #37630). Delta read from ACCEPT 7207645559 at d1295a6cd5 · 2026-11-27T02:34Z

The delta itself holds. adaa6a8825 is a pure merge: its tree equals git merge-tree of d1295a6cd5 and 077831538 (no hand edit). 00112a6842 lowers one row, state-machines-and-approvals.md 5936 → 5927, with its note. That is the measurement after #37726. Checks on this head: 25 success, 19 expected skip, 0 failed; Type Check · source gates success.

But main has moved again, and the queue will red the same way. #37739 landed at 6f5c1cfa and changed skills/objectstack-ai/references/context-packs.md. I merged this head onto current origin/main in a scratch worktree and ran node scripts/check-skills-token-ratchet.mjs: red, "skills/objectstack-ai/references/context-packs.md is 1453 tokens; its ratchet ceiling is 1454, above the measurement by 1". This is the gate this PR adds, working as designed.

Owed. Merge origin/main (at or after 6f5c1cfa) and lower that one row, 1454 → 1453, in the same form as 00112a6842. Then re-run the ratchet on the merged head, and send the head for a delta read. That read covers the merge's tree and the row change only.

For the area. Every skills PR that lands first can force this step again, as you noted. Once the next head is green, enqueue it promptly, so the window for another shrink to slip in stays short.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#1 · os-elon-musk · session_016WV4czzx9dtSEm3jWWL9c3

L1 verdict (L1-a): REWORK (mechanical, one row) at head e53ab63eec0fd4b83d46543a108269066658a5cd (Fixes #37630). Delta read from REWORK 7208250389 at 00112a6842 · 2026-11-27T02:56Z

The delta itself holds. d2e31ded9a and e53ab63eec are both pure merges: each tree equals git merge-tree of its two parents. a998be3d0e lowers context-packs.md 1454 → 1453 with its note, which is what 7208250389 asked. The other row changes in the script since 00112a6842 (objectstack-data/rules/security.md 4340, objectstack-ui/rules/actions.md 3890, with their notes) are main's own bytes from #37762, brought in by the merge. Checks on this head: 25 success, 19 expected skip, 0 failed.

Main moved once more, the other way. #37765 landed at 9862d636 and grew skills/objectstack-ai/SKILL.md by 2 tokens, to 6801. On main that is within main's ceiling of 6801. This PR lowered that row to 6799 earlier, and the merge keeps the PR's 6799. I merged this head onto 9862d636 in a scratch worktree (it merges clean) and ran the ratchet: red, "skills/objectstack-ai/SKILL.md is 6801 tokens; the ratchet ceiling is 6799 (over by 2)", total 199710 / 199708 (+2).

Owed. Merge origin/main (at or after 9862d636) and set that row to the merged tree's measurement, 6799 → 6801, with a note naming #37765. Then run the ratchet on that head merged with the newest main just before you send it.

To stop the chase. This PR pins 37 rows, so any skills PR that lands first can move one of them. Once the next head is green against the current main, it should go to the front of the merge queue. I am asking the seat to do that (the seat does the queue jump). My delta read of the next head covers only its merge trees and the row values against the ratchet.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#1 · os-elon-musk · session_016WV4czzx9dtSEm3jWWL9c3

L1 verdict (L1-a): ACCEPT (delta) at head e9f74d656961e3a6d09a54f44a62fb35398d6f4a (Fixes #37630). Delta read from REWORK 7208574157 at e53ab63eec · 2026-11-27T03:21Z

What moved. 57e51b48 is a pure merge of 9862d636 (its tree equals git merge-tree of its parents). e9f74d65 sets the skills/objectstack-ai/SKILL.md row to 6801, which is byte-identical to main's row, so this PR no longer changes that line. The #37765 note sits in the re-lock comment.

The gate against today's main. Main is 00cb37b0e7, with no commit touching skills/ or the ratchet script since 9862d636. I merged this head onto it in a scratch worktree and ran node scripts/check-skills-token-ratchet.mjs: green, ratcheted (authored) 199710 / 199710 (+0). Checks on this head: 25 success, 19 expected skip, 0 failed; mergeable_state clean.

The full read in 7207645559 stands. The rest of the net diff is unchanged in kind: verdict() and its pins, and rows pinned at their measurements.

Landing: not governed, ≤3000 lines, no narrowing. The area lands it now. If a skills PR lands before it is enqueued, merge main once more and re-run the ratchet on the merged tree first. Fixes closes the card.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#1 · os-elon-musk · session_016WV4cwPhGV4g9p1BGQaZbP

Re-landing · area o1-C · head e9f74d6569 · 2026-11-27T03:22Z · ACCEPT → PR #37747 comment 7208927706 (L1-a delta; full read 7207645559). Dequeued earlier by the gate's own red after main moved (#37726, #37739, #37765); each fixed by a main merge and the affected row.

Probe Reading
check-runs at e9f74d6569 25 success · 19 expected skip · 0 failed · 0 pending
main since 9862d6369a no commit touching skills/ or the ratchet script
check-governed-merges.mjs --pr 37747 NOT governed · +111 / −51
landing-k.mjs --pr 37747 K = 5 < 15

State: auto-merge re-armed; #37630 closes on merge via Fixes.

@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 27, 2026
Merged via the queue into main with commit cac93cc Nov 27, 2026
44 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/area-o1C-37630 branch November 27, 2026 04:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/m skip-changeset PR has no user-facing published change; bypasses the changeset gate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

check-skills-token-ratchet: say when a ceiling sits above the measured tokens (a raise outlived by a later shrink)

2 participants