// tests/lib/main-merge-gate.test.mjs // Step 12 (plan-v2) — pin that commands/trekexecute.md Phase 8 // names the main-merge-gate lifecycle event, the decline + recovery // surface, and the always-on gate prose. import { test } from 'node:test'; import { strict as assert } from 'node:assert'; import { readFileSync } from 'node:fs'; import { dirname, join } from 'node:path'; import { fileURLToPath } from 'node:url'; const HERE = dirname(fileURLToPath(import.meta.url)); const ROOT = join(HERE, '..', '..'); const CMD = readFileSync(join(ROOT, 'commands/trekexecute.md'), 'utf-8'); test('Phase 8 names the main-merge-gate lifecycle event', () => { assert.ok( CMD.includes('main-merge-gate'), 'commands/trekexecute.md should emit `main-merge-gate` from Phase 8', ); }); test('Phase 8 documents both approved + declined event branches', () => { assert.ok(CMD.includes('main-merge-approved'), 'should emit main-merge-approved on confirm'); assert.ok(CMD.includes('main-merge-declined'), 'should emit main-merge-declined on decline'); }); test('Phase 8 documents the --resume recovery surface for the main-merge gate', () => { assert.ok( CMD.includes('--resume re-enters'), 'Phase 8 should document that `--resume re-enters at the gate` after a decline', ); }); test('Phase 8 main-merge gate is always-on (regardless of gates_mode)', () => { // Main-merge gate is the one boundary that pauses on every run; the prose // must say so explicitly so the contract survives copy-edit drift. assert.ok( /always[\s\S]{0,200}gates_mode|gates_mode[\s\S]{0,200}always|always pauses on every run/.test(CMD), 'Phase 8 should state main-merge gate is always-on, regardless of gates_mode', ); });