voyage/tests/lib/gates-flag-coverage.test.mjs
Kjell Tore Guttormsen 308b149e70
refactor(gates): the autonomy gate is the --gates flag parser
lib/util/autonomy-gate.mjs keeps only gatesValue + parseGatesArgs and the
CLI ({"ok":true,"gates":true|false}; exact usage error on a bad value;
the old --state/--event arguments are a usage error). The four commands
run 'autonomy-gate.mjs --gates [value]' and read gates. Prose (README,
operations, architecture, sdlc-playbook-gap) and the S24, gates-flag
and [#1] tests follow (R9).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-07 10:37:03 +01:00

48 lines
1.6 KiB
JavaScript

// tests/lib/gates-flag-coverage.test.mjs
// Step 11 (plan-v2) — pin that all four pipeline commands document the
// --gates autonomy-control flag and map its value through the
// lib/util/autonomy-gate.mjs flag parser.
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, '..', '..');
function read(rel) { return readFileSync(join(ROOT, rel), 'utf-8'); }
const COMMANDS = [
'commands/trekbrief.md',
'commands/trekresearch.md',
'commands/trekplan.md',
'commands/trekexecute.md',
];
for (const cmdPath of COMMANDS) {
test(`${cmdPath} documents the --gates flag`, () => {
const text = read(cmdPath);
assert.ok(
text.includes('--gates'),
`${cmdPath} should document the --gates autonomy-control flag (Step 11)`,
);
});
test(`${cmdPath} wires the autonomy-gate.mjs CLI shim`, () => {
const text = read(cmdPath);
assert.ok(
text.includes('autonomy-gate.mjs'),
`${cmdPath} should reference lib/util/autonomy-gate.mjs, the --gates flag parser`,
);
});
}
test('commands/trekexecute.md mentions MAIN_MERGE_GATE', () => {
const text = read('commands/trekexecute.md');
assert.ok(
text.includes('MAIN_MERGE_GATE'),
'commands/trekexecute.md should name MAIN_MERGE_GATE — the lock on the review verdict before the merge into main; the guard is what asks before merge and push, whatever --gates says',
);
});