From 653ee4189392da29ed371724c81cd59118a8b07f Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 21 Sep 2026 08:30:17 +0000 Subject: [PATCH 1/3] fix(pm): move the contract-review tier off the retired ceiling, and split RETIRED from EXHAUSTED MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CONTRACT_REVIEW_TIER moves to the model id the harness actually serves, read from the session's own `external_metadata.last_served_model`. The ladder's ceiling is no longer a word written beside the constant: it is derived from it (`tierWordOf` / `TIER_CEILING`), so a retirement ruling moves one line and the rendering follows. The downgrade fuse gains the case it never had. A quota exemption covers a tier that is EXHAUSTED and will come back — wait out of the queue, never downgrade, never self-review. A tier that is RETIRED never comes back, and the two differ on who may act: a retirement is a maintainer ruling, never a seat's reading. Self-tests pin the constant and the rendering together: the ladder's ceiling is compared against the constant, no retired tier word survives any rendering, the tier's VALUE is spelled in exactly one place across `scripts/pm/**` and `.claude/skills/pm-dispatch/**`, and the rulebook's fuse carries both arms. Claude-Session: https://claude.ai/code/session_01AmH9bKvGoLjiY86Q4Z3og2 Co-authored-by: Claude --- .../pm-dispatch/references/contract-review.md | 2 +- scripts/pm/dispatch-gates.mjs | 131 +++++++++++++++++- 2 files changed, 126 insertions(+), 7 deletions(-) diff --git a/.claude/skills/pm-dispatch/references/contract-review.md b/.claude/skills/pm-dispatch/references/contract-review.md index 5c729d04ce3..aebe3ca8b11 100644 --- a/.claude/skills/pm-dispatch/references/contract-review.md +++ b/.claude/skills/pm-dispatch/references/contract-review.md @@ -57,4 +57,4 @@ - 产出裁决的每轮都须读到契约复审档位,见回退证据 ⇒ 裁决整体作废。 - 父会话只可逐字采纳或整体作废(核验失败、越范围、格式不完整),⛔ 永不改写润色。 - PASS、FAIL 与作废都落 PR 或卡;同 head 再起子代理须引前次作废因,⛔ 不重起求 PASS。 -- 契约复核 ⛔ 不适用额度耗尽豁免降档:豁免对象是派发,复核 ⛔ 不随派发档位免除。 +- 额度耗尽豁免只及派发 ⛔ 不及复核;档位退役 ≠ 耗尽,恒维护者裁决 ⛔ 非席位读数。 diff --git a/scripts/pm/dispatch-gates.mjs b/scripts/pm/dispatch-gates.mjs index 955b1f4259d..b419b239128 100644 --- a/scripts/pm/dispatch-gates.mjs +++ b/scripts/pm/dispatch-gates.mjs @@ -12119,9 +12119,27 @@ export function residueLines( * gate's accept set is the maintainer's decision, not a refresh-time * convenience. The review label deliberately names WHAT is reviewed, never a * model (maintainer, 2026-08-16: 「needs:fable-review 这个标签不好,下次模型升级怎么办」). + * + * ## A tier that is GONE is not a tier that is EXHAUSTED (#19544) + * + * The exits below carry a QUOTA exemption: a tier that is exhausted comes + * back, so the card waits out of the queue and the review is never downgraded + * and never self-reviewed. A tier that has been RETIRED never comes back, and + * the two cases differ on WHO MAY ACT: a seat reading 「⛔ 不许降档」 onto a + * vanished tier holds its whole lane forever, and a seat picking the + * replacement itself is the silent downgrade the fuse exists to stop. So a + * retirement is a maintainer ruling and ⛔ never a seat's reading — and when + * the ruling lands, this VALUE is the one line that moves. The ceiling of the + * ladder `tierLines` prints is DERIVED from it ({@link TIER_CEILING}) so the + * two cannot drift apart. This value moved off the retired ceiling on the + * maintainer's 2026-09-21 ruling — verbatim: 「fable 没有了」, answered with + * 「改成 opus」 — which is why the docblocks below still name the retired tier + * where they record what was ruled AT THE TIME; a record of what was served + * then stays true. Rule text: `references/contract-review.md` 「降档保险丝」. + * * Rulebook: `.claude/skills/pm-dispatch/SKILL.md` 「入队与落地」 — the clause-② gate and the `needs:contract-review` review-chain bullets. */ -export const CONTRACT_REVIEW_TIER = 'claude-fable-5-1'; +export const CONTRACT_REVIEW_TIER = 'claude-opus-5'; /** * The globs that MANDATE a model tier for any card whose file surface touches @@ -12201,9 +12219,10 @@ export const CONTRACT_REVIEW_TIER = 'claude-fable-5-1'; * * The sanctioned exits from a mandate — the one-line-class mechanical-edit * downgrade (a card CONTENT judgment, like clause ②), the measured quota - * exemption (fable unavailable ⇒ opus, never lower) and the proactive - * low-headroom downgrade — are claim-time judgments, not properties of the - * file surface. This tool states the mandate; the seat records any exit and + * exemption (the mandated tier EXHAUSTED ⇒ the default tier, never lower — a + * tier that is RETIRED is not exhausted and is a maintainer ruling instead, + * ⛔ never a seat's reading) and the proactive low-headroom downgrade — are + * claim-time judgments, not properties of the file surface. This tool states the mandate; the seat records any exit and * its reason in the claim comment. ONE exit is path-shaped, and so it IS * encoded: the one-line-class downgrade does not exist for a surface under * `skills/**` — the 2026-09-10 ruling's 必须, because a closed enumeration @@ -12331,6 +12350,49 @@ export const TIER_FLOOR = 'sonnet'; /** The default judgment tier for a card with no mandate — the ruling's 默认判断档. */ export const TIER_DEFAULT = 'opus'; +/** + * The FAMILY word inside a model id — `claude--` ⇒ `family`. + * + * The ladder the claim comment quotes is written in family words (`sonnet`, + * `opus`), while {@link CONTRACT_REVIEW_TIER} is a full model id, so the + * ceiling has to cross between the two vocabularies somewhere. It crosses + * HERE, by derivation, because the alternative — writing the ceiling's word + * down beside the constant — is the second value site the constant's own + * docblock refuses, and it is exactly how the ladder came to read 「ceiling + * fable」 for a tier the harness had stopped serving. + * + * An id this cannot read returns VERBATIM rather than throwing or guessing: a + * ladder printing the whole model id is louder than one printing a family word + * nobody ruled, and `--tier` runs on every dispatch, so a model id in an + * unfamiliar shape must not take the tool down. Both directions are pinned. + */ +export function tierWordOf(modelId) { + const m = /^claude-([a-z]+)-/.exec(String(modelId ?? '')); + return m === null ? String(modelId ?? '') : m[1]; +} + +/** + * The ladder's CEILING — the contract-review tier, in the ladder's vocabulary. + * + * ⛔ Not a constant of its own: derived from {@link CONTRACT_REVIEW_TIER} so a + * retirement ruling moves ONE line and the ladder follows. The day the ceiling + * and the default read the same word is not a bug — it is what a retired + * ceiling falling to the default LOOKS like, and the ladder says so rather + * than keeping a tier nobody can be dispatched at. + */ +export const TIER_CEILING = tierWordOf(CONTRACT_REVIEW_TIER); + +/** + * Tier family words this ladder once printed and must never print again. + * + * ⛔ Not a tier table and ⛔ not an ordering — a RETIRED-SPELLING guard, the + * same shape as the retired clause-② keys pinned further down. The self-test + * asserts no rendering contains one, so the day a ceiling is written down by + * hand again it reds instead of quietly outliving the harness that served it. + * A word leaves this list only when a maintainer ruling brings the tier back. + */ +export const RETIRED_TIER_WORDS = Object.freeze(['fable']); + /** * Place a card's file surface against the mandatory globs. Pure over its * inputs, so the self-test can drive every branch offline. @@ -12394,7 +12456,7 @@ export function tierLines(result) { if (!mandatory) { return [ `Model tier — no path-derived mandate: the surface hits none of the ${declared} declared glob(s), derived here, not recalled.`, - ` The tier stays the PM's per-card judgment call (floor ${TIER_FLOOR} · default ${TIER_DEFAULT} · ceiling fable).`, + ` The tier stays the PM's per-card judgment call (floor ${TIER_FLOOR} · default ${TIER_DEFAULT} · ceiling ${TIER_CEILING}).`, clause2, ...suspicion, ]; @@ -12415,7 +12477,8 @@ export function tierLines(result) { `Model tier — MANDATORY: ${tier} (derived from the file surface, not recalled).`, ...hits.map((h) => ` - ${h.path} ⇢ '${h.glob}' — ${h.why}`), ` Exits, each recorded with its reason in the claim comment's \`Container & model\` line: ${oneLineExit};` + - ' the measured quota exemption (fable unavailable ⇒ opus, never lower); the proactive low-headroom downgrade.', + ` the measured quota exemption (the mandated tier EXHAUSTED ⇒ ${TIER_DEFAULT}, never lower — a tier that is` + + " RETIRED is a maintainer ruling instead, ⛔ never a seat's reading); the proactive low-headroom downgrade.", clause2, ...suspicion, ]; @@ -25232,6 +25295,62 @@ function selfTest() { t(`every frame-sync-enforced copy is fable-mandated (unmandated: ${frameFiles.filter((f) => !deriveTier([f]).mandatory).join(', ') || 'none'})`, frameFiles.length > 0 && frameFiles.every((f) => deriveTier([f]).tier === CONTRACT_REVIEW_TIER)); t('the SKILL.md main file and the dev-agent definition are declared in their own right, not only via the frame table', MANDATORY_TIER_GLOBS.some((g) => g.glob === '.claude/skills/pm-dispatch/SKILL.md') && MANDATORY_TIER_GLOBS.some((g) => g.glob === '.claude/agents/os-dev.md')); + // ── The ladder's CEILING and the constant, pinned TOGETHER (#19544) ─────── + // + // The ceiling used to be a WORD written beside the constant, and the pair + // drifted in the one direction nothing could see: the harness stopped + // serving the tier, the constant kept naming it, and the ladder went on + // printing its family word as a LIVE rule for a tier no dispatch could + // reach. The ceiling is derived now, so these cases hold the RENDERING + // against the constant rather than against a remembered word — write the + // ceiling by hand again and they red, whichever half was edited. + const ladderRenderings = [plainLines, mandLines, catalogLines, tierLines(fableOf(['packages/spec/src/api/error-code-ledger.zod.ts'])).join('\n')]; + t('the ladder prints a ceiling DERIVED from the contract-review constant, so the two cannot drift apart', plainLines.includes(`ceiling ${tierWordOf(CONTRACT_REVIEW_TIER)}`), plainLines.split('\n').find((l) => l.includes('ceiling')) ?? 'no ladder line was rendered at all'); + t("…in the ladder's own vocabulary — the constant's FAMILY word, never the raw model id", TIER_CEILING === tierWordOf(CONTRACT_REVIEW_TIER) && !plainLines.includes(CONTRACT_REVIEW_TIER)); + t('tierWordOf reads the family out of an id, and hands an unreadable one back VERBATIM rather than guessing a word', tierWordOf('claude-example-9-9') === 'example' && tierWordOf('an-unfamiliar-shape') === 'an-unfamiliar-shape' && tierWordOf(null) === ''); + t(`⛔ no RETIRED tier word survives in any rendering — ladder, exits and suspicion line all read the constant (dirty: ${ladderRenderings.map((l, i) => RETIRED_TIER_WORDS.filter((w) => l.toLowerCase().includes(w)).map((w) => `${i}/${w}`).join(' ')).filter(Boolean).join(' ') || 'none'})`, ladderRenderings.every((l) => RETIRED_TIER_WORDS.every((w) => !l.toLowerCase().includes(w)))); + t('the retired-spelling guard is not vacuous — it names at least one word, and none of them is a tier still in the ladder', RETIRED_TIER_WORDS.length > 0 && !RETIRED_TIER_WORDS.includes(TIER_FLOOR) && !RETIRED_TIER_WORDS.includes(TIER_DEFAULT) && !RETIRED_TIER_WORDS.includes(TIER_CEILING)); + // The constant's docblock promises the model id is spelled as a VALUE on its + // own line and NOWHERE else across these two roots. That promise carried no + // pin, which is precisely how a second spelling could outlive a retirement: + // the seat edits the declaration, the copy stays, and nothing compares them. + // Read from the TREE, never from a list of files someone remembered. + const walkFilesUnder = (dir, out = []) => { + for (const entry of readdirSync(dir, { withFileTypes: true })) { + const abs = nodePath.join(dir, entry.name); + if (entry.isDirectory()) walkFilesUnder(abs, out); + else if (entry.isFile()) out.push(abs); + } + return out; + }; + const TIER_VALUE_ROOTS = ['scripts/pm', '.claude/skills/pm-dispatch']; + const scanTierRoots = (predicate) => { + const hits = []; + for (const rel of TIER_VALUE_ROOTS) { + for (const abs of walkFilesUnder(nodePath.join(ROOT, rel))) { + readFileSync(abs, 'utf8').split('\n').forEach((line, i) => { + const found = predicate(line); + if (found) hits.push({ at: `${nodePath.relative(ROOT, abs)}:${i + 1}`, found, line }); + }); + } + } + return hits; + }; + const valueSites = scanTierRoots((line) => (line.includes(CONTRACT_REVIEW_TIER) ? CONTRACT_REVIEW_TIER : null)); + t(`the tier's VALUE is spelled in exactly ONE place under ${TIER_VALUE_ROOTS.join(' and ')} (found: ${valueSites.map((h) => h.at).join(', ') || 'none'})`, valueSites.length === 1); + t('…and that one place is the `export const` DECLARATION, not a comment or a rule that quotes the id', valueSites.length === 1 && valueSites[0].line.startsWith('export const CONTRACT_REVIEW_TIER = ') && valueSites[0].at.startsWith('scripts/pm/dispatch-gates.mjs:')); + const skillIdSpellings = scanTierRoots((line) => { + const m = /\bclaude-[a-z]+-\d[\w.-]*/.exec(line); + return m === null ? null : m[0]; + }).filter((h) => h.at.startsWith('.claude/skills/pm-dispatch/')); + t(`the pm-dispatch skill tree spells NO model id at all — it names the CONSTANT, which is why a retirement never edits it (found: ${skillIdSpellings.map((h) => h.at).join(', ') || 'none'})`, skillIdSpellings.length === 0); + // The rulebook half of the same coupling: the skill names the constant, and + // its downgrade fuse carries the case the quota exemption never had. + const fuseRules = readFileSync(nodePath.join(ROOT, '.claude/skills/pm-dispatch/references/contract-review.md'), 'utf8'); + t('the rulebook names the contract-review tier by its CONSTANT, so a retirement moves the value and the prose follows', fuseRules.includes('`CONTRACT_REVIEW_TIER`')); + t('…and its fuse keeps the quota exemption pointed at DISPATCH, never at the review', /额度耗尽豁免[^\n]*⛔[^\n]*不及复核/.test(fuseRules)); + t('…and carries the case it never had: a RETIRED tier is not an exhausted one, and it is a maintainer ruling, ⛔ never a seat\'s reading', /档位退役[^\n]*≠[^\n]*耗尽[^\n]*维护者裁决[^\n]*⛔[^\n]*非席位读数/.test(fuseRules)); + // ── Clause-② suspicion (the enqueue-gate card): hit / no hit / wording ──── // // The wording cases are not decoration — the suspicion line is quoted into From 4d09523ad6db4df4353317744fa1d7a1f548952c Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 21 Sep 2026 09:00:16 +0000 Subject: [PATCH 2/3] test(pm): hold the retired-word guard to LIVE rules, and read the ladder line itself MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The first cut of the two pins was too wide in both directions. The ceiling pin searched the whole no-mandate rendering, which also carries the clause-② suspicion line naming the tier by its id; the retired-word guard searched the provenance rows too, and those quote maintainer rulings verbatim — a record of what was ruled AT THE TIME stays true however the tier moves afterwards. So the ceiling pin reads the ladder LINE, and the guard reads the rule lines with the `- ⇢ ` rows filtered out, with a non-vacuity case proving the filtered text still carries rules to search. Claude-Session: https://claude.ai/code/session_01AmH9bKvGoLjiY86Q4Z3og2 Co-authored-by: Claude --- scripts/pm/dispatch-gates.mjs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/scripts/pm/dispatch-gates.mjs b/scripts/pm/dispatch-gates.mjs index b419b239128..e3a804cfc19 100644 --- a/scripts/pm/dispatch-gates.mjs +++ b/scripts/pm/dispatch-gates.mjs @@ -25304,11 +25304,19 @@ function selfTest() { // reach. The ceiling is derived now, so these cases hold the RENDERING // against the constant rather than against a remembered word — write the // ceiling by hand again and they red, whichever half was edited. - const ladderRenderings = [plainLines, mandLines, catalogLines, tierLines(fableOf(['packages/spec/src/api/error-code-ledger.zod.ts'])).join('\n')]; - t('the ladder prints a ceiling DERIVED from the contract-review constant, so the two cannot drift apart', plainLines.includes(`ceiling ${tierWordOf(CONTRACT_REVIEW_TIER)}`), plainLines.split('\n').find((l) => l.includes('ceiling')) ?? 'no ladder line was rendered at all'); - t("…in the ladder's own vocabulary — the constant's FAMILY word, never the raw model id", TIER_CEILING === tierWordOf(CONTRACT_REVIEW_TIER) && !plainLines.includes(CONTRACT_REVIEW_TIER)); + // The provenance ROWS (` - ⇢ '' — `) are excluded from the + // retired-word guard below, and deliberately: several of them quote a + // maintainer ruling verbatim, and a record of what was ruled AT THE TIME + // stays true however the tier moves afterwards. What the guard covers is the + // rules — the ladder, the exits, the clause-② note, the suspicion line. + const liveRuleText = (rendered) => rendered.split('\n').filter((l) => !/^\s+- /.test(l)).join('\n'); + const ladderRenderings = [plainLines, mandLines, catalogLines, tierLines(fableOf(['packages/spec/src/api/error-code-ledger.zod.ts'])).join('\n')].map(liveRuleText); + const ladderLine = plainLines.split('\n').find((l) => l.includes('The tier stays')) ?? ''; + t('the ladder prints a ceiling DERIVED from the contract-review constant, so the two cannot drift apart', ladderLine.includes(`ceiling ${tierWordOf(CONTRACT_REVIEW_TIER)})`), ladderLine || 'no ladder line was rendered at all'); + t("…in the ladder's own vocabulary — the constant's FAMILY word, so a parseable id NEVER reaches the ladder verbatim", /^claude-[a-z]+-/.test(CONTRACT_REVIEW_TIER) && TIER_CEILING === tierWordOf(CONTRACT_REVIEW_TIER) && !ladderLine.includes(CONTRACT_REVIEW_TIER), ladderLine); t('tierWordOf reads the family out of an id, and hands an unreadable one back VERBATIM rather than guessing a word', tierWordOf('claude-example-9-9') === 'example' && tierWordOf('an-unfamiliar-shape') === 'an-unfamiliar-shape' && tierWordOf(null) === ''); - t(`⛔ no RETIRED tier word survives in any rendering — ladder, exits and suspicion line all read the constant (dirty: ${ladderRenderings.map((l, i) => RETIRED_TIER_WORDS.filter((w) => l.toLowerCase().includes(w)).map((w) => `${i}/${w}`).join(' ')).filter(Boolean).join(' ') || 'none'})`, ladderRenderings.every((l) => RETIRED_TIER_WORDS.every((w) => !l.toLowerCase().includes(w)))); + t(`⛔ no RETIRED tier word survives in any live RULE — ladder, exits, clause-② note and suspicion line all read the constant (dirty: ${ladderRenderings.map((l, i) => RETIRED_TIER_WORDS.filter((w) => l.toLowerCase().includes(w)).map((w) => `${i}/${w}`).join(' ')).filter(Boolean).join(' ') || 'none'})`, ladderRenderings.every((l) => RETIRED_TIER_WORDS.every((w) => !l.toLowerCase().includes(w)))); + t('…and the guard is not reading an empty string — every rendering it clears still carries its own rule text', ladderRenderings.every((l) => l.includes('Model tier')) && ladderRenderings.some((l) => l.includes('Exits,'))); t('the retired-spelling guard is not vacuous — it names at least one word, and none of them is a tier still in the ladder', RETIRED_TIER_WORDS.length > 0 && !RETIRED_TIER_WORDS.includes(TIER_FLOOR) && !RETIRED_TIER_WORDS.includes(TIER_DEFAULT) && !RETIRED_TIER_WORDS.includes(TIER_CEILING)); // The constant's docblock promises the model id is spelled as a VALUE on its // own line and NOWHERE else across these two roots. That promise carried no From adc6aebfe22bd3b6ca6680394079e64bc2f2934f Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 21 Sep 2026 09:13:25 +0000 Subject: [PATCH 3/3] test(pm): drop the value-site pin that duplicates a landed one, keep the one it cannot see MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The single-value-site promise was already pinned further down the battery, and better: that case derives its scan roots from the mandate globs and FINDS the definition line instead of remembering it. A second copy of one assertion is a second thing to keep in step, so it goes. What stays is the question that pin cannot answer. It searches for the tier's CURRENT value, so a RETIRED id left behind in the rulebook tree matches nothing and passes — while reading, to anyone grepping, as a live tier rule. The surviving case asks the rulebook root whether it spells a model id at all. Claude-Session: https://claude.ai/code/session_01AmH9bKvGoLjiY86Q4Z3og2 Co-authored-by: Claude --- scripts/pm/dispatch-gates.mjs | 42 +++++++++++++---------------------- 1 file changed, 16 insertions(+), 26 deletions(-) diff --git a/scripts/pm/dispatch-gates.mjs b/scripts/pm/dispatch-gates.mjs index e3a804cfc19..1c17c94d0d6 100644 --- a/scripts/pm/dispatch-gates.mjs +++ b/scripts/pm/dispatch-gates.mjs @@ -25318,11 +25318,13 @@ function selfTest() { t(`⛔ no RETIRED tier word survives in any live RULE — ladder, exits, clause-② note and suspicion line all read the constant (dirty: ${ladderRenderings.map((l, i) => RETIRED_TIER_WORDS.filter((w) => l.toLowerCase().includes(w)).map((w) => `${i}/${w}`).join(' ')).filter(Boolean).join(' ') || 'none'})`, ladderRenderings.every((l) => RETIRED_TIER_WORDS.every((w) => !l.toLowerCase().includes(w)))); t('…and the guard is not reading an empty string — every rendering it clears still carries its own rule text', ladderRenderings.every((l) => l.includes('Model tier')) && ladderRenderings.some((l) => l.includes('Exits,'))); t('the retired-spelling guard is not vacuous — it names at least one word, and none of them is a tier still in the ladder', RETIRED_TIER_WORDS.length > 0 && !RETIRED_TIER_WORDS.includes(TIER_FLOOR) && !RETIRED_TIER_WORDS.includes(TIER_DEFAULT) && !RETIRED_TIER_WORDS.includes(TIER_CEILING)); - // The constant's docblock promises the model id is spelled as a VALUE on its - // own line and NOWHERE else across these two roots. That promise carried no - // pin, which is precisely how a second spelling could outlive a retirement: - // the seat edits the declaration, the copy stays, and nothing compares them. - // Read from the TREE, never from a list of files someone remembered. + // A sibling case further down pins the constant's CURRENT value to exactly + // one site under these roots. What that case cannot see is a RETIRED id left + // behind — it is not the current value, so nothing compares it to anything, + // and it reads to a grepping seat as a live tier rule. So this one asks the + // rulebook root a different question: does it spell a model id AT ALL? The + // skill's own rule is 「本文不写模型名」, and a retirement is the moment that + // promise pays for itself — the tree needs no edit, so it cannot go stale. const walkFilesUnder = (dir, out = []) => { for (const entry of readdirSync(dir, { withFileTypes: true })) { const abs = nodePath.join(dir, entry.name); @@ -25331,27 +25333,15 @@ function selfTest() { } return out; }; - const TIER_VALUE_ROOTS = ['scripts/pm', '.claude/skills/pm-dispatch']; - const scanTierRoots = (predicate) => { - const hits = []; - for (const rel of TIER_VALUE_ROOTS) { - for (const abs of walkFilesUnder(nodePath.join(ROOT, rel))) { - readFileSync(abs, 'utf8').split('\n').forEach((line, i) => { - const found = predicate(line); - if (found) hits.push({ at: `${nodePath.relative(ROOT, abs)}:${i + 1}`, found, line }); - }); - } - } - return hits; - }; - const valueSites = scanTierRoots((line) => (line.includes(CONTRACT_REVIEW_TIER) ? CONTRACT_REVIEW_TIER : null)); - t(`the tier's VALUE is spelled in exactly ONE place under ${TIER_VALUE_ROOTS.join(' and ')} (found: ${valueSites.map((h) => h.at).join(', ') || 'none'})`, valueSites.length === 1); - t('…and that one place is the `export const` DECLARATION, not a comment or a rule that quotes the id', valueSites.length === 1 && valueSites[0].line.startsWith('export const CONTRACT_REVIEW_TIER = ') && valueSites[0].at.startsWith('scripts/pm/dispatch-gates.mjs:')); - const skillIdSpellings = scanTierRoots((line) => { - const m = /\bclaude-[a-z]+-\d[\w.-]*/.exec(line); - return m === null ? null : m[0]; - }).filter((h) => h.at.startsWith('.claude/skills/pm-dispatch/')); - t(`the pm-dispatch skill tree spells NO model id at all — it names the CONSTANT, which is why a retirement never edits it (found: ${skillIdSpellings.map((h) => h.at).join(', ') || 'none'})`, skillIdSpellings.length === 0); + const SKILL_RULEBOOK_ROOT = '.claude/skills/pm-dispatch'; + const skillRulebookFiles = walkFilesUnder(nodePath.join(ROOT, SKILL_RULEBOOK_ROOT)); + const skillIdSpellings = []; + for (const abs of skillRulebookFiles) { + readFileSync(abs, 'utf8').split('\n').forEach((line, i) => { + if (/\bclaude-[a-z]+-\d[\w.-]*/.test(line)) skillIdSpellings.push(`${nodePath.relative(ROOT, abs)}:${i + 1}`); + }); + } + t(`${SKILL_RULEBOOK_ROOT} spells NO model id at all — ${skillRulebookFiles.length} file(s) read, and a RETIRED id left there is caught HERE, where a current-value pin cannot see it (found: ${skillIdSpellings.join(', ') || 'none'})`, skillRulebookFiles.length > 0 && skillIdSpellings.length === 0); // The rulebook half of the same coupling: the skill names the constant, and // its downgrade fuse carries the case the quota exemption never had. const fuseRules = readFileSync(nodePath.join(ROOT, '.claude/skills/pm-dispatch/references/contract-review.md'), 'utf8');