ktg-plugin-marketplace/plugins/ultraplan-local/tests/lib/main-merge-gate.test.mjs
Kjell Tore Guttormsen b837274b77 feat(ultraplan-local): emit main-merge-gate stats event from Phase 8
Wire the main-merge-gate lifecycle event into commands/ultraexecute-local.md
Phase 8. Three event variants emitted via lib/stats/event-emit.mjs (S8):
  - main-merge-gate     fired at the gate boundary
  - main-merge-approved fired on operator confirm
  - main-merge-declined fired on operator decline (run recorded as partial)

The gate ALWAYS pauses regardless of gates_mode — it is the one always-on
boundary that --gates does not toggle. On decline, --resume re-enters at
the gate, and the wave session branches survive on the remote thanks to
Hard Rule 19's push-before-cleanup. Recovery surface is documented inline.

Pin in tests/lib/main-merge-gate.test.mjs locks the always-on prose, the
event names, and the recovery-surface contract.
2026-05-04 07:55:41 +02:00

42 lines
1.7 KiB
JavaScript

// tests/lib/main-merge-gate.test.mjs
// Step 12 (plan-v2) — pin that commands/ultraexecute-local.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/ultraexecute-local.md'), 'utf-8');
test('Phase 8 names the main-merge-gate lifecycle event', () => {
assert.ok(
CMD.includes('main-merge-gate'),
'commands/ultraexecute-local.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',
);
});