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
This commit is contained in:
parent
626140bb6a
commit
2c9e2de00a
5 changed files with 141 additions and 13 deletions
|
|
@ -65,7 +65,7 @@ layer4: false # default off
|
|||
|
||||
## Testing
|
||||
|
||||
Automated test suite using `node:test` (258 cases, zero npm dependencies):
|
||||
Automated test suite using `node:test` (263 cases, zero npm dependencies):
|
||||
|
||||
```bash
|
||||
node --test tests/*.test.mjs
|
||||
|
|
@ -75,7 +75,7 @@ node --test tests/*.test.mjs
|
|||
|------|-------|----------|
|
||||
| `tests/session-start.test.mjs` | 11 | State init, JSONL, tier-2 cross-session alert |
|
||||
| `tests/prompt-analyzer.test.mjs` | 100 | All v1.x patterns × 2 + thresholds + valence + v1.2 pushback contract |
|
||||
| `tests/tool-tracker.test.mjs` | 8 | Counting, burst, reminders |
|
||||
| `tests/tool-tracker.test.mjs` | 13 | Counting, burst, reminders + read-tool calibration |
|
||||
| `tests/session-end.test.mjs` | 7 | Finalize, duration, flags, v1.1.0 string + v1.2 array shapes |
|
||||
| `tests/privacy.test.mjs` | 7 | Canary + matched-phrase × original + 5 v1.2 detector variants |
|
||||
| `tests/skill-md.test.mjs` | 3 | Constitution citation + Score 5 + 11 guidance criteria |
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue