-
-
Notifications
You must be signed in to change notification settings - Fork 925
fix: Restore deleted memory hooks and implement three-tier MEMORY architecture #411
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
fix: Restore deleted memory hooks and implement three-tier MEMORY architecture #411
Conversation
…hitecture Fixes danielmiessler#372, danielmiessler#377, danielmiessler#362, danielmiessler#350 ## Summary Restores memory capture functionality deleted in kai→pai rebrand and implements the complete three-tier MEMORY architecture documented in MEMORYSYSTEM.md. ## Restored Hooks (from commit 45bb441^) - capture-all-events.ts - Universal event logging to JSONL - capture-session-summary.ts - Auto-generate session summaries - stop-hook.ts - Capture work at session end - subagent-stop-hook.ts - Track delegated agent results ## Restored Libraries - lib/observability.ts - Event logging functions (Issue danielmiessler#377) - lib/metadata-extraction.ts - Agent metadata enrichment (Issue danielmiessler#362) ## Three-Tier MEMORY Architecture Added complete directory structure as specified in docs: - Work/ - Per-task active tracking (HOT) - Learning/{OBSERVE,THINK,PLAN,BUILD,EXECUTE,VERIFY,ALGORITHM}/ - Phase-based synthesis (WARM) - History/{sessions,learnings,research,decisions,raw-outputs}/ - Immutable archive (COLD) - State/ - Real-time operational metrics - Signals/ - Pattern detection logs ## Path Fixes (Issue danielmiessler#350) - Updated initialize-session.ts: history/ → MEMORY/ - Now creates full three-tier structure on session start ## Migration Added migrate-to-memory.ts for users with existing history/ data ## Testing - Hooks tested locally with .claude setup - Event capture verified (59 events logged) - Session summaries working (4 sessions captured) - All module imports resolved Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Updates documentation to reflect: - Three-tier Hot/Warm/Cold structure - Data flow between tiers - Correct hook references (pai-hook-system not pai-history-system) - Learning bubble-up criteria - Signal tracking system Aligns documentation with MEMORYSYSTEM.md spec.
|
@danielmiessler - I've submitted this PR to restore the memory hooks that were deleted in v2.1.0 and implement the complete three-tier MEMORY architecture documented in MEMORYSYSTEM.md. This fixes 4 open issues (#372, #377, #362, #350) that have been blocking users since Jan 8-11. Key points:
Would appreciate your review when you have time. Happy to make any adjustments you'd like. Thanks for building PAI - it's an incredible project! 🙏 |
|
FYI to issue reporters who might want to test this: @berggrenmartinj-bit (#372) - All 4 deleted hooks restored If any of you have a chance to test this PR, feedback would be greatly appreciated! |
Found during local testing: hooks were writing to flat MEMORY/ structure instead of the three-tier MEMORY/History/ location. **Path corrections:** - capture-all-events.ts: raw-outputs/ → History/raw-outputs/ - capture-session-summary.ts: sessions/ → History/sessions/ + raw-outputs/ → History/raw-outputs/ - stop-hook.ts: sessions/ → History/sessions/ - subagent-stop-hook.ts: research/ → History/research/ **Why this matters:** The three-tier architecture requires: - Work/ = Hot (active tasks) - Learning/ = Warm (phase-based synthesis) - History/ = Cold (immutable archive) ← events/sessions go here **Testing:** ✅ Verified events write to MEMORY/History/raw-outputs/2026-01/ ✅ Verified sessions write to MEMORY/History/sessions/2026-01/ ✅ Tested all 4 hooks - no errors ✅ 637 events captured during testing Aligns implementation with MEMORYSYSTEM.md specification.
Update: Path Fixes AppliedFound and fixed a bug during local testing: Issue: Hooks were creating the three-tier directory structure but then writing to the old flat locations. Fix: Updated all 4 capture hooks to write to
Testing: ✅ Verified locally - 637 events captured to correct locations during testing session. The three-tier architecture now works as specified:
Ready for review! |
Summary
Restores memory capture functionality deleted during kai→pai rebrand and implements the complete three-tier MEMORY architecture documented in
MEMORYSYSTEM.md.Issues Fixed
What Was Broken
In v2.1.0, four critical memory hooks were deleted (commit 45bb441) without being migrated:
capture-all-events.ts(130 lines)capture-session-summary.ts(159 lines)stop-hook.ts(190 lines)subagent-stop-hook.ts(233 lines)Additionally, two library files were missing:
lib/observability.ts- Event logging functionslib/metadata-extraction.ts- Agent metadata enrichmentResult: MEMORY system documented but non-functional.
What This PR Does
1. Restores Deleted Hooks (4 files)
Recovered from git history (commit 45bb441^) and updated for MEMORY/ structure:
capture-all-events.ts- Universal event logging to JSONLcapture-session-summary.ts- Auto-generate session summariesstop-hook.ts- Capture work at session endsubagent-stop-hook.ts- Track delegated agent results2. Restores Missing Libraries (2 files)
lib/observability.ts- Fixes Issue: pai-hook-system pack - missing observability.ts + outdated history/MEMORY references #377lib/metadata-extraction.ts- Fixes Bug: pai-history-system missing src/lib/metadata-extraction.ts #3623. Implements Three-Tier MEMORY Architecture
Added complete directory structure per
MEMORYSYSTEM.md:HOT (CAPTURE) - Active task tracking:
WARM (SYNTHESIS) - Phase-based learning aggregation:
COLD (APPLICATION) - Immutable historical archive:
Pattern Detection & State:
4. Path Fixes (Issue #350)
initialize-session.ts:history/→MEMORY/History/5. Documentation Updates
pai-hook-system/README.md- Lists all 12 componentsMEMORY/README.md- Reflects three-tier architectureCHANGELOG.md- Documents changes6. Migration Tool
migrate-to-memory.ts- Migrate existing history/ dataTesting Evidence
Tested locally with working
.claudesetup:Alignment with Architecture
This implementation follows the official specs:
MEMORYSYSTEM.md- Three-tier architecture specificationPAISYSTEMARCHITECTURE.md- System integrationTHEHOOKSYSTEM.md- Hook lifecycleBreaking Changes
None - This is purely additive:
Files Changed
Added: 10 files (+1,180 lines)
Modified: 3 files
initialize-session.ts- Updated pathspai-hook-system/README.md- Documented componentsMEMORY/README.md- Three-tier architectureChecklist
${PAI_DIR}Future Work
This PR restores basic functionality. Still needed (separate PRs):
Timeline: Developed Jan 15, 2026 in response to community issues #372, #377, #362, #350 reported Jan 8-11.
Co-Authored-By: Claude Sonnet 4.5 noreply@anthropic.com