voyage/tests/lib/removed-surfaces.test.mjs
Kjell Tore Guttormsen 2a35d067d9
chore(cleanup): R-b R3 — profiles, phase signals and the effort dialog removed, one fixed path per command
The four profiles, the resolver, the profile validator and docs/profiles.md go;
/trekbrief Phase 3.5 and the brief's phase_signals checks go (an older brief's
key is ignored); MANIFEST_PROFILE_DRIFT and profile_used go. Every Profile,
Composition rule, Sequencing gate and High-effort section leaves the commands.
Decision 209: /trekresearch runs the full swarm with contrarian-researcher as
wave 2 every run; /trekreview and the coordinator run all four passes with no
high-effort normalization. Voyage agents are spawned with no model (their own
model: opus applies); the two built-in spawns pass model "opus". --profile
stays in the parser as a retired flag that swallows its value. §Model & effort
moves to docs/architecture.md; the sequencing-gate eval case goes.

Files removed: 44 (43 from the R3 list + tests/commands/trekreview.test.mjs,
whose every test pinned removed text). Files edited: 43.
Tests: 2467 (2466 pass / 0 fail / 1 skipped) before, 2309 (2309 pass / 0 fail /
0 skipped) after. Durable check: all three groups green, none pending.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-07 21:12:57 +01:00

138 lines
6.4 KiB
JavaScript

