From 56c4ee87e06f718b08e80c5e8cfa001242a44d3e Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 21 Nov 2026 23:05:01 +0000 Subject: [PATCH 1/6] fix(pm): the split's record stage reads the queue's record leg, so no reader prints Tier S over a record the queue refuses Claude-Session: https://claude.ai/code/session_01QsR2jTeURPvEm465RcoYEC Co-authored-by: Claude --- scripts/pm/check-governed-merges.mjs | 49 +++++++++++++++++------ scripts/pm/check-governed-queue-guard.mjs | 33 ++++++++++++--- 2 files changed, 65 insertions(+), 17 deletions(-) diff --git a/scripts/pm/check-governed-merges.mjs b/scripts/pm/check-governed-merges.mjs index fbe521ed46e..2914b6fe203 100644 --- a/scripts/pm/check-governed-merges.mjs +++ b/scripts/pm/check-governed-merges.mjs @@ -502,12 +502,14 @@ * enforces 3 there. `ui/.claude/**` and every other repository's `.claude/**` * are Tier H as before. * - * ⛔ Two readers do NOT chain the split and still read the raw row's Tier S: - * the relay's review-request plan (`fleet-write/execute.mjs`) and the - * half-states patrol's landing row, both through `landingTierOf` on the - * matched slice. Neither decides a landing — the queue guard does — so a - * `Rule-change: yes` pull is refused at the queue but is not auto-routed to - * the maintainer by the relay; CODEOWNERS routes the settings and hooks paths. + * The two readers that decide no landing chain the split too, on the same + * reading: the relay's review-request plan (`governedReviewPlan`, + * `fleet-write/execute.mjs`) requests the approvers for a `.claude/**` pull + * the split reads Tier H, and the half-states patrol's landing row H43 lists + * it. The record conjunct holds only where the queue's record leg would + * clear the same comment — it stands at its face's tier and reads a clean + * PASS (`recordLeg`, `ruleChangeRecordReasons`) — so no reader prints Tier S + * over a record the queue refuses. * * Published `skills/**` stays a Tier H ROW: the 2026-09-18 seat did not propose * moving it, and no row moved since. What moved on 2026-11-14 is a READING on @@ -1258,7 +1260,9 @@ const SELF_TEST_BATTERIES = Object.freeze({ '⚖️ #33603: the sweep lists a low-risk arm landing APART and judges it on a same-head at-tier PASS record': 71, '⭐ the weekly audit card: every reading the job files on, both ways (#33814)': 54, '⚖️ #33539: the ADR leg of the low-risk arm — an add-only note lands Tier S, any other ADR change stays H': 52, - '⚖️ #35321: the guard instruments are Tier H, and `.claude/**` splits by declaration': 40, + // 40 → 44 (#35612, N1 of #35610): a record the queue's record leg refuses — a FAIL, below its tier, or a leg not + // read — keeps the split at Tier H however its `Rule-change-verified:` line reads; one case pins the words. + '⚖️ #35321: the guard instruments are Tier H, and `.claude/**` splits by declaration': 44, }); // DELETING an entry silences that battery's floor exactly as effectively as @@ -3175,11 +3179,13 @@ export const RULE_CHANGE_RECORD_STAGE_PENDING_REASON = * Why the record keeps the split at Tier H, or [] — the split's last conjunct. Pure. * * `record` is the reading the low-risk arm's record stage already takes (`lowRiskRecordStage`, the queue guard), - * with two keys of this split's own: `ruleChangeVerified` (`readRuleChangeVerified` of the located comment) and + * with three keys of this split's own: `ruleChangeVerified` (`readRuleChangeVerified` of the located comment), * `ruleChangeCarried` (`null`, or `{ from, ok, reason }` for a record carried from an older head — it stands only - * when the hops moved nothing under the split row). The conjunct holds only for a record FOUND on this head whose - * line was READ and reads the value the body `declared`: missing, unreadable, `yes`, or the other seat value are - * each a reason, as is a record that is absent, unsigned or unread. + * when the hops moved nothing under the split row) and `recordLeg` (`{ state, reason }`: the queue's own record leg + * on the same comment, `recordVerdict` then `recordPassVerdict` — `stands` only at its face's tier and on a clean + * PASS). The conjunct holds only for a record FOUND on this head that the record leg clears and whose line was READ + * and reads the value the body `declared`: missing, unreadable, `yes`, or the other seat value are each a reason, + * as is a record that is absent, unsigned, unread, below its tier, not a clean PASS, or whose leg was not read. */ export function ruleChangeRecordReasons(record, declared) { const want = `${RULE_CHANGE_VERIFIED_KEY}: ${declared}`; @@ -3195,6 +3201,15 @@ export function ruleChangeRecordReasons(record, declared) { const which = `its contract-review record (${record.where ?? 'a'} comment ${record.id ?? '(no id)'})`; const carried = record.ruleChangeCarried; if (carried && carried.ok !== true) reasons.push(`${which} ${carried.reason ?? 'was carried from an older head over hops that could not be read'}`); + // The queue's record leg on the same comment: ⛔ a caller that hands no leg reading gets no Tier S (N1 of #35610). + const leg = record.recordLeg; + if (leg?.state !== 'stands') { + const said = leg?.reason ? `: ${leg.reason}` : ''; + if (!leg) reasons.push(`${which} was not read by the queue's record leg, so whether it stands at its tier and reads a clean PASS is unknown`); + else if (leg.state === 'not-pass') reasons.push(`${which} does not read a clean PASS${said}`); + else if (leg.state === 'below-tier') reasons.push(`${which} does not stand at its face's tier (its \`Served-tier:\` line)${said}`); + else reasons.push(`${which} does not stand on the queue's record leg (${leg.state})${said}`); + } const line = record.ruleChangeVerified; if (!line || line.state === 'missing') reasons.push(`${which} carries no \`${RULE_CHANGE_VERIFIED_KEY}:\` line`); else if (line.state !== 'read') reasons.push(`the \`${RULE_CHANGE_VERIFIED_KEY}:\` line of ${which} is unreadable: ${line.reason ?? 'no reason recorded'}`); @@ -7420,7 +7435,7 @@ async function selfTest() { const REPO = SELF_REPO_ID; // The reading the `.claude/**` declaration split (2026-11-19) lands Tier S on: the body's one bare line, and a // record FOUND on this head whose own line verifies it. `ruleReading` moves one half at a time for the controls. - const ruleRecord = (value = 'none', over = {}) => ({ measured: true, reason: null, located: 'found', where: 'PR', id: 7, carried: null, ruleChangeCarried: null, ruleChangeVerified: value === null ? { state: 'missing' } : { state: 'read', value }, ...over }); + const ruleRecord = (value = 'none', over = {}) => ({ measured: true, reason: null, located: 'found', where: 'PR', id: 7, carried: null, ruleChangeCarried: null, ruleChangeVerified: value === null ? { state: 'missing' } : { state: 'read', value }, recordLeg: { state: 'stands', reason: null }, ...over }); const ruleReading = (body = 'Rule-change: none', record = ruleRecord()) => ({ measured: true, reason: null, body, ...(record === null ? {} : { record }) }); const RULE_NONE = ruleReading(); // Report fixtures take a REAL window from the real resolver, never a @@ -8243,10 +8258,20 @@ async function selfTest() { 'an unsigned record': ruleRecord('none', { located: 'unsigned' }), 'a record that was not read': { measured: false, reason: 'the PR thread answered 502' }, 'a record carried over a hop that moved the tree': ruleRecord('none', { ruleChangeCarried: { from: 'a'.repeat(40), ok: false, reason: 'was carried over hops that moved .claude/x.md' } }), + // N1 of #35610: the record leg the queue reads on the same comment — the verified line alone is not enough. + 'a record that reads FAIL': ruleRecord('none', { recordLeg: { state: 'not-pass', reason: 'it reads FAIL' } }), + 'a record below its tier': ruleRecord('none', { recordLeg: { state: 'below-tier', reason: null } }), + 'a record whose leg was not read': ruleRecord('none', { recordLeg: undefined }), }; for (const [name, record] of Object.entries(unverified)) { assert(`⛔ unverified-is-Tier-H: ${name}`, tier([WORDING], ruleReading('Rule-change: none', record)) === GOVERNED_TIER_H && split([WORDING], ruleReading('Rule-change: none', record)).reasons.length === 1, why([WORDING], ruleReading('Rule-change: none', record))); } + assert('⛔ N1: the-record-legs-words-name-why-and-the-same-record-with-a-standing-leg-verifies', + /does not read a clean PASS: it reads FAIL/.test(why([WORDING], ruleReading('Rule-change: none', unverified['a record that reads FAIL']))) && + /does not stand at its face's tier/.test(why([WORDING], ruleReading('Rule-change: none', unverified['a record below its tier']))) && + /was not read by the queue's record leg/.test(why([WORDING], ruleReading('Rule-change: none', unverified['a record whose leg was not read']))) && + tier([WORDING], ruleReading('Rule-change: none', ruleRecord('none'))) === GOVERNED_TIER_S, + why([WORDING], ruleReading('Rule-change: none', unverified['a record that reads FAIL']))); assert('control-a-carried-record-whose-hops-moved-nothing-under-the-row-still-verifies', tier([WORDING], ruleReading('Rule-change: none', ruleRecord('none', { ruleChangeCarried: { from: 'a'.repeat(40), ok: true, reason: null } }))) === GOVERNED_TIER_S); assert('⛔ the-record-not-handed-in-is-PENDING-Tier-H-never-none', diff --git a/scripts/pm/check-governed-queue-guard.mjs b/scripts/pm/check-governed-queue-guard.mjs index d8b1d36934e..09956607f03 100644 --- a/scripts/pm/check-governed-queue-guard.mjs +++ b/scripts/pm/check-governed-queue-guard.mjs @@ -800,7 +800,9 @@ const SELF_TEST_BATTERIES = Object.freeze({ // Raised 74 → 84 with every card the pull NAMES: `security` on the second card behind a `Part of`, a branch name // and a `Refs`, their clean control, the first card beside a clean second, the second card unread, the limit, the // reader's own walk, `namedCardsOf`, and the cleared entry that spends no stage read — ten pins. - '⚖️ the low-risk skills arm at the queue: body, labels and every path, read off the pull this leg holds (#33501)': 84, + // 84 → 85 (#35612): the stage carries the record leg's verdict, so the `.claude/**` split reads a FAIL or a + // below-tier record Tier H wherever it is read (N1 of #35610). + '⚖️ the low-risk skills arm at the queue: body, labels and every path, read off the pull this leg holds (#33501)': 85, // Raised 12 → 13 with the arm's record stage on the ADR leg: a record without the line, a `security`-labelled card; // 13 → 14 with a second card the note names. '⚖️ the ADR leg at the queue: an add-only note clears on its PASS record, any other ADR change is H (#33539)': 14, @@ -2407,9 +2409,17 @@ export function lowRiskRecordStage({ pair, recognisers }) { // register's reader, and holds a carried record to its own rule: the hops moved nothing under the row. ruleChangeVerified: readRuleChangeVerified(comment.body), ruleChangeCarried: located.carriedFrom ? ((refusal) => ({ from: located.carriedFrom, ok: refusal === null, reason: refusal }))(ruleChangeCarryRefusal(located.carriedFrom, pair)) : null, + // ...and the record LEG's own verdict on the same pair (`recordVerdict`, `recordPassVerdict`): the split's record + // conjunct holds only where the queue would clear this record — at its face's tier, on a clean PASS (N1 of #35610). + recordLeg: recordLegReading(recordPassVerdict(recordVerdict({ pair, recognisers }), pair, recognisers)), }; } +/** A record-leg verdict as the split's record stage carries it: `{ state, reason }`. Pure. */ +function recordLegReading(leg) { + return { state: leg?.state ?? 'unreadable', reason: leg?.verdictReason ?? leg?.reason ?? null }; +} + /** * How many cards BESIDE the one that carries its record a pull request may name and still be read on the arm. * Each costs two reads in the merge group, so a body naming more is not read at all: Tier H. @@ -2660,7 +2670,7 @@ export function ruleChangeRecordVerdict(record, pair, recognisers, declared) { if (passed.state !== 'stands') return passed; const rows = (recognisers?.threads ?? []).flatMap((thread) => (Array.isArray(pair?.[thread.rows]) ? pair[thread.rows] : [])); const comment = rows.find((r) => r?.id === record.id) ?? null; - const reasons = ruleChangeRecordReasons({ measured: true, reason: null, located: 'found', where: record.where ?? null, id: record.id ?? null, ruleChangeCarried: null, ruleChangeVerified: comment === null ? null : readRuleChangeVerified(comment.body) }, declared); + const reasons = ruleChangeRecordReasons({ measured: true, reason: null, located: 'found', where: record.where ?? null, id: record.id ?? null, ruleChangeCarried: null, ruleChangeVerified: comment === null ? null : readRuleChangeVerified(comment.body), recordLeg: recordLegReading(passed) }, declared); if (reasons.length > 0) return { ...passed, state: 'not-pass', verdict: null, verdictReason: `the \`.claude/**\` declaration split is not verified — ${reasons.join('; ')}` }; return passed; } @@ -4298,7 +4308,7 @@ export async function selfTest() { // The `.claude/**` declaration split (2026-11-19) as the queue leg leaves it once the body declares `none` and the // record on the head verifies it. The pure-verdict cases below are about the legs AFTER the tier, so `run` hands // every split entry that reading on the queue leg — the early-warning leg reads no body, exactly as the live one. - const VERIFIED_STAGE = Object.freeze({ measured: true, reason: null, located: 'found', where: 'PR', id: 1, carried: null, securityTouching: null, ruleChangeVerified: Object.freeze({ state: 'read', value: 'none' }), ruleChangeCarried: null }); + const VERIFIED_STAGE = Object.freeze({ measured: true, reason: null, located: 'found', where: 'PR', id: 1, carried: null, securityTouching: null, ruleChangeVerified: Object.freeze({ state: 'read', value: 'none' }), ruleChangeCarried: null, recordLeg: Object.freeze({ state: 'stands', reason: null }) }); const VERIFIED = Object.freeze({ measured: true, reason: null, body: 'Rule-change: none', record: VERIFIED_STAGE }); const declared = (entry) => readLowRiskTier(entry, REPO, pull(HEAD, { body: 'Rule-change: none' }), { record: VERIFIED_STAGE }); const run = (event, rows, approvals = new Map(), records = new Map()) => { @@ -7101,13 +7111,26 @@ export async function selfTest() { const pairOf = (rows) => ({ pr: 70, card: REF_CARD, headSha: REF_HEAD, paths: [SK], repo: REPO, prComments: rows, cardComments: [] }); const found = lowRiskRecordStage({ pair: pairOf([armRecord()]), recognisers: live }); const absent = lowRiskRecordStage({ pair: pairOf([]), recognisers: live }); - return JSON.stringify(found) === JSON.stringify({ measured: true, reason: null, located: 'found', where: 'PR', id: 900, carried: null, securityTouching: { state: 'read', value: 'no' }, ruleChangeVerified: { state: 'read', value: 'none' }, ruleChangeCarried: null }) && + return JSON.stringify(found) === JSON.stringify({ measured: true, reason: null, located: 'found', where: 'PR', id: 900, carried: null, securityTouching: { state: 'read', value: 'no' }, ruleChangeVerified: { state: 'read', value: 'none' }, ruleChangeCarried: null, recordLeg: { state: 'stands', reason: null } }) && absent.measured === true && absent.located === 'absent' && absent.securityTouching === null && lowRiskRecordStage({ pair: pairOf([armRecord()]), recognisers: { available: false, reason: 'x' } }).measured === false && lowRiskRecordStage({ pair: pairOf([armRecord()]), recognisers: { ...live, reading: undefined } }).measured === false && lowRiskRecordStage({ pair: { ...pairOf([armRecord()]), prComments: undefined }, recognisers: live }).measured === false && lowRiskRecordStage({ pair: pairOf([recordComment()]), recognisers: live }).securityTouching.state === 'missing'; })()); + // N1 of #35610: the split's record stage carries the record LEG's verdict on the same comment, so a reader of the + // stage (`--pr`, the relay) can never print Tier S over a record the queue's record leg refuses. + assert('⛔ N1: the-stage-carries-the-record-legs-verdict-a-FAIL-or-a-below-tier-record-reads-Tier-H-on-the-split-and-a-clean-PASS-reads-S', (() => { + const pairOf = (rows, paths = ['.claude/agents/os-dev.md']) => ({ pr: 70, card: REF_CARD, headSha: REF_HEAD, paths, repo: REPO, prComments: rows, cardComments: [] }); + const legOf = (row) => lowRiskRecordStage({ pair: pairOf([row]), recognisers: live }); + const splitOn = (record) => applyRuleChangeSplit(governedPathsIn(['.claude/agents/os-dev.md'], REPO), REPO, { measured: true, reason: null, body: 'Rule-change: none', record })[0].tier; + const failed = legOf(recordComment({ verdictWord: '**VERDICT: FAIL**' })); + const below = legOf(recordComment({ tierLine: 'Served-tier: 75/75 `TIER_DEFAULT`' })); + const clean = legOf(recordComment()); + return failed.recordLeg.state === 'not-pass' && /reads FAIL/.test(failed.recordLeg.reason) && failed.ruleChangeVerified.value === 'none' && splitOn(failed) === TIER_H && + below.recordLeg.state === 'below-tier' && splitOn(below) === TIER_H && + clean.recordLeg.state === 'stands' && splitOn(clean) === TIER_S; + })()); assert('readCardLabels-never-throws-and-counts-its-reads-a-card-nobody-could-name-reads-nothing', await (async () => { const none = await readCardLabels({ card: { card: null, reason: 'its body names no card' }, fetchLabels: async () => { throw new Error('must not be read'); } }); const both = await readCardLabels({ card: { card: 69 }, named: [69], fetchLabels: async () => ['a'], fetchTimeline: async () => [] }); @@ -7189,7 +7212,7 @@ export async function selfTest() { const cardless = await stageOf({ pull: { ...pull, body: 'Clause-②: no\nMetadata-protocol: none\n' } }); const unreadPull = await stageOf({ pull: null }); return order === `comments 70,comments ${REF_CARD},labels ${REF_CARD},timeline ${REF_CARD}` && clean.apiCalls === 4 && clean.card.card === REF_CARD && - JSON.stringify(clean.record) === JSON.stringify({ measured: true, reason: null, located: 'found', where: 'PR', id: 900, carried: null, securityTouching: { state: 'read', value: 'no' }, ruleChangeVerified: { state: 'read', value: 'none' }, ruleChangeCarried: null }) && + JSON.stringify(clean.record) === JSON.stringify({ measured: true, reason: null, located: 'found', where: 'PR', id: 900, carried: null, securityTouching: { state: 'read', value: 'no' }, ruleChangeVerified: { state: 'read', value: 'none' }, ruleChangeCarried: null, recordLeg: { state: 'stands', reason: null } }) && JSON.stringify(clean.cardLabels) === JSON.stringify({ measured: true, reason: null, card: REF_CARD, labels: ['tooling'], timeline: { measured: true, reason: null, events: [] }, others: { measured: true, reason: null, cards: [] } }) && noLine.record.securityTouching.state === 'missing' && untrusted.record.located === 'absent' && unloaded.apiCalls === 0 && unloaded.record.measured === false && /would not load: boom/.test(unloaded.record.reason) && unloaded.cardLabels.measured === false && From aeb2a0d15de301e0a302d90c0c252b9d2c6e0065 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 21 Nov 2026 23:08:37 +0000 Subject: [PATCH 2/6] fix(pm): the relay's review plan chains the .claude/** declaration split, so a declared rule change requests the approver at pr_ready Claude-Session: https://claude.ai/code/session_01QsR2jTeURPvEm465RcoYEC Co-authored-by: Claude --- scripts/pm/fleet-write/execute.mjs | 166 +++++++++++++++++++++++++++-- 1 file changed, 158 insertions(+), 8 deletions(-) diff --git a/scripts/pm/fleet-write/execute.mjs b/scripts/pm/fleet-write/execute.mjs index 234edcf225d..88b8a2037a0 100644 --- a/scripts/pm/fleet-write/execute.mjs +++ b/scripts/pm/fleet-write/execute.mjs @@ -521,6 +521,24 @@ * card), a mixed pull or a repository outside `lowRisk.repos` requests exactly * as the path-only plan, and the verdict row says why. * + * The `.claude/**` declaration split (maintainer ruling 2026-11-19 on #35321): + * the plan chains `applyRuleChangeSplit` last, as the register's + * `governedTierFor` does, so the path-only plan reads a `.claude/**` pull + * Tier H — a path list cannot say what its body declares. When EVERY governed + * hit is a row carrying `ruleChange` for the target and no path sits under + * `.claude/settings*.json` or `.claude/hooks/` (`ruleChangeReadable`), the + * follow-up reads the body off the pull answer (`pullLowRiskReading`) and, + * when the body declares a seat value (`none`, or `ruled` with its + * `Ruling-ref:` line), the record stage through the queue guard's one reader + * (`readLowRiskRecordStage`, card labels left unread) — the record must stand + * at its tier, read a clean PASS and carry the same `Rule-change-verified:` + * value (`ruleChangeReadingFor`). Only then does it request nobody. ⛔ Fail + * closed: `Rule-change: yes`, no line, a settings or hooks path, a record + * absent, unread or not verifying, a mixed pull, or a repository outside + * `ruleChange.repos` requests exactly as the path-only plan, and the verdict + * row says why. A record carried from an older head is refused here (no + * checkout diffs the hops), so it requests too. + * * ## The step summary — what a person reads back * * `$GITHUB_STEP_SUMMARY` gets one table per run: request id · sender and its @@ -578,6 +596,7 @@ import { isEntrypoint } from '../../invoked-as.mjs'; // The register and the approver list, READ — never restated here (the ops.mjs header, "The governed-review follow-up"). import { applyLowRiskArm, + applyRuleChangeSplit, applyWorkflowSplit, fetchTimelineOver, GOVERNED_TIER_H, @@ -595,6 +614,7 @@ import { pullPathsFrom, readWorkflowDiff, repoIdForSlug, + RULE_CHANGE_RULING, slugFromRemote, } from '../check-governed-merges.mjs'; import { @@ -925,21 +945,27 @@ export function reviewedLogins(json) { * keeps them H, so a path-only call answers as before. `lowRiskVerdict` is that verdict, or null when no arm row * was hit, for the row's words. * + * The same reading is handed to `applyRuleChangeSplit` LAST (the `.claude/**` declaration split): with no reading the + * split row is Tier H, so a path-only call requests the approvers for a `.claude/**` pull; only a reading whose body + * declares a seat value and whose record verifies it moves that row to S. `ruleChangeVerdict` is the split's + * verdict, or null when no split row was hit. + * * Logins are matched as GitHub matches them, case-insensitively; the answer keeps `approvers`' own spelling and order. */ export function governedReviewPlan({ paths, repo, author = null, requested = [], assigned = [], reviewed = [], approvers = GOVERNED_APPROVERS, workflowDiff = null, lowRisk = null } = {}) { const repoId = repoIdForSlug(repo); const matched = repoId ? governedPathsIn(Array.isArray(paths) ? paths : [], repoId) : []; - const read = matched.length === 0 ? [] : applyLowRiskArm(applyWorkflowSplit(matched, repoId, workflowDiff), repoId, lowRisk); + const read = matched.length === 0 ? [] : applyRuleChangeSplit(applyLowRiskArm(applyWorkflowSplit(matched, repoId, workflowDiff), repoId, lowRisk), repoId, lowRisk); const tier = matched.length === 0 ? null : landingTierOf(read); const lowRiskVerdict = read.find((s) => s?.lowRiskVerdict)?.lowRiskVerdict ?? null; + const ruleChangeVerdict = read.find((s) => s?.ruleChangeVerdict)?.ruleChangeVerdict ?? null; const lower = (list) => (Array.isArray(list) ? list : []).map((l) => String(l).toLowerCase()); const have = new Set([...lower(requested), ...lower(assigned), ...lower(reviewed)]); const list = Array.isArray(approvers) ? approvers : []; const covered = list.filter((a) => have.has(a.toLowerCase())); const missing = tier === GOVERNED_TIER_H ? list.filter((a) => !have.has(a.toLowerCase())) : []; const isAuthor = (a) => typeof author === 'string' && a.toLowerCase() === author.toLowerCase(); - return { repoId, matched, tier, lowRiskVerdict, covered, toRequest: missing.filter((a) => !isAuthor(a)), toAssign: missing.filter(isAuthor) }; + return { repoId, matched, tier, lowRiskVerdict, ruleChangeVerdict, covered, toRequest: missing.filter((a) => !isAuthor(a)), toAssign: missing.filter(isAuthor) }; } /** The words the follow-up's verdict row prints for a plan — what was hit, who is covered, what will be sent. Pure. */ @@ -989,6 +1015,24 @@ export function lowRiskArmReadable(plan) { return { read: true, why: null }; } +/** + * Whether the `.claude/**` declaration split may be READ for this plan (header: "The governed-review follow-up"): a + * Tier H plan whose EVERY governed hit is a row carrying `ruleChange` for this repository, and whose split did not + * already decide by path (a settings or hooks file). Pure; the same `{ read, why }` shape as `lowRiskArmReadable`, + * and a cost gate only — it can keep a plan H, never move one to S. + */ +export function ruleChangeReadable(plan) { + const hits = Array.isArray(plan?.matched) ? plan.matched : []; + const splitRows = hits.filter((s) => s?.ruleChange); + if (plan?.tier !== GOVERNED_TIER_H || splitRows.length === 0) return { read: false, why: null }; + const others = hits.filter((s) => !s?.ruleChange); + if (others.length > 0) return { read: false, why: `another governed row is hit too (${others.map((s) => `\`${s.glob}\``).join(', ')}), so the path-only tier stands` }; + const outside = splitRows.filter((s) => !(Array.isArray(s.ruleChange.repos) && s.ruleChange.repos.includes(plan.repoId))); + if (outside.length > 0) return { read: false, why: `${plan.repoId} is not in the row's ruleChange.repos (${(outside[0].ruleChange.repos ?? []).join(', ')}), so the path-only tier stands` }; + if (plan.ruleChangeVerdict?.byPath === true) return { read: false, why: `${plan.ruleChangeVerdict.reasons.join('; ')}` }; + return { read: true, why: null }; +} + /** * How far past its merge base a head may be for the relay to read its catalog files: the head is fetched at * depth `ahead_by + 1`, which holds the merge base (every commit on the shortest path from the head down to it @@ -1103,6 +1147,48 @@ export async function lowRiskReadingFor({ repo, pull, paths, files, pr, api, t, return pullLowRiskReading(pr, paths, { timeline, changesets, catalogFiles, record: stage.record, cardLabels: stage.cardLabels }); } +/** + * The `.claude/**` declaration split's reading for ONE pull (header: "The governed-review follow-up"): the body off + * the pull answer `pr` (`pullLowRiskReading`, the reading the register's split takes), and — only when that body + * leaves the split's RECORD STAGE pending, so a `yes` or an absent line pays for nothing — the record stage through + * the queue guard's `readLowRiskRecordStage`, imported, ⛔ no second reader, over the guard's own comment reader on + * the relay's token, card labels left unread (they are the low-risk arm's conjunct, not this split's). No checkout is + * handed to it, so a record carried from an older head is refused, never re-tested here. A recogniser load that + * fails or a thread that does not read is NOT MEASURED, so Tier H. Never throws. + */ +export async function ruleChangeReadingFor({ repo, pull, paths, pr, api, t, loadRecognisers = loadRecordRecognisers }) { + const first = pullLowRiskReading(pr, paths); + const plan = governedReviewPlan({ paths, repo, lowRisk: first }); + if (plan.ruleChangeVerdict?.recordStage !== LOW_RISK_RECORD_STAGE.pending) return first; + let recognisers; + try { + recognisers = await loadRecognisers(); + } catch (error) { + recognisers = { available: false, reason: `the recogniser load threw: ${String(error?.message ?? error).split('\n')[0]}` }; + } + const reader = { apiUrl: api, slug: repo, token: t?.token ?? '', fetchImpl: t?.fetch ?? globalThis.fetch }; + const stage = await readLowRiskRecordStage({ + pr: pull, + pull: pr, + headSha: pr?.head?.sha ?? null, + paths, + repo: plan.repoId, + recognisers, + fetchComments: makeCommentReader(reader), + withCardLabels: false, + }); + return pullLowRiskReading(pr, paths, { record: stage.record }); +} + +/** The words the split's verdict adds to the verdict row: Tier S and the ruling, or every reason it is H. Pure. */ +export function ruleChangeReadingText(plan) { + const v = plan?.ruleChangeVerdict; + if (!v) return ''; + if (v.tier === GOVERNED_TIER_S) return ` · \`.claude/**\` declaration split read: Tier S on \`Rule-change: ${v.declared}\`, verified on the record (${RULE_CHANGE_RULING})`; + const reasons = v.measured ? v.reasons : [v.reason]; + return ` · \`.claude/**\` declaration split read: Tier H, fail closed — ${reasons.join('; ')}`; +} + /** * The relay's checkout made ready for `lowRiskReadingFor`: `{ run, derivation }` — `run` the register's * `{ ok, out }` git seam over `git` (stdout trimmed, a throw read as `ok: false`), `derivation` the head, the merge @@ -2290,6 +2376,22 @@ async function requestGovernedReview({ index, op, pull, payload, api, t, log, ro return { ok: true }; } } + // The `.claude/**` declaration split (header): read only when every governed hit is that row in its ruleChange.repos + // and no settings or hooks path decided it; a body declaring a seat value over a record that verifies it sends + // nothing, and every other outcome — `yes`, no line, a record that does not verify, unread — requests as before. + const splitReadable = ruleChangeReadable(plan); + if (splitReadable.why) readingWords += ` · \`.claude/**\` declaration split not read: ${splitReadable.why}`; + if (splitReadable.read) { + lowRisk = await ruleChangeReadingFor({ repo, pull, paths, pr: pr.json, api, t }); + plan = governedReviewPlan({ approvers, paths, repo, workflowDiff: reading, lowRisk }); + readingWords += scrub(ruleChangeReadingText(plan), [token]); + if (plan.tier !== GOVERNED_TIER_H) { + const text = `${governedReviewText(plan, { approvers, repo, files: read.files.length })}${readingWords}`; + rows.push({ action: index, op, call: FILES, status: 200, result: text }); + log(` · action ${index} ${op}: ${text}${renamed}`); + return { ok: true }; + } + } const reviews = await rest(api, `/repos/${repo}/pulls/${pull}/reviews?per_page=100`, {}, t); if (reviews.status !== 200 || !Array.isArray(reviews.json)) { return failed(`GET /repos/${repo}/pulls/${pull}/reviews`, reviews.status, `${reviews.call} -> HTTP ${reviews.status}${reviews.detail ? ` (${reviews.detail})` : ''}: the pull's reviews could not be read, so who has already reviewed is unknown and no review was requested — its diff hits a Tier H surface; read it on the board and request by hand`); @@ -2633,7 +2735,10 @@ const SELF_TEST_BATTERIES = Object.freeze({ // 45 → 50 with the arm's record stage on the relay: nine H variants of the stage in one plan case, twelve in one run case (the record // without its line first), the record on the card thread, the recogniser seam, and the stage's cost on a pull-read H. // 50 → 52 with every card the pull names: five H variants of a second card in one run case, and its clean control. - "the governed-review follow-up: after pr_ready alone — a pr_create summons NOBODY and never reads the pull's files, because a human is asked only at the seat's hand-off (pr_request_reviewers after ACCEPT + a same-head PASS); after pr_ready the pull's file list is read in full, a Tier H hit requests review from every GOVERNED_APPROVERS account not already requested, assigned or reviewed — the pull's own author assigned instead, never requested; a Tier S or ungoverned diff sends nothing and says so; a workflow-only pull in split.repos is judged by the queue guard's reading, merge base → head, and requests only when it says H or cannot be read; a skills-only pull in lowRisk.repos is judged by the low-risk arm's own reading — pull, file statuses, timeline, changesets and catalog modes, then the review record's `Security-touching:` line and the card's labels — and requests only when it says H or cannot be read; an unreadable or truncated list, an unreadable pull or review list, or a refused write is a FAILED action": 52, + // 52 → 62 (#35612): the `.claude/**` declaration split on the plan — `none` over a verifying record plans nobody, and + // `yes`, no line, settings/hooks, an unread, non-verifying or FAIL record, a mixed pull each plan both; the readable + // gate, the words, four runs, and hotcrm on the `workflows` row (its plan and its run). + "the governed-review follow-up: after pr_ready alone — a pr_create summons NOBODY and never reads the pull's files, because a human is asked only at the seat's hand-off (pr_request_reviewers after ACCEPT + a same-head PASS); after pr_ready the pull's file list is read in full, a Tier H hit requests review from every GOVERNED_APPROVERS account not already requested, assigned or reviewed — the pull's own author assigned instead, never requested; a Tier S or ungoverned diff sends nothing and says so; a workflow-only pull in split.repos is judged by the queue guard's reading, merge base → head, and requests only when it says H or cannot be read; a skills-only pull in lowRisk.repos is judged by the low-risk arm's own reading — pull, file statuses, timeline, changesets and catalog modes, then the review record's `Security-touching:` line and the card's labels — and requests only when it says H or cannot be read; an unreadable or truncated list, an unreadable pull or review list, or a refused write is a FAILED action": 62, // 17 → 21 with the head fence: a stale head, the embedded copy never trusted, a run naming no pull, a pull unread. "the run_rerun_failed: the five fences judged HERE on the run and its pull, read immediately before ONE bodiless POST — the pull's current head by its own GET, never the run's embedded copy, and a run naming no pull refused by name; each refused with the POST not sent and accepted on the measured run; a run, pull, baseline or fence that fails is zero writes; the 201 confirmed only by reading attempt 2 back with its failed jobs queued or in progress, naming their job ids; attempt 2 never seen, a failed job completed, or a job list unread is FAILED; no annotation": 21, "the pr_enqueue_front: the pull's own GET, its whole file list and its base's queue read immediately before ONE enqueuePullRequest mutation with jump true and the expected head — open, ready, its head, not Version Packages, no governed path, at most the human-merge line count, a queue read whole with no jumped entry; each fence refused with the mutation not sent; GraphQL errors FAILED naming the missing grant; the 200 confirmed only by reading the queue back with the pull jumped and nothing ahead; queued without the jump or behind another is FAILED, never re-sent; the queue read unpaced; no annotation": 20, @@ -3023,7 +3128,7 @@ export async function selfTest() { t("…the pull's own author, when it is an uncovered approver, is ASSIGNED and never requested — the other approver is requested as before", pick(planPair({ paths: ['AGENTS.md'], repo: REPO, author: A2 })), [GOVERNED_TIER_H, [A1], [A2], []]); t('…an approver already requested, assigned or holding a submitted review is covered — the H43 union — and matched case-insensitively', pick(planPair({ paths: ['skills/x/SKILL.md'], repo: REPO, author: A2, requested: [A1.toUpperCase()], assigned: [A2] })), [GOVERNED_TIER_H, [], [], [A1, A2]]); t("…a submitted review covers its author's slot; a pending (unsubmitted) one does not", [reviewedLogins([{ state: 'COMMENTED', user: { login: 'x' } }, { state: 'PENDING', user: { login: 'y' } }]), planPair({ paths: ['CLAUDE.md'], repo: REPO, reviewed: [A1] }).toRequest], [['x'], [A2]]); - t('…a Tier S diff (the .claude/** row alone) is tier S and sends nothing; an ungoverned diff is tier null; a mixed S+H diff is H', [planPair({ paths: ['.claude/skills/pm-dispatch/SKILL.md'], repo: REPO }), planPair({ paths: ['packages/core/src/a.ts'], repo: REPO }), planPair({ paths: ['.claude/agents/os-dev.md', 'docs/NORTH-STAR.md'], repo: REPO })].map((p) => [p.tier, p.toRequest.length + p.toAssign.length]), [[GOVERNED_TIER_S, 0], [null, 0], [GOVERNED_TIER_H, 2]]); + t('…a `.claude/**` diff on its path list alone is tier H and plans both (the declaration split, unread, fails closed — #35612); an ungoverned diff is tier null; a mixed diff is H', [planPair({ paths: ['.claude/skills/pm-dispatch/SKILL.md'], repo: REPO }), planPair({ paths: ['packages/core/src/a.ts'], repo: REPO }), planPair({ paths: ['.claude/agents/os-dev.md', 'docs/NORTH-STAR.md'], repo: REPO })].map((p) => [p.tier, p.toRequest.length + p.toAssign.length]), [[GOVERNED_TIER_H, 2], [null, 0], [GOVERNED_TIER_H, 2]]); t('…a target outside GOVERNED_REPOS has no governing row: repoId null, tier null, nothing to send', (({ repoId, tier, toRequest }) => [repoId, tier, toRequest])(planPair({ paths: ['docs/adr/0001-x.md'], repo: 'objectstack-ai/elsewhere' })), [null, null, []]); t('…the register is scoped per repository: a workflow path is Tier H on objectui and ungoverned on objectos', [planPair({ paths: ['.github/workflows/ci.yml'], repo: 'objectstack-ai/objectui' }).tier, planPair({ paths: ['.github/workflows/ci.yml'], repo: 'objectstack-ai/objectos' }).tier], [GOVERNED_TIER_H, null]); t('…a rename OUT of a governed path counts by its old name (pullPathsFrom reads previous_filename)', planPair({ paths: pullPathsFrom([{ filename: 'docs/agents.md', previous_filename: 'AGENTS.md' }]).paths, repo: REPO }).tier, GOVERNED_TIER_H); @@ -3047,8 +3152,8 @@ export async function selfTest() { t('…the file list, the pull and its reviews were read first, in that order, and the rows say the verdict and the landing', [both.seen.map((s) => s.call), both.rows.slice(1).map((r) => [r.action, r.op, r.call, r.status, r.result])], [[PERM, PULL, GRAPHQL, FILES, PULL, REVIEWS, REQUEST], [[1, 'pr_ready', FILES, 200, `governed review: Tier H (\`docs/NORTH-STAR.md\`×1) — requesting \`${A1}\`, \`${A2}\``], [1, 'pr_ready', REQUEST, 201, `#${N} ${URL} · review requested from ${A1}, ${A2}`]]]); const none = await runPair(ready([{ op: 'comment', issue: 1, body: 'after' }]), { ...allowed, [PULL]: pullOf(), ...readied, [FILES]: files('packages/core/src/a.ts', 'README.md'), [`POST /repos/${REPO}/issues/1/comments`]: { status: 201, json: { id: 1 } } }); t('a non-governed diff: the file list is read, NOTHING is requested, the row says so, and the later action runs', [none.exit, writes(none.seen).map((s) => s.call), none.rows[1]?.result, none.seen.filter((s) => s.call === PULL).length], [EXIT_OK, [GRAPHQL, `POST /repos/${REPO}/issues/1/comments`], 'governed review: no governed row hit across 2 file(s) — no review requested', 1]); - const tierS = await runPair(ready(), { ...allowed, [PULL]: pullOf(), ...readied, [FILES]: files('.claude/skills/pm-dispatch/SKILL.md') }); - t("a Tier S diff (.claude/** alone) requests nobody — it lands on a seat's review of record", [tierS.exit, writes(tierS.seen).map((s) => s.call), tierS.rows[1]?.result], [EXIT_OK, [GRAPHQL], "governed review: Tier S (`.claude/**`×1) lands on a seat's review of record — no review requested"]); + const tierS = await runPair(ready(), { ...allowed, [PULL]: pullOf(), ...readied, [FILES]: files('.claude/skills/pm-dispatch/SKILL.md'), [REVIEWS]: reviewsBy(), [REQUEST]: requestedAnswer([A1, A2]) }); + t('⛔ a `.claude/**` pull whose body declares no `Rule-change:` line requests BOTH — the declaration split reads it Tier H, and the row says why (#35612)', [tierS.exit, writes(tierS.seen).map((s) => s.call), tierS.rows[1]?.result.includes('· `.claude/**` declaration split read: Tier H, fail closed — the PR body carries no `Rule-change:` line')], [EXIT_OK, [GRAPHQL, REQUEST], true], tierS.rows[1]?.result); const authored = await runPair(ready(), { ...allowed, ...tierH, [PULL]: pullOf({ author: A2 }), [REQUEST]: requestedAnswer([A1]), [ASSIGN]: assignedAnswer([A2]) }); t('⭐ the author-identity branch: a pull authored by an approver requests the OTHER approver and ASSIGNS the author — never a request naming the author', [authored.exit, writes(authored.seen).slice(1).map((s) => [s.call, s.body]), authored.rows.map((r) => r.result).slice(1)], [EXIT_OK, [[REQUEST, { reviewers: [A1] }], [ASSIGN, { assignees: [A2] }]], [`governed review: Tier H (\`docs/NORTH-STAR.md\`×1) — requesting \`${A1}\` and assigning the author \`${A2}\` (a request naming the author is a 422)`, `#${N} ${URL} · review requested from ${A1}`, `#${N} ${URL} · assignees ${A2}`]]); const covered = await runPair(ready(), { ...allowed, ...tierH, [PULL]: pullOf({ requested: [A1] }), [REVIEWS]: reviewsBy(A2) }); @@ -3133,7 +3238,7 @@ export async function selfTest() { t('⛔ unreadable-workflow-pull-requests: no checkout, a commit missing after the fetch, git throwing, a fetch that throws, a checkout of another repository or a refused compare — each requests BOTH approvers exactly as today, and its row says UNREAD with the fail-closed words', Object.entries(unreadable).map(([k, r]) => [k, r.exit, writes(r.seen).map((s) => s.call), r.rows[1]?.result.includes('workflow split UNREAD') && r.rows[1]?.result.includes('fail closed, the path-only tier H stands')]), Object.keys(unreadable).map((k) => [k, EXIT_OK, [GRAPHQL, REQUEST], true]), Object.values(unreadable).map((r) => r.rows[1]?.result).join(' | ')); const mixedCalls = []; const mixed = await runPair(ready(), wfAnswers(HEAD_S, { [FILES]: files(WF, '.claude/agents/os-dev.md') }), { git: fakeGit(mixedCalls, { present: [MB, HEAD_S] }) }); - t('⛔ mixed-workflow-pull-requests: a workflow edit beside another governed row (.claude/**) is never split — no compare, no git, both requested, the row naming the other row', [mixed.exit, mixed.seen.some((s) => s.call.includes('/compare/')), mixedCalls.length, writes(mixed.seen).map((s) => s.call), mixed.rows[1]?.result.endsWith('· workflow split not read: another governed row is hit too (`.claude/**`), so the path-only tier stands')], [EXIT_OK, false, 0, [GRAPHQL, REQUEST], true], mixed.rows[1]?.result); + t('⛔ mixed-workflow-pull-requests: a workflow edit beside another governed row (.claude/**) is never split — no compare, no git, both requested, the row naming the other row', [mixed.exit, mixed.seen.some((s) => s.call.includes('/compare/')), mixedCalls.length, writes(mixed.seen).map((s) => s.call), mixed.rows[1]?.result.includes('· workflow split not read: another governed row is hit too (`.claude/**`), so the path-only tier stands')], [EXIT_OK, false, 0, [GRAPHQL, REQUEST], true], mixed.rows[1]?.result); const UI = 'objectstack-ai/objectui'; const uiN = (p) => p.replace(REPO, UI); const uiCalls = []; @@ -3302,11 +3407,56 @@ export async function selfTest() { t('⛔ unreadable-skills-pull-requests: no checkout, an unread timeline, a refused compare, a head past the fetch cap, a checkout of another repository, a fetch that throws, a head the fetch cannot bring, or no head sha — each requests BOTH approvers exactly as today, and its row says Tier H, fail closed, with the reason', Object.entries(armUnread).map(([k, [r, why]]) => [k, r.exit, writes(r.seen).map((s) => s.call), r.rows[1]?.result.includes('low-risk skills arm read: Tier H, fail closed') && r.rows[1]?.result.includes(why)]), Object.keys(armUnread).map((k) => [k, EXIT_OK, [GRAPHQL, REQUEST], true]), Object.values(armUnread).map(([r]) => r.rows[1]?.result).join(' | ')); const armMixedCalls = []; const armMixed = await runPair(ready(), armAnswers({ [FILES]: armFiles(SK, CS, '.claude/agents/os-dev.md') }), { git: armGit(armMixedCalls) }); - t('⛔ mixed-skills-pull-requests: a skills edit beside another governed row (.claude/**) is not read — no timeline, no compare, no git, both requested, the row naming the other row', [armMixed.exit, armMixed.seen.some((s) => s.call === TIMELINE || s.call === ARM_COMPARE), armMixedCalls.length, writes(armMixed.seen).map((s) => s.call), armMixed.rows[1]?.result.endsWith('· low-risk skills arm not read: another governed row is hit too (`.claude/**`), so the path-only tier stands')], [EXIT_OK, false, 0, [GRAPHQL, REQUEST], true], armMixed.rows[1]?.result); + t('⛔ mixed-skills-pull-requests: a skills edit beside another governed row (.claude/**) is not read — no timeline, no compare, no git, both requested, the row naming the other row', [armMixed.exit, armMixed.seen.some((s) => s.call === TIMELINE || s.call === ARM_COMPARE), armMixedCalls.length, writes(armMixed.seen).map((s) => s.call), armMixed.rows[1]?.result.includes('· low-risk skills arm not read: another governed row is hit too (`.claude/**`), so the path-only tier stands')], [EXIT_OK, false, 0, [GRAPHQL, REQUEST], true], armMixed.rows[1]?.result); const armUiCalls = []; const armUi = await runPair({ ...ready(), repo: UI_REPO }, { [uiRepo(PERM)]: allowed[PERM], ...readied, [uiRepo(PULL)]: { status: 200, json: armPullJson() }, [uiRepo(FILES)]: armFiles(SK, CS), [uiRepo(REVIEWS)]: reviewsBy(), [uiRepo(REQUEST)]: requestedAnswer([A1, A2]) }, { git: armGit(armUiCalls) }); t('⛔ objectui-skills-pull-requests: a skills pull on a repository outside lowRisk.repos is not read — no timeline, no compare, no git, both requested, the row naming lowRisk.repos', [armUi.exit, armUi.seen.some((s) => s.call.includes('/timeline') || s.call.includes('/compare/')), armUiCalls.length, writes(armUi.seen).map((s) => s.call), armUi.rows[1]?.result.endsWith("· low-risk skills arm not read: objectui is not in the row's lowRisk.repos (objectstack), so the path-only tier stands")], [EXIT_OK, false, 0, [GRAPHQL, uiRepo(REQUEST)], true], armUi.rows[1]?.result); t('no annotation is emitted for the follow-up — pr_ready is not an annotated op', [both.annotations, authored.logs.some((l) => l.startsWith('::notice'))], [[], false]); + + // ⚖️ The `.claude/**` declaration split on the relay (#35612): the plan chains `applyRuleChangeSplit` on the same + // reading, so a body declaring `yes`, nothing, or a settings/hooks path plans both approvers, and a declared `none` + // over a record that verifies it plans nobody. Each pinned with the control one step away. + const CL = '.claude/skills/pm-dispatch/SKILL.md'; + const RC_BODY = (line) => `Fixes #1\n\nClause-②: no\nMetadata-protocol: none\n${line === null ? '' : `${line}\n`}`; + const rcRecord = (value = 'none', over = {}) => ({ measured: true, reason: null, located: 'found', where: 'PR', id: 900, carried: null, securityTouching: null, ruleChangeVerified: value === null ? { state: 'missing' } : { state: 'read', value }, ruleChangeCarried: null, recordLeg: { state: 'stands', reason: null }, ...over }); + const rcRead = (line, record = rcRecord()) => pullLowRiskReading(armPullJson({ body: RC_BODY(line) }), [CL], record === null ? {} : { record }); + const rcPlan = (paths, reading) => planPair({ paths, repo: REPO, lowRisk: reading }); + t('⭐ split plan: `Rule-change: none` over a record that verifies it is Tier S and plans NOBODY; the control — the same pull read on its path list alone — plans both', [rcPlan([CL], rcRead('Rule-change: none')), rcPlan([CL], null)].map((p) => [p.tier, p.toRequest, p.ruleChangeVerdict?.declared ?? null]), [[GOVERNED_TIER_S, [], 'none'], [GOVERNED_TIER_H, [A1, A2], null]]); + const rcVariants = { + 'Rule-change: yes': [rcPlan([CL], rcRead('Rule-change: yes')), 'declares `Rule-change: yes`'], + 'no Rule-change line': [rcPlan([CL], rcRead(null)), 'carries no `Rule-change:` line'], + 'a settings path': [rcPlan(['.claude/settings.json'], rcRead('Rule-change: none')), 'the harness permission set'], + 'a hooks path beside the wording': [rcPlan([CL, '.claude/hooks/guard-main-checkout.sh'], rcRead('Rule-change: none')), 'a harness hook'], + 'none, the record not read yet': [rcPlan([CL], rcRead('Rule-change: none', null)), 'its contract-review record was not read'], + 'none, the record verifying yes': [rcPlan([CL], rcRead('Rule-change: none', rcRecord('yes'))), 'reads `Rule-change-verified: yes`'], + 'none, the record a FAIL': [rcPlan([CL], rcRead('Rule-change: none', rcRecord('none', { recordLeg: { state: 'not-pass', reason: 'it reads FAIL' } }))), 'does not read a clean PASS'], + 'none, AGENTS.md beside it': [rcPlan([CL, 'AGENTS.md'], rcRead('Rule-change: none')), null], + }; + t('⛔ split plan: `yes`, no line, a settings or hooks path, a record unread, verifying another value or a FAIL, or another Tier H row beside it plans BOTH, and the words name the reason', Object.entries(rcVariants).map(([k, [plan, why]]) => [k, plan.tier, plan.toRequest, why === null || ruleChangeReadingText(plan).includes(why)]), Object.keys(rcVariants).map((k) => [k, GOVERNED_TIER_H, [A1, A2], true]), Object.values(rcVariants).map(([plan]) => ruleChangeReadingText(plan)).join(' | ')); + t('ruleChangeReadable: the split row alone in objectstack is read; another row beside it, a settings/hooks path, or a non-split plan is not — with the words why', [ruleChangeReadable(planPair({ paths: [CL], repo: REPO })), ruleChangeReadable(planPair({ paths: [CL, 'AGENTS.md'], repo: REPO })).why, ruleChangeReadable(planPair({ paths: ['.claude/hooks/x.sh'], repo: REPO })).why?.includes('a harness hook'), ruleChangeReadable(planPair({ paths: ['AGENTS.md'], repo: REPO })), ruleChangeReadable(planPair({ paths: ['ui/.claude/x.md'], repo: REPO }))], [{ read: true, why: null }, 'another governed row is hit too (`AGENTS.md`), so the path-only tier stands', true, { read: false, why: null }, { read: false, why: null }]); + t('the split words: Tier S names the declared value and the ruling; no split row adds nothing', [ruleChangeReadingText(rcPlan([CL], rcRead('Rule-change: none'))), ruleChangeReadingText(planPair({ paths: ['AGENTS.md'], repo: REPO }))], [` · \`.claude/**\` declaration split read: Tier S on \`Rule-change: none\`, verified on the record (${RULE_CHANGE_RULING})`, '']); + + // The run: pr_ready on a `.claude/**` pull through the fake platform — the body off the pull answer, then the record + // off the pull's thread (and the card's) through the guard's own reader. + const rcAnswers = (line, rows, extra = {}) => ({ ...allowed, ...readied, [PULL]: { status: 200, json: armPullJson({ body: RC_BODY(line) }) }, [FILES]: files(CL), [REVIEWS]: reviewsBy(), [REQUEST]: requestedAnswer([A1, A2]), [THREAD(N)]: { status: 200, json: rows }, [THREAD(1)]: { status: 200, json: [] }, ...extra }); + const rcNone = await runPair(ready(), rcAnswers('Rule-change: none', [reviewOfRecord('Rule-change-verified: none')])); + t('⭐ pr_ready on a `.claude/**` pull declaring `Rule-change: none`, its record on the head verifying it: NO request, both threads read, no card label, the row says Tier S on the declaration', [rcNone.exit, writes(rcNone.seen).map((s) => s.call), [THREAD(N), THREAD(1)].every((c) => rcNone.seen.some((s) => s.call === c)), rcNone.seen.some((s) => s.call === CARD_LABELS || s.call === REVIEWS), rcNone.rows[1]?.result.startsWith('governed review: Tier S (`.claude/**`×1)') && rcNone.rows[1]?.result.includes('declaration split read: Tier S on `Rule-change: none`')], [EXIT_OK, [GRAPHQL], true, false, true], rcNone.rows[1]?.result); + const rcYes = await runPair(ready(), rcAnswers('Rule-change: yes', [reviewOfRecord('Rule-change-verified: yes')])); + t('⛔ the control: the same pull declaring `Rule-change: yes` requests BOTH and reads no thread — the body alone decides it', [rcYes.exit, writes(rcYes.seen).map((s) => s.call), writes(rcYes.seen)[1]?.body, rcYes.seen.some((s) => s.call === THREAD(N)), rcYes.rows[1]?.result.includes('declares `Rule-change: yes`')], [EXIT_OK, [GRAPHQL, REQUEST], { reviewers: [A1, A2] }, false, true], rcYes.rows[1]?.result); + const rcUnverified = await runPair(ready(), rcAnswers('Rule-change: none', [reviewOfRecord('Rule-change-verified: yes')])); + t('⛔ `Rule-change: none` over a record that verifies `yes` requests BOTH, the row naming the record', [rcUnverified.exit, writes(rcUnverified.seen).map((s) => s.call), rcUnverified.rows[1]?.result.includes('reads `Rule-change-verified: yes`')], [EXIT_OK, [GRAPHQL, REQUEST], true], rcUnverified.rows[1]?.result); + const rcNoRecord = await runPair(ready(), rcAnswers('Rule-change: none', [])); + t('⛔ `Rule-change: none` with no record on the head yet requests BOTH — the record is what lands it', [rcNoRecord.exit, writes(rcNoRecord.seen).map((s) => s.call), rcNoRecord.rows[1]?.result.includes('no contract-review record names this head')], [EXIT_OK, [GRAPHQL, REQUEST], true], rcNoRecord.rows[1]?.result); + + // ⚖️ hotcrm on the `workflows` row (2026-11-19, card #35321 item 4): a hotcrm workflow pull is Tier H and outside + // split.repos, so the relay requests the approver there — the row naming split.repos — and the control: an + // ungoverned hotcrm path requests nobody (#35612 item 5). + const HOT = 'objectstack-ai/hotcrm'; + const hot = (p) => p.replace(REPO, HOT); + const HOT_WF = '.github/workflows/ci.yml'; + t('hotcrm plan: a workflow path is Tier H and plans both; an ungoverned path plans nobody', [planPair({ paths: [HOT_WF], repo: HOT }), planPair({ paths: ['packages/crm/src/a.ts'], repo: HOT })].map((p) => [p.repoId, p.tier, p.toRequest]), [['hotcrm', GOVERNED_TIER_H, [A1, A2]], ['hotcrm', null, []]]); + const hotRun = await runPair({ ...ready(), repo: HOT }, { [hot(PERM)]: allowed[PERM], ...readied, [hot(PULL)]: pullOf(), [hot(FILES)]: files(HOT_WF), [hot(REVIEWS)]: reviewsBy(), [hot(REQUEST)]: requestedAnswer([A1, A2]) }); + t('⭐ hotcrm-workflow-pull-requests: pr_ready on a hotcrm workflow pull requests BOTH at the hotcrm pull, no compare read, the row naming split.repos', [hotRun.exit, writes(hotRun.seen).map((s) => s.call), writes(hotRun.seen)[1]?.body, hotRun.seen.some((s) => s.call.includes('/compare/')), hotRun.rows[1]?.result.endsWith("· workflow split not read: hotcrm is not in the row's split.repos (objectstack), so the path-only tier stands")], [EXIT_OK, [GRAPHQL, hot(REQUEST)], { reviewers: [A1, A2] }, false, true], hotRun.rows[1]?.result); } // ── the transfer ──────────────────────────────────────────────────────── From f32ad3753011e1b7b8efb2c72934f96ab952f98f Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 21 Nov 2026 23:11:08 +0000 Subject: [PATCH 3/6] 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 --- scripts/pm/check-half-states.mjs | 125 +++++++++++++++++++++++++++++-- 1 file changed, 118 insertions(+), 7 deletions(-) diff --git a/scripts/pm/check-half-states.mjs b/scripts/pm/check-half-states.mjs index 0295859bbc6..4b0a9a678d7 100644 --- a/scripts/pm/check-half-states.mjs +++ b/scripts/pm/check-half-states.mjs @@ -10373,7 +10373,11 @@ export function renderDanglingReferences(report, { markdown = false } = {}) { // Tier H row in a mixed diff keeps the PR here, and an empty or tier-less slice // reads H (fail closed). ⛔ No second copy of which surfaces are which lives in // this file — a register that did not load stands nothing down, and the sweep -// never reaches these rows without it. +// never reaches these rows without it. The `.claude/**` row is S only as the +// register's declaration split reads it (`h43RuleChangeSlice`, #35612): the +// body's `Rule-change:` line off the LIST row, then the PR thread's record on +// the head — so a pull declaring `yes` or nothing, or touching settings or +// hooks, is Tier H here and its maintainer request is owed. // // ## The register is IMPORTED, never restated — and never fatally // @@ -10460,11 +10464,17 @@ export async function loadGovernedRegister(load = (specifier) => import(specifie const recordTier = merges?.GOVERNED_TIER_S; const approvers = guard?.GOVERNED_APPROVERS; const repoIdForSlug = merges?.repoIdForSlug; + // The `.claude/**` declaration split (2026-11-19) and its record line reader: the slice H43 and H48 judge is the + // one the split has read, never the raw row's tier (#35612). + const split = merges?.applyRuleChangeSplit; + const readVerified = merges?.readRuleChangeVerified; if ( typeof matcher !== 'function' || typeof tierOf !== 'function' || typeof recordTier !== 'string' || typeof repoIdForSlug !== 'function' || + typeof split !== 'function' || + typeof readVerified !== 'function' || !Array.isArray(approvers) || approvers.length === 0 ) { @@ -10477,7 +10487,8 @@ export async function loadGovernedRegister(load = (specifier) => import(specifie repo: null, reason: 'the governed register loaded but did not export what this row reads — `governedPathsIn`, ' + - '`landingTierOf`, `GOVERNED_TIER_S`, `repoIdForSlug` and a non-empty `GOVERNED_APPROVERS`. A rename ' + + '`landingTierOf`, `GOVERNED_TIER_S`, `repoIdForSlug`, `applyRuleChangeSplit`, `readRuleChangeVerified` ' + + 'and a non-empty `GOVERNED_APPROVERS`. A rename ' + 'is the likely cause, and this row is the reader that noticed', }; } @@ -10506,7 +10517,7 @@ export async function loadGovernedRegister(load = (specifier) => import(specifie // the register: a guard without it leaves H43's threads UNJUDGED (`h43RecordAuthors`), never the rest unread. const authorTrusted = typeof guard?.recordAuthorTrusted === 'function' ? guard.recordAuthorTrusted : null; const loadRecognisers = typeof guard?.loadRecordRecognisers === 'function' ? guard.loadRecordRecognisers : null; - return { available: true, matcher: (paths) => matcher(paths, repo), tierOf, recordTier, approvers, repo, reason: null, authorTrusted, loadRecognisers }; + return { available: true, matcher: (paths) => matcher(paths, repo), split: (matched, reading) => split(matched, repo, reading), readVerified, tierOf, recordTier, approvers, repo, reason: null, authorTrusted, loadRecognisers }; } catch (err) { return { available: false, @@ -10547,6 +10558,58 @@ export function governedLandsOnRecord(governed, register = GOVERNED_REGISTER) { return register.tierOf(list) === register.recordTier; } +/** + * The matched slice with the `.claude/**` declaration split READ (2026-11-19; #35612), as the queue guard reads it: + * the register's own `applyRuleChangeSplit` on the PR's body off its LIST row and, second, its `record` — so a pull + * that declares `Rule-change: yes`, declares nothing, or touches a settings or hooks path is Tier H and stays in + * H43's and H48's population, and one declaring `none` (or `ruled` with its `Ruling-ref:`) stands down only on a + * record that verifies it (`h43RuleChangeRecord`). `record` null leaves the record stage `pending` — Tier H, and the + * sweep reads the thread and asks again (`h43RuleChangePending`). A register that did not load returns the slice + * as it came: `governedLandsOnRecord` stands nothing down there anyway. Pure. + */ +export function h43RuleChangeSlice(governed, pr, record = null, register = GOVERNED_REGISTER) { + const list = Array.isArray(governed) ? governed : []; + if (!register?.available || typeof register.split !== 'function') return list; + const reading = { measured: true, reason: null, body: typeof pr?.body === 'string' ? pr.body : '', ...(record === null ? {} : { record }) }; + return register.split(list, reading); +} + +/** Does the split's record stage still wait on the PR thread for this slice? Pure. */ +export function h43RuleChangePending(slice) { + return (Array.isArray(slice) ? slice : []).some((s) => s?.ruleChangeVerdict?.recordStage === 'pending'); +} + +/** + * The split's `record` off the PR's own thread — the record H43's hand-off reads (`latestContractReviewOnHead` over + * the comments `authors` admits, the queue guard's binding) with its `Rule-change-verified:` line read by the + * register's reader (`readVerified`), and its record leg as this row can read it: `stands` on a PASS, `not-pass` + * otherwise. Two bounds, stated, both in the direction of standing down where the queue would not (under-report, + * never ask early): only the PR thread is read (a record on the card alone reads `absent`, so Tier H), and the + * record's `Served-tier:` line and signature are not read here. An unread thread or an unloaded binding is NOT + * MEASURED: Tier H. Pure. + */ +export function h43RuleChangeRecord(commentRows, headSha, authors = undefined, register = GOVERNED_REGISTER) { + if (!Array.isArray(commentRows) || authors?.available !== true || typeof register?.readVerified !== 'function') { + return { measured: false, reason: !Array.isArray(commentRows) ? 'the PR thread was not read' : 'the record-author binding or the line reader did not load' }; + } + const trusted = commentRows.filter((row) => authors.admits(row)); + const review = latestContractReviewOnHead(trusted, headSha); + if (review === null) return { measured: true, reason: null, located: 'absent', where: null, id: null, carried: null, ruleChangeVerified: null }; + const row = trusted.find((r) => r?.id === review.id) ?? null; + const passed = review.verdict === 'PASS'; + return { + measured: true, + reason: null, + located: 'found', + where: 'PR', + id: review.id, + carried: null, + ruleChangeCarried: null, + ruleChangeVerified: row === null ? null : register.readVerified(row.body), + recordLeg: { state: passed ? 'stands' : 'not-pass', reason: passed ? null : `its one \`VERDICT:\` line reads ${review.verdict ?? 'nothing (none or two)'}` }, + }; +} + /** * The two fields a PR LIST row already carries. No request buys this, which is * 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 for (const pr of seenPrs.values()) { const files = filesByPr.get(pr.number); if (!files) continue; - const governed = GOVERNED_REGISTER.matcher(files.paths ?? []); + // The `.claude/**` declaration split, read off the body the LIST row carries (#35612): never the raw row's tier. + const governed = h43RuleChangeSlice(GOVERNED_REGISTER.matcher(files.paths ?? []), pr); if (governed.length > 0) governedByPr.set(pr.number, governed); } stats.governedPrs = governedByPr.size; + // A body that declares a seat value leaves the split's record stage pending: ONE thread read per such PR — + // H48's fetch class, cached, and one H48 buys for it anyway while it reads Tier H — then the split asks again. + const splitPending = [...seenPrs.values()].filter((pr) => h43RuleChangePending(governedByPr.get(pr.number))); + let recordAuthors = null; + if (splitPending.length > 0) { + recordAuthors = await h43RecordAuthors(); + if (!recordAuthors.available) stats.governedRecordAuthorsReason = recordAuthors.reason; + } + for (const pr of splitPending) { + const record = h43RuleChangeRecord(await prCommentRowsFor(pr.number), pr.head?.sha, recordAuthors); + governedByPr.set(pr.number, h43RuleChangeSlice(GOVERNED_REGISTER.matcher(filesByPr.get(pr.number)?.paths ?? []), pr, record)); + } + // Oldest-first, because the PR nobody has asked about for longest is the // one the cap must not be the reason nobody hears about. The policy reads // 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 // are both on the thread, nobody is owed a request, so such a PR buys no // review page and fires no row; an unread thread is UNJUDGED. // The PASS is read through the queue guard's author binding (card #33705), loaded once, here, at sweep time. - const recordAuthors = shortOfCoverage.length > 0 ? await h43RecordAuthors() : null; - if (recordAuthors !== null && !recordAuthors.available) stats.governedRecordAuthorsReason = recordAuthors.reason; + if (recordAuthors === null && shortOfCoverage.length > 0) { + recordAuthors = await h43RecordAuthors(); + if (!recordAuthors.available) stats.governedRecordAuthorsReason = recordAuthors.reason; + } const handoffByPr = new Map(); for (const pr of shortOfCoverage) { const rows = await prCommentRowsFor(pr.number); @@ -26348,7 +26427,9 @@ export const SELF_TEST_BATTERIES = Object.freeze({ // 93 → 94: a code span holding the KEY mentions the line and is unreadable; only the value may sit in one. // 94 → 103: the nine verdict-reader rows that landed with no pin of their own — the closed finding that // must END, the FAIL spellings, the fail-safe idiom. The battery registers 126 cases beside these rows. - 'H43 hand-off timing': 103, + // 103 → 109 (#35612): the `.claude/**` declaration split on the slice — stood down on a verified `none`, listed on + // `yes`, the six Tier H shapes, the pending stage, the thread's record reading, an unloaded register, the loader. + 'H43 hand-off timing': 109, // Registered with the seat-patrol rows (#28642), pin just under the count: two // free readings, each with its firing controls and its out-of-scope arms inside; // H71's intake readers (seat title, card labels and epic parent) add five. @@ -33866,6 +33947,36 @@ async function selfTest() { 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'); t43('H43 tier: ⛔ a register that did not load stands NOTHING down', governedLandsOnRecord(TIER_S_43, { available: false, tierOf: null, recordTier: null }), false); t43('H43 tier: …nor does one that loaded without the tier reader', governedLandsOnRecord(TIER_S_43, { available: true, tierOf: null, recordTier: 'S' }), false); + + // ⚖️ The `.claude/**` declaration split (#35612): the slice H43 and H48 judge is the register's split, read off the + // body and the PR thread's record — `Rule-change: yes`, no line or a hooks path is Tier H and listed; a declared + // `none` stands down only on a record that verifies it. Each with its control one step away. + const CL43 = ['.claude/agents/os-dev.md']; + const RC43 = (line) => ({ number: 43, body: `Fixes #1\n\n${line}\n`, head: { sha: HEAD43 } }); + const VERIFIED43 = PASS43.replace('\n\n**VERDICT', '\nRule-change-verified: none\n\n**VERDICT'); + const rcSlice43 = (line, rows = rows43(ACCEPT43, VERIFIED43), paths = CL43) => { + if (!GOVERNED_REGISTER.available) return []; + const first = h43RuleChangeSlice(GOVERNED_REGISTER.matcher(paths), RC43(line)); + return h43RuleChangePending(first) ? h43RuleChangeSlice(GOVERNED_REGISTER.matcher(paths), RC43(line), h43RuleChangeRecord(rows, HEAD43, AUTH43)) : first; + }; + 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,'); + 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', [ + rcSlice43('Clause-②: no'), + rcSlice43('Rule-change: none', rows43(ACCEPT43, VERIFIED43), [...CL43, '.claude/hooks/guard-main-checkout.sh']), + rcSlice43('Rule-change: none', rows43(ACCEPT43, VERIFIED43.replace('Rule-change-verified: none', 'Rule-change-verified: yes'))), + rcSlice43('Rule-change: none', rows43(ACCEPT43, VERIFIED43.replace('**VERDICT: PASS**', '**VERDICT: FAIL**'))), + rcSlice43('Rule-change: none', rows43(ACCEPT43)), + rcSlice43('Rule-change: none', null), + ].map((slice) => governedLandsOnRecord(slice)).join(), 'false,false,false,false,false,false'); + 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'); + 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', (() => { + const found = h43RuleChangeRecord(rows43(ACCEPT43, VERIFIED43), HEAD43, AUTH43); + const failed = h43RuleChangeRecord(rows43(VERIFIED43.replace('**VERDICT: PASS**', '**VERDICT: FAIL**')), HEAD43, AUTH43); + const stranger = h43RuleChangeRecord([{ ...rows43(VERIFIED43)[0], user: { login: 'drive-by-commenter' } }], HEAD43, AUTH43); + 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(); + })(), 'found,none,stands,not-pass,absent,absent,false,false'); + 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'); + 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); 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); // The coverage clause, both branches, cut out of the summary line so only From 43c83caf609419b87f7001a7ec6bb2977e01affe Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 21 Nov 2026 23:15:26 +0000 Subject: [PATCH 4/6] fix(pm): the queue guard's early-warning leg reads the .claude/** declaration off the event payload's body Claude-Session: https://claude.ai/code/session_01QsR2jTeURPvEm465RcoYEC Co-authored-by: Claude --- scripts/pm/check-governed-queue-guard.mjs | 66 ++++++++++++++++++++--- 1 file changed, 60 insertions(+), 6 deletions(-) diff --git a/scripts/pm/check-governed-queue-guard.mjs b/scripts/pm/check-governed-queue-guard.mjs index 09956607f03..b945209467d 100644 --- a/scripts/pm/check-governed-queue-guard.mjs +++ b/scripts/pm/check-governed-queue-guard.mjs @@ -480,9 +480,13 @@ * not have crossed a `.claude/**` hunk (`ruleChangeCarryRefusal`); * - the four guard instruments and this guard's own workflow file are plain * Tier H rows of the register, so nothing here names them; - * - the `pull_request` early-warning leg reads no body, so it names such a - * diff "Tier H UNTIL the PR body is read" (`declarationUnread`) and never - * reddens; `CODEOWNERS` must carry a line for each always-Tier-H path. + * - the `pull_request` early-warning leg reads the body its event payload + * carries (the body as of the event: an edit after it is read by the next + * push or by the queue leg) and no record, so a `yes` or missing line is + * Tier H on the body, a declared seat value is "Tier H UNTIL its record is + * read" (`ruleChangeRecordStagePending`), and a payload with no body names + * the diff "Tier H UNTIL the PR body is read" (`declarationUnread`); it + * never reddens. `CODEOWNERS` must carry a line for each always-Tier-H path. * * ## The FOURTH leg: the SIZE line (#19036, maintainer ruling 2026-09-18) * @@ -724,6 +728,7 @@ import { governedSurfacesFor, governedTierFor, groupHitsByException, + landingTierOf, landsByHumanMerge, lowRiskArmVerdict, mergeWorkflowReadings, @@ -732,6 +737,7 @@ import { recomputeProvenanceFor, readRuleChangeVerified, readWorkflowDiff, + ruleChangeRecordStagePending, renderLiftApprovals, renderLowRiskLines, renderRuleChangeLines, @@ -770,7 +776,9 @@ const SELF_TEST_BATTERIES = Object.freeze({ 'the 2026-09-04 unpinned predicate (the queue leg\'s)': 12, 'decomposition, and the multi-PR group trap': 13, 'the verdict table, both events': 10, - 'the pull_request leg is an EARLY WARNING and never reddens': 6, + // 6 → 9 (#35612): the leg reads the payload's body — a declared `none` waits on its record, `yes` is Tier H on the + // body, no body still waits on the body; an entry with no split row is untouched. + 'the pull_request leg is an EARLY WARNING and never reddens': 9, 'the replay fixtures: the three incidents this guard descends from': 11, '⭐ the ordering guarantee, measured with a spy that THROWS': 7, 'the words a reader acts on (requirement (e))': 26, @@ -1359,6 +1367,8 @@ export function resolveEventContext({ eventName, payload }) { headSha: pull.head.sha, namedPull: Number(pull.number), draft: pull.draft === true, + // The body as of this event (#35612): the early-warning leg reads the `.claude/**` declaration off it. + body: typeof pull.body === 'string' ? pull.body : null, label: `pull request #${pull.number}`, }; } @@ -1774,6 +1784,14 @@ export function renderGuardVerdict(verdict) { ` (GOVERNED_APPROVERS: ${GOVERNED_APPROVERS.join(', ')}). The queue leg reads the body and the record;`, ' `node scripts/pm/check-governed-merges.mjs --pr ` reads them now.', ] + : ruleChangeRecordStagePending(entry.surfaces) + ? [ + ` ⚖️ landing tier: H(人合) UNTIL its record is read — the PR body declares \`Rule-change: ${entry.surfaces.find((s) => s?.ruleChangeVerdict?.declared)?.ruleChangeVerdict.declared ?? '(unread)'}\`, and every governed path`, + ` above lies under ${tierSGlobs()}, which splits by declaration (2026-11-19): it lands Tier S(席内达档 L2 审核落地)`, + ` once a \`## Contract review\` comment on ${REVIEW_OF_RECORD_LOCATION} naming the CURRENT head — \`Served-tier:`, + ' CONTRACT_REVIEW_TIER`, `**VERDICT: PASS**` — reads the same value on its `Rule-change-verified:` line. This leg', + ' reads no record; the queue leg does, and `node scripts/pm/check-governed-merges.mjs --pr ` reads it now.', + ] : entry.tier === TIER_S ? [ ` ⚖️ landing tier: S(席内达档 L2 审核落地) — every governed path above lies under a Tier S surface (${tierSGlobs()}),`, @@ -2249,6 +2267,18 @@ export function readLowRiskTier(entry, repo, pull, { timeline = null, runGit = n return entry; } +/** + * The early-warning leg's reading of the `.claude/**` declaration split off the event payload's body (#35612): the + * entry's split rows re-read with `{ body }` and no record, the tier re-read on the slice. Mutates and returns `entry`. + * Every other row passes through `applyRuleChangeSplit` as the same object. Pure but for the mutation. + */ +export function readPayloadDeclaration(entry, repo, body) { + if (!entry || !Array.isArray(entry.surfaces) || !entry.surfaces.some((s) => s?.ruleChangeVerdict)) return entry; + entry.surfaces = applyRuleChangeSplit(entry.surfaces, repo, { measured: true, reason: null, body: String(body ?? '') }); + entry.tier = landingTierOf(entry.surfaces); + return entry; +} + /** * A reader that answers each key from its first SUCCESSFUL read. A rejection is not cached: the next caller * reads again, so one leg's transient failure is never another leg's verdict. @@ -2689,8 +2719,13 @@ export function ruleChangeRecordVerdict(record, pair, recognisers, declared) { * still governs everything the verdict is derived FROM; it never governed * things the verdict merely mentions. */ -export async function runGuard({ event, repo, rows, fetchReviews, fetchPull, fetchComments, fetchTimeline = null, fetchLabels = null, loadRecognisers = loadRecordRecognisers, lifted = [], runGit = null, baseRef = null }) { +export async function runGuard({ event, repo, rows, fetchReviews, fetchPull, fetchComments, fetchTimeline = null, fetchLabels = null, loadRecognisers = loadRecordRecognisers, lifted = [], runGit = null, baseRef = null, pullBody = null }) { const { governed, unattributed } = decomposeGovernedWork(rows, assertGovernedRepo(repo, 'runGuard')); + // The early-warning leg reads the `.claude/**` declaration off the body its event payload carries (#35612); no record + // is read here, so a declared seat value stays Tier H with its record stage pending and the words say so. + if (event === EVENT_PULL_REQUEST && typeof pullBody === 'string') { + for (const entry of governed) readPayloadDeclaration(entry, repo, pullBody); + } if (governed.length === 0 && unattributed.length === 0) { return guardVerdict({ event, repo, governed, unattributed, apiCalls: 0, lifted }); } @@ -4135,7 +4170,7 @@ async function main() { const fetchLabels = makeLabelReader(reader); const runGit = (args, input) => git(repoRoot, args, input); - const verdict = await runGuard({ event: context.event, repo, rows, fetchReviews, fetchPull, fetchComments, fetchTimeline, fetchLabels, lifted, runGit, baseRef: context.baseSha ?? null }); + const verdict = await runGuard({ event: context.event, repo, rows, fetchReviews, fetchPull, fetchComments, fetchTimeline, fetchLabels, lifted, runGit, baseRef: context.baseSha ?? null, pullBody: context.body ?? null }); // The SIZE leg (#19036): every queued pull request, through the same pull // reader the governed leg reads heads with. `merge_group` only, '' on the // other leg, so the `pull_request` output is byte-identical to what it was. @@ -4695,6 +4730,25 @@ export async function selfTest() { /`Rule-change: none`/.test(warnedSText) && /`Rule-change-verified:`/.test(warnedSText) && /declaration split .*NOT MEASURED/.test(warnedSText) && !/No review of record\n? *substitutes here/.test(warnedSText), warnedSText, ); + // #35612: the early-warning leg reads the body its event payload carries — `yes` is Tier H on the body, a declared + // `none` is Tier H UNTIL its record is read (this leg reads none), and the control: no body is still "UNTIL the PR + // body is read". End to end through `runGuard` with the payload body, and the context carries the body. + const payloadRun = async (body) => runGuard({ event: 'pull_request', repo: REPO, rows: [row(9529, ['.claude/agents/os-dev.md'])], fetchReviews: async () => [], fetchPull: async () => { throw new Error('the pull_request leg reads no pull'); }, fetchComments: async () => { throw new Error('the pull_request leg reads no thread'); }, pullBody: body }); + const payloadNone = await payloadRun('Fixes #1\n\nRule-change: none\n'); + const payloadYes = await payloadRun('Fixes #1\n\nRule-change: yes\n'); + const payloadUnread = await payloadRun(null); + const [noneText, yesText, unreadText] = [payloadNone, payloadYes, payloadUnread].map(renderGuardVerdict); + assert('⭐ #35612 the-early-warning-reads-the-payload-body-a-declared-none-is-Tier-H-UNTIL-its-record-is-read-and-names-the-value', + payloadNone.exitCode === EXIT_CLEAR && payloadNone.entries[0].tier === TIER_H && !declarationUnread(payloadNone.entries[0]) && ruleChangeRecordStagePending(payloadNone.entries[0].surfaces) && + /landing tier: H\(人合\) UNTIL its record is read — the PR body declares `Rule-change: none`/.test(noneText) && /`Rule-change-verified:`/.test(noneText) && !/UNTIL the PR body is read/.test(noneText), + noneText); + assert('⛔ #35612 a-payload-body-declaring-yes-is-Tier-H-on-the-body-with-the-maintainers-landing-and-the-control-no-body-still-reads-UNTIL-the-PR-body-is-read', + payloadYes.entries[0].tier === TIER_H && !ruleChangeRecordStagePending(payloadYes.entries[0].surfaces) && /declares `Rule-change: yes`/.test(yesText) && /authorized APPROVED review/.test(yesText) && !/UNTIL/.test(yesText) && + declarationUnread(payloadUnread.entries[0]) && /UNTIL the PR body is read/.test(unreadText) && + resolveEventContext({ eventName: 'pull_request', payload: { pull_request: { number: 1, body: 'Rule-change: none', base: { sha: 'b'.repeat(40) }, head: { sha: 'h'.repeat(40) } } } }).body === 'Rule-change: none' && + resolveEventContext({ eventName: 'pull_request', payload: { pull_request: { number: 1, body: null, base: { sha: 'b'.repeat(40) }, head: { sha: 'h'.repeat(40) } } } }).body === null, + yesText); + assert('#35612 readPayloadDeclaration-leaves-an-entry-with-no-split-row-as-it-was', (() => { const e = decomposeGovernedWork([row(9530, ['AGENTS.md'])], REPO).governed[0]; const before = e.surfaces; return readPayloadDeclaration(e, REPO, 'Rule-change: none').surfaces === before && e.tier === TIER_H; })()); const warnedHText = renderGuardVerdict(warnedV); assert('and-names-Tier-H-and-the-approval-it-waits-for-with-no-Tier-S-block', /landing tier: H/.test(warnedHText) && /authorized APPROVED review/.test(warnedHText) && !/Tier S \(/.test(warnedHText), warnedHText); // The PR #25965 shape end to end on this leg: the warning names the PAYLOAD's From 9e4e6762618ec75c5140b8f45c27be54db353793 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 21 Nov 2026 23:15:58 +0000 Subject: [PATCH 5/6] fix(pm): the owed-review list finds a narrowing declared on the Metadata-protocol line alone, as the queue leg does Claude-Session: https://claude.ai/code/session_01QsR2jTeURPvEm465RcoYEC Co-authored-by: Claude --- scripts/pm/check-owed-reviews.mjs | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/scripts/pm/check-owed-reviews.mjs b/scripts/pm/check-owed-reviews.mjs index 8c8ad24ec49..24cc5f9587f 100644 --- a/scripts/pm/check-owed-reviews.mjs +++ b/scripts/pm/check-owed-reviews.mjs @@ -111,7 +111,7 @@ import process from 'node:process'; import { isEntrypoint } from '../invoked-as.mjs'; import { cardIntakeKeys, CONTRACT_REVIEW_HEADING_MARKER, contractReviewVerdictLines, latestMarkedComment, readSignatureLine, seatIntakeKeys } from './check-half-states.mjs'; import { repoIdForSlug } from './check-governed-merges.mjs'; -import { GOVERNED_APPROVERS, recordAuthorTrusted, recordTrustedAuthors } from './check-governed-queue-guard.mjs'; +import { GOVERNED_APPROVERS, NARROWING_FACE_LINE, narrowingDeclarationsIn, recordAuthorTrusted, recordTrustedAuthors } from './check-governed-queue-guard.mjs'; import { FLEET_BOT_LOGIN } from './check-handover.mjs'; import { readClause2Line } from './clause2-line.mjs'; import { parseSeat } from './fleet-roster.mjs'; @@ -197,17 +197,25 @@ export function parseArgs(argv) { * path limbs are `reviewFace`'s `hits` (the queue guard's own reading), the * declaration limbs are `readClause2Line` on the PR body, and the face named * beside them is `reviewFace`'s answer for the same inputs. + * + * ⭐ A narrowing is found the way the queue's narrowed leg finds one (`narrowingDeclarationsIn`, imported): a + * `Metadata-protocol: narrowed` line counts as well as a `Clause-②:` narrowing arm, and the face is then read with + * the narrowing spelling handed in first (`NARROWING_FACE_LINE`), exactly as that leg holds the record — so a + * narrowing declared on the protocol line alone, on a diff with no schema and no governed path, is listed at the + * narrowing face's tier, never missed (N4 of #35610). One bound, stated: this list reads the body alone; the queue + * leg also reads the changesets its commits touch. */ export function owedFace(pull, repo = DEFAULT_REPO) { const paths = Array.isArray(pull?.files) ? pull.files : []; const body = String(pull?.body ?? ''); + const narrowing = narrowingDeclarationsIn(body).length > 0; // `reviewFace` takes the register's repository ID; an unregistered slug reaches it as null and is refused there, loudly. - const face = reviewFace(paths, repoIdForSlug(repo), { declaredOn: [body] }); + const face = reviewFace(paths, repoIdForSlug(repo), { declaredOn: narrowing ? [NARROWING_FACE_LINE, body] : [body] }); const limbs = []; if (face.hits.schema.length > 0) limbs.push('schema'); if (face.hits.rules.length > 0) limbs.push('rules'); const declared = readClause2Line(body); - if (declared?.kind === 'declared' && declared.arm === 'narrowing') limbs.push('narrowing'); + if (narrowing) limbs.push('narrowing'); else if (declared?.kind === 'declared' && declared.value === 'yes') limbs.push('declaration'); else if (declared?.kind === 'malformed') limbs.push('clause2-unreadable'); if (labelNames(pull).includes(WAITING_LABEL)) limbs.push('label'); @@ -610,7 +618,8 @@ let selfTestReachedVerdict = false; const SELF_TEST_BATTERIES = Object.freeze({ 'arguments: modes and every refusal': 6, - 'the owed face: paths, the Clause-② line, the label — drafts included, nothing else owes': 9, + // 9 → 11 (N4 of #35610): a narrowing on the `Metadata-protocol:` line alone owes the narrowing face; its control. + 'the owed face: paths, the Clause-② line, the label — drafts included, nothing else owes': 11, // 8 → 13 (#33705): the queue guard's author binding (an untrusted PASS unread, unable to shadow a trusted FAIL, an // approver's read) and its counted verdict reading (two lines `ambiguous`, an inline word alone `unstated`). 'the record: on this head (by whom, as stated), on an earlier head, none, unjudged': 13, @@ -690,6 +699,10 @@ export function selfTest() { t('a published schema path owes the schema face', owedFace(pull({ files: ['packages/spec/src/data/field.zod.ts'] })).limbs.includes('schema')); t('⭐ a `Clause-②: no (narrowing)` body owes with no contract path (the narrowing face)', owedFace(pull({ files: ['ui/packages/plugin-ai/package.json'], body: 'Clause-②: no (narrowing)\nMetadata-protocol: narrowed' })).limbs.join() === 'narrowing'); t('a `Clause-②: yes` body owes the declaration face', owedFace(pull({ files: ['packages/runtime/src/x.ts'], body: 'Clause-②: yes\nMetadata-protocol: added' })).limbs.join() === 'declaration'); + // N4 of #35610: a narrowing declared on the `Metadata-protocol:` line alone owes, at the narrowing face's tier — as + // the queue's narrowed leg demands; the control, the same body declaring `none`, owes nothing. + t('⭐ a narrowing declared on `Metadata-protocol: narrowed` alone, beside a bare `Clause-②: no`, owes the narrowing face — as the queue leg reads it', ((r, q) => r.limbs.join() === 'narrowing' && r.face === q.face && r.tierName === q.tierName && r.face !== null)(owedFace(pull({ files: ['packages/runtime/src/x.ts'], body: 'Clause-②: no\nMetadata-protocol: narrowed' })), owedFace(pull({ files: ['packages/runtime/src/x.ts'], body: 'Clause-②: no (narrowing)\nMetadata-protocol: narrowed' })))); + t('…the control: the same body with `Metadata-protocol: none` owes nothing, and the unfilled template menu declares nothing', owedFace(pull({ files: ['packages/runtime/src/x.ts'], body: 'Clause-②: no\nMetadata-protocol: none' })).limbs.length === 0 && owedFace(pull({ files: ['packages/runtime/src/x.ts'], body: 'Clause-②: no\nMetadata-protocol: added | narrowed | semantic | none' })).limbs.length === 0); t('a malformed `Clause-②:` line is listed, never dropped', owedFace(pull({ files: ['packages/runtime/src/x.ts'], body: 'Clause-②: maybe' })).limbs.join() === 'clause2-unreadable'); t('⭐ the waiting label alone owes', owedFace(pull({ files: ['packages/runtime/src/x.ts'], body: 'Clause-②: no', labels: [{ name: WAITING_LABEL }] })).limbs.join() === 'label'); t('⛔ an ordinary runtime diff declaring `Clause-②: no` owes NOTHING — no row', row({ files: ['packages/runtime/src/x.ts'], body: 'Clause-②: no' }) === null); From 101fd543d0d8e5cf66e8b944dca3b4d9403ff745 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 21 Nov 2026 23:16:19 +0000 Subject: [PATCH 6/6] docs(pm): the dev file says exactly one line leads with Rule-change, and the skills-lane exception names the guard instruments Claude-Session: https://claude.ai/code/session_01QsR2jTeURPvEm465RcoYEC Co-authored-by: Claude --- .claude/agents/os-dev.md | 2 +- .claude/skills/pm-dispatch/SKILL.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.claude/agents/os-dev.md b/.claude/agents/os-dev.md index a3a0b7970fa..0a06de6a678 100644 --- a/.claude/agents/os-dev.md +++ b/.claude/agents/os-dev.md @@ -276,7 +276,7 @@ model: opus - 认领的 `Clause-②:`、`Metadata-protocol:` 两行照抄进 PR 正文行首;无则零写,⛔ 不自造。 - 两行同抄进 changeset 正文行首;`Check Changeset` 读 PR 正文:kind 即 `minor`,`none` 即 `patch`。 - 种类非 `none` 或带 `(narrowing)` ⇒ 按 diff 加写 `Skills-docs:` 行;拼法与分工住认领模板。 -- diff 触根 `.claude/**` ⇒ PR 正文写行首 `Rule-change:` 行,按 diff 自判。 +- diff 触根 `.claude/**` ⇒ PR 正文恰一行首 `Rule-change:`,按 diff 自判。 - `none` 未改车队规则(agent 不经维护者可做什么、做什么与先后、什么须交他);`yes` 改了;`ruled` 照抄已裁条文,写行首 `Ruling-ref:` 引维护者原话、出处、时间。缺行同 `yes`:Tier H。 - ⛔ 永不 `Fixes` 一张还在决策箱的卡:合并会静默关掉它,而收件箱过滤只读 open。 - ⛔ 不写否定式的关单句,它照样关掉点名的卡:解析器无视否定,只匹配关键词 + `#`。 diff --git a/.claude/skills/pm-dispatch/SKILL.md b/.claude/skills/pm-dispatch/SKILL.md index dab47a467b2..b228d182aea 100644 --- a/.claude/skills/pm-dispatch/SKILL.md +++ b/.claude/skills/pm-dispatch/SKILL.md @@ -205,7 +205,7 @@ PM 的工作是循环:选卡 → 认领 → 派发 → 收集 → L1 审核 → - `pr_create` 派不请;`pr_ready` 只补交棒漏;非例外 head 移 ⇒ 撤挂回等;脱中继 PR 自读请/派。 - 速读「要你做什么」求批点名 PASS 评论 id+`Head-sha`;无 PASS ⇒ 写 contract review owed 不求批。 - ④ 轮报单列 awaiting a human merge 并现读请审人;⛔ 未请审不在 chat 报「等你批」,先补请。 -- skills 车道自有 PR:纯代码面如 `scripts/pm/` 由本席自读(清单不减)后落地,守卫除外。 +- skills 车道自有 PR:纯代码面如 `scripts/pm/` 由本席自读(清单不减)后落地,守卫仪器除外。 - Tier S = `Rule-change: none`/`ruled` 记录核过的 `.claude/**`+下行面,余皆 H;达档 PASS 后 ready→入队。 - 本仓 workflows 读 `readWorkflowDiff`(发布面/C2/拒读⇒H),技能与只增 ADR `lowRiskArmVerdict`,未读⇒H。 - 入队资格:每 check 绿或预期 skip,⛔ 非必查子集;名单 check-expected-skips.mjs 只判 objectstack。