- brief-validator: BRIEF_TYPE_VALUES ['ultrabrief','ultrareview'] -> ['trekbrief','trekreview'] + dependent branches - research-validator: 'ultraresearch-brief' -> 'trekresearch-brief' - review-validator: 'ultrareview' -> 'trekreview' - 3 templates frontmatter type: - 4 synthetic fixtures: ultraplan-synthetic/ultrareview-synthetic -> trek* (frontmatter only; bodies untouched, Jaccard floor preserved) - 2 trekreview fixtures: type: trekreview - 6 validator-test fixtures + asserts - agents/review-coordinator.md frontmatter example Atomic: validator + fixtures committed together — partial state would cause vacuous test passes or hard validator rejection. Part of voyage-rebrand session 2 (W3.3 / Step 5). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
60 lines
1.9 KiB
JavaScript
60 lines
1.9 KiB
JavaScript
import { test } from 'node:test';
|
|
import { strict as assert } from 'node:assert';
|
|
import { validateResearchContent } from '../../lib/validators/research-validator.mjs';
|
|
|
|
const GOOD = `---
|
|
type: trekresearch-brief
|
|
created: 2026-04-30
|
|
question: "How to do X?"
|
|
confidence: 0.8
|
|
dimensions: 3
|
|
---
|
|
|
|
## Executive Summary
|
|
|
|
3 sentences.
|
|
|
|
## Dimensions
|
|
|
|
### Dim A — Confidence: high
|
|
`;
|
|
|
|
test('validateResearch — happy path', () => {
|
|
const r = validateResearchContent(GOOD);
|
|
assert.equal(r.valid, true, JSON.stringify(r.errors));
|
|
});
|
|
|
|
test('validateResearch — wrong type', () => {
|
|
const t = GOOD.replace('type: trekresearch-brief', 'type: random');
|
|
const r = validateResearchContent(t);
|
|
assert.equal(r.valid, false);
|
|
assert.ok(r.errors.find(e => e.code === 'RESEARCH_WRONG_TYPE'));
|
|
});
|
|
|
|
test('validateResearch — confidence out of range', () => {
|
|
const t = GOOD.replace('confidence: 0.8', 'confidence: 1.5');
|
|
const r = validateResearchContent(t);
|
|
assert.equal(r.valid, false);
|
|
assert.ok(r.errors.find(e => e.code === 'RESEARCH_BAD_CONFIDENCE'));
|
|
});
|
|
|
|
test('validateResearch — missing confidence is warning, not error', () => {
|
|
const t = GOOD.replace(/^confidence: 0\.8\n/m, '');
|
|
const r = validateResearchContent(t);
|
|
assert.equal(r.valid, true);
|
|
assert.ok(r.warnings.find(w => w.code === 'RESEARCH_NO_CONFIDENCE'));
|
|
});
|
|
|
|
test('validateResearch — strict missing body section is error', () => {
|
|
const t = GOOD.replace(/## Dimensions\n\n### Dim A — Confidence: high\n/, '');
|
|
const r = validateResearchContent(t, { strict: true });
|
|
assert.equal(r.valid, false);
|
|
assert.ok(r.errors.find(e => e.code === 'RESEARCH_MISSING_SECTION'));
|
|
});
|
|
|
|
test('validateResearch — bad dimensions value', () => {
|
|
const t = GOOD.replace('dimensions: 3', 'dimensions: 0');
|
|
const r = validateResearchContent(t);
|
|
assert.equal(r.valid, false);
|
|
assert.ok(r.errors.find(e => e.code === 'RESEARCH_BAD_DIMENSIONS'));
|
|
});
|