Personal_AI_Infrastructure icon indicating copy to clipboard operation
Personal_AI_Infrastructure copied to clipboard

Bug: Hooks write to history/ instead of documented MEMORY/ structure

Open Steffen025 opened this issue 2 days ago • 0 comments

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

  1. Install PAI with pai-hook-system and pai-core-install
  2. Start a Claude Code session
  3. Observe that history/sessions/ is created (not MEMORY/sessions/)
  4. Compare with MEMORY/README.md which documents MEMORY/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

Steffen025 avatar Jan 17 '26 12:01 Steffen025