This file is the shared briefing for any coding agent working in this repository — Codex, Claude Code, OpenCode, Aider, Cursor, or anything else that reads AGENTS.md / CLAUDE.md at repo root.
Sacred Brain — a small personal memory+agents stack running on a Raspberry Pi. It is starting a compatibility rename toward the neutral name agent-memory; keep Sacred Brain names working while adding agent-memory aliases.
Two core services run under systemd:
- Hippocampus (
:54321) — FastAPI memory store, Mem0-backed with SQLite persistence. The authoritative store. - Memory Governor (
:54323) — FastAPI policy/coordination layer in front of Hippocampus. Handles salience, consolidation, tiers (safe/raw), scopes, and durable write queueing.
See docs/README.md for the full docs index. docs/ARCHITECTURE.md + docs/STACK.md are the quickest on-ramp for the live picture; CHANGELOG.md is the timeline.
- Design docs →
docs/*.md. Permanent. Explain what and why. - Task files →
agents/tasks/NNN_slug.md. Disposable work orders — one focused PR each. Format inagents/tasks/README.md. - Historical tasks (Codex-only) →
codex/tasks/001–009. Kept for provenance; do not add new files here. New tasks go underagents/tasks/. - Session notes →
SESSION_LOG.mdandCHANGELOG.md.
- Read the design docs relevant to the area you're touching (usually
docs/MEMORY_GOVERNOR.md,docs/ARCHITECTURE.md). - Check
agents/tasks/for a pending task. If none fits, author one using the template inagents/tasks/README.mdbefore coding. - Implement in small, reviewable steps. Keep tests passing (
justfilehassmoke,health,config-check). - Update the task file status inline (
(in progress)→(done)). - Note significant milestones in
SESSION_LOG.mdorCHANGELOG.md.
/home/ryer/projects/sacred-brain/is a back-compat symlink to/home/ryer/projects/agent-memory/— same tree, either path is fine to edit.- Hippocampus stays a dumb semantic store. New policy/lifecycle logic goes in the Governor.
- There are two deployment layouts, and they are not interchangeable:
- User layout — this is the live one (red5). Runs as
ryerviasystemctl --user; state in~/.local/state/agent-memory/, config in~/.config/agent-memory/, units inops/systemd/user/. - System layout. Runs as the
agent-memoryuser (nologin); state in/var/lib/agent-memory/, config in/etc/agent-memory/, docs in/usr/local/share/agent-memory/docs/, installed by theMakefile. There is no source tree on a deployed host: every unit invokes a console script from the pipx venv, so a checkout is build-time only. No host currently runs this layout (red4 was decommissioned 2026-08-28).
- User layout — this is the live one (red5). Runs as
- All new memory features should respect the
safe/rawtier split and scope filtering — don't bypass them.
If an agent needs extra guidance beyond what's here, add a short section below with the agent's name. Everything above applies to all agents.
If
.agents/CONTEXT_MEMORY.mdor.claude/CONTEXT_MEMORY.mdexists in the workspace, treat its bullet list as recalled long-term memory for this session. It is generated byscripts/governor_context.shand is safe to ignore if absent.To search long-term memory on demand (including ChatGPT conversation imports), run
agent-memory-search <query> [user_id] [limit](legacy alias:sacred-search). Defaults:user_id=sam,limit=5. Useuser_id=davidto search memories extracted from David's ChatGPT history. This hits Hippocampus directly — archive memories that the Governor's/recallsuppresses are included here.
Legacy task files under codex/tasks/ are historical; codex/instructions.md is superseded by this file for new work. The Governor bridge (see docs/CODEX_BRIDGE.md) pre-pulls recalled memories into .agents/CONTEXT_MEMORY.md via the codex-with-governor launcher wrapper — the same file OpenCode reads.
Project-scoped memory in .claude/ is welcome. The Governor bridge (see docs/CLAUDE_CODE_BRIDGE.md) writes recalled memories into .claude/CONTEXT_MEMORY.md on SessionStart and ships transcript tails to /observe before compaction.
Reads this file directly. The Governor bridge (see docs/OPENCODE_BRIDGE.md) writes recalled memories into .agents/CONTEXT_MEMORY.md via either a native pre-session hook or the opencode-with-governor launcher wrapper.
Pi exposes a typed extension API instead of a shell-hook config slot, so the bridge ships as a TypeScript extension at ~/.pi/agent/extensions/sacred-brain-bridge.ts (sourced from extensions/pi-bridge.ts in this repo). It subscribes to session_start/before_agent_start/session_before_compact/session_shutdown and (a) pulls recalled memory into .agents/CONTEXT_MEMORY.md and directly into the system prompt, (b) POSTs the to-be-summarised tail to /observe with source pi:precompact (capped at 0.35 salience), and (c) drains ~/.cache/agent-memory/pi-pending-outcome.jsonl on session shutdown. See docs/PI_BRIDGE.md.