Bug: Hooks write to history/ instead of documented MEMORY/ structure
Problem
After installing PAI with pai-hook-system and pai-core-install, I noticed that two parallel directory structures were created:
.claude/
├── history/ ← Hooks write here
│ ├── sessions/
│ ├── raw-outputs/
│ └── ...
└── MEMORY/ ← Documentation says data should be here
├── sessions/
├── raw-outputs/
└── ...
This causes confusion because the MEMORY/README.md (from pai-core-install) documents that all session data should live in MEMORY/, but the hooks actually write to history/.
Root Cause
The hooks in pai-hook-system were not updated when the MEMORY/ structure was introduced in pai-core-install.
Documentation says (MEMORY/README.md lines 7-19):
MEMORY/
├── research/ # Research session outputs
├── sessions/ # Session summaries and context
├── learnings/ # Learning artifacts and insights
├── security/ # Security event logs
├── raw-outputs/ # JSONL event streams
└── ...
Hooks actually do:
| File | Line | Writes to |
|---|---|---|
pai-hook-system/src/initialize-session.ts |
101-103 | history/sessions, history/learnings, history/research |
pai-observability-server/src/.../file-ingest.ts |
29, 36 | history/raw-outputs |
Steps to Reproduce
- Install PAI with
pai-hook-systemandpai-core-install - Start a Claude Code session
- Observe that
history/sessions/is created (notMEMORY/sessions/) - Compare with
MEMORY/README.mdwhich documentsMEMORY/sessions/
Suggested Fix
Update all hooks to write to MEMORY/ subdirectories as documented:
// Before (initialize-session.ts lines 101-103)
join(paiDir, 'history', 'sessions'),
join(paiDir, 'history', 'learnings'),
join(paiDir, 'history', 'research'),
// After
join(paiDir, 'MEMORY', 'sessions'),
join(paiDir, 'MEMORY', 'learnings'),
join(paiDir, 'MEMORY', 'research'),
Files that need updating:
-
Packs/pai-hook-system/src/initialize-session.ts -
Packs/pai-observability-server/src/observability/apps/server/src/file-ingest.ts - Any other hooks referencing
history/
Offer to Contribute
I've already fixed this in my local PAI installation and would be happy to submit a PR with the changes if that would be helpful.
Environment: PAI installed from main branch, 2026-01-17