ai-psychosis/tests
Kjell Tore Guttormsen 2c9e2de00a fix(hooks): differentiate burst and edit-ratio heuristics on tool type
The burst counter incremented on any tool call <30s apart regardless of
tool type, so a bulk read of many files produced the same "Rapid-fire"
alert as a rapid-fire editing sequence. The edit-ratio check reported
"possible stuck/spiral" for any session under 10% edits past 30 minutes,
which a read-heavy analysis session satisfies structurally whether or not
the work is productive. Both mechanisms are confirmed in
docs/BRIEF-vurdering-v2.md, verification points 1a and 1b.

tool-tracker.mjs now tracks whether the current burst run consists only
of read tools and suppresses the rapid-fire alert for such runs. A
read-dominant session (>=70% reads) reports its low edit ratio as
context rather than as a stuck/spiral claim, and never as the sole
reason for a warning. Bursts involving Edit/Write/Bash and
non-read-dominant sessions behave exactly as before.

No new data is recorded: the differentiation uses tool_name, which
events.jsonl already logs. The privacy design is untouched.

Tests first (Iron Law): 5 cases in tests/tool-tracker.test.mjs, 3 of
which failed against the previous implementation, 2 of which are
regression guards that passed before and still pass.

Verified: node --test tests/*.test.mjs -> 263 pass, 5 fail. All 5
failures are the perf wall-clock assertions, which fail identically on
HEAD without this change (measured by stashing and re-running) — they
are a pre-existing property of this machine, not a regression.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011wMhJuPFUiWqKLSQjrzCXP
2026-08-13 20:59:42 +02:00
..
domain-detection.test.mjs feat(ai-psychosis): add 8 paper-grounded domain patterns 2026-05-01 21:32:26 +02:00
interaction-report.test.mjs feat(ai-psychosis): /interaction-report surfaces v1.2 fields 2026-05-01 21:53:41 +02:00
lib.test.mjs fix(hooks): close F-5 path-traversal hardening in lib.mjs, split by field 2026-08-09 10:04:33 +02:00
perf.test.mjs test(ai-psychosis): perf budget validated at v1.2 pattern set 2026-05-01 21:56:14 +02:00
privacy.test.mjs test(ai-psychosis): privacy canary covers v1.2 detectors 2026-05-01 21:54:22 +02:00
prompt-analyzer.test.mjs fix(hooks): include required hookEventName in hookSpecificOutput JSON 2026-06-24 06:46:11 +02:00
session-end.test.mjs feat(ai-psychosis): promote domain_context to array for multi-domain support 2026-05-01 21:28:36 +02:00
session-start.test.mjs fix(hooks): close F-5 path-traversal hardening in lib.mjs, split by field 2026-08-09 10:04:33 +02:00
skill-md.test.mjs docs(ai-psychosis): SKILL.md cites paper Score 5 + 11 guidance criteria 2026-05-01 21:51:21 +02:00
stakes-matrix.test.mjs feat(ai-psychosis): domain-stakes weighting on alert thresholds 2026-05-01 21:46:29 +02:00
test-helper.mjs feat(ultraplan-local): v1.6.0 — /ultraresearch-local deep research command 2026-04-08 08:58:35 +02:00
tool-tracker.test.mjs fix(hooks): differentiate burst and edit-ratio heuristics on tool type 2026-08-13 20:59:42 +02:00
user-info.test.mjs feat(ai-psychosis): tier-1 user-info isolation alert (per-session) 2026-05-01 21:38:51 +02:00
validation-seeking.test.mjs feat(ai-psychosis): domain-stakes weighting on alert thresholds 2026-05-01 21:46:29 +02:00