Skip to content
473 changes: 464 additions & 9 deletions scripts/pm/check-governed-merges.mjs

Large diffs are not rendered by default.

158 changes: 138 additions & 20 deletions scripts/pm/check-governed-queue-guard.mjs

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions scripts/pm/dispatch-gates.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -14055,13 +14055,15 @@ export function changedLineLines(size) {
`Changed lines — NOT MEASURED: a path list carries no diff to count. The human-merge threshold (${t},` +
' additions + deletions, generated files INCLUDED) is read off the worktree by this tool run with no paths,' +
' and at landing by `node scripts/pm/check-governed-merges.mjs --pr <n>`.',
CARD_TOTAL_LINE,
];
}
const reading = `Changed lines — ${s.changedLines} (+${s.additions} / -${s.deletions}; generated files INCLUDED) vs the human-merge threshold ${t}:`;
if (!s.exceeds) {
return [
`${reading} under. Read off THIS worktree's diff against the merge base, not off the PR; the landing pre-check` +
' (`check-governed-merges.mjs --pr <n>`) reads the PR\'s own number.',
CARD_TOTAL_LINE,
];
}
return [
Expand All @@ -14071,9 +14073,20 @@ export function changedLineLines(size) {
' it, or arms auto-merge before that — ACCEPT on the card, `pm:awaiting-merge` on the PR, the final 维护者速读,' +
' review requested from GOVERNED_APPROVERS. The landing pre-check `check-governed-merges.mjs --pr <n>` reads the' +
' PR\'s own number.',
CARD_TOTAL_LINE,
];
}

/**
* Why this reading carries no CARD total (ruling 7303003476: the line is counted per card), printed on every
* branch above. This tool reads the worktree and no API, so the open and merged pulls naming the card are not
* read here; `check-governed-merges.mjs --pr` reads them at landing, and the queue guard before the merge.
*/
export const CARD_TOTAL_LINE =
'Card total — NOT MEASURED here: this tool reads the worktree and no API. The line is counted per card (ruling' +
' 7303003476): a diff under it is still over it when the open and merged pulls naming its card total more, and' +
' then this PR too lands as a Tier H one does. `check-governed-merges.mjs --pr <n>` and the queue guard read that total.';

// ---------------------------------------------------------------------------
// The claim's `Container & model:` line — read against the ladder this file
// derives, so the tier a seat DECLARES is compared to something
Expand Down
2 changes: 2 additions & 0 deletions scripts/pm/dispatch-gates.self-test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -12318,6 +12318,8 @@ export function selfTest({ tier = 'full' } = {}) {
t('exactly at the threshold is under it — strictly greater, as the gate reads it', atLine.includes('under.') && !atLine.includes('HUMAN MERGE'), atLine);
const noneLine = changedLineLines(null).join('\n');
t('an explicit path list is NOT MEASURED, said out loud, never a silent under', noneLine.includes('NOT MEASURED') && !noneLine.includes('under.') && noneLine.includes('--pr'), noneLine);
t('⭐ per card (ruling 7303003476): every branch says the card total is NOT read here, why, and who reads it — an under-line diff of an over-line card is still Tier H',
[overLine, atLine, noneLine].every((w) => w.includes('Card total — NOT MEASURED here') && w.includes('no API') && w.includes('--pr <n>') && w.includes('7303003476')), atLine);
t('the threshold is read from the gate — no second copy here — and it is the ruled 3000', HUMAN_MERGE_LINE_THRESHOLD === 3000 && changedLineLines({ additions: 3001, deletions: 0 }).join('\n').includes('OVER'));
t('a text buffer counts its lines, an unterminated last line included', lineCountOf(Buffer.from('a\nb\n')) === 2 && lineCountOf(Buffer.from('a\nb')) === 2 && lineCountOf(Buffer.alloc(0)) === 0);
t('a buffer with a NUL in its first 8000 bytes is binary: null, which the caller counts as zero lines', lineCountOf(Buffer.from([0x61, 0, 0x62])) === null);
Expand Down
Loading
Loading