title: Session DNA Format: JSON over YAML

content: JSON is chosen for the Session DNA format due to its token efficiency, strictness to reduce parsing errors, and ubiquitous library support in Python.


title: Three-Tier Memory Architecture

content: The system uses Hot Memory (In-Prompt <2K tokens, includes Session DNA), Warm Memory (On-Demand Redis <10ms, last 50 events), and Cold Memory (Semantic Search PostgreSQL/Qdrant >10ms) to optimize token usage.


title: Agent Queue Implementation: Redis Lists

content: Agents are decoupled from the session using Redis Lists as a task queue, with a persistent worker process, ensuring agents survive session respawns.


title: Zero-Boot Protocol Steps

content: The new protocol reduces boot context from 80K to <10K tokens: 1. Load static rules (~8K tokens). 2. Call on_session_start() to fetch DNA and reconstruct state. 3. Generate curated <200 line MEMORY.md. 4. Inject DNA and memory (~1.5K tokens).

steps: Load GLOBAL_RULES.md and CLAUDE.md (~8K tokens)

steps: Inject DNA and curated memory into prompt (~1.5K tokens)


title: 5-Week Migration Plan

content: Phased rollout plan: Week 1 (Passive Instrumentation), Week 2 (Build Core Components), Week 3 (Activate Agent Survival), Week 4 (Beta Test Zero-Boot), Week 5 (Full Rollout).

steps: Week 2: Develop MCP server, DNA logic, Redis queue

steps: Week 3: Reroute agent dispatching, verify restart survival

steps: Week 4: Implement new boot logic, A/B test

steps: Week 5: Make Zero-Boot default, deprecate old handoff


title: Session DNA Zero-Boot Capability

content: The Session DNA allows resuming sessions with <10K tokens instead of 80K, reducing boot overhead from 40% to under 5%, creating a seamless 'Invisible Seams' experience for the user.


title: Infrastructure Cost: $0 Additional

content: The architecture runs on existing Elestio stack (PostgreSQL, Redis, Qdrant). Marginal increase in storage is within limits, meeting the <$5/mo constraint. Performance targets: DNA load <200ms, Event persist <50ms.


title: Invisible Seams User Experience

content: UX strategy to make session boundaries undetectable: synthesized proactive greeting from DNA, warning at 80% context, and mid-sentence continuity via snapshot saved to Redis.


title: Event Sourcing: PostgreSQL & Redis

content: Dual-write strategy for state: Events are written to PostgreSQL (durable primary) and simultaneously XADDed to a Redis Stream (hot cache) with TTL for fast state reconstruction on respawn.


title: FalkorDB Knowledge Graph Update

content: On DECISION_MADE events, the system updates the FalkorDB knowledge graph, creating relationships between entities (e.g., FastAPI-[:IS_CHOSEN_FOR]->Talking Widget).


title: Session DNA JSON Schema

content: Draft-07 JSON Schema defining the structure of the Session DNA, including schema_version, session_id, mission (objective, status), conversation (tone, rapport_level), agents (status, heartbeat), state (decisions, blockers), and plan.


title: PreCompact Hook Logic

content: Hook triggered near context limit: Scans conversation for keywords (I decide, blocked by), generates structured events (DECISION_MADE), injects breadcrumbs ([Decision D-124]...), saves snapshot to Redis, updates DNA.


title: Agent Mailbox Pattern Workflow

content: Agent survival workflow: Genesis LPUSHes task to Redis List 'agent_task_queue' -> Worker BRPOPs and executes -> Worker HSETs result to 'agent_results_store' -> Genesis checks 'active_agents' table and picks up result.


title: MEMORY.md Auto-Curation Algorithm

content: Python pseudocode function generate_curated_memory(dna) that iterates over DNA fields (Mission, Blockers, Decisions, Plan) to produce a <200 line MEMORY.md file.


title: MCP Server (Session State Manager) Endpoints

content: FastAPI server with endpoints: GET /dna/{session_id}, POST /dna/{session_id}, POST /events/{session_id} to manage state.