sandman · design

memory for agentic sessions

sandman is rewritten from scratch, one part at a time. This build carries mark, take, chart, forget, the agent's recall, show and remember, its defer, due, done and drop, and the daemon, serve, whose tick ends sessions that never ended, settles held takes, releases unheld transcripts, encodes episodes, consolidates banks and topics and reviews its own guidance weekly; status, setup, upgrade and version run it. A fast store captures each session as an episode, a slow one absorbs episodes through replay, and the memory cycle decides what holds, what ends and when a transcript goes. It runs unattended: every change is a ledger line, recoverable from .pruned/ or the prompt history; today only forget deletes for good.

Data root

$SANDMAN_ROOT, else $HOME/.sandman.

The data flow, ①–④ a session's and ⑤ the weekly review, down the left edge: the verb each moment runs, what it writes under the root (docs/data/flow.json), and what chart reads back. Dashed verbs are not built yet: today the subether mod runs sandman mark at start and end and on each denied tool call, keeps its tool calls and prompts in its own daily tool log, and runs the earlier sandman's recall and take.
pathholds
.archive/claude/<yyyy>/<mm>/<dd>/<HHMMSS>-…-<session>.jsonlarchived transcripts, until release deletes one no note holds
.pruned/<yyyy>/<mm>/<dd>/<HHMMSS>-<bank>-<file>what consolidate, decay and a graduation moved aside: consumed traces, merged and pruned memories as they stood, each reply; swept to depth 1 by release, erased by forget
embeddings.jsonlrecall's embedding cache: {"h","path","v"} a line, h the SHA-256 of the model, 1024 and the text, the last line per hash winning; appended by recall and the tick, rewritten by the tick past twice its live size; about 14 MB for 635 memories, derived, so a synced root ignores it
eval/recall.jsonlrethink's labelled (cue, note) examples, one per judged send, the recall evaluation's growing set
intentions/<id>.mdintentions, work the person deferred: due a date or after an event, state open, done or dropped, the body what; written by defer, done and drop, never by the daemon
knowledge/<topic>/<file>.mdthe knowledge store: knowledge pages and playbooks filed by topic, each revised in place; a memory file's format, type knowledge or playbook
ledger/<yyyy>/<mm>/<dd>.jsonlevery mod event, one per line, by UTC day: start, end, guard (a denied tool call); call and prompt not built yet; the agent's recall, show, remember, defer, push, done, drop and rethink; the daemon's encode, consolidate and reflect; the cycle's rewrite (a release among them) and check
memories/.recent/<session>.jsonan archived session's short-term pointer: title, cwd, highlights, dreamed once dreamed
memories/<bank>/<file>.mdthe banks, the long-term store's memories, filed by repository: memory files; flat key: value frontmatter between --- fences
prompts/<job>.mda model job's guidance (encode, consolidate, reflect, judge) and recall's selection question (question), read when present; written only by reflect, every version it replaced under .history/<yyyy>/<mm>/<dd>/<HHMMSS>-<job>.md
run/the daemon's, mode 0700: serve.lock, serve.pid, serve.sock, serve.log and serve.log.1, each model run's <job>.in, .out, .err
traces/<bank>/<file>.mdtraces, newly encoded or remembered memories awaiting consolidation, one dir per bank; a topic's knowledge and playbook traces under @<topic>, a name no bank key can take
machinethis machine's id: one line, 32 lowercase hex from /dev/urandom, minted on first use; $SANDMAN_MACHINE overrides it
trail/, shifts/, breath/, score/, log/, .dream/, pending-takes/, .trace/the old sandman's, unread and unwritten by this build; forget does not reach them

mark

Run by the subether mod inside its 1.5 s budget, so it does nothing slow. Today it writes the start and end marks and a guard per tool call the mod's guard denies; next it carries call and prompt while recall (Next) and take take over start and end.

One JSON object on stdin; kind and session are required, any other field missing is null.

{"kind":"start"|"end","session":"<uuid>","cwd":"<path>"?,"surface":"<str>"?,"interactive":bool?,"reason":"<str>"?,"resume":"<str>"?}
{"kind":"guard","session":"<uuid>","rationale":"<str>","tool":"<str>"?}

