System · How it composes

Every session you run
makes the next one easier.

Memory of your sessions. Library of your writing. Notes of your rules. Messages between your sessions.

They're four substrates the agent uses together — automated by hooks, dispatched by chips, refined by crons. Each one solves a different memory problem; the system is what happens when they share a project anchor.

Agent orchestration

Main session, chip workers, isolated worktrees.

When a task is bigger than the current context, the main session spawns a chip via spawn_task. The chip gets its own worktree under .claude/worktrees/<slug>/ on a fresh branch. Two sessions never share a working tree.

The chip works, commits, and reports back over the parent's session-scoped inbox. Then it stays listening on its own session id, ready for follow-ups. No polling, no orphan processes — the Monitor watcher wakes only when there's a message.

# chip prompt boilerplate, four blocks total
Block 0.5 — pull project lore
  greprag lore query --scope chip-startup --format markdown

Block 1 — setup
  git worktree add .claude/worktrees/<slug> -b chip/<slug>
  cp $main_root/.env .env

Block 2 — report back
  greprag send "status..." --to <parent-addr> --session <parent-session>

Block 3 — stay reachable
  greprag inbox watch --session <own-session> --json

Block 0.5 is the pull side of the lore loop. The spawning agent queries the project's chip-startup scope and inlines the result into the chip prompt — so the chip starts already knowing what every previous chip learned the hard way.

Recursive learning loop

Discovery waste flows in. Ready-state flows out.

The four stores feed each other. A chip hits friction — say, it spends ten minutes finding the right test command. It seeds a lore note about that. A future chip queries scope=chip-startup at spawn time and skips the discovery.

When a chip misses the moment, the backstop catches it. The hourly cron's discovery-waste extractor reads the Odyssey turn envelopes for repeated-lookup signatures and emits candidate lore notes as an inbox digest. You review, accept, ingest.

chip hits friction
    ↓
seeds lore note (real-time, in-session)          → lore store
    ↘
      hourly cron reads turns                    ← Odyssey store
      extracts missed waste signals
      emits inbox digest                         → inbox store
    ↗
user reviews, accepts
    ↓
ingests as lore note                             → lore store
    ↓
next chip queries scope=chip-startup             ← lore store
spawns fully armed

Same loop, three entry points. The lore store is the steady state. Every cycle leaves the system knowing one more thing.

Odyssey review

Daily and weekly compaction, ready to read.

Daily compaction does two things at once: it summarizes the day, and it extracts atomic ship-events (a fix landed, a feature shipped, a deploy went out). The weekly cron reads dailies and produces a "what happened this week" digest.

Use it for retrospective. Use it as input to the next session's planning. Pull a window by period and feed it to a planning agent, or skim it yourself.

$ curl "https://api.greprag.com/v1/memory/by-period?projectId=$PID&period=weekly&weeks=1"
$ curl "https://api.greprag.com/v1/memory/by-shape?projectId=$PID&shape=ship-event&limit=20"

Advisors

Cross-project counsel via greprag discover.

Specialized agents — a content-advisor for marketing, a business-advisor for strategy — sit outside any one project. They query the tenant-wide structure with greprag discover and pull lore and recent Odyssey rows from any project they need.

An advisor asks: "what shipped in greprag last week, and what's in flight on paybot?" One discover call returns the project list and counts. Two by-period calls return the weeklies. The advisor synthesizes; the stores supply the raw material.

$ greprag discover
Projects:
  greprag        (15 hourlies, 7 dailies, 1 weekly, 4 lore)
  paybot         (22 hourlies, 7 dailies, 1 weekly, 9 lore)
  openwriter     (8 hourlies, 5 dailies, 0 weeklies, 2 lore)

$ greprag lore query --project paybot --scope general

The shape of it

One engine. Four substrates. Composable.

Odyssey

The narrative — what happened.

Corpus

The library — what's been written.

Lore

The handbook — what every agent should know.

Inbox

The channel — who's saying what to whom.

All four sit on one substrate: a unified nodes table, discriminated by shape. Pure-lexical retrieval at read. Write-side LLM where the work is worth it. Same project anchor across the whole thing.