Session 5 of voyage-rebrand (V6). Operator-authorized cross-plugin scope. - git mv plugins/ultraplan-local plugins/voyage (rename detected, history preserved) - .claude-plugin/marketplace.json: voyage entry replaces ultraplan-local - CLAUDE.md: voyage row in plugin list, voyage in design-system consumer list - README.md: bulk rename ultra*-local commands -> trek* commands; ultraplan-local refs -> voyage; type discriminators (type: trekbrief/trekreview); session-title pattern (voyage:<command>:<slug>); v4.0.0 release-note paragraph - plugins/voyage/.claude-plugin/plugin.json: homepage/repository URLs point to monorepo voyage path - plugins/voyage/verify.sh: drop URL whitelist exception (no longer needed) Closes voyage-rebrand. bash plugins/voyage/verify.sh PASS 7/7. npm test 361/361.
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)`,
|
|
);
|
|
}
|
|
});
|