5 nye validator-moduler (alle m/ CLI-shim for invokering fra commands): - brief-validator.mjs — frontmatter (type, brief_version, task, slug, research_topics, research_status), state machine (research_topics > 0 + skipped requires brief_quality: partial), body sections (Intent/Goal/Success Criteria) - research-validator.mjs — type=ultraresearch-brief, confidence ∈ [0,1], dimensions ≥ 1, body sections, --dir mode for batch validering - plan-validator.mjs — wrapper over plan-schema + manifest-yaml; håndhever step-count == manifest-count, plan_version=1.7 - progress-validator.mjs — schema_version, status enum, current_step in range, step shape, checkResumeReadiness - architecture-discovery.mjs — EKSTERN KONTRAKT: drift-WARN ikke drift-FAIL; tolererer non-canonical filnavn, surfacer loose files som warnings Doc-consistency-test pinning prose vs source-of-truth: - agents/*.md count == CLAUDE.md agent-tabell rader - commands/*.md mentioned i CLAUDE.md - command frontmatter.name == filnavn - templates/plan-template.md plan_version 1.7 invariant - settings.json kun kjente scopes (ultraplan, ultraresearch) - settings.json ingen exploration eller agentTeam (vestigial guard etter Spor 0) - CLAUDE.md refererer alle 4 pipeline-commands Wave 1 + Wave 2 = 108 tester grønn. [skip-docs]: Test-infrastrukturen er ikke user-facing før Spor 1 wiring lander; README/CLAUDE.md oppdateres når commands faktisk endrer atferd (neste commit). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
102 lines
4 KiB
JavaScript
102 lines
4 KiB
JavaScript
// tests/lib/doc-consistency.test.mjs
|
|
// Pin invariants between prose (CLAUDE.md, README.md) and source files
|
|
// (agents/*.md, commands/*.md, templates/, settings.json).
|
|
//
|
|
// When this test fails, fix the source-of-truth — do NOT rewrite the test to
|
|
// hide drift. Borrowed pattern from llm-security commit 97c5c9d.
|
|
|
|
import { test } from 'node:test';
|
|
import { strict as assert } from 'node:assert';
|
|
import { readFileSync, readdirSync } from 'node:fs';
|
|
import { join, dirname } from 'node:path';
|
|
import { fileURLToPath } from 'node:url';
|
|
import { parseDocument } from '../../lib/util/frontmatter.mjs';
|
|
|
|
const HERE = dirname(fileURLToPath(import.meta.url));
|
|
const ROOT = join(HERE, '..', '..');
|
|
|
|
function read(rel) { return readFileSync(join(ROOT, rel), 'utf-8'); }
|
|
function listMd(rel) { return readdirSync(join(ROOT, rel)).filter(f => f.endsWith('.md')); }
|
|
|
|
test('CLAUDE.md agents table row count == agents/*.md file count', () => {
|
|
const md = read('CLAUDE.md');
|
|
const agentFiles = listMd('agents');
|
|
const agentTable = md.split('## Agents')[1] || '';
|
|
const tableSection = agentTable.split('\n## ')[0];
|
|
const dataRows = tableSection
|
|
.split('\n')
|
|
.filter(l => l.startsWith('|') && !l.match(/^\|[\s-]+\|/) && !l.match(/^\|\s*Agent\s*\|/));
|
|
assert.equal(
|
|
dataRows.length,
|
|
agentFiles.length,
|
|
`Drift: ${agentFiles.length} agent files vs ${dataRows.length} CLAUDE.md table rows. ` +
|
|
`Sync agents/ ↔ CLAUDE.md.`,
|
|
);
|
|
});
|
|
|
|
test('CLAUDE.md commands table mentions every commands/*.md file', () => {
|
|
const md = read('CLAUDE.md');
|
|
const commandFiles = listMd('commands');
|
|
for (const f of commandFiles) {
|
|
const cmdName = `/${f.replace(/\.md$/, '')}`;
|
|
assert.ok(
|
|
md.includes(cmdName),
|
|
`commands/${f} not mentioned in CLAUDE.md (looked for ${cmdName})`,
|
|
);
|
|
}
|
|
});
|
|
|
|
test('every command frontmatter name matches its filename', () => {
|
|
for (const f of listMd('commands')) {
|
|
const text = read(`commands/${f}`);
|
|
const doc = parseDocument(text);
|
|
if (!doc.valid) continue;
|
|
const expected = f.replace(/\.md$/, '');
|
|
if (doc.parsed.frontmatter && doc.parsed.frontmatter.name !== undefined) {
|
|
assert.equal(
|
|
doc.parsed.frontmatter.name,
|
|
expected,
|
|
`commands/${f} frontmatter.name="${doc.parsed.frontmatter.name}" should be "${expected}"`,
|
|
);
|
|
}
|
|
}
|
|
});
|
|
|
|
test('templates/plan-template.md declares plan_version: 1.7', () => {
|
|
const tpl = read('templates/plan-template.md');
|
|
assert.match(tpl, /plan_version:\s*['"]?1\.7['"]?/);
|
|
});
|
|
|
|
test('commands/ultraexecute-local.md still parses v1.7 plan schema', () => {
|
|
const cmd = read('commands/ultraexecute-local.md');
|
|
const tpl = read('templates/plan-template.md');
|
|
const tplVersion = (tpl.match(/plan_version:\s*['"]?([\d.]+)['"]?/) || [])[1];
|
|
assert.ok(tplVersion, 'templates/plan-template.md missing plan_version');
|
|
assert.ok(
|
|
cmd.includes(`plan_version`) || cmd.includes(`Step N:`) || cmd.includes('### Step '),
|
|
'commands/ultraexecute-local.md should reference v1.7 plan-schema parsing',
|
|
);
|
|
});
|
|
|
|
test('settings.json has only known top-level scopes after Spor 0 cleanup', () => {
|
|
const cfg = JSON.parse(read('settings.json'));
|
|
const known = ['ultraplan', 'ultraresearch'];
|
|
for (const k of Object.keys(cfg)) {
|
|
assert.ok(known.includes(k), `Unknown top-level scope in settings.json: ${k}`);
|
|
}
|
|
});
|
|
|
|
test('settings.json no longer carries vestigial exploration block', () => {
|
|
const cfg = JSON.parse(read('settings.json'));
|
|
assert.equal(cfg.ultraplan?.exploration, undefined,
|
|
'exploration block was vestigial — should be deleted in v3.1.0 Spor 0');
|
|
assert.equal(cfg.ultraplan?.agentTeam, undefined,
|
|
'agentTeam block was vestigial — should be deleted in v3.1.0 Spor 0');
|
|
});
|
|
|
|
test('CLAUDE.md mentions all four pipeline commands', () => {
|
|
const md = read('CLAUDE.md');
|
|
for (const c of ['/ultrabrief-local', '/ultraresearch-local', '/ultraplan-local', '/ultraexecute-local']) {
|
|
assert.ok(md.includes(c), `CLAUDE.md missing reference to ${c}`);
|
|
}
|
|
});
|