ms-ai-architect/tests/kb-update/test-rx-p2-wiring.test.mjs
Kjell Tore Guttormsen b68514487c fix(ms-ai-architect): RX-P2 reg-kjede-wiring + komprehensiv agent-sti-forankring [skip-docs]
- classify->dpia->ros kjede-wiring: dpia/ros Task-templater far eksplisitte
  AI Act-klassifiserings- + DPIA-funn-felt (kjede-data agentene allerede branchet pa)
- dpia-agent uutforbar "spor bruker" -> "marker vurderingen" (Hvis-ikke-klassifisert
  + Error Handling); speilet til ros-analysis-agent
- adr-writer-agent: Write-verktoy fjernet, returnerer ADR-markdown til hovedkontekst
  (command er eneste skriver -- subagenter skriver aldri)
- KB-sti-forankring (komprehensiv): 36 bare referanse-subdir-stier i 6 agenter +
  2 commands fullkvalifisert med CLAUDE_PLUGIN_ROOT/skills/<skill>/references/ ---
  ogsa innen-skill kortformer, uresolverbare i installert modus
- mekanisme: validate-plugin.sh Check 6d (bare-subdir-lint m/ hyphen-guard) +
  negativ-probe-test (beviser tenner) + RX-P2 wiring-regresjonstester

Suite 859/859 exit 0. validate-plugin 250 PASS / 0 FAIL. 145 forankrede stier
verifisert eksisterende (0 mangler).
2026-07-15 12:17:01 +02:00

45 lines
2.3 KiB
JavaScript

// RX-P2 regression guards: classify→dpia→ros chain wiring (del 1), removal of the
// unexecutable "ask user" subagent instructions (del 2), and single ADR write-ownership
// (del 4). Path anchoring (del 3) + its lint (del 5) are enforced by validate-plugin.sh
// Check 6d via test-validate-plugin.test.mjs.
import { test } from 'node:test';
import assert from 'node:assert/strict';
import { readFileSync } from 'node:fs';
import { fileURLToPath } from 'node:url';
import { dirname, join } from 'node:path';
const here = dirname(fileURLToPath(import.meta.url));
const root = join(here, '..', '..'); // tests/kb-update -> plugin root
const read = (rel) => readFileSync(join(root, rel), 'utf8');
// --- Del 1: chain wiring — the Task templates must carry explicit chain-data fields ---
test('dpia.md Task template passes AI Act classification as chain-data', () => {
const dpia = read('commands/dpia.md');
assert.match(dpia, /\*\*AI Act-klassifisering \(fra \/architect:classify/);
});
test('ros.md Task template passes AI Act classification (dim. 6) + DPIA findings as chain-data', () => {
const ros = read('commands/ros.md');
assert.match(ros, /\*\*AI Act-klassifisering \(dimensjon 6/);
assert.match(ros, /\*\*DPIA-funn \(fra \/architect:dpia/);
});
// --- Del 2: no unexecutable "ask the user" instructions in Task-spawned subagents ---
test('dpia-agent.md no longer instructs the subagent to ask the user', () => {
const agent = read('agents/dpia-agent.md');
assert.doesNotMatch(agent, /Spør om det bør gjøres/);
assert.doesNotMatch(agent, /Request specific details needed/);
});
test('ros-analysis-agent.md no longer instructs the subagent to ask the user', () => {
const agent = read('agents/ros-analysis-agent.md');
assert.doesNotMatch(agent, /Request specific details needed/);
});
// --- Del 4: adr-writer-agent returns content; the command is the single writer ---
test('adr-writer-agent.md does not carry the Write tool and does not write files', () => {
const agent = read('agents/adr-writer-agent.md');
const toolsLine = agent.split('\n').find((l) => l.startsWith('tools:')) || '';
assert.doesNotMatch(toolsLine, /Write/, 'adr-writer-agent must not have the Write tool (subagents never write)');
assert.doesNotMatch(agent, /### 4\. Write to File/);
});