Skip to content

Commit 7c84b66

Browse files
committed
fix(pm): the arm audit settles a measured Tier H past an unread input, names an edited carry hop, and the verifier refuses hand-offs in any spelling
The governed-merges arm leg no longer reads NOT MEASURED where its measured inputs alone settle Tier H (the guard's own arm re-read with each unread input answered the way that gives it no reason); an unread labels list is an unread input; an edited Regen-provenance hop that breaks a carry is named on the BREACH reason; the guard's changeset read spelling is pinned to the deletion exception; a same-second dismissal is pinned as is. The review-tier verifier refuses camelCase and hyphenated hand-off verbs and hand-offs under other verbs (a copilot review, a session created, run or interrupted). Claude-Session: https://claude.ai/code/session_01ADHkmRnBQzshoJUDvT6keE Co-authored-by: Claude <noreply@anthropic.com>
1 parent 895783a commit 7c84b66

2 files changed

Lines changed: 186 additions & 10 deletions

File tree

‎scripts/pm/check-governed-merges.mjs‎

Lines changed: 147 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4463,6 +4463,8 @@ export async function loadArmReaders(load = (specifier) => import(specifier)) {
44634463
* the record leg would have read had it not been edited, on every BREACH reason (N9, N10); a recogniser set with no
44644464
* trusted-author list is `not-measured` (N11), and the comments the author binding dropped are counted in the
44654465
* guard's own words (`ignoredAuthorLines`, N11).
4466+
* #33765: an unread labels list is unread too (N-b), and a Tier H the measured inputs settle alone stays `tier-h`
4467+
* with its unread inputs named (N-a, `armSettledWithoutUnread`); an edited `Regen-provenance:` hop is named (N-e).
44664468
* The carry test's `baseRef` is the landed commit's first parent (N6): between it and the merge group's base lie
44674469
* only the squash commits of entries ahead in the same group, which no queued head contains, so `git merge-base`
44684470
* of either base with a head names the same commit and the carry reads the same.
@@ -4504,8 +4506,15 @@ export async function readArmLanding(entry, { paths, repo, readers, fetchers, ru
45044506
guard.readLowRiskTier(work, repo, head, { timeline: { measured: true, reason: null, events }, runGit: armGit });
45054507
if (!guard.landsOnLowRiskArm(work)) {
45064508
const reasons = work.surfaces.find((s) => s?.lowRiskVerdict)?.lowRiskVerdict?.reasons ?? [];
4507-
const unread = armReadsNotMeasured(gitFailures, pull.fork, runGit);
4508-
if (unread.length > 0) return unmeasured(`the low-risk arm could not read ${unread.join('; ')}, so its Tier H cannot say how the queue read it (arm: ${reasons.join('; ') || 'no reason recorded'})`);
4509+
// #33765 N-b: an unread labels list is an unread input too, though no git read failed.
4510+
const inputs = armUnreadInputs(gitFailures, pull.fork, runGit, pull.labels);
4511+
if (inputs.length > 0) {
4512+
const unread = inputs.map((u) => u.words);
4513+
// #33765 N-a: a reason the measured inputs give on their own settles Tier H whatever the unread ones say.
4514+
const settled = armSettledWithoutUnread({ guard, entry, paths, repo, head, events, runGit, inputs });
4515+
if (settled) return { state: 'tier-h', headSha, reasons: settled, unread };
4516+
return unmeasured(`the low-risk arm could not read ${unread.join('; ')}, so its Tier H cannot say how the queue read it (arm: ${reasons.join('; ') || 'no reason recorded'})`);
4517+
}
45094518
return { state: 'tier-h', headSha, reasons };
45104519
}
45114520
if (sizeLimbFires(entry.size)) return { state: 'tier-h', headSha, reasons: [`the landed diff crosses the ${HUMAN_MERGE_LINE_THRESHOLD}-line human-merge line`] };
@@ -4533,7 +4542,9 @@ export async function readArmLanding(entry, { paths, repo, readers, fetchers, ru
45334542
const enqueue = guard.authorizedEnqueueVerdict(guard.enqueuerFromTimeline(events.filter((e) => before(e?.created_at))));
45344543
if (enqueue.state === 'authorized') return { state: 'cleared', by: 'enqueue', who: [enqueue.login], headSha };
45354544
if (recognisers?.available !== true) return unmeasured(recognisers?.reason ?? 'the record recognisers were not loaded');
4536-
// N11: no trusted-author list is a reading that is missing, not a thread with no record in it.
4545+
// N11: no trusted-author list is a reading that is missing, not a thread with no record in it. Defensive only
4546+
// (#33765 N-c): the guard's `loadRecordRecognisers` answers `available: false` rather than a set without the
4547+
// list, and a list it builds always holds the relay's login, so only a hand-built recogniser set reaches here.
45374548
if (!Array.isArray(recognisers.trustedAuthors) || recognisers.trustedAuthors.length === 0) {
45384549
return unmeasured('the record recognisers carry no trusted-author list, so no comment can be read as a record');
45394550
}
@@ -4578,6 +4589,17 @@ export async function readArmLanding(entry, { paths, repo, readers, fetchers, ru
45784589
try {
45794590
const would = guard.recordVerdict({ pair: unedited, recognisers, cardNote });
45804591
if (would?.id != null && editedAfter.has(would.id)) edited = `; ${editedAfter.get(would.id)} was edited after the landing, so it does not count (it is the record this leg would otherwise have read)`;
4592+
// #33765 N-e: a record the unedited threads reach through a carry also rests on its `Regen-provenance:` hops.
4593+
// An edited row is named when leaving it out of the unedited threads changes what the leg would have read.
4594+
if (would?.carriedFrom) {
4595+
const same = (v) => v?.state === would.state && v?.id === would.id && v?.carriedFrom === would.carriedFrom;
4596+
for (const [id, where] of editedAfter) {
4597+
if (id === would.id) continue;
4598+
const without = { ...unedited };
4599+
for (const thread of recognisers.threads) if (Array.isArray(without[thread.rows])) without[thread.rows] = without[thread.rows].filter((r) => r?.id !== id);
4600+
if (!same(guard.recordVerdict({ pair: without, recognisers, cardNote }))) edited += `; ${where} was edited after the landing, so it does not count (it is a \`Regen-provenance:\` hop of the carry this leg would otherwise have read)`;
4601+
}
4602+
}
45814603
} catch { /* a name only; the BREACH stands without it */ }
45824604
}
45834605
const reason = (record.state === 'absent' ? `no \`## Contract review\` record on its head (${record.readSummary})`
@@ -4591,7 +4613,9 @@ export async function readArmLanding(entry, { paths, repo, readers, fetchers, ru
45914613
* The reviews as they stood when the commit landed (#33729 N8): a review GitHub now reads DISMISSED, whose
45924614
* dismissal the timeline dates at or after the landing, is put back in the state the timeline's `review_dismissed`
45934615
* event names (`dismissed_review.state`). A dismissal with no such event, no review id or no readable time stays
4594-
* DISMISSED: toward BREACH, never toward cleared. Pure.
4616+
* DISMISSED: toward BREACH, never toward cleared. A dismissal in the same second as the landing is read as after
4617+
* it and restores the approval (#33765 N-g, pinned as is): GitHub's times are whole seconds, so that order is
4618+
* unknowable, and the restored approval is the maintainer's own, so the entry reads cleared, never `pass`. Pure.
45954619
*/
45964620
export function reviewsAsLanded(reviews, events, landed) {
45974621
const restored = new Map();
@@ -4614,23 +4638,90 @@ export function reviewsAsLanded(reviews, events, landed) {
46144638
* that commit answering nothing proves the deletion, so it is a measured H; any other answer, or a throw, is unread.
46154639
* Pure but for `runGit`.
46164640
*/
4617-
export function armReadsNotMeasured(gitFailures, fork, runGit) {
4641+
export function armReadsNotMeasured(gitFailures, fork, runGit, labels = []) {
4642+
return armUnreadInputs(gitFailures, fork, runGit, labels).map((u) => u.words);
4643+
}
4644+
4645+
/**
4646+
* The guard's changeset read, `git show SHA:PATH`, as the deleted-changeset exception and the favourable answer
4647+
* both key on it (#33765 N-f). The self-test records the argv the guard really sends and holds it to this.
4648+
*/
4649+
export const ARM_CHANGESET_SHOW = /^([0-9a-f]{7,40}):(.+)$/;
4650+
4651+
/** `armReadsNotMeasured`'s inputs, each `{ words, argv }` (`argv` null for a non-git input). Pure but for `runGit`. */
4652+
function armUnreadInputs(gitFailures, fork, runGit, labels) {
46184653
const unread = [];
46194654
for (const { argv, why } of Array.isArray(gitFailures) ? gitFailures : []) {
4620-
const shown = argv?.[0] === 'show' ? /^([0-9a-f]{7,40}):(.+)$/.exec(String(argv[1] ?? '')) : null;
4655+
const shown = argv?.[0] === 'show' ? ARM_CHANGESET_SHOW.exec(String(argv[1] ?? '')) : null;
46214656
if (shown) {
46224657
let listed = null;
46234658
try {
46244659
listed = String(runGit(['ls-tree', '-z', '--name-only', shown[1], '--', shown[2]]));
46254660
} catch { /* unread */ }
46264661
if (listed === '') continue;
46274662
}
4628-
unread.push(`\`git ${(argv ?? []).slice(0, 2).join(' ')}\` (${why})`);
4663+
unread.push({ words: `\`git ${(argv ?? []).slice(0, 2).join(' ')}\` (${why})`, argv });
46294664
}
4630-
if (!fork || fork.measured !== true) unread.push('its head repository (the fork predicate)');
4665+
if (!fork || fork.measured !== true) unread.push({ words: 'its head repository (the fork predicate)', argv: null });
4666+
if (!Array.isArray(labels)) unread.push({ words: 'its labels', argv: null });
46314667
return unread;
46324668
}
46334669

4670+
/** A clean low-risk changeset: the answer to an unread `git show SHA:PATH` that gives the arm no reason. */
4671+
const ARM_FAVOURABLE_CHANGESET = "---\n'@objectstack/skills': patch\n---\n\nClause-②: no\nMetadata-protocol: none\n";
4672+
4673+
/**
4674+
* The answer to one of the arm's git reads that gives the arm no reason (#33765 N-a): a clean changeset for the
4675+
* guard's `show SHA:PATH`, and every path a modified regular file for its `diff-tree`; null for any other read,
4676+
* which then cannot be answered the arm's way. Pure.
4677+
*/
4678+
export function favourableArmGitRead(argv, paths) {
4679+
if (argv?.[0] === 'show' && ARM_CHANGESET_SHOW.test(String(argv[1] ?? ''))) return ARM_FAVOURABLE_CHANGESET;
4680+
if (argv?.[0] === 'diff-tree') return (Array.isArray(paths) ? paths : []).map((p) => `:100644 100644 ${'0'.repeat(40)} ${'0'.repeat(40)} M\0${p}\0`).join('');
4681+
return null;
4682+
}
4683+
4684+
/**
4685+
* Does the arm read H on its measured inputs alone (#33765 N-a)? The guard's own arm re-reads a fresh
4686+
* decomposition with every unread input answered the way that gives the arm no reason: the git read by
4687+
* `favourableArmGitRead`, the fork predicate as no fork, the labels as none. The arm's verdict is a conjunction,
4688+
* so if it still reads H, the reasons it gives come from measured inputs and settle Tier H: those reasons, or null
4689+
* (a read with no such answer, a read that fails anew, or an arm that would read S), which stays NOT MEASURED.
4690+
* Never throws.
4691+
*/
4692+
function armSettledWithoutUnread({ guard, entry, paths, repo, head, events, runGit, inputs }) {
4693+
try {
4694+
const answers = new Map();
4695+
for (const { argv } of inputs) {
4696+
if (!argv) continue;
4697+
const answer = favourableArmGitRead(argv, paths);
4698+
if (answer === null) return null;
4699+
answers.set(JSON.stringify(argv), answer);
4700+
}
4701+
const [work] = guard.decomposeGovernedWork([{ pr: entry.pr, sha: entry.sha, subject: entry.subject, paths }], repo).governed;
4702+
if (!work) return null;
4703+
const failures = [];
4704+
const git = (argv) => {
4705+
const key = JSON.stringify(argv);
4706+
if (answers.has(key)) return answers.get(key);
4707+
try {
4708+
return runGit(argv);
4709+
} catch (error) {
4710+
failures.push({ argv, why: String(error?.message ?? error).split('\n')[0] });
4711+
throw error;
4712+
}
4713+
};
4714+
const fork = head.fork?.measured === true ? head.fork : { measured: true, isFork: false };
4715+
const labels = Array.isArray(head.labels) ? head.labels : [];
4716+
guard.readLowRiskTier(work, repo, { ...head, fork, labels }, { timeline: { measured: true, reason: null, events }, runGit: git });
4717+
if (guard.landsOnLowRiskArm(work) || armUnreadInputs(failures, fork, runGit, labels).length > 0) return null;
4718+
const reasons = work.surfaces.find((s) => s?.lowRiskVerdict)?.lowRiskVerdict?.reasons ?? [];
4719+
return reasons.length > 0 ? reasons : null;
4720+
} catch {
4721+
return null;
4722+
}
4723+
}
4724+
46344725
/** The arm cell under a sweep row, or ''. Pure. */
46354726
export function armCell(entry) {
46364727
const a = entry?.arm;
@@ -4642,7 +4733,8 @@ export function armCell(entry) {
46424733
if (a.state === 'cleared') return `\n low-risk arm: Tier S${head}, cleared by an authorized ${a.by === 'review' ? 'approval' : 'enqueue'} (${(a.who ?? []).join(', ')}) before the record leg — the maintainer's merge`;
46434734
if (a.state === 'not-measured') return `\n ⚠️ low-risk arm NOT MEASURED${head} — ${a.reason}; listed here, unjudged`;
46444735
const reasons = a.reasons ?? [];
4645-
return `\n low-risk arm: Tier H${head} — ${reasons.slice(0, 2).join('; ') || 'no reason recorded'}${reasons.length > 2 ? ` (+${reasons.length - 2} more)` : ''}`;
4736+
const unread = (a.unread ?? []).length > 0 ? `; settled without the unread ${a.unread.join('; ')}` : '';
4737+
return `\n low-risk arm: Tier H${head} — ${reasons.slice(0, 2).join('; ') || 'no reason recorded'}${reasons.length > 2 ? ` (+${reasons.length - 2} more)` : ''}${unread}`;
46464738
}
46474739

46484740
/**
@@ -9183,6 +9275,52 @@ async function selfTest() {
91839275
return v?.state === 'breach' && v.ignored?.length === 1 && cell.includes('some-commenter') && cell.includes('#33541') ? true : JSON.stringify(v);
91849276
})() === true);
91859277

9278+
// #33765 N-a: a git read that failed, beside a reason the measured inputs give alone, is a measured Tier H.
9279+
const diffTreeThrows = gitWith((a) => { if (a[0] === 'diff-tree') throw new Error('fatal: bad object'); });
9280+
assert('⭐ #33765-N-a-an-unread-diff-tree-beside-a-security-label-is-a-measured-Tier-H-naming-what-it-did-not-read', await (async () => {
9281+
const v = await run({ git: diffTreeThrows, pull: { labels: ['security'] } });
9282+
return v?.state === 'tier-h' && v.reasons.some((r) => /`security` label/.test(r)) && !v.reasons.some((r) => /status and mode/.test(r)) &&
9283+
v.unread?.some((u) => /git diff-tree/.test(u)) && armCell({ arm: v }).includes('settled without the unread `git diff-tree') ? true : JSON.stringify(v);
9284+
})() === true);
9285+
assert('⭐ #33765-N-a-an-unread-changeset-beside-a-Clause-2-yes-body-and-an-unread-fork-beside-a-fork-free-reason-are-Tier-H',
9286+
await tierH({ git: gitWith((a) => { if (a[0] === 'show') throw new Error('fatal: unable to read'); if (a[0] === 'ls-tree') return `${CS}\0`; }), pull: { body: 'Fixes #69\n\nClause-②: yes\nMetadata-protocol: none\n' } }, /Clause-②/) === true &&
9287+
await tierH({ pull: { fork: { measured: false, isFork: false }, labels: ['security'] } }, /`security` label/) === true);
9288+
assert('⛔ #33765-N-a-control-an-unread-read-that-alone-keeps-the-arm-H-stays-NOT-MEASURED-never-measured-S',
9289+
await unmeasured({ git: diffTreeThrows }, /could not read `git diff-tree/) === true &&
9290+
await unmeasured({ git: gitWith((a) => { if (a[0] === 'diff-tree') throw new Error('fatal: bad object'); if (a[0] === 'show') throw new Error('fatal: unable to read'); if (a[0] === 'ls-tree') return `${CS}\0`; }) }, /could not read `git show.*`git diff-tree/) === true);
9291+
assert('⛔ #33765-N-a-an-unread-read-the-arm-has-no-favourable-answer-for-stays-NOT-MEASURED', favourableArmGitRead(['rev-parse', 'x'], [SK]) === null &&
9292+
favourableArmGitRead(['show', `${LANDED}:${CS}`], [SK]) !== null && favourableArmGitRead(['diff-tree', LANDED], [SK]).includes(`M\0${SK}\0`));
9293+
// #33765 N-b: an unread labels list is an unread input, though no git read failed.
9294+
assert('⛔ #33765-N-b-an-unread-labels-list-alone-is-NOT-MEASURED-not-tier-h', await unmeasured({ pull: { labels: null } }, /could not read its labels/) === true &&
9295+
armReadsNotMeasured([], { measured: true }, runGit, null).includes('its labels') && armReadsNotMeasured([], { measured: true }, runGit).length === 0);
9296+
assert('#33765-N-b-an-unread-labels-list-beside-a-Clause-2-yes-body-is-a-measured-Tier-H', await tierH({ pull: { labels: null, body: 'Fixes #69\n\nClause-②: yes\nMetadata-protocol: none\n' } }, /Clause-②/) === true);
9297+
// #33765 N-f: the argv the guard really sends for a changeset is the spelling the deletion exception and the
9298+
// favourable answer key on; a renamed read reds here instead of folding the exception into NOT MEASURED.
9299+
assert('⛔ #33765-N-f-the-guards-changeset-and-status-reads-are-the-spellings-the-arm-keys-on', await (async () => {
9300+
const sent = [];
9301+
await run({ git: (a) => { sent.push(a); return runGit(a); } });
9302+
const shows = sent.filter((a) => a[0] === 'show');
9303+
const trees = sent.filter((a) => a[0] === 'diff-tree');
9304+
return shows.length > 0 && trees.length > 0 && shows.every((a) => a.length === 2 && ARM_CHANGESET_SHOW.test(a[1]) && a[1] === `${LANDED}:${CS}`) &&
9305+
[...shows, ...trees].every((a) => favourableArmGitRead(a, [SK, CS]) !== null) ? true : JSON.stringify(sent);
9306+
})() === true);
9307+
// #33765 N-e: an edited `Regen-provenance:` hop that breaks the carry is named on the BREACH reason.
9308+
const OLD = 'd'.repeat(40);
9309+
const HOP = (over = {}) => ({ id: 905, created_at: '2026-11-15T04:10:00Z', user: { login: RELAY }, body: `Regen-provenance: 900 · \`${OLD}\` → \`${HEAD}\` · \`git diff --name-only\` → (empty)`, ...over });
9310+
const carryGit = gitWith((a) => {
9311+
if (a[0] === 'diff') return '';
9312+
if (a[0] === 'rev-parse' && String(a[1]).endsWith('^{commit}')) return `${String(a[1]).slice(0, -'^{commit}'.length)}\n`;
9313+
});
9314+
assert('#33765-N-e-control-a-record-carried-over-an-unedited-hop-is-PASS', (await run({ prRows: [record({ head: OLD, at: '2026-11-15T03:00:00Z' }), HOP()], git: carryGit }))?.state === 'pass');
9315+
assert('⛔ #33765-N-e-a-Regen-provenance-hop-edited-after-the-landing-is-named-on-the-BREACH', await breach({ prRows: [record({ head: OLD, at: '2026-11-15T03:00:00Z' }), HOP({ updated_at: '2026-11-15T06:00:00Z' })], git: carryGit },
9316+
/no `## Contract review` record on its head .*PR comment 905 was edited after the landing.*`Regen-provenance:` hop/) === true);
9317+
assert('#33765-N-e-an-edited-claim-beside-a-carry-is-still-not-named', await (async () => {
9318+
const v = await run({ prRows: [record({ head: OLD, at: '2026-11-15T03:00:00Z' }), HOP({ updated_at: '2026-11-15T06:00:00Z' }), { id: 950, created_at: '2026-11-15T04:00:00Z', updated_at: '2026-11-15T06:00:00Z', user: { login: RELAY }, body: 'Claim: PM loop' }], git: carryGit });
9319+
return v?.state === 'breach' && v.reason.includes('PR comment 905') && !v.reason.includes('950') ? true : JSON.stringify(v);
9320+
})() === true);
9321+
// #33765 N-g, pinned as is: a dismissal in the landing's own second is read as after it and restores the approval.
9322+
assert('#33765-N-g-a-dismissal-in-the-same-second-as-the-landing-restores-the-approval-pinned-as-is', await cleared({ prRows: [], reviews: [dismissedReview], events: DISMISSED(MERGED_AT) }, 'review') === true);
9323+
91869324
const at = (e, arm) => ({ ...e, attribution: { mergedBy: 'os-zhuang', mergedAt: MERGED_AT, title: 't', size: null }, attributionChannel: 'env-token', arm });
91879325
const human = at(classifyCommit({ sha: 'e'.repeat(40), date: MERGED_AT, subject: 'docs(adr): x (#71)' }, ['docs/adr/0001-x.md'], OS), undefined);
91889326
const report = renderReport({ window: dateWindowFor('2026-11-14T00:00:00Z'), repos: allAudited, scanned: 3, lookups: 3,

0 commit comments

Comments
 (0)