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>
106 lines
3.4 KiB
JavaScript
106 lines
3.4 KiB
JavaScript
// lib/review/rule-catalogue.mjs
|
|
// Canonical rule catalogue for /trekreview v1.0.
|
|
//
|
|
// 12 rule keys, 4-tier severity (matches brief contract).
|
|
// llm-security 5-tier alignment is a v1.1 candidate.
|
|
|
|
export const SEVERITY_VALUES = Object.freeze(['BLOCKER', 'MAJOR', 'MINOR', 'SUGGESTION']);
|
|
|
|
export const CATEGORY_VALUES = Object.freeze([
|
|
'conformance',
|
|
'correctness',
|
|
'scope',
|
|
'tests',
|
|
'security',
|
|
'maintenance',
|
|
]);
|
|
|
|
export const RULE_CATALOGUE = Object.freeze([
|
|
Object.freeze({
|
|
rule_key: 'MISSING_BRIEF_REF',
|
|
severity: 'MAJOR',
|
|
category: 'conformance',
|
|
description: 'Finding lacks brief_ref pointing to the brief section it traces back to.',
|
|
}),
|
|
Object.freeze({
|
|
rule_key: 'UNIMPLEMENTED_CRITERION',
|
|
severity: 'BLOCKER',
|
|
category: 'conformance',
|
|
description: 'A brief Success Criterion has no corresponding implementation in the delivered code.',
|
|
}),
|
|
Object.freeze({
|
|
rule_key: 'SCOPE_CREEP_BUILT',
|
|
severity: 'MAJOR',
|
|
category: 'scope',
|
|
description: 'Code implements features beyond what the brief requested.',
|
|
}),
|
|
Object.freeze({
|
|
rule_key: 'NON_GOAL_VIOLATED',
|
|
severity: 'BLOCKER',
|
|
category: 'scope',
|
|
description: 'Code implements something the brief explicitly listed as a Non-Goal.',
|
|
}),
|
|
Object.freeze({
|
|
rule_key: 'MISSING_TEST',
|
|
severity: 'MAJOR',
|
|
category: 'tests',
|
|
description: 'Delivered behavior has no automated test coverage.',
|
|
}),
|
|
Object.freeze({
|
|
rule_key: 'SECURITY_INJECTION',
|
|
severity: 'BLOCKER',
|
|
category: 'security',
|
|
description: 'Code path constructs commands, queries, or templates from untrusted input without sanitization.',
|
|
}),
|
|
Object.freeze({
|
|
rule_key: 'PLACEHOLDER_IN_CODE',
|
|
severity: 'MAJOR',
|
|
category: 'maintenance',
|
|
description: 'Committed code contains TBD/TODO/FIXME/XXX/console.log/debugger placeholders.',
|
|
}),
|
|
Object.freeze({
|
|
rule_key: 'MISSING_ERROR_HANDLING',
|
|
severity: 'MINOR',
|
|
category: 'correctness',
|
|
description: 'Code path can fail silently (uncaught promise, unchecked return, missing try/catch on I/O).',
|
|
}),
|
|
Object.freeze({
|
|
rule_key: 'UNDECLARED_DEPENDENCY',
|
|
severity: 'MAJOR',
|
|
category: 'maintenance',
|
|
description: 'Code imports or invokes something not declared in package.json / not bundled / not present in PATH.',
|
|
}),
|
|
Object.freeze({
|
|
rule_key: 'PLAN_EXECUTE_DRIFT',
|
|
severity: 'MAJOR',
|
|
category: 'conformance',
|
|
description: 'Delivered code diverges from what the plan said would be built (different file, different approach, different API).',
|
|
}),
|
|
Object.freeze({
|
|
rule_key: 'BROKEN_SUCCESS_CRITERION',
|
|
severity: 'BLOCKER',
|
|
category: 'conformance',
|
|
description: 'A brief Success Criterion is implemented but the verification command/test fails or is structurally incorrect.',
|
|
}),
|
|
Object.freeze({
|
|
rule_key: 'COVERAGE_SILENT_SKIP',
|
|
severity: 'MAJOR',
|
|
category: 'tests',
|
|
description: 'Triage gate skipped a file without recording it in the Coverage section of review.md (hidden truncation).',
|
|
}),
|
|
]);
|
|
|
|
export const RULE_KEYS = Object.freeze(new Set(RULE_CATALOGUE.map((r) => r.rule_key)));
|
|
|
|
/**
|
|
* Look up a rule entry by its key.
|
|
* @param {string} key
|
|
* @returns {object|null} the frozen entry, or null if not found
|
|
*/
|
|
export function getRule(key) {
|
|
if (typeof key !== 'string') return null;
|
|
for (const entry of RULE_CATALOGUE) {
|
|
if (entry.rule_key === key) return entry;
|
|
}
|
|
return null;
|
|
}
|