It appends one compact line, keys alphabetical, to today's (UTC) ledger/<yyyy>/<mm>/<dd>.jsonl in one O_APPEND write under a shared flock, so concurrent writers interleave whole lines and forget's rewrite loses none; a guard's rationale is one-lined to 1,000 characters:

{"at":"2026-11-09T08:05:00Z","cwd":"/work/alpha","interactive":true,"kind":"start","machine":"studio","reason":"startup","resume":null,"session":"5a000000-0000-4000-8000-00000000000a","surface":"cli"}
{"at":"2026-11-09T09:10:00Z","kind":"guard","machine":"studio","rationale":"sample: never force-push","session":"5a000000-0000-4000-8000-00000000000a","tool":"Bash"}

A guard is never a session's mark: every reader of sessions (chart's active, take, reconcile, settle, encode) reads only start, end and encode lines.

exit 0 written, silent; exit 2 stdin not JSON, or kind or session missing or invalid, a guard without a string rationale: one stderr line, nothing written; exit 1 the root cannot hold the line: one stderr line.

take

The one verb the mod runs at a session's end, inside its 1.5 s budget: nothing slow, nothing spawned. A session is marked at its start and taken at its end; one without a start mark is outside this system, and the seed marks only an interactive one, so a headless claude -p run (a routine) is never taken, reconciled or encoded.

One JSON object on stdin; session is checked as in mark.

{"session":"<uuid>","cwd":"<path>"?,"reason":"<str>"?}

It decides one outcome, the first that holds, and appends one end line to today's ledger with the same writer as mark:

