Sed-pipeline (16 patterns, longest-match-first) sweeper residuelle ultra*-treff i prose, command-narrativ, agent-prompts, hook-kommentarer, doc-prosa. Pipeline-utvidelser fra V4-prompten: - BSD-syntax [[:<:]]ultra[[:>:]] istedenfor \bultra\b (BSD sed mangler \b) - 6 compound-patterns for ultraplan/ultraexecute/ultraresearch/ultrabrief/ ultrareview/ultracontinue uten -local-suffiks - ultra*-stats glob -> trek*-stats glob - Linje-eksklusjon redusert til ultra-cc-architect (Q8); session-state- eksklusjonen var over-protektiv - File-eksklusjon utvidet til settings.json, package.json, plugin.json, hele .claude/-treet (gitignored + V5-territorium) Q8-undantak holdt: architecture-discovery.mjs + project-discovery.mjs urort. Filnavn-konvensjon holdt: .session-state.local.json + *.local.* preservert. Manuell narrative-fix: tests/lib/agent-frontmatter.test.mjs linje 10 mangled "/ultra*-local" til "/voyage*-local" (ingen slik kommando finnes); korrigert til "/trek*". Residualer utenfor scope (V5 handterer): package.json + .claude-plugin/ plugin.json (Step 12-14 versjons-bump). .claude/* er gitignored spec-historikk med tilsiktet BEFORE/AFTER-narrativ. Part of voyage-rebrand session 3 (Wave 4 / Step 10). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
63 lines
2.7 KiB
JavaScript
63 lines
2.7 KiB
JavaScript
// tests/lib/source-findings.test.mjs
|
|
// SC3(b) structural test for Handover 6.
|
|
//
|
|
// The brief requires `plan.md` produced from a `type: trekreview` brief to
|
|
// contain `source_findings: [<id>, ...]` in its frontmatter. Without an
|
|
// automated test, SC3(b) is unverified.
|
|
//
|
|
// This test exercises the STRUCTURAL contract:
|
|
// 1. plan-validator accepts a plan with source_findings (additive optional field)
|
|
// 2. frontmatter parser extracts source_findings as an array of strings
|
|
// 3. each ID is 40-char hex (matches lib/parsers/finding-id.mjs format)
|
|
//
|
|
// LLM behavior (the planner actually emitting source_findings when it consumes
|
|
// a review.md) is non-testable without live invocation — this test only covers
|
|
// the schema half.
|
|
|
|
import { test } from 'node:test';
|
|
import { strict as assert } from 'node:assert';
|
|
import { readFileSync } from 'node:fs';
|
|
import { join, dirname } from 'node:path';
|
|
import { fileURLToPath } from 'node:url';
|
|
import { parseDocument } from '../../lib/util/frontmatter.mjs';
|
|
import { validatePlan } from '../../lib/validators/plan-validator.mjs';
|
|
|
|
const HERE = dirname(fileURLToPath(import.meta.url));
|
|
const ROOT = join(HERE, '..', '..');
|
|
const FIXTURE = join(ROOT, 'tests/fixtures/trekreview/plan-with-source-findings.md');
|
|
|
|
const HEX_ID_RE = /^[0-9a-f]{40}$/;
|
|
|
|
test('plan-validator accepts plan.md with source_findings field', () => {
|
|
const result = validatePlan(FIXTURE, { strict: true });
|
|
assert.ok(
|
|
result.valid,
|
|
`plan-validator rejected synthetic plan with source_findings: ` +
|
|
`${(result.errors || []).map(e => `[${e.code}] ${e.message}`).join('; ')}`,
|
|
);
|
|
});
|
|
|
|
test('frontmatter parser extracts source_findings as array of strings', () => {
|
|
const text = readFileSync(FIXTURE, 'utf-8');
|
|
const doc = parseDocument(text);
|
|
assert.ok(doc.valid, `frontmatter did not parse: ${(doc.errors || []).map(e => e.message).join(', ')}`);
|
|
const sf = doc.parsed.frontmatter && doc.parsed.frontmatter.source_findings;
|
|
assert.ok(Array.isArray(sf), `frontmatter.source_findings is not an array (got ${typeof sf})`);
|
|
assert.ok(sf.length > 0, 'frontmatter.source_findings is empty — fixture should carry at least one ID');
|
|
for (const id of sf) {
|
|
assert.strictEqual(typeof id, 'string', `source_findings entry is not a string: ${JSON.stringify(id)}`);
|
|
}
|
|
});
|
|
|
|
test('source_findings IDs match the format from finding-id.mjs (40-char hex)', () => {
|
|
const text = readFileSync(FIXTURE, 'utf-8');
|
|
const doc = parseDocument(text);
|
|
const sf = doc.parsed.frontmatter.source_findings;
|
|
for (const id of sf) {
|
|
assert.ok(
|
|
HEX_ID_RE.test(id),
|
|
`source_findings ID ${JSON.stringify(id)} is not 40-char lowercase hex ` +
|
|
`(format produced by lib/parsers/finding-id.mjs computeFindingId)`,
|
|
);
|
|
}
|
|
});
|