$ man kei-sleep-sync
/sleep layer · RULE 0.15
Offline pattern consolidation via cloud-agent trigger. Mirrors hippocampal REM consolidation: daytime writes raw episodes; sleep replays, generalises, and ejects what stayed noise. The user reads the morning report; nothing is auto-injected into the next session.
biological analog
| BRAIN PHASE | KEISEI ANALOG |
| Waking (hippocampus captures raw) | Local session → JSONL trace in ~/.claude/memory/traces/ |
| NREM (slow-wave rehearsal → cortex) | session-end-dump.sh → kei-sleep-sync → git push |
| REM (integration, pattern extraction) | Nightly cloud agent via /schedule → analyze + patterns |
| Morning recall | git pull; read reports/sleep-<date>.md |
3-phase nightly cycle
# sleep-on-it queue, ≤5 tasks/night quick 15 min standard 60 min deep 240 min marathon 480 min (1 task) weekly 60 min (Sun UTC) ✓ per-checkpoint commit at N min ✓ exit reasons: done / time_budget / failed▸ /sleep-on-it
# 03:07 local (jittered) 1. clone repo shallow 2. diff traces/ vs reports/last-run 3. analyze new sessions 4. detect ≥3 cross-session patterns 5. commit reports/sleep-<date>.md commit: REM: consolidation YYYY-MM-DD
# every 7 days from install anchor 1. kei-conflict-scan 2. kei-refactor-engine 3. kei-graph-check (optional gate) output modes: · plan only (default) · plan + fork branch zero-conflict guarantee: requires_human_decision → excluded
invariants
traces/*.jsonl is never modified or deleted by the cloud agent. A trace lost on push stays lost — the next session does not retry.
Wizard recommends PRIVATE visibility, warns loudly on PUBLIC. A public memory-repo leaks user prompts, tool calls, file paths, and code snippets.
Session-end path exits 0 on every sync error. A broken network must never delay session close.
Cloud agent's report is read-only text for the user. Nothing is consumed automatically by another Claude Code session. Codification → /escalate-recurrence.
setup
# inside Claude Code > /sleep-setup # or at install time $ ./install.sh --with-sleep-sync