diff --git a/memory/2026-03-01-session-continuity-protocol-feature-planning.md b/memory/2026-03-01-session-continuity-protocol-feature-planning.md new file mode 100644 index 000000000..4ff5ed7f0 --- /dev/null +++ b/memory/2026-03-01-session-continuity-protocol-feature-planning.md @@ -0,0 +1,42 @@ +# 2026-03-01 Session Notes + +## Session Continuity Protocol Feature Planning + +Nicholai designed a comprehensive feature to help Signet agents survive context window limits by capturing session state checkpoints before compaction. The system uses two data channels: passive accumulation (automatic observation of queries and /remember calls) and agent-initiated digests (via MCP tool, Phase 2). + +### Architecture Overview + +The implementation spans three phases: +- **Phase 1**: schema, sessionKey plumbing, passive checkpoints, recovery injection, API endpoints +- **Phase 2**: MCP session_digest tool and agent instruction updates +- **Phase 3**: pre-compaction enrichment, pruning tuning, scorer integration + +Checkpoints are stored in a new `session_checkpoints` table with normalized project paths (via realpath) for reliable matching across symlinks. The table uses UUIDs instead of sequences to avoid race conditions on concurrent writes. + +### Key Decisions + +- **Separate table from memories**: checkpoints have different lifecycle (hours vs weeks), query patterns, and retention. Mixing would pollute the scoring/decay pipeline. +- **Dropped sequence column**: avoids race conditions; ordering by `created_at DESC` instead. +- **Added project_normalized**: resolves symlink aliases for reliable cross-session matching. +- **Buffered checkpoint writes**: 2-3 second debounce to avoid blocking hot paths on user-prompt-submit. +- **Pre-reserved budget for recovery**: 2000-char section injected at session-start before memory injection to guarantee space. + +### Implementation Scope + +Nine implementation steps identified: +1. SessionKey plumbing in CLI hooks to extract and forward `session_id` from Claude Code +2. Migration 016 for session_checkpoints table and indexes +3. New continuity-state module for per-session accumulation tracking +4. New session-checkpoints module for checkpoint CRUD operations +5. Buffered flush queue (setTimeout-based) +6. Hook integration (session-start, user-prompt-submit, remember, session-end, pre-compaction) +7. CLI parsing updates +8. Redaction of agent-initiated digests before storage +9. Configuration schema under PipelineV2Config + +### Open Threads + +- Phase 2 and 3 implementation deferred +- MCP session_digest tool design pending +- Pruning policy and retention day thresholds TBD +- Scorer integration with checkpoint relevance ranking pending \ No newline at end of file diff --git a/memory/memories.db b/memory/memories.db index 84dd2db10..0297f7def 100644 Binary files a/memory/memories.db and b/memory/memories.db differ diff --git a/memory/memories.db-shm b/memory/memories.db-shm index 0a2485ec7..291e7319e 100644 Binary files a/memory/memories.db-shm and b/memory/memories.db-shm differ diff --git a/memory/memories.db-wal b/memory/memories.db-wal index 30547eb63..4f8a10a55 100644 Binary files a/memory/memories.db-wal and b/memory/memories.db-wal differ