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>
94 lines
3.1 KiB
JavaScript
94 lines
3.1 KiB
JavaScript
import { test } from 'node:test';
|
|
import { strict as assert } from 'node:assert';
|
|
import { validateBriefContent } from '../../lib/validators/brief-validator.mjs';
|
|
|
|
const GOOD_BRIEF = `---
|
|
type: ultrabrief
|
|
brief_version: "2.0"
|
|
created: 2026-04-30
|
|
task: "Add JWT auth to API"
|
|
slug: jwt-auth
|
|
project_dir: .claude/projects/2026-04-30-jwt-auth/
|
|
research_topics: 2
|
|
research_status: pending
|
|
auto_research: false
|
|
interview_turns: 5
|
|
source: interview
|
|
---
|
|
|
|
# Task: JWT auth
|
|
|
|
## Intent
|
|
|
|
Why this matters.
|
|
|
|
## Goal
|
|
|
|
What success looks like.
|
|
|
|
## Success Criteria
|
|
|
|
- All tests pass.
|
|
`;
|
|
|
|
test('validateBrief — happy path', () => {
|
|
const r = validateBriefContent(GOOD_BRIEF, { strict: true });
|
|
assert.equal(r.valid, true, JSON.stringify(r.errors));
|
|
});
|
|
|
|
test('validateBrief — wrong type rejected', () => {
|
|
const t = GOOD_BRIEF.replace('type: ultrabrief', 'type: notabrief');
|
|
const r = validateBriefContent(t);
|
|
assert.equal(r.valid, false);
|
|
assert.ok(r.errors.find(e => e.code === 'BRIEF_WRONG_TYPE'));
|
|
});
|
|
|
|
test('validateBrief — missing required field', () => {
|
|
const t = GOOD_BRIEF.replace(/^research_topics: 2\n/m, '');
|
|
const r = validateBriefContent(t);
|
|
assert.equal(r.valid, false);
|
|
assert.ok(r.errors.find(e => e.code === 'BRIEF_MISSING_FIELD' && /research_topics/.test(e.message)));
|
|
});
|
|
|
|
test('validateBrief — bad research_status value', () => {
|
|
const t = GOOD_BRIEF.replace('research_status: pending', 'research_status: maybe');
|
|
const r = validateBriefContent(t);
|
|
assert.equal(r.valid, false);
|
|
assert.ok(r.errors.find(e => e.code === 'BRIEF_BAD_STATUS'));
|
|
});
|
|
|
|
test('validateBrief — state machine: research_topics > 0 + skipped without partial = error', () => {
|
|
const t = GOOD_BRIEF.replace('research_status: pending', 'research_status: skipped');
|
|
const r = validateBriefContent(t);
|
|
assert.equal(r.valid, false);
|
|
assert.ok(r.errors.find(e => e.code === 'BRIEF_STATE_INCOHERENT'));
|
|
});
|
|
|
|
test('validateBrief — state machine: skipped + brief_quality: partial = warning only', () => {
|
|
const t = GOOD_BRIEF
|
|
.replace('research_status: pending', 'research_status: skipped')
|
|
.replace('source: interview', 'source: interview\nbrief_quality: partial');
|
|
const r = validateBriefContent(t);
|
|
assert.equal(r.valid, true, JSON.stringify(r.errors));
|
|
assert.ok(r.warnings.find(w => w.code === 'BRIEF_PARTIAL_SKIPPED'));
|
|
});
|
|
|
|
test('validateBrief — strict requires body sections', () => {
|
|
const t = GOOD_BRIEF.replace(/## Intent\n\nWhy this matters\.\n\n/, '');
|
|
const r = validateBriefContent(t, { strict: true });
|
|
assert.equal(r.valid, false);
|
|
assert.ok(r.errors.find(e => e.code === 'BRIEF_MISSING_SECTION'));
|
|
});
|
|
|
|
test('validateBrief — soft demotes section errors to warnings', () => {
|
|
const t = GOOD_BRIEF.replace(/## Goal\n\nWhat success looks like\.\n\n/, '');
|
|
const r = validateBriefContent(t, { strict: false });
|
|
assert.equal(r.valid, true);
|
|
assert.ok(r.warnings.find(w => w.code === 'BRIEF_MISSING_SECTION'));
|
|
});
|
|
|
|
test('validateBrief — missing frontmatter is hard error', () => {
|
|
const r = validateBriefContent('# just markdown\n\nno frontmatter\n');
|
|
assert.equal(r.valid, false);
|
|
assert.ok(r.errors.find(e => e.code === 'FM_MISSING'));
|
|
});
|