// tests/lib/removed-surfaces.test.mjs
// Cleanup R-b removed three surfaces: Voyage's own measurement, statistics and
// export (R1, decision 189; Claude Code's own OpenTelemetry took over), the
// STORM loop and the research engine choice (R2, decision 190), and the
// profiles, phase signals and effort dialog (R3, decision 191). No tracked
// file may name them again, so a removed surface cannot come back unseen.
//
// Scope: every tracked text file except CHANGELOG.md (history), *.local.*
// files (never tracked) and this test. A term is a plain substring, except a
// flag, which must stand as its own token (`--engine`, `--profile`).
//
// Every group always runs. When this test fails, remove the mention; add an
// EXEMPT entry only for a line that must keep the term, with the reason.
import { test } from 'node:test';
import { strict as assert } from 'node:assert';
import { execFileSync } from 'node:child_process';
import { mkdtempSync, mkdirSync, writeFileSync, readFileSync, rmSync } from 'node:fs';
import { join, dirname } from 'node:path';
import { tmpdir } from 'node:os';
import { fileURLToPath } from 'node:url';
const HERE = dirname(fileURLToPath(import.meta.url));
const ROOT = join(HERE, '..', '..');
const SELF = 'tests/lib/removed-surfaces.test.mjs';
const flag = name => new RegExp(`(?<![\\w-])${name}(?![\\w-])`);
export const GROUPS = {
R1: [
'lib/stats/', 'lib/exporters/', 'otel-export', 'post-bash-stats', 'stats-append', 'event-emit',
'yardstick.mjs', 'scripts/yardstick', 'end-state-gate', 'end-state-registry', 'comparison-gate',
'brief-approved', '-stats.jsonl', 'main-merge-gate', 'main-merge-approved', 'main-merge-declined',
'VOYAGE_EXPORT_MODE', 'VOYAGE_OTEL_ENDPOINT', 'VOYAGE_TEXTFILE_DIR', 'VOYAGE_OTEL_ALLOW_PRIVATE',
'VOYAGE_TOKEN_METER', 'gold-scorer', 'synthesis-measure',
],
R2: [
'VOYAGE_STORM_ENABLED', 'TREKRESEARCH_MAX_CONV_TURNS', 'VOYAGE_DISABLE_CAP_HOOK', 'VOYAGE_CAP_SCOPE_TTL_MS',
'research-loop-cap', 'pre-agent-cap', 'storm-measure', flag('--engine'), 'effective_engine',
],
R3: [
'lib/profiles/', flag('--profile'), 'phase_signals', 'phase_signal_result', 'resolve-phase-model',
'docs/profiles.md', 'MANIFEST_PROFILE_DRIFT', 'BRIEF_V51_MISSING_SIGNALS', 'VOYAGE_PROFILE',
'VOYAGE_ALLOW_HAIKU', 'voyage-profiles/', 'resolveTrekcontinueProfile', 'profile_used',
],
};
// Named exceptions: "path:line" -> reason. Each must still hit (a stale
// exemption fails below).
const EXEMPT = new Map([
['docs/HANDOVER-CONTRACTS.md:81', 'public contract: an older brief\'s key is ignored (decisions 179/191)'],
['docs/proevesett.md:139', 'dated v1/v2 measurement record of the fixed test set, kept unedited'],
['docs/proevesett.md:143', 'dated v1/v2 measurement record of the fixed test set, kept unedited'],
['docs/proevesett.md:146', 'dated v1/v2 measurement record of the fixed test set, kept unedited'],
['lib/parsers/arg-parser.mjs:16', 'retired flag swallows its value'],
['lib/parsers/arg-parser.mjs:20', 'retired flag swallows its value'],
['lib/parsers/arg-parser.mjs:25', 'retired flag swallows its value'],
['lib/parsers/arg-parser.mjs:30', 'retired flag swallows its value'],
['lib/parsers/arg-parser.mjs:36', 'retired flag swallows its value'],
['lib/parsers/arg-parser.mjs:41', 'retired flag swallows its value'],
['lib/parsers/arg-parser.mjs:46', 'retired flag swallows its value'],
['tests/lib/arg-parser.test.mjs:285', 'retired flag swallows its value'],
['tests/lib/arg-parser.test.mjs:286', 'retired flag swallows its value'],
['tests/validators/brief-validator.test.mjs:200', 'older brief stays valid (decision 191)'],
['tests/validators/brief-validator.test.mjs:203', 'older brief stays valid (decision 191)'],
['tests/validators/brief-validator.test.mjs:205', 'older brief stays valid (decision 191)'],
]);
const matches = (term, line) => (typeof term === 'string' ? line.includes(term) : term.test(line));
// "path:line" for every line of the given files that names a term of the group.
export function scan(root, files, terms) {
const hits = [];
for (const rel of files) {
const buf = readFileSync(join(root, rel));
if (buf.includes(0)) continue; // binary
buf.toString('utf-8').split('\n').forEach((line, i) => {
if (terms.some(t => matches(t, line))) hits.push(`${rel}:${i + 1}`);
});
}
return hits;
}
export function inScope(rel) {
return rel !== 'CHANGELOG.md' && rel !== SELF && !/\.local\./.test(rel);
}
let files = null;
function tracked() {
if (!files) {
files = execFileSync('git', ['ls-files', '-z'], { cwd: ROOT, encoding: 'utf-8' })
.split('\0').filter(Boolean).filter(inScope);
}
return files;
}
test('scan finds a term, and a flag only as its own token (known-positive)', () => {
const dir = mkdtempSync(join(tmpdir(), 'removed-surfaces-'));
try {
mkdirSync(join(dir, 'docs'), { recursive: true });
writeFileSync(join(dir, 'docs', 'a.md'), [
'Set VOYAGE_STORM_ENABLED=1 first.',
'Run with --engine deep-research.',
'The engine-findings compare stays; so does --engines-list.',
'Pass `--profile economy`.',
].join('\n'));
assert.deepEqual(scan(dir, ['docs/a.md'], GROUPS.R2), ['docs/a.md:1', 'docs/a.md:2']);
assert.deepEqual(scan(dir, ['docs/a.md'], GROUPS.R3), ['docs/a.md:4']);
} finally {
rmSync(dir, { recursive: true, force: true });
}
});
test('scope leaves out history, local files and this test', () => {
assert.ok(inScope('commands/trekresearch.md'));
assert.ok(inScope('lib/validators/brief-validator.mjs'));
assert.ok(!inScope('CHANGELOG.md'));
assert.ok(!inScope('docs/notes.local.md'));
assert.ok(!inScope(SELF));
});
for (const group of Object.keys(GROUPS)) {
test(`${group}: no tracked file names a removed surface`, () => {
const all = tracked();
assert.ok(all.length > 100, `git ls-files returned ${all.length} files; refusing to pass on an empty scan`);
const hits = scan(ROOT, all, GROUPS[group]).filter(h => !EXEMPT.has(h));
assert.deepEqual(hits, [], `${hits.length} line(s) still name a ${group} surface:\n${hits.join('\n')}`);
});
}
test('every EXEMPT entry still names a removed surface', () => {
const terms = Object.values(GROUPS).flat();
for (const key of EXEMPT.keys()) {
const rel = key.replace(/:\d+$/, '');
assert.ok(tracked().includes(rel), `EXEMPT names untracked ${rel}`);
assert.ok(scan(ROOT, [rel], terms).includes(key), `EXEMPT entry "${key}" no longer hits; remove it`);
}
});