test(ai-psychosis): extend privacy canary to pattern-phrase leak

This commit is contained in:
Kjell Tore Guttormsen 2026-05-01 17:56:31 +02:00
commit 767bc06c51

View file

@ -41,4 +41,26 @@ describe('privacy', () => {
const allContent = readAllFiles(dir);
assert.ok(!allContent.includes(canary), `Canary "${canary}" found in data files — privacy violation`);
});
it('never leaks matched-pattern phrases through full lifecycle', () => {
dir = setupTestDir();
const matchedPhrase = 'are you sure';
const canary = 'CANARY_PRIVACY_xyz123';
const prompt = `${matchedPhrase}? ${canary}`;
runHook('session-start.mjs', { session_id: 'priv2', cwd: '/tmp' }, dir);
runHook('prompt-analyzer.mjs', { session_id: 'priv2', prompt }, dir);
runHook('tool-tracker.mjs', { session_id: 'priv2', tool_name: 'Edit' }, dir);
runHook('session-end.mjs', { session_id: 'priv2', cwd: '/tmp' }, dir);
const allContent = readAllFiles(dir);
assert.ok(
!allContent.includes(canary),
`Canary "${canary}" leaked — pattern-match did not protect prompt text`
);
assert.ok(
!allContent.toLowerCase().includes(matchedPhrase),
`Matched phrase "${matchedPhrase}" leaked — pattern name or trigger phrase written to disk`
);
});
});