feat(voyage)!: marketplace handoff — rename plugins/ultraplan-local to plugins/voyage [skip-docs]
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.
This commit is contained in:
parent
8f1bf9b7b4
commit
7a90d348ad
149 changed files with 26 additions and 33 deletions
|
|
@ -0,0 +1,81 @@
|
|||
import { test } from 'node:test';
|
||||
import { strict as assert } from 'node:assert';
|
||||
import { mkdtempSync, mkdirSync, writeFileSync, rmSync } from 'node:fs';
|
||||
import { tmpdir } from 'node:os';
|
||||
import { join } from 'node:path';
|
||||
import { discoverArchitecture } from '../../lib/validators/architecture-discovery.mjs';
|
||||
|
||||
function setup(structure) {
|
||||
const root = mkdtempSync(join(tmpdir(), 'trekplan-arch-'));
|
||||
for (const [path, content] of Object.entries(structure)) {
|
||||
const full = join(root, path);
|
||||
mkdirSync(join(full, '..'), { recursive: true });
|
||||
writeFileSync(full, content);
|
||||
}
|
||||
return root;
|
||||
}
|
||||
|
||||
test('discoverArchitecture — canonical overview.md found cleanly', () => {
|
||||
const root = setup({ 'architecture/overview.md': '# Overview\n' });
|
||||
try {
|
||||
const r = discoverArchitecture(root);
|
||||
assert.equal(r.found, true);
|
||||
assert.match(r.overview, /architecture\/overview\.md$/);
|
||||
assert.equal(r.warnings.length, 0);
|
||||
assert.equal(r.firstHeading, 'Overview');
|
||||
} finally { rmSync(root, { recursive: true, force: true }); }
|
||||
});
|
||||
|
||||
test('discoverArchitecture — no architecture dir = not found, no warnings', () => {
|
||||
const root = setup({ 'brief.md': 'b' });
|
||||
try {
|
||||
const r = discoverArchitecture(root);
|
||||
assert.equal(r.found, false);
|
||||
assert.equal(r.warnings.length, 0);
|
||||
} finally { rmSync(root, { recursive: true, force: true }); }
|
||||
});
|
||||
|
||||
test('discoverArchitecture — non-canonical name discovered with warning (drift-WARN)', () => {
|
||||
const root = setup({ 'architecture/architecture-overview.md': '# Drifted\n' });
|
||||
try {
|
||||
const r = discoverArchitecture(root);
|
||||
assert.equal(r.found, true);
|
||||
assert.ok(r.warnings.find(w => w.code === 'ARCH_NON_CANONICAL_OVERVIEW'));
|
||||
} finally { rmSync(root, { recursive: true, force: true }); }
|
||||
});
|
||||
|
||||
test('discoverArchitecture — loose unknown files surfaced as drift warning', () => {
|
||||
const root = setup({
|
||||
'architecture/overview.md': '# OK\n',
|
||||
'architecture/random-note.md': 'x',
|
||||
'architecture/another.md': 'y',
|
||||
});
|
||||
try {
|
||||
const r = discoverArchitecture(root);
|
||||
assert.equal(r.found, true);
|
||||
assert.ok(r.warnings.find(w => w.code === 'ARCH_LOOSE_FILES'));
|
||||
assert.equal(r.looseFiles.length, 2);
|
||||
} finally { rmSync(root, { recursive: true, force: true }); }
|
||||
});
|
||||
|
||||
test('discoverArchitecture — gaps.md detected when present', () => {
|
||||
const root = setup({
|
||||
'architecture/overview.md': '# OK\n',
|
||||
'architecture/gaps.md': '# Gaps\n',
|
||||
});
|
||||
try {
|
||||
const r = discoverArchitecture(root);
|
||||
assert.match(r.gaps, /architecture\/gaps\.md$/);
|
||||
} finally { rmSync(root, { recursive: true, force: true }); }
|
||||
});
|
||||
|
||||
test('discoverArchitecture — never reads body beyond first heading', () => {
|
||||
const root = setup({
|
||||
'architecture/overview.md': '# Overview\n\n## Components\n\nlots of detail that we MUST NOT validate\n',
|
||||
});
|
||||
try {
|
||||
const r = discoverArchitecture(root);
|
||||
assert.equal(r.firstHeading, 'Overview');
|
||||
// Validator does not assert on Components section — that's the contract.
|
||||
} finally { rmSync(root, { recursive: true, force: true }); }
|
||||
});
|
||||
154
plugins/voyage/tests/validators/brief-validator.test.mjs
Normal file
154
plugins/voyage/tests/validators/brief-validator.test.mjs
Normal file
|
|
@ -0,0 +1,154 @@
|
|||
import { test } from 'node:test';
|
||||
import { strict as assert } from 'node:assert';
|
||||
import { validateBriefContent } from '../../lib/validators/brief-validator.mjs';
|
||||
|
||||
const GOOD_BRIEF = `---
|
||||
type: trekbrief
|
||||
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: trekbrief', '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'));
|
||||
});
|
||||
|
||||
const REVIEW_AS_BRIEF = `---
|
||||
type: trekreview
|
||||
task: "Review delivered trekreview v1.0"
|
||||
slug: trekreview
|
||||
project_dir: .claude/projects/2026-05-01-trekreview/
|
||||
findings:
|
||||
- 0123456789abcdef0123456789abcdef01234567
|
||||
- fedcba9876543210fedcba9876543210fedcba98
|
||||
---
|
||||
|
||||
# Review brief
|
||||
|
||||
## Intent
|
||||
|
||||
Adversarial review of delivered trekreview v1.0.
|
||||
|
||||
## Goal
|
||||
|
||||
Find what was missed.
|
||||
|
||||
## Success Criteria
|
||||
|
||||
- All BLOCKER findings get a fix-plan.
|
||||
`;
|
||||
|
||||
test('validateBrief — trekreview type accepted with findings array', () => {
|
||||
const r = validateBriefContent(REVIEW_AS_BRIEF, { strict: true });
|
||||
assert.equal(r.valid, true, JSON.stringify(r.errors));
|
||||
});
|
||||
|
||||
test('validateBrief — trekreview without findings rejected (BRIEF_MISSING_FIELD)', () => {
|
||||
const t = REVIEW_AS_BRIEF.replace(/findings:\n - 0123[\s\S]*?- fedcba[0-9a-f]+\n/, '');
|
||||
const r = validateBriefContent(t);
|
||||
assert.equal(r.valid, false);
|
||||
assert.ok(
|
||||
r.errors.find(e => e.code === 'BRIEF_MISSING_FIELD' && /findings/.test(e.message)),
|
||||
`expected BRIEF_MISSING_FIELD for findings; got ${JSON.stringify(r.errors)}`,
|
||||
);
|
||||
});
|
||||
|
||||
test('validateBrief — trekreview with findings as scalar (not array) rejected (BRIEF_BAD_FINDINGS_TYPE)', () => {
|
||||
const t = REVIEW_AS_BRIEF.replace(
|
||||
/findings:\n - 0123[\s\S]*?- fedcba[0-9a-f]+/,
|
||||
'findings: not-an-array',
|
||||
);
|
||||
const r = validateBriefContent(t);
|
||||
assert.equal(r.valid, false);
|
||||
assert.ok(r.errors.find(e => e.code === 'BRIEF_BAD_FINDINGS_TYPE'));
|
||||
});
|
||||
|
||||
test('validateBrief — wrong-type error message includes accepted set', () => {
|
||||
const t = REVIEW_AS_BRIEF.replace('type: trekreview', 'type: somethingelse');
|
||||
const r = validateBriefContent(t);
|
||||
assert.equal(r.valid, false);
|
||||
const wrongType = r.errors.find(e => e.code === 'BRIEF_WRONG_TYPE');
|
||||
assert.ok(wrongType);
|
||||
assert.ok(/trekbrief/.test(wrongType.message));
|
||||
assert.ok(/trekreview/.test(wrongType.message));
|
||||
});
|
||||
|
|
@ -0,0 +1,135 @@
|
|||
// tests/validators/next-session-prompt-validator.test.mjs
|
||||
// Unit + CLI integration tests for lib/validators/next-session-prompt-validator.mjs.
|
||||
// Covers Bug 3 contract: producer-mismatch detection + state-anchored staleness +
|
||||
// 24h soft-warning + missing-frontmatter downgrade.
|
||||
|
||||
import { test } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { mkdtempSync, rmSync, writeFileSync } from 'node:fs';
|
||||
import { tmpdir } from 'node:os';
|
||||
import { join } from 'node:path';
|
||||
import { execFileSync } from 'node:child_process';
|
||||
|
||||
import {
|
||||
validateNextSessionPromptContent,
|
||||
validateNextSessionPromptObject,
|
||||
validateNextSessionPromptConsistency,
|
||||
} from '../../lib/validators/next-session-prompt-validator.mjs';
|
||||
|
||||
function frontmatter(producedBy, producedAt, extra = '') {
|
||||
return `---\nproduced_by: ${producedBy}\nproduced_at: ${producedAt}\n${extra}---\n\n# A1 — example\n\nbody\n`;
|
||||
}
|
||||
|
||||
test('validateNextSessionPromptContent — both consistent producers (valid)', () => {
|
||||
const text = frontmatter('trekexecute', '2026-05-04T16:00:00.000Z');
|
||||
const r = validateNextSessionPromptContent(text);
|
||||
assert.equal(r.valid, true, JSON.stringify(r.errors));
|
||||
assert.equal(r.parsed.produced_by, 'trekexecute');
|
||||
});
|
||||
|
||||
test('validateNextSessionPromptObject — missing produced_by is invalid', () => {
|
||||
const r = validateNextSessionPromptObject({ produced_at: '2026-05-04T16:00:00Z' });
|
||||
assert.equal(r.valid, false);
|
||||
assert.ok(r.errors.find(e => e.code === 'NEXT_SESSION_PROMPT_MISSING_FIELD' && /produced_by/.test(e.message)));
|
||||
});
|
||||
|
||||
test('validateNextSessionPromptObject — missing produced_at is invalid', () => {
|
||||
const r = validateNextSessionPromptObject({ produced_by: 'trekexecute' });
|
||||
assert.equal(r.valid, false);
|
||||
assert.ok(r.errors.find(e => e.code === 'NEXT_SESSION_PROMPT_MISSING_FIELD' && /produced_at/.test(e.message)));
|
||||
});
|
||||
|
||||
test('validateNextSessionPromptObject — invalid produced_at timestamp rejected', () => {
|
||||
const r = validateNextSessionPromptObject({ produced_by: 'x', produced_at: 'not-a-date' });
|
||||
assert.equal(r.valid, false);
|
||||
assert.ok(r.errors.find(e => e.code === 'NEXT_SESSION_PROMPT_INVALID_TIMESTAMP'));
|
||||
});
|
||||
|
||||
test('validateNextSessionPromptContent — no frontmatter downgrades to warning (valid)', () => {
|
||||
const r = validateNextSessionPromptContent('# Plain markdown, no frontmatter\n\ntext\n');
|
||||
assert.equal(r.valid, true);
|
||||
assert.ok(r.warnings.find(w => w.code === 'NEXT_SESSION_PROMPT_NO_FRONTMATTER'));
|
||||
});
|
||||
|
||||
test('validateNextSessionPromptConsistency — producer mismatch with both fresh fails', () => {
|
||||
const a = { path: '/a', parsed: { produced_by: 'trekexecute', produced_at: '2026-05-04T16:00:00.000Z' } };
|
||||
const b = { path: '/b', parsed: { produced_by: 'graceful-handoff', produced_at: '2026-05-04T16:05:00.000Z' } };
|
||||
const state = { updated_at: '2026-05-04T15:00:00.000Z' };
|
||||
const r = validateNextSessionPromptConsistency(a, b, { state, now: Date.parse('2026-05-04T16:30:00.000Z') });
|
||||
assert.equal(r.valid, false);
|
||||
assert.ok(r.errors.find(e => e.code === 'NEXT_SESSION_PROMPT_PRODUCER_MISMATCH'));
|
||||
});
|
||||
|
||||
test('validateNextSessionPromptConsistency — state-anchored stale candidate ignored', () => {
|
||||
const a = { path: '/a', parsed: { produced_by: 'graceful-handoff', produced_at: '2026-05-03T10:00:00.000Z' } };
|
||||
const b = { path: '/b', parsed: { produced_by: 'trekexecute', produced_at: '2026-05-04T16:05:00.000Z' } };
|
||||
const state = { updated_at: '2026-05-04T16:00:00.000Z' };
|
||||
const r = validateNextSessionPromptConsistency(a, b, { state, now: Date.parse('2026-05-04T16:30:00.000Z') });
|
||||
assert.equal(r.valid, true, JSON.stringify(r.errors));
|
||||
assert.ok(r.warnings.find(w => w.code === 'NEXT_SESSION_PROMPT_STALE_IGNORED'));
|
||||
});
|
||||
|
||||
test('validateNextSessionPromptConsistency — 24h wall-clock drift emits soft warning', () => {
|
||||
const a = { path: '/a', parsed: { produced_by: 'trekexecute', produced_at: '2026-05-01T16:00:00.000Z' } };
|
||||
const b = { path: '/b', parsed: { produced_by: 'trekexecute', produced_at: '2026-05-01T16:00:00.000Z' } };
|
||||
const r = validateNextSessionPromptConsistency(a, b, { now: Date.parse('2026-05-04T16:30:00.000Z') });
|
||||
assert.equal(r.valid, true);
|
||||
assert.ok(r.warnings.find(w => w.code === 'NEXT_SESSION_PROMPT_WALL_CLOCK_DRIFT'));
|
||||
});
|
||||
|
||||
test('validateNextSessionPromptConsistency — same producer, both fresh, no errors', () => {
|
||||
const a = { path: '/a', parsed: { produced_by: 'trekexecute', produced_at: '2026-05-04T16:00:00.000Z' } };
|
||||
const b = { path: '/b', parsed: { produced_by: 'trekexecute', produced_at: '2026-05-04T16:01:00.000Z' } };
|
||||
const r = validateNextSessionPromptConsistency(a, b, { now: Date.parse('2026-05-04T16:30:00.000Z') });
|
||||
assert.equal(r.valid, true);
|
||||
assert.deepEqual(r.errors, []);
|
||||
// No 24h warning: produced_at is well within 24h of `now`.
|
||||
assert.deepEqual(r.warnings.filter(w => w.code === 'NEXT_SESSION_PROMPT_WALL_CLOCK_DRIFT'), []);
|
||||
});
|
||||
|
||||
test('CLI shim — single-file mode returns JSON for valid file', () => {
|
||||
const dir = mkdtempSync(join(tmpdir(), 'nspv-cli-'));
|
||||
try {
|
||||
const file = join(dir, 'NEXT-SESSION-PROMPT.local.md');
|
||||
writeFileSync(file, frontmatter('trekexecute', '2026-05-04T16:00:00.000Z'));
|
||||
const out = execFileSync(process.execPath, [
|
||||
'lib/validators/next-session-prompt-validator.mjs',
|
||||
'--json',
|
||||
file,
|
||||
], { encoding: 'utf-8' });
|
||||
const parsed = JSON.parse(out);
|
||||
assert.equal(parsed.valid, true);
|
||||
} finally {
|
||||
rmSync(dir, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
|
||||
test('CLI shim — consistency mode flags producer mismatch', () => {
|
||||
const dir = mkdtempSync(join(tmpdir(), 'nspv-cli-'));
|
||||
try {
|
||||
const a = join(dir, 'a.md');
|
||||
const b = join(dir, 'b.md');
|
||||
writeFileSync(a, frontmatter('trekexecute', '2026-05-04T16:00:00.000Z'));
|
||||
writeFileSync(b, frontmatter('graceful-handoff', '2026-05-04T16:01:00.000Z'));
|
||||
let exitCode = 0;
|
||||
let out = '';
|
||||
try {
|
||||
out = execFileSync(process.execPath, [
|
||||
'lib/validators/next-session-prompt-validator.mjs',
|
||||
'--json',
|
||||
'--consistency',
|
||||
a,
|
||||
b,
|
||||
], { encoding: 'utf-8' });
|
||||
} catch (e) {
|
||||
exitCode = e.status;
|
||||
out = e.stdout ? e.stdout.toString() : '';
|
||||
}
|
||||
assert.notEqual(exitCode, 0);
|
||||
const parsed = JSON.parse(out);
|
||||
assert.equal(parsed.valid, false);
|
||||
assert.ok(parsed.errors.find(e => e.code === 'NEXT_SESSION_PROMPT_PRODUCER_MISMATCH'));
|
||||
} finally {
|
||||
rmSync(dir, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
99
plugins/voyage/tests/validators/plan-validator.test.mjs
Normal file
99
plugins/voyage/tests/validators/plan-validator.test.mjs
Normal file
|
|
@ -0,0 +1,99 @@
|
|||
import { test } from 'node:test';
|
||||
import { strict as assert } from 'node:assert';
|
||||
import { validatePlanContent } from '../../lib/validators/plan-validator.mjs';
|
||||
|
||||
const VALID_PLAN = `---
|
||||
plan_version: "1.7"
|
||||
---
|
||||
|
||||
# Plan
|
||||
|
||||
## Implementation Plan
|
||||
|
||||
### Step 1: Add foo
|
||||
|
||||
- Files: a.ts
|
||||
- Manifest:
|
||||
\`\`\`yaml
|
||||
manifest:
|
||||
expected_paths:
|
||||
- a.ts
|
||||
min_file_count: 1
|
||||
commit_message_pattern: "^feat:"
|
||||
bash_syntax_check: []
|
||||
forbidden_paths: []
|
||||
must_contain: []
|
||||
\`\`\`
|
||||
|
||||
### Step 2: Add bar
|
||||
|
||||
- Files: b.ts
|
||||
- Manifest:
|
||||
\`\`\`yaml
|
||||
manifest:
|
||||
expected_paths:
|
||||
- b.ts
|
||||
min_file_count: 1
|
||||
commit_message_pattern: "^feat:"
|
||||
bash_syntax_check: []
|
||||
forbidden_paths: []
|
||||
must_contain: []
|
||||
\`\`\`
|
||||
`;
|
||||
|
||||
const FORBIDDEN_PLAN = `---
|
||||
plan_version: "1.7"
|
||||
---
|
||||
|
||||
## Fase 1: Drift form
|
||||
|
||||
content
|
||||
`;
|
||||
|
||||
const STEP_WITHOUT_MANIFEST = `### Step 1: oops
|
||||
no manifest
|
||||
|
||||
### Step 2: ok
|
||||
|
||||
- Manifest:
|
||||
\`\`\`yaml
|
||||
manifest:
|
||||
expected_paths: [foo]
|
||||
min_file_count: 1
|
||||
commit_message_pattern: "^x:"
|
||||
bash_syntax_check: []
|
||||
forbidden_paths: []
|
||||
must_contain: []
|
||||
\`\`\`
|
||||
`;
|
||||
|
||||
test('validatePlan — strict accepts canonical v1.7 plan', () => {
|
||||
const r = validatePlanContent(VALID_PLAN, { strict: true });
|
||||
assert.equal(r.valid, true, JSON.stringify(r.errors));
|
||||
assert.equal(r.parsed.steps.length, 2);
|
||||
assert.equal(r.parsed.planVersion, '1.7');
|
||||
});
|
||||
|
||||
test('validatePlan — forbidden Fase form blocks in strict mode', () => {
|
||||
const r = validatePlanContent(FORBIDDEN_PLAN, { strict: true });
|
||||
assert.equal(r.valid, false);
|
||||
assert.ok(r.errors.find(e => e.code === 'PLAN_FORBIDDEN_HEADING'));
|
||||
});
|
||||
|
||||
test('validatePlan — manifest count mismatch caught', () => {
|
||||
const r = validatePlanContent(STEP_WITHOUT_MANIFEST, { strict: true });
|
||||
assert.equal(r.valid, false);
|
||||
assert.ok(r.errors.find(e => /Step 1/.test(e.message) && /MANIFEST_MISSING/.test(e.code)));
|
||||
});
|
||||
|
||||
test('validatePlan — version warning when missing', () => {
|
||||
const noVersion = VALID_PLAN.replace(/plan_version: "1\.7"\n/, '');
|
||||
const r = validatePlanContent(noVersion, { strict: true });
|
||||
assert.ok(r.warnings.find(w => w.code === 'PLAN_NO_VERSION'));
|
||||
});
|
||||
|
||||
test('validatePlan — older version triggers warning', () => {
|
||||
const old = VALID_PLAN.replace('plan_version: "1.7"', 'plan_version: "1.5"');
|
||||
const r = validatePlanContent(old, { strict: true });
|
||||
assert.ok(r.warnings.find(w => w.code === 'PLAN_VERSION_MISMATCH'));
|
||||
});
|
||||
79
plugins/voyage/tests/validators/progress-validator.test.mjs
Normal file
79
plugins/voyage/tests/validators/progress-validator.test.mjs
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
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);
|
||||
});
|
||||
60
plugins/voyage/tests/validators/research-validator.test.mjs
Normal file
60
plugins/voyage/tests/validators/research-validator.test.mjs
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
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'));
|
||||
});
|
||||
114
plugins/voyage/tests/validators/review-validator.test.mjs
Normal file
114
plugins/voyage/tests/validators/review-validator.test.mjs
Normal file
|
|
@ -0,0 +1,114 @@
|
|||
import { test } from 'node:test';
|
||||
import { strict as assert } from 'node:assert';
|
||||
import { validateReviewContent } from '../../lib/validators/review-validator.mjs';
|
||||
|
||||
const GOOD_REVIEW = `---
|
||||
type: trekreview
|
||||
review_version: "1.0"
|
||||
created: 2026-05-01
|
||||
task: "Add JWT auth"
|
||||
slug: jwt-auth
|
||||
project_dir: .claude/projects/2026-04-30-jwt-auth/
|
||||
brief_path: .claude/projects/2026-04-30-jwt-auth/brief.md
|
||||
scope_sha_start: abc123
|
||||
scope_sha_end: def456
|
||||
reviewed_files_count: 7
|
||||
findings:
|
||||
- 0123456789abcdef0123456789abcdef01234567
|
||||
- fedcba9876543210fedcba9876543210fedcba98
|
||||
---
|
||||
|
||||
# Review
|
||||
|
||||
## Executive Summary
|
||||
|
||||
Verdict: ALLOW.
|
||||
|
||||
## Coverage
|
||||
|
||||
| File | Treatment | Reason |
|
||||
|------|-----------|--------|
|
||||
| lib/foo.mjs | deep-review | risk |
|
||||
|
||||
## Remediation Summary
|
||||
|
||||
None.
|
||||
`;
|
||||
|
||||
test('validateReview — happy path', () => {
|
||||
const r = validateReviewContent(GOOD_REVIEW, { strict: true });
|
||||
assert.equal(r.valid, true, JSON.stringify(r.errors));
|
||||
});
|
||||
|
||||
test('validateReview — wrong type rejected (REVIEW_WRONG_TYPE)', () => {
|
||||
const t = GOOD_REVIEW.replace('type: trekreview', 'type: trekbrief');
|
||||
const r = validateReviewContent(t);
|
||||
assert.equal(r.valid, false);
|
||||
assert.ok(r.errors.find(e => e.code === 'REVIEW_WRONG_TYPE'));
|
||||
});
|
||||
|
||||
test('validateReview — missing required field (REVIEW_MISSING_FIELD)', () => {
|
||||
const t = GOOD_REVIEW.replace(/^brief_path: .*\n/m, '');
|
||||
const r = validateReviewContent(t);
|
||||
assert.equal(r.valid, false);
|
||||
assert.ok(r.errors.find(e => e.code === 'REVIEW_MISSING_FIELD' && /brief_path/.test(e.message)));
|
||||
});
|
||||
|
||||
test('validateReview — missing required body section in strict (REVIEW_MISSING_SECTION)', () => {
|
||||
const t = GOOD_REVIEW.replace(/## Coverage[\s\S]*?(?=## Remediation)/m, '');
|
||||
const r = validateReviewContent(t, { strict: true });
|
||||
assert.equal(r.valid, false);
|
||||
assert.ok(r.errors.find(e => e.code === 'REVIEW_MISSING_SECTION' && /Coverage/.test(e.message)));
|
||||
});
|
||||
|
||||
test('validateReview — Coverage section is REQUIRED (no soft demotion to make Coverage optional)', () => {
|
||||
const t = GOOD_REVIEW.replace(/## Coverage[\s\S]*?(?=## Remediation)/m, '');
|
||||
const r = validateReviewContent(t, { strict: true });
|
||||
assert.equal(r.valid, false);
|
||||
});
|
||||
|
||||
test('validateReview — soft mode demotes section errors to warnings', () => {
|
||||
const t = GOOD_REVIEW.replace(/## Remediation Summary[\s\S]*$/m, '');
|
||||
const r = validateReviewContent(t, { strict: false });
|
||||
assert.equal(r.valid, true);
|
||||
assert.ok(r.warnings.find(w => w.code === 'REVIEW_MISSING_SECTION'));
|
||||
});
|
||||
|
||||
test('validateReview — missing frontmatter is hard error (FM_MISSING)', () => {
|
||||
const r = validateReviewContent('# review\n\nno frontmatter\n');
|
||||
assert.equal(r.valid, false);
|
||||
assert.ok(r.errors.find(e => e.code === 'FM_MISSING'));
|
||||
});
|
||||
|
||||
test('validateReview — findings not an array → REVIEW_BAD_FINDINGS_TYPE', () => {
|
||||
// Replace block-style list with scalar → parser yields string
|
||||
const t = GOOD_REVIEW.replace(
|
||||
/findings:\n - 0123[\s\S]*?- fedcba[0-9a-f]+/,
|
||||
'findings: not-an-array',
|
||||
);
|
||||
const r = validateReviewContent(t);
|
||||
assert.equal(r.valid, false);
|
||||
assert.ok(
|
||||
r.errors.find(e => e.code === 'REVIEW_BAD_FINDINGS_TYPE'),
|
||||
`expected REVIEW_BAD_FINDINGS_TYPE, got: ${JSON.stringify(r.errors)}`,
|
||||
);
|
||||
});
|
||||
|
||||
test('validateReview — finding-ID not 40-char hex → REVIEW_BAD_FINDING_ID', () => {
|
||||
const t = GOOD_REVIEW.replace(
|
||||
'0123456789abcdef0123456789abcdef01234567',
|
||||
'NOT-A-VALID-HEX-ID',
|
||||
);
|
||||
const r = validateReviewContent(t);
|
||||
assert.equal(r.valid, false);
|
||||
assert.ok(r.errors.find(e => e.code === 'REVIEW_BAD_FINDING_ID'));
|
||||
});
|
||||
|
||||
test('validateReview — empty findings array is acceptable (no findings = ALLOW verdict)', () => {
|
||||
const t = GOOD_REVIEW.replace(
|
||||
/findings:\n - 0123[\s\S]*?- fedcba[0-9a-f]+/,
|
||||
'findings: []',
|
||||
);
|
||||
const r = validateReviewContent(t);
|
||||
assert.equal(r.valid, true, JSON.stringify(r.errors));
|
||||
});
|
||||
145
plugins/voyage/tests/validators/session-state-validator.test.mjs
Normal file
145
plugins/voyage/tests/validators/session-state-validator.test.mjs
Normal file
|
|
@ -0,0 +1,145 @@
|
|||
// tests/validators/session-state-validator.test.mjs
|
||||
// Unit + integration tests for lib/validators/session-state-validator.mjs.
|
||||
// Schema v1 contract — see docs/HANDOVER-CONTRACTS.md (Handover 7).
|
||||
|
||||
import { test } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import {
|
||||
validateSessionStateObject,
|
||||
validateSessionStateContent,
|
||||
validateSessionState,
|
||||
} from '../../lib/validators/session-state-validator.mjs';
|
||||
|
||||
function goodState() {
|
||||
return {
|
||||
schema_version: 1,
|
||||
project: '.claude/projects/2026-05-01-example',
|
||||
next_session_brief_path: '.claude/projects/2026-05-01-example/brief.md',
|
||||
next_session_label: 'Session 2: Implement validator + tests',
|
||||
status: 'in_progress',
|
||||
updated_at: '2026-05-01T18:00:00.000Z',
|
||||
};
|
||||
}
|
||||
|
||||
test('validateSessionStateObject — happy path returns valid', () => {
|
||||
const r = validateSessionStateObject(goodState());
|
||||
assert.equal(r.valid, true);
|
||||
assert.deepEqual(r.errors, []);
|
||||
assert.deepEqual(r.warnings, []);
|
||||
});
|
||||
|
||||
test('validateSessionStateObject — missing project field', () => {
|
||||
const s = goodState();
|
||||
delete s.project;
|
||||
const r = validateSessionStateObject(s);
|
||||
assert.equal(r.valid, false);
|
||||
assert.ok(r.errors.find(e => e.code === 'SESSION_STATE_MISSING_FIELD' && /project/.test(e.message)));
|
||||
});
|
||||
|
||||
test('validateSessionStateObject — missing status field', () => {
|
||||
const s = goodState();
|
||||
delete s.status;
|
||||
const r = validateSessionStateObject(s);
|
||||
assert.equal(r.valid, false);
|
||||
assert.ok(r.errors.find(e => e.code === 'SESSION_STATE_MISSING_FIELD' && /status/.test(e.message)));
|
||||
});
|
||||
|
||||
test('validateSessionStateObject — missing next_session_brief_path', () => {
|
||||
const s = goodState();
|
||||
delete s.next_session_brief_path;
|
||||
const r = validateSessionStateObject(s);
|
||||
assert.equal(r.valid, false);
|
||||
assert.ok(r.errors.find(e => e.code === 'SESSION_STATE_MISSING_FIELD' && /next_session_brief_path/.test(e.message)));
|
||||
});
|
||||
|
||||
test('validateSessionStateObject — missing next_session_label', () => {
|
||||
const s = goodState();
|
||||
delete s.next_session_label;
|
||||
const r = validateSessionStateObject(s);
|
||||
assert.equal(r.valid, false);
|
||||
assert.ok(r.errors.find(e => e.code === 'SESSION_STATE_MISSING_FIELD' && /next_session_label/.test(e.message)));
|
||||
});
|
||||
|
||||
test('validateSessionStateObject — missing updated_at', () => {
|
||||
const s = goodState();
|
||||
delete s.updated_at;
|
||||
const r = validateSessionStateObject(s);
|
||||
assert.equal(r.valid, false);
|
||||
assert.ok(r.errors.find(e => e.code === 'SESSION_STATE_MISSING_FIELD' && /updated_at/.test(e.message)));
|
||||
});
|
||||
|
||||
test('validateSessionStateObject — invalid status value rejected', () => {
|
||||
const s = goodState();
|
||||
s.status = 'maybe';
|
||||
const r = validateSessionStateObject(s);
|
||||
assert.equal(r.valid, false);
|
||||
assert.ok(r.errors.find(e => e.code === 'SESSION_STATE_INVALID_STATUS'));
|
||||
});
|
||||
|
||||
test('validateSessionStateObject — status completed valid but warns NOT_RESUMABLE', () => {
|
||||
const s = goodState();
|
||||
s.status = 'completed';
|
||||
const r = validateSessionStateObject(s);
|
||||
assert.equal(r.valid, true);
|
||||
assert.deepEqual(r.errors, []);
|
||||
assert.ok(r.warnings.find(w => w.code === 'SESSION_STATE_NOT_RESUMABLE'));
|
||||
});
|
||||
|
||||
test('validateSessionStateObject — schema_version mismatch fails', () => {
|
||||
const s = goodState();
|
||||
s.schema_version = 2;
|
||||
const r = validateSessionStateObject(s);
|
||||
assert.equal(r.valid, false);
|
||||
assert.ok(r.errors.find(e => e.code === 'SESSION_STATE_SCHEMA_MISMATCH'));
|
||||
});
|
||||
|
||||
test('validateSessionStateObject — invalid timestamp rejected', () => {
|
||||
const s = goodState();
|
||||
s.updated_at = 'not-a-date';
|
||||
const r = validateSessionStateObject(s);
|
||||
assert.equal(r.valid, false);
|
||||
assert.ok(r.errors.find(e => e.code === 'SESSION_STATE_INVALID_TIMESTAMP'));
|
||||
});
|
||||
|
||||
test('validateSessionStateContent — malformed JSON returns SESSION_STATE_PARSE_ERROR', () => {
|
||||
const r = validateSessionStateContent('{ broken');
|
||||
assert.equal(r.valid, false);
|
||||
assert.ok(r.errors.find(e => e.code === 'SESSION_STATE_PARSE_ERROR'));
|
||||
});
|
||||
|
||||
test('validateSessionState — missing file returns SESSION_STATE_NOT_FOUND', () => {
|
||||
const r = validateSessionState('/tmp/nonexistent-trekcontinue-test-9b2f4e.json');
|
||||
assert.equal(r.valid, false);
|
||||
assert.ok(r.errors.find(e => e.code === 'SESSION_STATE_NOT_FOUND'));
|
||||
});
|
||||
|
||||
test('validateSessionState — fixture file loads and parses correctly (SC-1)', () => {
|
||||
const r = validateSessionState('tests/fixtures/session-state/valid-in-progress.json');
|
||||
assert.equal(r.valid, true);
|
||||
assert.equal(r.parsed.status, 'in_progress');
|
||||
assert.equal(typeof r.parsed.project, 'string');
|
||||
assert.equal(typeof r.parsed.next_session_brief_path, 'string');
|
||||
assert.equal(typeof r.parsed.next_session_label, 'string');
|
||||
});
|
||||
|
||||
test('validateSessionState — malformed fixture returns SESSION_STATE_PARSE_ERROR (SC-3)', () => {
|
||||
const r = validateSessionState('tests/fixtures/session-state/malformed.json');
|
||||
assert.equal(r.valid, false);
|
||||
assert.ok(r.errors.find(e => e.code === 'SESSION_STATE_PARSE_ERROR'));
|
||||
});
|
||||
|
||||
test('validateSessionStateObject — forward-compat: unknown keys ignored silently', () => {
|
||||
// Simulates graceful-handoff v2.2 dual-write with extra fields.
|
||||
const s = {
|
||||
...goodState(),
|
||||
branch: 'main',
|
||||
git_status: { dirty: false, ahead: 0, detached: false },
|
||||
committed_by: 'graceful-handoff',
|
||||
last_commits: [{ sha: 'abc1234', msg: 'feat: foo' }],
|
||||
next_steps: ['cd repo', 'git status'],
|
||||
};
|
||||
const r = validateSessionStateObject(s);
|
||||
assert.equal(r.valid, true);
|
||||
assert.deepEqual(r.errors, []);
|
||||
assert.deepEqual(r.warnings, []);
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue