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>
79 lines
2.6 KiB
JavaScript
79 lines
2.6 KiB
JavaScript
import { test } from 'node:test';
|
|
import { strict as assert } from 'node:assert';
|
|
import { validateProgressObject, checkResumeReadiness } from '../../lib/validators/progress-validator.mjs';
|
|
|
|
function goodProgress() {
|
|
return {
|
|
schema_version: '1',
|
|
plan: '.claude/projects/x/plan.md',
|
|
plan_type: 'plan',
|
|
plan_version: '1.7',
|
|
started_at: '2026-04-18T12:00:00Z',
|
|
updated_at: '2026-04-18T13:00:00Z',
|
|
mode: 'execute',
|
|
total_steps: 2,
|
|
current_step: 1,
|
|
status: 'in_progress',
|
|
steps: {
|
|
'1': { status: 'completed', attempts: 1, error: null, completed_at: '2026-04-18T12:30:00Z', commit: 'abc123', manifest_audit: 'pass' },
|
|
'2': { status: 'pending', attempts: 0, error: null, completed_at: null, commit: null, manifest_audit: null },
|
|
},
|
|
};
|
|
}
|
|
|
|
test('validateProgress — happy path', () => {
|
|
const r = validateProgressObject(goodProgress());
|
|
assert.equal(r.valid, true, JSON.stringify(r.errors));
|
|
});
|
|
|
|
test('validateProgress — wrong schema_version', () => {
|
|
const p = goodProgress();
|
|
p.schema_version = '2';
|
|
const r = validateProgressObject(p);
|
|
assert.equal(r.valid, false);
|
|
assert.ok(r.errors.find(e => e.code === 'PROGRESS_SCHEMA_MISMATCH'));
|
|
});
|
|
|
|
test('validateProgress — missing required field', () => {
|
|
const p = goodProgress();
|
|
delete p.total_steps;
|
|
const r = validateProgressObject(p);
|
|
assert.equal(r.valid, false);
|
|
assert.ok(r.errors.find(e => e.code === 'PROGRESS_MISSING_FIELD' && /total_steps/.test(e.message)));
|
|
});
|
|
|
|
test('validateProgress — bad status', () => {
|
|
const p = goodProgress();
|
|
p.status = 'maybe';
|
|
const r = validateProgressObject(p);
|
|
assert.equal(r.valid, false);
|
|
assert.ok(r.errors.find(e => e.code === 'PROGRESS_BAD_STATUS'));
|
|
});
|
|
|
|
test('validateProgress — current_step out of range', () => {
|
|
const p = goodProgress();
|
|
p.current_step = 99;
|
|
const r = validateProgressObject(p);
|
|
assert.equal(r.valid, false);
|
|
assert.ok(r.errors.find(e => e.code === 'PROGRESS_STEP_RANGE'));
|
|
});
|
|
|
|
test('validateProgress — step count mismatch is warning', () => {
|
|
const p = goodProgress();
|
|
p.total_steps = 5;
|
|
const r = validateProgressObject(p);
|
|
assert.ok(r.warnings.find(w => w.code === 'PROGRESS_STEP_COUNT_MISMATCH'));
|
|
});
|
|
|
|
test('checkResumeReadiness — completed run cannot resume', () => {
|
|
const p = goodProgress();
|
|
p.status = 'completed';
|
|
const r = checkResumeReadiness(p);
|
|
assert.equal(r.valid, false);
|
|
assert.ok(r.errors.find(e => e.code === 'PROGRESS_ALREADY_DONE'));
|
|
});
|
|
|
|
test('checkResumeReadiness — in-progress is resumable', () => {
|
|
const r = checkResumeReadiness(goodProgress());
|
|
assert.equal(r.valid, true);
|
|
});
|