Skip to content

Commit ac1482d

Browse files
committed
test(pm): each fail-closed --land gate case asserts its own refusal reason
Claude-Session: https://claude.ai/code/session_01ADHkmPoqLCQHtTFH1fsaSB Co-authored-by: Claude <noreply@anthropic.com>
1 parent 4034dfb commit ac1482d

1 file changed

Lines changed: 34 additions & 22 deletions

File tree

‎scripts/pm/label-write.mjs‎

Lines changed: 34 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2377,7 +2377,7 @@ const SELF_TEST_BATTERIES = Object.freeze({
23772377
[FOLD_BATTERY]: 28,
23782378
[REAL_TRANSPORT_BATTERY]: 5,
23792379
[STATELESS_BATTERY]: 19,
2380-
[LAND_DOGFOOD_BATTERY]: 33,
2380+
[LAND_DOGFOOD_BATTERY]: 37,
23812381
});
23822382
const SELF_TEST_BATTERY_FLOOR = 17;
23832383
const UNATTRIBUTED_BATTERY = '(unattributed)';
@@ -2987,7 +2987,7 @@ export async function selfTest() {
29872987
// ⭐ The card's both-ways rows.
29882988
const na = await land(pull({ cards: { 8: [report(NA)] } }));
29892989
t('⭐ REFUSED: a `!` title whose newest report says `n/a` — exit 2, ZERO sends, no pr_ready, nothing written', refused(na), REFUSED, na.text.slice(-600));
2990-
t('…and the refusal names the title marker, the report comment id, its dogfood_battery text, and what clears it', ['`!` before the colon of the title', 'report: comment 501', JSON.stringify(NA), 'to clear: run the full dogfood battery on head', HEAD].map((w) => na.text.includes(w)), [true, true, true, true, true]);
2990+
t('…and the refusal names the title marker, the report comment id, its dogfood_battery text, why, and what clears it', ['`!` before the colon of the title', 'report: comment 501', JSON.stringify(NA), 'why: the battery was not run', 'to clear: run the full dogfood battery on head', HEAD].map((w) => na.text.includes(w)), [true, true, true, true, true, true]);
29912991
const onHead = await land(pull());
29922992
t('⭐ PASSES: a `!` title whose newest report ran on the head — ONE dispatch, comment → pr_ready → automerge_enable, ready and armed, exit 0', [onHead.exit, onHead.sent[0]?.actions.map((a) => a.op), onHead.fake.board.draft, onHead.text.includes('② dogfood gate ✓'), onHead.text.includes('ran on the head')], [EXIT_OK, ['comment', 'pr_ready', 'automerge_enable'], false, true, true], onHead.text.slice(-600));
29932993
t('…from the pull and the card thread alone — no commit walk when the battery names the head', onHead.fake.calls.map((c) => c.op), ['card-read', 'pull-read', 'comments-list', 'card-read', 'comments-list', 'pull-read']);
@@ -3000,36 +3000,48 @@ export async function selfTest() {
30003000
const twoMerges = await land(pull({ cards: { 8: [report(RAN_BELOW)] }, commits: { [HEAD]: [STRAY, MAIN_SIDE], [STRAY]: [BELOW, MAIN_SIDE] }, onBase: [MAIN_SIDE] }));
30013001
t('…and over TWO merges of main, each judged', [twoMerges.exit, twoMerges.text.includes('ran 2 merge(s)')], [EXIT_OK, true]);
30023002
const notMain = await land(pull({ cards: { 8: [report(RAN_BELOW)] }, commits: { [HEAD]: [BELOW, STRAY] }, onBase: [MAIN_SIDE] }));
3003-
t('⛔ REFUSED: a merge whose second parent the base does not hold — a merge of another branch is new code', [...refused(notMain), notMain.text.includes('does not hold')], [...REFUSED, true]);
3003+
t('⛔ REFUSED: a merge whose second parent the base does not hold — a merge of another branch is new code', [...refused(notMain), notMain.text.includes('which `main` does not hold')], [...REFUSED, true]);
30043004
const plain = await land(pull({ title: 'fix(pm): an ordinary fixture', cards: { 8: [report(NA)] } }));
30053005
t('⭐ NOT JUDGED: no `!` and no `(narrowing)` arm lands as today — even over an `n/a` report — with no gate read at all', [plain.exit, plain.text.includes('not judged'), plain.fake.calls.map((c) => c.op)], [EXIT_OK, true, ['card-read', 'card-read', 'comments-list', 'pull-read']]);
30063006
const widening = await land(pull({ title: 'feat(pm): a widening fixture', body: 'Fixes #8\n\nClause-②: yes (widening)\n', cards: {} }));
30073007
t('…a `(widening)` arm is not a marker either', [widening.exit, widening.text.includes('not judged')], [EXIT_OK, true]);
30083008

30093009
// FAIL CLOSED — every case NOT MEASURED is a refusal.
3010+
// Each case: its board, and the fragment of the `why` only its own branch prints — so a branch ablated away
3011+
// cannot hide behind a later refusal that happens to fire too.
30103012
const cases = {
3011-
'an UNREADABLE title': pull({ title: '' }),
3012-
'a MALFORMED `Clause-②:` line on an unmarked title': pull({ title: 'fix: x', body: 'Fixes #8\n\nClause-②: maybe\n' }),
3013-
'NO CARD — no closing keyword, no `Part of`, no dev branch': pull({ body: 'A body naming nothing.\n', ref: 'feature/x' }),
3014-
'a card thread that does not read': pull({ cards: {} }),
3015-
'NO REPORT on the card': pull({ cards: { 8: [{ id: 9, created_at: '2026-11-08T14:00:00Z', user: { login: FLEET }, body: 'Claim: PM loop round 1' }] } }),
3016-
'an UNPARSABLE report': pull({ cards: { 8: [report(null, { raw: `${SIG}\nos-dev-report\n\n\`\`\`json\n{ "dogfood_battery": \n\`\`\`\n` })] } }),
3017-
'a report with no `dogfood_battery`': pull({ cards: { 8: [report(null, { raw: `${SIG}\nos-dev-report\n\n\`\`\`json\n{"issue": 8, "status": "done"}\n\`\`\`\n` })] } }),
3018-
'a battery naming NO sha': pull({ cards: { 8: [report('ran the battery · VERDICT command-exit 0')] } }),
3019-
'a TRUNCATED listing': pull({ cards: { 8: [...Array.from({ length: LAND_COMMENT_PAGE_CAP * 100 }, (_, i) => ({ id: 1000 + i, created_at: '2026-11-08T10:00:00Z', user: { login: FLEET }, body: 'note' }))] } }),
3020-
'a walk commit that does not read': pull({ cards: { 8: [report(RAN_BELOW)] } }),
3021-
[`a battery more than ${LAND_MERGE_HOP_CAP} merges below the head`]: pull({
3022-
head: 'f'.repeat(40),
3023-
cards: { 8: [report(RAN_BELOW)] },
3024-
commits: Object.fromEntries(Array.from({ length: LAND_MERGE_HOP_CAP + 1 }, (_, i) => [(i === 0 ? 'f'.repeat(40) : (i.toString(16).padStart(2, '0')).repeat(20)), [i === LAND_MERGE_HOP_CAP ? BELOW : ((i + 1).toString(16).padStart(2, '0')).repeat(20), MAIN_SIDE]])),
3025-
onBase: [MAIN_SIDE],
3026-
}),
3013+
'an UNREADABLE title': [pull({ title: '' }), 'its title did not read'],
3014+
'a MALFORMED `Clause-②:` line on an unmarked title': [pull({ title: 'fix: x', body: 'Fixes #8\n\nClause-②: maybe\n' }), 'reads malformed'],
3015+
'a pull that does not read': [{ ...pull(), hooks: { 'pull-read': [{ status: 404 }] } }, 'the pull did not read'],
3016+
'a pull read with no full head sha': [pull({ head: 'abc' }), 'no full head sha'],
3017+
'NO CARD — no closing keyword, no `Part of`, no dev branch': [pull({ body: 'A body naming nothing.\n', ref: 'feature/x' }), 'why: no card'],
3018+
'a card thread that does not read': [pull({ cards: {} }), "card #8's thread did not read"],
3019+
'NO REPORT on the card': [pull({ cards: { 8: [{ id: 9, created_at: '2026-11-08T14:00:00Z', user: { login: FLEET }, body: 'Claim: PM loop round 1' }] } }), 'carries no `os-dev-report` by'],
3020+
'an UNPARSABLE report': [pull({ cards: { 8: [report(null, { raw: `${SIG}\nos-dev-report\n\n\`\`\`json\n{ "dogfood_battery": \n\`\`\`\n` })] } }), 'no readable `dogfood_battery`'],
3021+
'a report with no `dogfood_battery`': [pull({ cards: { 8: [report(null, { raw: `${SIG}\nos-dev-report\n\n\`\`\`json\n{"issue": 8, "status": "done"}\n\`\`\`\n` })] } }), 'no readable `dogfood_battery`'],
3022+
'a battery naming NO sha': [pull({ cards: { 8: [report('ran the battery · VERDICT command-exit 0')] } }), 'names no sha it ran on'],
3023+
'a TRUNCATED listing': [pull({ cards: { 8: [...Array.from({ length: LAND_COMMENT_PAGE_CAP * 100 }, (_, i) => ({ id: 1000 + i, created_at: '2026-11-08T10:00:00Z', user: { login: FLEET }, body: 'note' }))] } }), 'TRUNCATED listing'],
3024+
'a walk commit that does not read': [pull({ cards: { 8: [report(RAN_BELOW)] } }), 'is NOT MEASURED'],
3025+
'a compare that does not read': [pull({ cards: { 8: [report(RAN_BELOW)] }, commits: { [HEAD]: [BELOW, MAIN_SIDE] }, onBase: [MAIN_SIDE] }), 'did not read (GET'],
3026+
[`a battery more than ${LAND_MERGE_HOP_CAP} merges below the head`]: [
3027+
pull({
3028+
head: 'f'.repeat(40),
3029+
cards: { 8: [report(RAN_BELOW)] },
3030+
commits: Object.fromEntries(Array.from({ length: LAND_MERGE_HOP_CAP + 1 }, (_, i) => [(i === 0 ? 'f'.repeat(40) : i.toString(16).padStart(2, '0').repeat(20)), [i === LAND_MERGE_HOP_CAP ? BELOW : (i + 1).toString(16).padStart(2, '0').repeat(20), MAIN_SIDE]])),
3031+
onBase: [MAIN_SIDE],
3032+
}),
3033+
`is not reached within ${LAND_MERGE_HOP_CAP} merges`,
3034+
],
30273035
};
3028-
for (const [name, board] of Object.entries(cases)) {
3036+
cases['a compare that does not read'][0].hooks = { 'compare-read': [{ status: 404 }] };
3037+
for (const [name, [board, why]] of Object.entries(cases)) {
30293038
const run = await land(board);
3030-
t(`⛔ FAIL CLOSED: ${name} refuses — exit 2, zero sends, nothing written`, refused(run), REFUSED, run.text.slice(-400));
3039+
t(`⛔ FAIL CLOSED: ${name} refuses — exit 2, zero sends, nothing written, its own reason printed`, [...refused(run), run.text.includes(why)], [...REFUSED, true], run.text.slice(-400));
30313040
}
3032-
const pageCount = (await land(cases['a TRUNCATED listing'])).fake.calls.filter((c) => c.op === 'comments-list').length;
3041+
const atCap = cases[`a battery more than ${LAND_MERGE_HOP_CAP} merges below the head`][0];
3042+
const oneShorter = await land({ ...atCap, commits: { ...atCap.commits, [(LAND_MERGE_HOP_CAP).toString(16).padStart(2, '0').repeat(20)]: undefined, [(LAND_MERGE_HOP_CAP - 1).toString(16).padStart(2, '0').repeat(20)]: [BELOW, MAIN_SIDE] } });
3043+
t(`…while a battery exactly ${LAND_MERGE_HOP_CAP} merges below the head passes — the cap is the hop count, not one short of it`, [oneShorter.exit, oneShorter.text.includes(`ran ${LAND_MERGE_HOP_CAP} merge(s)`)], [EXIT_OK, true], oneShorter.text.slice(-400));
3044+
const pageCount = (await land(cases['a TRUNCATED listing'][0])).fake.calls.filter((c) => c.op === 'comments-list').length;
30333045
t('…the truncated listing read exactly the page cap and stopped', pageCount, LAND_COMMENT_PAGE_CAP);
30343046

30353047
// Whose report, and which one.

0 commit comments

Comments
 (0)