// 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/); });