Skip to content

Commit f32ad37

Browse files
committed
fix(pm): H43 and H48 judge the slice the .claude/** declaration split read, so a declared rule change is listed as Tier H
Claude-Session: https://claude.ai/code/session_01QsR2jTeURPvEm465RcoYEC Co-authored-by: Claude <noreply@anthropic.com>
1 parent aeb2a0d commit f32ad37

1 file changed

Lines changed: 118 additions & 7 deletions

File tree

‎scripts/pm/check-half-states.mjs‎

Lines changed: 118 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10373,7 +10373,11 @@ export function renderDanglingReferences(report, { markdown = false } = {}) {
1037310373
// Tier H row in a mixed diff keeps the PR here, and an empty or tier-less slice
1037410374
// reads H (fail closed). ⛔ No second copy of which surfaces are which lives in
1037510375
// this file — a register that did not load stands nothing down, and the sweep
10376-
// never reaches these rows without it.
10376+
// never reaches these rows without it. The `.claude/**` row is S only as the
10377+
// register's declaration split reads it (`h43RuleChangeSlice`, #35612): the
10378+
// body's `Rule-change:` line off the LIST row, then the PR thread's record on
10379+
// the head — so a pull declaring `yes` or nothing, or touching settings or
10380+
// hooks, is Tier H here and its maintainer request is owed.
1037710381
//
1037810382
// ## The register is IMPORTED, never restated — and never fatally
1037910383
//
@@ -10460,11 +10464,17 @@ export async function loadGovernedRegister(load = (specifier) => import(specifie
1046010464
const recordTier = merges?.GOVERNED_TIER_S;
1046110465
const approvers = guard?.GOVERNED_APPROVERS;
1046210466
const repoIdForSlug = merges?.repoIdForSlug;
10467+
// The `.claude/**` declaration split (2026-11-19) and its record line reader: the slice H43 and H48 judge is the
10468+
// one the split has read, never the raw row's tier (#35612).
10469+
const split = merges?.applyRuleChangeSplit;
10470+
const readVerified = merges?.readRuleChangeVerified;
1046310471
if (
1046410472
typeof matcher !== 'function' ||
1046510473
typeof tierOf !== 'function' ||
1046610474
typeof recordTier !== 'string' ||
1046710475
typeof repoIdForSlug !== 'function' ||
10476+
typeof split !== 'function' ||
10477+
typeof readVerified !== 'function' ||
1046810478
!Array.isArray(approvers) ||
1046910479
approvers.length === 0
1047010480
) {
@@ -10477,7 +10487,8 @@ export async function loadGovernedRegister(load = (specifier) => import(specifie
1047710487
repo: null,
1047810488
reason:
1047910489
'the governed register loaded but did not export what this row reads — `governedPathsIn`, ' +
10480-
'`landingTierOf`, `GOVERNED_TIER_S`, `repoIdForSlug` and a non-empty `GOVERNED_APPROVERS`. A rename ' +
10490+
'`landingTierOf`, `GOVERNED_TIER_S`, `repoIdForSlug`, `applyRuleChangeSplit`, `readRuleChangeVerified` ' +
10491+
'and a non-empty `GOVERNED_APPROVERS`. A rename ' +
1048110492
'is the likely cause, and this row is the reader that noticed',
1048210493
};
1048310494
}
@@ -10506,7 +10517,7 @@ export async function loadGovernedRegister(load = (specifier) => import(specifie
1050610517
// the register: a guard without it leaves H43's threads UNJUDGED (`h43RecordAuthors`), never the rest unread.
1050710518
const authorTrusted = typeof guard?.recordAuthorTrusted === 'function' ? guard.recordAuthorTrusted : null;
1050810519
const loadRecognisers = typeof guard?.loadRecordRecognisers === 'function' ? guard.loadRecordRecognisers : null;
10509-
return { available: true, matcher: (paths) => matcher(paths, repo), tierOf, recordTier, approvers, repo, reason: null, authorTrusted, loadRecognisers };
10520+
return { available: true, matcher: (paths) => matcher(paths, repo), split: (matched, reading) => split(matched, repo, reading), readVerified, tierOf, recordTier, approvers, repo, reason: null, authorTrusted, loadRecognisers };
1051010521
} catch (err) {
1051110522
return {
1051210523
available: false,
@@ -10547,6 +10558,58 @@ export function governedLandsOnRecord(governed, register = GOVERNED_REGISTER) {
1054710558
return register.tierOf(list) === register.recordTier;
1054810559
}
1054910560

10561+
/**
10562+
* The matched slice with the `.claude/**` declaration split READ (2026-11-19; #35612), as the queue guard reads it:
10563+
* the register's own `applyRuleChangeSplit` on the PR's body off its LIST row and, second, its `record` — so a pull
10564+
* that declares `Rule-change: yes`, declares nothing, or touches a settings or hooks path is Tier H and stays in
10565+
* H43's and H48's population, and one declaring `none` (or `ruled` with its `Ruling-ref:`) stands down only on a
10566+
* record that verifies it (`h43RuleChangeRecord`). `record` null leaves the record stage `pending` — Tier H, and the
10567+
* sweep reads the thread and asks again (`h43RuleChangePending`). A register that did not load returns the slice
10568+
* as it came: `governedLandsOnRecord` stands nothing down there anyway. Pure.
10569+
*/
10570+
export function h43RuleChangeSlice(governed, pr, record = null, register = GOVERNED_REGISTER) {
10571+
const list = Array.isArray(governed) ? governed : [];
10572+
if (!register?.available || typeof register.split !== 'function') return list;
10573+
const reading = { measured: true, reason: null, body: typeof pr?.body === 'string' ? pr.body : '', ...(record === null ? {} : { record }) };
10574+
return register.split(list, reading);
10575+
}
10576+
10577+
/** Does the split's record stage still wait on the PR thread for this slice? Pure. */
10578+
export function h43RuleChangePending(slice) {
10579+
return (Array.isArray(slice) ? slice : []).some((s) => s?.ruleChangeVerdict?.recordStage === 'pending');
10580+
}
10581+
10582+
/**
10583+
* The split's `record` off the PR's own thread — the record H43's hand-off reads (`latestContractReviewOnHead` over
10584+
* the comments `authors` admits, the queue guard's binding) with its `Rule-change-verified:` line read by the
10585+
* register's reader (`readVerified`), and its record leg as this row can read it: `stands` on a PASS, `not-pass`
10586+
* otherwise. Two bounds, stated, both in the direction of standing down where the queue would not (under-report,
10587+
* never ask early): only the PR thread is read (a record on the card alone reads `absent`, so Tier H), and the
10588+
* record's `Served-tier:` line and signature are not read here. An unread thread or an unloaded binding is NOT
10589+
* MEASURED: Tier H. Pure.
10590+
*/
10591+
export function h43RuleChangeRecord(commentRows, headSha, authors = undefined, register = GOVERNED_REGISTER) {
10592+
if (!Array.isArray(commentRows) || authors?.available !== true || typeof register?.readVerified !== 'function') {
10593+
return { measured: false, reason: !Array.isArray(commentRows) ? 'the PR thread was not read' : 'the record-author binding or the line reader did not load' };
10594+
}
10595+
const trusted = commentRows.filter((row) => authors.admits(row));
10596+
const review = latestContractReviewOnHead(trusted, headSha);
10597+
if (review === null) return { measured: true, reason: null, located: 'absent', where: null, id: null, carried: null, ruleChangeVerified: null };
10598+
const row = trusted.find((r) => r?.id === review.id) ?? null;
10599+
const passed = review.verdict === 'PASS';
10600+
return {
10601+
measured: true,
10602+
reason: null,
10603+
located: 'found',
10604+
where: 'PR',
10605+
id: review.id,
10606+
carried: null,
10607+
ruleChangeCarried: null,
10608+
ruleChangeVerified: row === null ? null : register.readVerified(row.body),
10609+
recordLeg: { state: passed ? 'stands' : 'not-pass', reason: passed ? null : `its one \`VERDICT:\` line reads ${review.verdict ?? 'nothing (none or two)'}` },
10610+
};
10611+
}
10612+
1055010613
/**
1055110614
* The two fields a PR LIST row already carries. No request buys this, which is
1055210615
* why the review leg below is bought only when this set is already short.
@@ -24837,11 +24900,25 @@ async function sweepInto(findings, seen, seenPrs, seenMerged, seenUnscoped, seen
2483724900
for (const pr of seenPrs.values()) {
2483824901
const files = filesByPr.get(pr.number);
2483924902
if (!files) continue;
24840-
const governed = GOVERNED_REGISTER.matcher(files.paths ?? []);
24903+
// The `.claude/**` declaration split, read off the body the LIST row carries (#35612): never the raw row's tier.
24904+
const governed = h43RuleChangeSlice(GOVERNED_REGISTER.matcher(files.paths ?? []), pr);
2484124905
if (governed.length > 0) governedByPr.set(pr.number, governed);
2484224906
}
2484324907
stats.governedPrs = governedByPr.size;
2484424908

24909+
// A body that declares a seat value leaves the split's record stage pending: ONE thread read per such PR —
24910+
// H48's fetch class, cached, and one H48 buys for it anyway while it reads Tier H — then the split asks again.
24911+
const splitPending = [...seenPrs.values()].filter((pr) => h43RuleChangePending(governedByPr.get(pr.number)));
24912+
let recordAuthors = null;
24913+
if (splitPending.length > 0) {
24914+
recordAuthors = await h43RecordAuthors();
24915+
if (!recordAuthors.available) stats.governedRecordAuthorsReason = recordAuthors.reason;
24916+
}
24917+
for (const pr of splitPending) {
24918+
const record = h43RuleChangeRecord(await prCommentRowsFor(pr.number), pr.head?.sha, recordAuthors);
24919+
governedByPr.set(pr.number, h43RuleChangeSlice(GOVERNED_REGISTER.matcher(filesByPr.get(pr.number)?.paths ?? []), pr, record));
24920+
}
24921+
2484524922
// Oldest-first, because the PR nobody has asked about for longest is the
2484624923
// one the cap must not be the reason nobody hears about. The policy reads
2484724924
// the matched slice, so a Tier S PR — which the row stands down on — buys
@@ -24858,8 +24935,10 @@ async function sweepInto(findings, seen, seenPrs, seenMerged, seenUnscoped, seen
2485824935
// are both on the thread, nobody is owed a request, so such a PR buys no
2485924936
// review page and fires no row; an unread thread is UNJUDGED.
2486024937
// The PASS is read through the queue guard's author binding (card #33705), loaded once, here, at sweep time.
24861-
const recordAuthors = shortOfCoverage.length > 0 ? await h43RecordAuthors() : null;
24862-
if (recordAuthors !== null && !recordAuthors.available) stats.governedRecordAuthorsReason = recordAuthors.reason;
24938+
if (recordAuthors === null && shortOfCoverage.length > 0) {
24939+
recordAuthors = await h43RecordAuthors();
24940+
if (!recordAuthors.available) stats.governedRecordAuthorsReason = recordAuthors.reason;
24941+
}
2486324942
const handoffByPr = new Map();
2486424943
for (const pr of shortOfCoverage) {
2486524944
const rows = await prCommentRowsFor(pr.number);
@@ -26348,7 +26427,9 @@ export const SELF_TEST_BATTERIES = Object.freeze({
2634826427
// 93 → 94: a code span holding the KEY mentions the line and is unreadable; only the value may sit in one.
2634926428
// 94 → 103: the nine verdict-reader rows that landed with no pin of their own — the closed finding that
2635026429
// must END, the FAIL spellings, the fail-safe idiom. The battery registers 126 cases beside these rows.
26351-
'H43 hand-off timing': 103,
26430+
// 103 → 109 (#35612): the `.claude/**` declaration split on the slice — stood down on a verified `none`, listed on
26431+
// `yes`, the six Tier H shapes, the pending stage, the thread's record reading, an unloaded register, the loader.
26432+
'H43 hand-off timing': 109,
2635226433
// Registered with the seat-patrol rows (#28642), pin just under the count: two
2635326434
// free readings, each with its firing controls and its out-of-scope arms inside;
2635426435
// H71's intake readers (seat title, card labels and epic parent) add five.
@@ -33866,6 +33947,36 @@ async function selfTest() {
3386633947
t43('H43 tier: the answer is the register\'s, on the slice — S for the record row, H for mixed, H for a tier-less fixture, H for nothing', [governedLandsOnRecord(TIER_S_43), governedLandsOnRecord(MIXED_43), governedLandsOnRecord(GOV43), governedLandsOnRecord([])].join(), 'true,false,false,false');
3386733948
t43('H43 tier: ⛔ a register that did not load stands NOTHING down', governedLandsOnRecord(TIER_S_43, { available: false, tierOf: null, recordTier: null }), false);
3386833949
t43('H43 tier: …nor does one that loaded without the tier reader', governedLandsOnRecord(TIER_S_43, { available: true, tierOf: null, recordTier: 'S' }), false);
33950+
33951+
// ⚖️ The `.claude/**` declaration split (#35612): the slice H43 and H48 judge is the register's split, read off the
33952+
// body and the PR thread's record — `Rule-change: yes`, no line or a hooks path is Tier H and listed; a declared
33953+
// `none` stands down only on a record that verifies it. Each with its control one step away.
33954+
const CL43 = ['.claude/agents/os-dev.md'];
33955+
const RC43 = (line) => ({ number: 43, body: `Fixes #1\n\n${line}\n`, head: { sha: HEAD43 } });
33956+
const VERIFIED43 = PASS43.replace('\n\n**VERDICT', '\nRule-change-verified: none\n\n**VERDICT');
33957+
const rcSlice43 = (line, rows = rows43(ACCEPT43, VERIFIED43), paths = CL43) => {
33958+
if (!GOVERNED_REGISTER.available) return [];
33959+
const first = h43RuleChangeSlice(GOVERNED_REGISTER.matcher(paths), RC43(line));
33960+
return h43RuleChangePending(first) ? h43RuleChangeSlice(GOVERNED_REGISTER.matcher(paths), RC43(line), h43RuleChangeRecord(rows, HEAD43, AUTH43)) : first;
33961+
};
33962+
t43('⭐ #35612 H43 split: `Rule-change: none` over a PASS on the head verifying it stands down; the control — `Rule-change: yes` on the same thread — is Tier H and LISTED', [governedLandsOnRecord(rcSlice43('Rule-change: none')), governedLandsOnRecord(rcSlice43('Rule-change: yes')), typeof h43Gap(h43pr(43), rcSlice43('Rule-change: yes'), APP43, []), h43Gap(h43pr(43), rcSlice43('Rule-change: none'), APP43, [])].join(), 'true,false,string,');
33963+
t43('⛔ #35612 H43 split: no `Rule-change:` line, a hooks path beside the wording, a record verifying `yes`, a FAIL, no record on the head, or an unread thread — each Tier H, never stood down', [
33964+
rcSlice43('Clause-②: no'),
33965+
rcSlice43('Rule-change: none', rows43(ACCEPT43, VERIFIED43), [...CL43, '.claude/hooks/guard-main-checkout.sh']),
33966+
rcSlice43('Rule-change: none', rows43(ACCEPT43, VERIFIED43.replace('Rule-change-verified: none', 'Rule-change-verified: yes'))),
33967+
rcSlice43('Rule-change: none', rows43(ACCEPT43, VERIFIED43.replace('**VERDICT: PASS**', '**VERDICT: FAIL**'))),
33968+
rcSlice43('Rule-change: none', rows43(ACCEPT43)),
33969+
rcSlice43('Rule-change: none', null),
33970+
].map((slice) => governedLandsOnRecord(slice)).join(), 'false,false,false,false,false,false');
33971+
t43('#35612 H43 split: a body declaring a seat value leaves the record stage PENDING until the thread is read; `yes` and a hooks path never wait on it', GOVERNED_REGISTER.available ? [h43RuleChangePending(h43RuleChangeSlice(GOVERNED_REGISTER.matcher(CL43), RC43('Rule-change: none'))), h43RuleChangePending(h43RuleChangeSlice(GOVERNED_REGISTER.matcher(CL43), RC43('Rule-change: yes'))), h43RuleChangePending(h43RuleChangeSlice(GOVERNED_REGISTER.matcher(['.claude/settings.json']), RC43('Rule-change: none')))].join() : 'NOT MEASURED', 'true,false,false');
33972+
t43('#35612 H43 split record: a trusted PASS on the head with its line reads FOUND, the line and the leg; none on the head is ABSENT; an unread thread or binding is NOT MEASURED', (() => {
33973+
const found = h43RuleChangeRecord(rows43(ACCEPT43, VERIFIED43), HEAD43, AUTH43);
33974+
const failed = h43RuleChangeRecord(rows43(VERIFIED43.replace('**VERDICT: PASS**', '**VERDICT: FAIL**')), HEAD43, AUTH43);
33975+
const stranger = h43RuleChangeRecord([{ ...rows43(VERIFIED43)[0], user: { login: 'drive-by-commenter' } }], HEAD43, AUTH43);
33976+
return [found.located, found.ruleChangeVerified?.value, found.recordLeg?.state, failed.recordLeg?.state, stranger.located, h43RuleChangeRecord(rows43(OLD_PASS43), HEAD43, AUTH43).located, h43RuleChangeRecord(null, HEAD43, AUTH43).measured, h43RuleChangeRecord(rows43(VERIFIED43), HEAD43, { available: false }).measured].join();
33977+
})(), 'found,none,stands,not-pass,absent,absent,false,false');
33978+
t43('#35612 H43 split: a register that did not load returns the slice untouched — and stands nothing down', [h43RuleChangeSlice(GOV43, RC43('Rule-change: none'), null, { available: false }) === GOV43 || JSON.stringify(h43RuleChangeSlice(GOV43, RC43('Rule-change: none'), null, { available: false })) === JSON.stringify(GOV43), governedLandsOnRecord(TIER_S_43, { available: false })].join(), 'true,false');
33979+
t43('#35612 H43 register: the loader exports the split and its line reader, bound to the swept board', GOVERNED_REGISTER.available && typeof GOVERNED_REGISTER.split === 'function' && typeof GOVERNED_REGISTER.readVerified === 'function' && GOVERNED_REGISTER.readVerified('Rule-change-verified: ruled').value === 'ruled', true);
3386933980
t43('H43 summary: the review leg is stated as Tier H only', saidBy('h43GovernedReviews', summaryLine({ governedPrs: 8, governedReviewCandidates: 5, governedReviewProbed: 5 }, 0)).includes('Tier H only'), true);
3387033981

3387133982
// The coverage clause, both branches, cut out of the summary line so only

0 commit comments

Comments
 (0)