whenoutcome
no start mark for the session in the ledgernothing written
reason is resume: the end fires on the session a resume adoptsnothing written
$SANDMAN_NO_TAKE set, or CLAUDE_MEMORY_PIPELINE=1skipped
a job's state.json under <claude>/jobs/ names it, by resumeSessionId, else sessionId, whatever its state (the agents view lists a finished job until the person removes it), and reason is not clearheld, with job
no <claude>/projects/*/<session>.jsonlgone
otherwisetaken, with archived
{"archived":"<path>"?,"at":…,"cwd":…,"job":"<job dir>"?,"kind":"end","machine":…,"outcome":"skipped"|"held"|"gone"|"taken","reason":…,"session":…}

<claude> is $CLAUDE_CONFIG_DIR, else $HOME/.claude. The take renames, never copies, the transcript to .archive/claude/<yyyy>/<mm>/<dd>/<HHMMSS>-projects-<project>-<session>.jsonl at the take's UTC time (<HHMMSS>-<n>-… on a same-second clash) and its sidecar dir <session>/, when there is one, to the same stem plus -dir. Then it writes memories/.recent/<session>.json atomically, keys in this order, for the earlier recall and dream to read; it goes when recall (Next) replaces the earlier one:

{"archived":"<abs path>","cwd":str|null,"ended":"<the transcript's mtime>","title":"<str>","highlights":[…]}

chart

One compact JSON object on stdout, keys alphabetical. It reads the root and never writes it, bar minting machine; every absence is an empty list or a skipped item, never an error.

{"active":[{"cwd":str|null,"encoded":str|null,"end":str|null,"interactive":bool|null,"machine":str,"outcome":str|null,"seen":str|null,"session":str,"start":str|null}],
 "at":"<now, RFC 3339 UTC>",
 "ended":[{"at":str,"id":str,"into":str|null,"op":str,"path":str,"sessions":[str],"state":"ended"}],
 "guards":[{"at":str,"rationale":str,"session":str,"tool":str|null}],
 "intentions":[{"about":str|null,"after":str|null,"closed":str|null,"created":str|null,"due":str|null,"id":str,"session":str|null,"state":str|null,"what":str}],
 "knowledge":[{"created":str|null,"file":str,"from":[str],"id":str|null,"name":str,"origin":str|null,"session":str|null,"sessions":[str],"source":…,"state":"active","topic":str,"type":str}],
 "lineage":[{"at":str,"from":str,"op":str,"to":str}],
 "machine":"<this machine's id>",
 "memories":[{"bank":str,"created":str|null,"file":str,"from":[str],"id":str|null,"name":str,"origin":str|null,"session":str|null,"sessions":[str],"source":"consolidate"|"dream"|"reflect"|"remember"|"other","state":"active","type":str}],
 "taken":[{"bytes":int,"cwd":str|null,"dreamed":str|null,"highlights":int,"memories":int,"session":str,"state":"waiting"|"dreamed"|"archived","taken":str,"title":str|null}],
 "traces":[{"bank":str,"created":str|null,"file":str,"from":[str],"id":str|null,"name":str,"origin":str|null,"session":str|null,"sessions":[str],"state":"active","type":str}]}
Sample data: sandman chart over the test suite's fixture, drawn the way its consumer, bifrost's pipeline tab, draws it. The suite fails when docs/data/chart.json is not the verb's output.

forget

The privacy ending, and the one verb that deletes for good: no .pruned/ copy, and nothing recorded that names the session. The /delete skill and bridge's forget button run it twice.

① the ledgerits lines dropped, rewrites keptunder the writers' lock, first ② removedtranscripts, archive, pointerits traces, memories, run files ③ rewrittena merge's source, an intentionpruned ops, embeddings, log once the CLI exits, a watcher runs it again: the exit flush regrows the transcript
forget's order, ①–③. The ledger goes first, so a take or a tick racing it finds no start mark and archives nothing.
sandman forget <session>   # forgot: <n> removed, <n> rewritten | nothing to forget
storeforget
ledger/**, today's tooevery line holding the id dropped but a rewrite line, kept with the id off its from entries' sessions; the file rewritten by temp + rename under an exclusive flock
<claude>/projects/*/<session>.jsonl and <session>/removed, in every project
.archive/claude/**every copy and -dir named for it removed
memories/.recent/<session>.jsonremoved
traces, memories, knowledge pagesthose whose session is it removed (an encoded or remembered trace, a consolidate's keep), their lines in embeddings.jsonl too; any other holding the id rewritten without it: off a sessions: line, the line gone once empty, else - (a merge's source)
.pruned/**a copy whose session is it removed, a reply's ops on that trace dropped, any other holding the id rewritten
intentions/<id>.mdkept, its session link dropped: deferred work is the person's, not the session's
run/a model run's .in, .out, .err holding the id removed, and encode's when the last or next episode encoded was this one; serve.log and serve.log.1 without its lines

serve

The daemon, a foreground process launchd keeps alive as dev.gigantic.sandman. Its tick runs seven jobs, in order: it reconciles sessions that never ended, fills recall's embedding cache, settles held takes, releases transcripts no note holds, then one of: a rollback due, encode one episode, consolidate one bank, or, with neither waiting, once a week, reflect on the guidance.

① startstate bootinglock, socket, pid ② readyhealth on stdoutserves the socket ③ stoppinga signal or shutdownlistener dropped first ④ exitpid file, socket goneexit line, exit 0 launchd starts it again (KeepAlive); a kill's stale socket and pid file are replaced at ①
The daemon's life, ①–④. A second instance, a socket path over 103 bytes or a run/ others can reach stops at ① with one stderr line and exit 1.

At ① it creates run/ 0700 and refuses it if it is not this user's or group or other can reach it; takes an exclusive flock on run/serve.lock, held for life; binds run/serve.new and renames it over run/serve.sock, safe because the lock proves no one else is alive; and writes run/serve.pid. Then it logs its start and prints its health line on stdout, so whoever spawned it knows it is ready without polling.

One newline-terminated JSON request and one reply per connection, compact, keys alphabetical; a connection silent for 1 s is dropped unanswered. Errors are typed codes.

{"op":"health"}   → {"machine":str,"ok":true,"pid":int,"since":"<RFC 3339 start>","state":"booting"|"ready"|"stopping","version":"<release>-<build>"}
{"op":"shutdown"} → {"ok":true}, written after the listener is dropped
anything else     → {"code":"bad_request"|"unknown_op","ok":false}
sandman setup                            # install the release, retire the old agents, load or swap
sandman status                           # the daemon's health, its version the binary's
sandman upgrade --check                  # what the next swap would run
mise run install                         # a dev build as sandman-next, beside the release
claude setup-token                                          # in a terminal: prints a year's token, stores nothing
install -m 600 /dev/stdin ~/Codes/claude-oauth-token        # paste it, then Ctrl-D

Cut over 2026-11-18: ~/.local/bin/sandman is the release hotswap installed, the old binary and its agents are retired, and callers say sandman.

encode

A job of serve's tick, not a verb: one episode, a taken session, at a time, written as traces, newly encoded memories still labile, under traces/<bank>/, apart from the banks until consolidate.

Each tick, after settling, it derives from the ledger the oldest session of this machine whose latest end is taken, with no start or encode since, decides one outcome, and appends one line with mark's writer:

whenoutcome
no start mark of the session says interactive true: a start marked by mark alone, since the seed never marks a headless runskipped, no model call
no file at the end line's archivedgone
the encoder exits non-zero, outlives $SANDMAN_ENCODE_MS (300 000), or prints no valid objectfailed, with error; no trace written
otherwiseencoded; traces counts them, often 0
{"at":…,"error":"<one line>"?,"ids":["<each trace's id>"]?,"kind":"encode","machine":…,"outcome":"encoded"|"skipped"|"gone"|"failed","session":…,"token":…?,"traces":<count>}
---
id: 7d3e9a0b4c21
name: Pass a clock in; never mock time
description: tests take time from an injected clock, never a time mock
type: feedback
created: 2026-03-04T17:25:10Z
about: /work/ledger-api
session: 5a000000-0000-4000-8000-00000000000a
archived: <root>/.archive/claude/2026/03/04/172010-projects--work-5a000000-0000-4000-8000-00000000000a.jsonl
source: encode 2026-03-04T17:25:10Z · 5a000000-0000-4000-8000-00000000000a · model=opus
---

In /work/ledger-api, tests take time from a clock passed in. Said 2026-03-04: "no mocks for time in this repo, we pass a clock in".

Why: "mocks hid a real ordering bug last year".

consolidate

A job of serve's tick: it stabilises a bank's traces and integrates them with what the bank holds. A trace or a verdict that revises a memory updates it (reconsolidation); a merge folds memories that hold one fact into a new one; pruning drops a trace that does not hold or a memory gone stale; a memory moves to the bank it belongs to, or graduates into a topic's page. Nothing waits for a person.

It runs only in a tick with no episode to encode, one bank at a time, derived from disk each tick: of the banks holding a trace or a note judged (a wrong or stale verdict since its body last changed), a topic's @<topic> among them, whose newest trace created and verdict are older than $SANDMAN_CONSOLIDATE_QUIET_MS (600 000, so a burst of episodes lands first), the one whose oldest is oldest. It needs a trace newer than its last failed consolidate, or a verdict newer than its last consolidate of either outcome, so a bad reply never storms and a verdict left standing is answered once. The model run is encode's, with $SANDMAN_CONSOLIDATOR and $SANDMAN_CONSOLIDATE_MS (600 000), its guidance <root>/prompts/consolidate.md else the default, then its contract (src/prompts/consolidate.contract.md), then the bank. A topic's runs the same way with knowledge/<topic>/ in place of memories/<bank>/, and its keeps take knowledge or playbook only (how a page is written):

# bank
-work-ledger-api

# traces
<trace file="feedback_clock_in_benchmarks_too.md">
…the whole file…
</trace>

# memories
<memory file="feedback_pass_a_clock_in.md">
…the whole file…
</memory>

# listed
- reference_metrics_dashboard.md · ledger-api latency dashboard · Where ledger-api's latency dashboard lives

# judged
- reference_redis_queue_host.md · stale · the queue moved to postgres

# elsewhere
- knowledge/postgres/knowledge_job_queues.md · Postgres job queues · Queueing jobs in Postgres: SKIP LOCKED, one table

Memories go whole while their bytes fit $SANDMAN_CONSOLIDATE_BYTES (300 000); the rest are listed, and the contract says a listed memory may not be changed; # judged, absent when empty, lists each verdict a memory answers to, - for no reason; # elsewhere, absent when empty, at most 5 notes of other banks and topics, recall's candidates, whose cached embedding has cosine at least $SANDMAN_NEAR (0.8) with a trace's or memory's, nearest first, a tie in reader order, never written. The reply is {"ops":[…]}:

opmeansapplied
{"op":"keep","trace","type","name","description","body"}the trace becomes a memorymemories/<bank>/<type>_<slug>.md, encode's slug and clash; created, about, topic, session, archived from the trace
{"op":"merge","trace","memory","description","body"}the trace revises or extends the memorythe memory rewritten in place: its other keys kept in order, description and source replaced, updated set, the body replaced
{"op":"merge","memories":[…],"type","name","description","body"}two or more memories hold one facta new note, keep's slug: a new id, created now, topic a topic's, from: its parents' ids (one minted for a parent without), no sessions; the parents leave the bank
{"op":"revise","memory","description","body"}a judged memory correctedas a merge's write, without a trace; only a memory # judged lists
{"op":"retitle","memory","name","description"}a better nameits keys and body kept, name and description replaced, under keep's slug for the new name
{"op":"rehome","memory","bank"}it belongs to another bankunchanged but its topic, under keep's slug in that bank: one of the same kind (a bank's, or a topic's @<topic>) already on disk
{"op":"graduate","memories":[…],"topic","type","name","description","body","reason"}one or more memories are a topic's knowledge (rung 1)a new trace under traces/@<topic>/, as a merge of memories writes, type knowledge or playbook; the memories leave the bank
{"op":"prune","trace","reason"}the trace does not holdnothing enters the bank
{"op":"prune","memory","reason"}a trace shows the memory stalethe memory leaves the bank
{"at":…,"bank":…,"error":"<one line>"?,"kind":"consolidate","kept":n,"machine":…,"merged":n,"order":{…}?,"outcome":"consolidated"|"failed","pruned":n,"token":…?}

merged counts both merges; order, on a consolidated line, is the order measure.

reflect

A job of serve's tick, the weekly review: the pipeline rewrites the guidance encode and consolidate run on from evidence of what they did, and adopts a rewrite only when a replay judges it no worse; it also decays the store, proposes graduations (decay, the ladder) and may rewrite recall's selection question. No step waits for a person; the contracts stay fixed in the binary.

It runs only in a tick with no rollback due, no episode waiting and no quiet bank; at most once per $SANDMAN_REFLECT_MS (604 800 000, a week) after this machine's latest reflect line, and only when at least $SANDMAN_REFLECT_MIN (5) encode or consolidate model runs follow it: no evidence, no run and no line. The model run is encode's, with $SANDMAN_REFLECTOR and $SANDMAN_REFLECTOR_MS (600 000), its guidance <root>/prompts/reflect.md else the default (src/prompts/reflect.md), then its contract (reflect.contract.md), then:

<guidance job="encode">
…the guidance in force, whole…
</guidance>
<guidance job="consolidate">
…
</guidance>
<question>
Does the agent need this memory to carry out the request correctly?
</question>

# since
2026-11-07T09:00:00Z

# runs
- {"at":…,"ids":["7d3e9a0b4c21"],"kind":"encode","machine":…,"outcome":"encoded","session":…,"traces":1}

# ops
- -work-ledger-api: {"op":"prune","reason":"the session's story: a fix the repo's history records","trace":"project_fixed_the_retry_test.md"}

# merged again
- -work-ledger-api/feedback_pass_a_clock_in.md · merged 3 times

# remembered by hand
- No closing summary of changes — Every reply, in any repository: no closing summary (traces/-work/feedback_no_closing_summary.md)

# sent, never read
- -work-ledger-api/reference_redis_queue_host.md · sent 4 times, never shown

# irrelevant
- -work-ledger-api/reference_redis_queue_host.md · bump the http client in ledger-api

# standing
- 3f9a0c1d2b4e · -work-ledger-api/feedback_pass_a_clock_in.md · Pass a clock in — ledger-api tests take time from an injected clock · used in 6 sessions

# relearned
- 0a1b2c3d4e5f · -work/feedback_no_closing_summary.md · No closing summary — every reply: no closing summary · relearned in 3 sessions
{"at":…,"error":"<one line>"?,"history":{"<job>":"prompts/.history/…"},"kind":"reflect","machine":…,"order"?:{…},"outcome":"adopted"|"kept"|"failed"|"reverted",
 "proposed"?:n,"pruned"?:n,"reason":"<one line>"?,"replay":{"<job>":{"new":n,"old":n,"same":n}}?,"token":…?}

order is the store's before decay and after the pass, pruned decay's count, both on a failed review too; proposed the intentions written. kept means no guidance was proposed, the old won a replay, or there was nothing to replay (all three counts 0). One review costs one model run plus three per input replayed: at most 19 with the defaults.

The memory cycle

A session's transcript is encoded into traces, consolidated into memories and knowledge pages, sent by recall, judged, counted, then revised, merged, graduated or decayed; once no active note names the session, its transcript goes. Text and Rust, no database: every fact here is a file or a ledger line, and any index is a cache rebuilt from them. Built in full, in the ten stages under next.

① sessionan agent's work,marked, then taken ② archivethe transcript,held while named ③ traceencoded or remembered,awaits consolidate ④ memory|knowledgeid, sessions, from:the active store ⑤ recalla pointer sent,one ledger line ⑥ rethinkone verdict a send,in session or at encode ⑦ strengthcounted from lines,never stored ⑨ releaseunheld for 7 days:the transcript goes ⑧ decayunder the floor:pruned, an end ⑧ reconsolidatea trace, a verdict:revise or merge ⑧ graduatea page, a guidanceline, a mechanism no active note names it back into the store: the same id, or a new one
The cycle, ①–⑨. A guidance line or a mechanism graduates once the owner approves its proposal. A merge that writes a new note ends its parents, which, like decay, can leave a session unnamed.

The note

Every memory, knowledge page and trace keeps the file format it has today, with three keys added and one forbidden; writers put id first, from and origin just before sessions:

---
id: 3f9a0c1d2b4e                 12 lowercase hex from /dev/urandom, minted once, never changed (built)
name … archived                  as today
from: 0a1b2c3d4e5f 9e8d7c6b5a4f  the notes it was merged from, sorted; only on a note a merge created
origin: import|routine|hand      only on a note with neither sessions nor from (built)
sessions: <uuid> <uuid>          the archived sessions it descends from, sorted (built)
source: <stamp>                  as today
updated: <now>                   as today
---

The rewrite line and lineage

One ledger line per note rewritten, through mark's writer, never edited; recall's sent entries and the show and remember lines carry the note's id, an encoded line its traces' ids, and a path in an older line resolves through these lines' paths. Built for consolidate's keep, merge, prune, retitle, revise, rehome and rung 1's graduate, written once the ops have landed, all in one write, before its line. A write that fails puts the pass back (its notes removed, its inputs renamed back) and fails it; a kill between the moves and the write leaves copies no line ends, which the sweep keeps and check names (4) for a person to restore or end:

{"at","from":[{"digest":"<SHA-256 of the file as it stood>","id","path","sessions":[…]}],"kind":"rewrite","machine",
 "model":"<model>"|null,"op":"keep"|"merge"|"revise"|"retitle"|"rehome"|"graduate"|"prune"|"release"|"revert",
 "reason":str|null,"to":{"id","path"}|{"artifact":"<path>"}|null}
opfrom → towritten by
graduatememories → a new traces/@<topic>/ trace (rung 1); a note → {"artifact"} (rungs 2, 3)consolidate; done on the owner's approval
keepa trace → the same id under memories/ or knowledge/consolidate
mergea trace and a note → the note; two or more notes → a new idconsolidate
prunea note → nullconsolidate; the weekly review (decay)
rehomea note → the same id in another bank or topicconsolidate
releaseper archived file {"bytes","digest","id":null,"path","sessions":[<session>]} → nullthe tick's release job
retitlea note → the same id under another name and fileconsolidate
reverta note an order op wrote → null; [] → each note it ended, put backa pass that fails its measure
revisea note → the same id, body rewritten after a wrong or stale verdictconsolidate
two back: lines only parents: bodies kept active a1 · endedsessions: s1, on the linebody deleted a2 · endedsessions: s2, on the linebody deleted p1 · endedfrom: a1 a2body in .pruned/ p2 · endedsessions: s3 s4body in .pruned/ n · activefrom: p1 p2sessions: none a trace merged into n, a revise, a retitle or a rehome: n continues, its id kept, its sessions: extended when n ends, the bodies of p1 and p2 are deleted; n's stays while the note it ended into is active s1–s4 are named by no active note, so their transcripts are released
Lineage at depth 1. The sessions live on the generation that read them; a note born of a merge names its parents instead, and the ledger keeps every generation's ids, digests and sessions: the rewrite lines, chart's lineage; the oldest generation's bodies are deleted by release's depth-1 sweep.

rethink

sandman rethink <path> --irrelevant|--used|--wrong|--stale [--why "<text>"] [--session <uuid>]
rethink {"path":string, "verdict":string, "why"?:string, "session"?:string}       # the MCP tool, passed as --<verdict>
{"at","by":"agent"|"encode","cue":<the send's>|null,"file","id","kind":"rethink","machine","session","verdict","why":str|null}
{"about","at","cue","digest","id","label":0|1,"path","session","verdict"}                  eval/recall.jsonl
the send the verdict counts against a senda cue and a note,one recall line irrelevantnot about the cuethe note untouched wrong | staleabout the cue, but untrueor out of date usedabout the cue, true,acted on recall classifiera label-0 examplefor the recall eval the note, blamed−4 strength: reviseor prune candidate the note, raised+3 strength,idle clock reset every judged send is also a classifier example: used, wrong and stale as label 1 a send nobody judged counts for nothing
Two blames: relevance is the classifier's, truth the note's. An irrelevant send never weakens the note it sent.

Strength and decay

strength = (1 + 3·used + 1·shown − 4·judged) × 2^(−idle ÷ 30)

Graduation

① page or playbookmemories converge on a subjectautomatic, in consolidatecost: reread at every merge ② standing guidanceused in 5 sessions, never wrongproposed weekly, owner approvescost: context in every session ③ mechanismrelearned in 3 sessionsproposed weekly, owner approvescost: code, tests and a gate a rung-2 line replaces a line or justifies the characters it adds; pinning is no rung
The ladder, 1 → 2 → 3. Each rung costs more to keep true and less to apply: a page is reread by a model, a line is read by every session in its scope, a mechanism runs without being read.
{"op":"graduate","memories":[<file>,…],"topic","type":"knowledge"|"playbook","name","description","body","reason"}   consolidate's
"propose":[{"artifact","line","note","replaces":str|null,"rung":2|3,"why"}]                                    the weekly review's

Release

check

sandman check            # every violation, or check: <n> notes, <h> held, <r> released: clean; writes nothing
sandman check --fix      # what can be repaired mechanically, then check
sandman check --release  # what the release job would delete now, with its bytes; writes nothing
                         #   <path>: release · <session> · <n> bytes | <path>: sweep · <n> bytes, then
                         #   release: <t> transcripts, <c> copies, <n> bytes[; held back: <v> violations]
  1. every note's frontmatter reads (LF fences, no CR) and has id:, 12 lowercase hex, unique across memories, knowledge and traces;
  2. every note has a source (sessions, from: or origin: import|routine|hand), and none of those keys is - or empty;
  3. sessions: holds uuids, from: ids, each sorted and once; no note has strength:;
  4. every from: id was ended by a rewrite line, no active note's id was, and every id'd .pruned/ copy's id is active or ended;
  5. every rewrite line has the shape above, an id ends at most once, and every to id is active or ended by a later line;
  6. .pruned/ holds no body past depth 1 and its grace;
  7. no released transcript is on disk, and none an active note names is released (since its latest take).

A violation is one stdout line, <path>: <invariant n>: <detail>, the path as show takes it, in reader order, and exit 1; the first note in reader order keeps a shared id. --fix, each note by temp + rename, drops an empty or - list and an origin outside the three, sorts and dedupes the two lists, mints an id for a note without a valid one of its own, gives a sourceless note origin by its stamp's first word (remember → hand; consolidate, dream, reconsolidate, reflect → routine; else import), prints check: fixed <n>, writes {"at","fixed":n,"kind":"check","machine"}, then checks. A frontmatter it cannot read (CRLF, a fence never closed), a bad word on a list, a strength: and the ledger are left for a person. A rewrite line's violation reads ledger <its at>: 5: …, after every note's, then an orphaned copy's <its .pruned/ path>: 4: id <id> is neither active nor ended: restore it or end it. forget keeps a rewrite line, its session taken off the entries, and one into a note it erases loses its to and that note's entries, so 4–5 hold through it. A 6 or a 7 reads <its .pruned/ or .archive/ path>: 6: past depth 1 and its grace, … 7: released <at>, still on disk, after the ledger's; a note's 7 is names released <session>. --release prints every violation but 6s first, exit 1 while any holds the job back.

chart

"memories"|"knowledge"|"traces": [{…,"from":[str],"id":str|null,"origin":str|null,"state":"active","strength":number}]
"ended":   [{"at","id","into":str|null,"op","path","sessions":[str],"state":"ended"}]
"lineage": [{"at","from":<id>,"op","to":<id>}]
"taken":   [{…,"held":bool,"released":str|null}]          a released one from its release line, state "released"

Gate spans

Every run of mise run check is one OpenTelemetry trace through floodgate span: a check span with each step nested under it (fmt, clippy, cover, stele.check and stele.emit), so floodgate's page shows which steps cost the time and CPU.

A step is wrapped in mise run span -- <name> [--attr k=v]… -- <cmd…> (.mise/tasks/span): it execs floodgate span when floodgate is on PATH, else the command after the second --, so a machine without floodgate, CI included, gates as before. The steps live in the check:steps task and check wraps it; to add a step, put it in check:steps wrapped the same way; a step left bare is time no span explains.

The check:steps and cover tasks set LLAMA_LIB_PROFILE=Release (llama-cpp-sys-2's own hook), so llama.cpp builds without debug info, which embeds the build directory's absolute path in every object and kept mbx from sharing them between checkouts. A cold gate in a fresh worktree fell from about 1,476 to about 840 CPU-seconds (measured 2026-11-29 · floodgate spans, a fresh worktree after a first run). What remains uncached is mbx's: 25 ggml-cpu and ggml-metal compilations carry -F<SDK>/System/Library/Frameworks, a flag its C adapter does not model, and the build script is keyed by its per-checkout OUT_DIR. GGML_ACCELERATE=OFF would drop the flag from ggml-cpu but hangs the sandman-infer ops test, so it stays on.

Next

Parts still to bring over, and the memory cycle's ten stages, all built.

The memory cycle, built one stage a sitting, each leaving mise run check green:

  1. ids and sources built — id: on every write (encode, remember, consolidate's keep and merge), origin: hand from remember without a session; the reader's id, from, origin; chart's row keys and state; check invariants 1–3 and --fix. The owner then runs check and check --fix on the root.
  2. rewrite lines built — consolidate's ops as rewrite lines; id on recall, show and remember lines, ids on encode's; chart's ended and lineage; invariants 4–5.
  3. rethink in session built — the verb, the MCP tool, the seed's sentence, eval/recall.jsonl, forget over it.
  4. rethink at encode built — # recalled, encode's contract and verdicts.
  5. strength built — the count, chart's strength, the knobs.
  6. order in a bank built — consolidate's merge of notes, # judged (revise, prune), retitle; the order measure.
  7. across banks built — rehome, rung-1 graduation, # elsewhere.
  8. the weekly review built — decay, # standing, # relearned, proposals as intentions, done and drop on them.
  9. release built — the job, the depth-1 sweep, chart's held and released, invariants 6–7, check --release. The owner reads check --release on the root before installing it: its first run releases every transcript no note names.
  10. the recall evaluation built — a score over eval/recall.jsonl, the order measure's eval and its revert; reflect's selection question, scored by the decision model over the examples.