ai-psychosis/CHANGELOG.md
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

295 lines
13 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Changelog
All notable changes to this project will be documented in this file.
## [Unreleased]
### Fixed
- **The burst and edit-ratio heuristics could not tell reading from editing**
(`docs/BRIEF-vurdering-v2.md` tiltak 1, verification points 1a/1b). A bulk
read of many files produced the same "Rapid-fire: N consecutive fast
interactions" alert as a rapid-fire editing sequence, and a read-heavy
analysis session was reported as "possible stuck/spiral" purely because its
edit ratio is structurally low. `tool-tracker.mjs` now tracks whether a
burst run consists only of read tools (`Read`/`Grep`/`Glob`/`NotebookRead`)
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 are
unchanged. No new data is recorded — the differentiation uses `tool_name`,
which `events.jsonl` already logs.
## [1.2.2] — 2026-08-02
### Fixed
- **Three cited Anthropic URLs in `SKILL.md` returned HTTP 404.**
`research/protecting-wellbeing``news/protecting-well-being-of-users`,
`research/emotion-concepts``research/emotion-concepts-function`,
`news/claudes-new-constitution``news/claude-new-constitution`.
- **A quoted guidance criterion was silently truncated mid-sentence.**
Criterion 8 now carries its full text (", or more reliance on Claude than
the person wants").
- **The sycophancy rubric's direction was left implicit.** `SKILL.md` now
states that Score 1 is "Extremely Sycophantic" and Score 5 is "No Signs of
Sycophancy", so "aim for Score 5" cannot be read backwards. Attribution
sharpened to the Appendix rubric, pp. 910.
- **`/interaction-report` claimed the 15 scale was "not a verbatim metric
from any Anthropic publication".** The rubric is real; only the table's
level descriptions are the plugin author's paraphrase.
- **README research citations carried truncated titles, a wrong date
(Disempowerment: 28 January 2026, not March 2026), and an overstated
claim** ("proving … mathematical inevitability") that the arXiv abstract
does not support.
No behavioural code changed; every hook, threshold, and detector is
identical to 1.2.1. Full verification log in `docs/review-2026-06-20.md`.
## [1.2.1] — 2026-06-24
### Fixed
- **Hooks emitted invalid JSON, so Claude Code dropped their injected
context.** `outputWithContext()` wrote a `hookSpecificOutput` object
without the required `hookEventName` field; the harness rejected it
("hookSpecificOutput is missing required field hookEventName") and
discarded the context the SessionStart, UserPromptSubmit, and PostToolUse
hooks tried to inject. The helper now takes the event name and every
caller passes its own (`SessionStart` / `UserPromptSubmit` / `PostToolUse`).
## [1.2.0] — 2026-05-01
Research-paper-driven detector update. Implements operational findings from
Anthropic's "How people ask Claude for guidance" Appendix (April 2026).
### Added
- **User-information detector** — three-class signal (`yes_people` /
`yes_digital` / `no`) following the paper's page-11 finding that human
contact is the strongest disempowerment signal. ~32 patterns covering
therapist/friend/mentor (yes_people), search/AI/forums (yes_digital),
and explicit isolation phrases (no). Sticky upward priority.
- **Validation-seeking detector** — separate from `val_flags`. Targets
reality-testing ("am I crazy?"), pre-committed stance + confirmation,
and side-taking pressing. ~12 patterns.
- **Tier-1 user-info isolation alert** — fires per session when
`user_info_class === 'no'` + high-stakes domain + `turn_count >= 15`.
- **Tier-2 cross-session isolation alert** — fires at `SessionStart` when
the last 3 end records all classify as `no` in high-stakes domains.
Bounded `readRecentEndRecords()` tail-scan in `lib.mjs` keeps this
scalable to 50K+ session histories.
- **8 new paper-grounded domain patterns** — `legal`, `parenting`, `health`,
`financial`, `professional`, `spirituality`, `consumer`, `personal_dev`.
Total domains 4 → 9.
- **Pushback re-contextualization (alert)** — v1.1.0 only counted; v1.2 adds
the alert with domain awareness:
- Relationship/spirituality: pushback signals validation-pressing — alert.
- Legal/parenting/health/financial/professional: pushback is healthy
self-advocacy — no alert.
- Otherwise: conservative default — alert.
- **Domain-stakes weighting matrix** — `DOMAIN_STAKES` in `lib.mjs` (1.01.5).
Applied ONLY to new v1.2 alerts (pushback in HIGH_SYCOPHANCY, valseek in
HIGH_STAKES). v1.1.0 alert sensitivity is preserved.
- **Multi-domain support** — `state.domain_context` promoted from string to
array. v1.1.0 string records continue to aggregate correctly via
shape-coercion in `report-reader.mjs`.
- **`SKILL.md` updates** — verbatim Score 5 sycophancy phrase + 3 of the 11
guidance criteria (engagement-foster avoidance, confident-verdict caution,
speak-frankly principle).
- **`/interaction-report` v1.2 sections** — per-domain breakdown, user-info
distribution, valseek summary, stakes signal aggregation. Backward-compat
with v1.0/v1.1 records preserved.
- **Privacy canary extensions** — 5 new canary cases per detector category
(yes_people, yes_digital, no, valseek, legal domain).
- **Perf budget validated at v1.2 pattern set** — sample patterns expanded
to ~91+ entries; new wall-clock test exercises tier-2 read at
1000-record sessions.jsonl scale.
- **Test count: 126 → 258 cases** across 12 files (added `lib.test.mjs`,
`domain-detection.test.mjs`, `user-info.test.mjs`,
`validation-seeking.test.mjs`, `stakes-matrix.test.mjs`).
### Changed
- Pattern count: 41 → ~133 (25 negative + 12 pushback + 4 relationship
+ 48 new domains + 32 user-info + 12 valseek).
- End-record schema (v1.2): adds `user_info_class`, `valseek_count`,
`turn_count`. `domain_context` is always an array (was string in v1.1).
- `report-reader.mjs` discriminates v1.0 / v1.1 / v1.2 records via the
presence of `user_info_class`. v1.0/v1.1 records degrade gracefully.
### Deferred
- **Norwegian patterns** — moved to v1.3.
[1.2.0]: https://git.fromaitochitta.com/open/ai-psychosis/compare/v1.1.0...v1.2.0
## [1.1.0] — 2026-05-01
### Added
- **12 pushback patterns** — detects "you're wrong, my way is right"
signals that suggest the user is reinforcing their own position
rather than receiving feedback (e.g. `\b(you'?re|you are) wrong\b`,
`\bdo it my way\b`, `\b(stop|quit) (arguing|pushing back)\b`).
- **4 domain-context patterns** — flags relational/identity framing
(`\b(my|our) relationship\b`, `\b(my|our) (purpose|mission|destiny)\b`)
that, combined with high pushback or validation, signal narrative
crystallization risk.
- **Valence-aware composition** — same-invocation valence guard so a
healthy correction ("you were wrong, here's why") is not counted
as pushback escalation.
- **`/interaction-report` extensions** — pushback metrics + domain
framing distribution; companion `report-reader.mjs` script handles
legacy v1.0.0 records (missing `pushback`/`domain_context`) without
NaN propagation.
- **CC0 Constitution citation** in `SKILL.md` plus 5-publication
research framework (Anthropic, MIT CSAIL, Nature, arXiv, clinical).
- **Performance budget test** — `tests/perf.test.mjs` enforces hook
timing budget (logic <50ms, total <200ms wall-clock).
- **Privacy canary extension** — pattern-phrase leak canary in
`tests/privacy.test.mjs` confirms matched phrases never reach disk.
- **Test count: 73 → 126 cases** across 8 files (added skill-md,
perf, interaction-report tests; extended prompt-analyzer, privacy,
session-end, session-start).
### Changed
- Pattern count: 25 → 41 (25 negative + 12 pushback + 4 domain).
- `commands/interaction-report.md` documents v1.0.0 backward
compatibility for legacy JSONL records.
### Notes
- **English-only v1.1.0** — Norwegian/multilingual patterns deferred
to v1.2 (see `ROADMAP.md`).
- **First-mover honesty** — domain-precision is "good enough" for
v1.1.0; precision tuning planned for v1.2.
## [1.0.0] — 2026-04-05
### Added
- **Layer 4: Contemplative references** — conditional section in
`/interaction-report` when flags are elevated (total >= 5 or fatigue >= 2)
and `layer4: true`. Points to Miracle of Mind by Sadhguru.
- **Automated test suite** — 73 cases using `node:test` (zero npm deps):
session-start (4), prompt-analyzer (56), tool-tracker (8),
session-end (4), privacy canary (1)
### Fixed
- Dependency regex `you understand me` no longer matches "merging" (added `\b`)
### Changed
- CLAUDE.md testing section updated for automated tests
- Deprecated bash scripts removed (available in git history)
- All "Known gaps" from v0.4.0 resolved
## [0.4.0] — 2026-04-05
### Changed
- **All hooks migrated from bash+jq to Node.js** — full cross-platform
support (macOS, Linux, Windows)
- `lib.sh``lib.mjs` (shared library, 22 functions)
- `session-start.sh``session-start.mjs`
- `prompt-analyzer.sh``prompt-analyzer.mjs` (23 regex patterns)
- `tool-tracker.sh``tool-tracker.mjs`
- `session-end.sh``session-end.mjs`
- hooks.json now invokes `node ...mjs` instead of `bash ...sh`
- Zero npm dependencies — Node.js stdlib only (`fs`, `path`, `os`)
- Bash scripts deprecated (kept for reference, marked with DEPRECATED)
- Dependencies reduced: bash and jq no longer required
- All documentation updated for Node.js migration
### Fixed
- Data path fallback now matches documented path
(`~/.claude/plugins/data/ai-psychosis`)
- `.claude/` directory added to `.gitignore`
- Private repo path removed from design brief
- CONTRIBUTING.md line reference corrected
- README now links to CONTRIBUTING.md
- plugin.json includes author, license, repository fields
## [0.3.0] — 2026-04-05
### Added
- **Layer 3: Interaction reports** — `/interaction-report` slash command
for aggregated session statistics
- Time periods: `weekly` (default), `monthly`, `all`
- Overview: session count, avg duration, tool calls, edit ratio
- Pattern flags: dependency, escalation, fatigue, validation frequency
- Tool usage distribution (top 10)
- Daily activity breakdown
- Trend comparison vs previous period
- `commands/interaction-report.md` — pure markdown command, no script
dependencies (cross-platform: macOS, Linux, Windows)
- Layer 3 respects `layer3: true/false` in
`.claude/ai-psychosis.local.md` (opt-in, off by default)
### Changed
- README updated with Layer 3 usage instructions
- Platform compatibility expanded: Layer 3 works on Windows
- Version bumped to 0.3.0
## [0.2.0] — 2026-04-05
### Added
- **Layer 2: Programmatic pattern detection** — four hooks measuring session
time, tool usage, burst patterns, and language flags
- `session-start.sh` — daily session count, late-night detection
- `prompt-analyzer.sh` — dependency, escalation, fatigue, and
validation-seeking pattern flags (prompt text never stored)
- `tool-tracker.sh` — event logging, edit ratio, burst detection,
progressive alerts with cooldown
- `session-end.sh` — session finalization, JSONL record, state cleanup
- `lib.sh` — shared library with thresholds, state management, cooldown
logic, and layer configuration
- Per-project layer configuration via
`.claude/ai-psychosis.local.md`
- `require_layer()` guard in all hook scripts — layers are opt-in/out
- MIT LICENSE file
- `matcher` field in hooks.json for schema compliance
### Changed
- hooks.json now registers 4 events (was 2)
- `DATA_DIR` fallback hardened to `~/.claude/data/ai-psychosis`
- README rewritten with architecture diagram, research background,
privacy section, threshold reference tables
- Version bumped to 0.2.0
### Removed
- `periodic-reminder.sh` — replaced by `tool-tracker.sh`
- `session-awareness.sh` — replaced by `session-start.sh`
## [0.1.0] — 2026-04-04
### Added
- **Layer 1: Behavioral instructions** — `SKILL.md` with 5 rules and 5
named patterns (reinforcement loop, scope escalation, narrative
crystallization, emotional dependency, session overuse)
- `periodic-reminder.sh` — re-injects awareness every 25 tool calls
- `session-awareness.sh` — SessionStart context injection
- Plugin manifest (`plugin.json`)
- Design document (`docs/ai-ai-psychosis-brief_1.md`)
## Known gaps
- No CI pipeline
- Single-user plugin — no multi-user patterns considered
[1.1.0]: https://git.fromaitochitta.com/open/ai-psychosis/compare/v1.0.0...v1.1.0
[1.0.0]: https://git.fromaitochitta.com/open/ai-psychosis/compare/v0.4.0...v1.0.0
[0.4.0]: https://git.fromaitochitta.com/open/ai-psychosis/compare/v0.3.0...v0.4.0
[0.3.0]: https://git.fromaitochitta.com/open/ai-psychosis/compare/v0.2.0...v0.3.0
[0.2.0]: https://git.fromaitochitta.com/open/ai-psychosis/compare/v0.1.0...v0.2.0
[0.1.0]: https://git.fromaitochitta.com/open/ai-psychosis/releases/tag/v0.1.0