← back to Gated Morning Review
test-tk11801.mjs
49 lines
#!/usr/bin/env node
// TK-11801 negative test (CLAUDE.md TK-11431 amendment 3): prove the sweep does NOT
// auto-close a memo whose ticket is still OPEN just because its prose says "resolved",
// and that the fix goes RED if that guard is removed. Uses the GMR_QDIR / GMR_TK_STATUS_JSON
// seams so it never touches the real queue or shells `tk`.
import fs from 'fs';
import os from 'os';
import path from 'path';
const tmp = fs.mkdtempSync(path.join(os.tmpdir(), 'gmr-tk11801-'));
process.env.GMR_QDIR = tmp;
process.env.GMR_TK_STATUS_JSON = JSON.stringify({
'TK-11089': 'blocked', // OPEN — a genuine waiting-on-Steve ask
'TK-22222': 'doing', // OPEN
'TK-33333': 'done', // closed
});
const memo = (name, body) => fs.writeFileSync(path.join(tmp, name), body);
// 1. OPEN ticket, header SAYS "resolved" — the exact founding bug. Must NOT be STALE.
memo('2026-09-13-TK-11089-pj-resume-decision-GATED.md', '# GATED — TK-11089 resume?\n\n✅ DTD VERDICT: superseded reasoning, already resolved elsewhere.\n');
// 2. OPEN [doing] ticket with staleSig prose. Must NOT be STALE.
memo('TK-22222-thing.md', '# TK-22222 — no-op after the flip, nothing to do\n');
// 3. DONE ticket with staleSig. SHOULD be STALE (safe to close).
memo('TK-33333-old.md', '# TK-33333 — resolved and applied\n');
// 4. OPEN ticket BUT explicit STATUS: DONE marker. SHOULD be STALE (marker wins).
memo('TK-11089-b-explicit.md', '# TK-11089 phase 2\nSTATUS: DONE\nsuperseded\n');
// 5. No staleSig, open ticket, fresh. Must be DECIDE (surfaced).
memo('TK-22222-fresh.md', '# TK-22222 — please approve the deploy\n');
const { scanQueue } = await import('./lib.mjs?' + Date.now()); // fresh import after env set
const byFile = Object.fromEntries(scanQueue().map(i => [i.file, i.disposition]));
let fails = 0;
const expect = (file, want) => {
const got = byFile[file];
const ok = got === want;
console.log(`${ok ? 'PASS' : 'FAIL'} ${file} -> ${got} (want ${want})`);
if (!ok) fails++;
};
expect('2026-09-13-TK-11089-pj-resume-decision-GATED.md', 'DECIDE'); // the founding bug: NOT closed
expect('TK-22222-thing.md', 'DECIDE'); // open [doing]: NOT closed
expect('TK-33333-old.md', 'STALE'); // done: safe to close
expect('TK-11089-b-explicit.md', 'STALE'); // explicit marker wins
expect('TK-22222-fresh.md', 'DECIDE'); // surfaced
fs.rmSync(tmp, { recursive: true, force: true });
if (fails) { console.log(`\n${fails} FAILED`); process.exit(1); }
console.log('\nall 5 passed — open-ticket memos survive the sweep; only done/marked ones close.');