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>
81 lines
3 KiB
JavaScript
81 lines
3 KiB
JavaScript
import { test } from 'node:test';
|
|
import { strict as assert } from 'node:assert';
|
|
import { mkdtempSync, mkdirSync, writeFileSync, rmSync } from 'node:fs';
|
|
import { tmpdir } from 'node:os';
|
|
import { join } from 'node:path';
|
|
import { discoverArchitecture } from '../../lib/validators/architecture-discovery.mjs';
|
|
|
|
function setup(structure) {
|
|
const root = mkdtempSync(join(tmpdir(), 'ultraplan-arch-'));
|
|
for (const [path, content] of Object.entries(structure)) {
|
|
const full = join(root, path);
|
|
mkdirSync(join(full, '..'), { recursive: true });
|
|
writeFileSync(full, content);
|
|
}
|
|
return root;
|
|
}
|
|
|
|
test('discoverArchitecture — canonical overview.md found cleanly', () => {
|
|
const root = setup({ 'architecture/overview.md': '# Overview\n' });
|
|
try {
|
|
const r = discoverArchitecture(root);
|
|
assert.equal(r.found, true);
|
|
assert.match(r.overview, /architecture\/overview\.md$/);
|
|
assert.equal(r.warnings.length, 0);
|
|
assert.equal(r.firstHeading, 'Overview');
|
|
} finally { rmSync(root, { recursive: true, force: true }); }
|
|
});
|
|
|
|
test('discoverArchitecture — no architecture dir = not found, no warnings', () => {
|
|
const root = setup({ 'brief.md': 'b' });
|
|
try {
|
|
const r = discoverArchitecture(root);
|
|
assert.equal(r.found, false);
|
|
assert.equal(r.warnings.length, 0);
|
|
} finally { rmSync(root, { recursive: true, force: true }); }
|
|
});
|
|
|
|
test('discoverArchitecture — non-canonical name discovered with warning (drift-WARN)', () => {
|
|
const root = setup({ 'architecture/architecture-overview.md': '# Drifted\n' });
|
|
try {
|
|
const r = discoverArchitecture(root);
|
|
assert.equal(r.found, true);
|
|
assert.ok(r.warnings.find(w => w.code === 'ARCH_NON_CANONICAL_OVERVIEW'));
|
|
} finally { rmSync(root, { recursive: true, force: true }); }
|
|
});
|
|
|
|
test('discoverArchitecture — loose unknown files surfaced as drift warning', () => {
|
|
const root = setup({
|
|
'architecture/overview.md': '# OK\n',
|
|
'architecture/random-note.md': 'x',
|
|
'architecture/another.md': 'y',
|
|
});
|
|
try {
|
|
const r = discoverArchitecture(root);
|
|
assert.equal(r.found, true);
|
|
assert.ok(r.warnings.find(w => w.code === 'ARCH_LOOSE_FILES'));
|
|
assert.equal(r.looseFiles.length, 2);
|
|
} finally { rmSync(root, { recursive: true, force: true }); }
|
|
});
|
|
|
|
test('discoverArchitecture — gaps.md detected when present', () => {
|
|
const root = setup({
|
|
'architecture/overview.md': '# OK\n',
|
|
'architecture/gaps.md': '# Gaps\n',
|
|
});
|
|
try {
|
|
const r = discoverArchitecture(root);
|
|
assert.match(r.gaps, /architecture\/gaps\.md$/);
|
|
} finally { rmSync(root, { recursive: true, force: true }); }
|
|
});
|
|
|
|
test('discoverArchitecture — never reads body beyond first heading', () => {
|
|
const root = setup({
|
|
'architecture/overview.md': '# Overview\n\n## Components\n\nlots of detail that we MUST NOT validate\n',
|
|
});
|
|
try {
|
|
const r = discoverArchitecture(root);
|
|
assert.equal(r.firstHeading, 'Overview');
|
|
// Validator does not assert on Components section — that's the contract.
|
|
} finally { rmSync(root, { recursive: true, force: true }); }
|
|
});
|