# Memento notes
<!--
ref: @wildeagency-public/memento-notes
tags: [session management, context preservation, memento, workflow optimization]
triggers: [context is about to become unusable, session needs to be documented, working set is spent, heavy managed session requires insurance]
trigger_prompt: When a user is transitioning between tasks or sessions and needs to ensure that important context is captured without losing valuable information.
version: 10
updated_at: 2026-10-24T21:05:52.846Z
-->
The depth half of `@protocol/memento`, split out 2026-08-07 so the operating instructions stay small. Fetch when changing the practice, not performing it.
The depth half of `@protocol/memento`, split out so the operating
instructions stay small. **Fetch this when CHANGING the practice, never when performing one** — the
kernel is read at peak context, which is the entire reason it was made short.
## A memento is two acts — and only the clear is expensive
Write the note, then clear the context. These are separable, they have different costs, and the
costs invert with disposition — which is why one rule cannot govern both.
A **dispatcher's** state is routing state: who is doing what, owed replies, a cursor. It compresses
into pointers almost losslessly, so write-and-clear is one ritual and shedding weight is nearly
free. A **doer's** state is its *working set* — the files it has read, the map of the codebase it
has built, the error trails, the reason the half-finished thing is half-finished. "Pointers, not
packing" compresses away exactly that. So for a doer the write is cheap insurance and **the clear is
the expensive act**: what is shed comes back re-derived at the read rate, minus whatever the note
could not carry.
Therefore, in a **doer** (any code/project session — the default disposition):
- **Write** freely — at seams, under pressure, whenever a hand-off would be worth having. A few
thousand tokens, pure insurance, nothing lost.
- **Clear** only when the context is about to become unusable anyway (compaction imminent / at the
limit), when the working set is genuinely spent (task complete, topic switch), or when the
operator asks. **Never merely because a number got large at an otherwise clean seam.**
- An orchestrator that wants insurance on a heavy managed session **instructs the write and does not
clear.**
That last option is the one that keeps getting skipped, and it is strictly cheaper than the act that
caused harm. The response vocabulary reads as two choices (cycle / do not cycle) when it is three —
**write-only** sits between them: when writing a prohibition, say what remains permitted, especially
the option adjacent to the forbidden one.
**"Never on a fixed timer" was already in this protocol and did not prevent this — do not re-shorten
the rule back to it.** The sweep that prompted this rule did not fire on a timer: it fired on **weight**, into
three code sessions at seams it had correctly judged clean, and the seam list explicitly blessed
that with *"context has grown past your pressure threshold"*. The doctrine carried the permission
that did the harm; banning timers never touched it. The operator watched it happen in two code sessions: a
context-cycle directive suits dispatcher lanes, not code sessions. Lanes are unaffected — cadence-steered memento for a
dispatcher engine remains correct, because a dispatcher is the disposition the cheap half was measured
on.
## Who fires it — self or orchestrated
**Self** — a session mementos itself at a seam: write → clear (`/clear`, or your engine's restart command
for a dispatcher engine) → resume on next boot.
**Orchestrated** — a session that *manages other sessions* mementos a session it manages. It must
**not** write the memento itself: it doesn't hold the managed session's live, cached context, and
summarizing from outside is the expensive, uncacheable anti-pattern. It conducts three beats:
1. **Instruct** the managed session to memento itself.
2. **Confirm** the new `resume-<date>-<slug>.md` landed in that session's directory.
3. **Clear** it (`/clear`, or your engine's restart command).
**Beat 3 is conditional, and for a doer it is usually wrong.** Run beats 1–2 and STOP unless the
managed session meets a clear condition above. Instructing the write is cheap and safe at any
weight; clearing a project session that is mid-understanding destroys a working set it must
re-derive. If what you want is insurance against losing a heavy session, beats 1–2 already gave it
to you.
## Relocate, then point — a dangling pointer is the silent failure
"Point, don't pack" assumes the target survives the clear. Two things routinely do not: the
**session scratchpad** (session-scoped by construction) and anything under `/tmp`. A resume note
citing either reads exactly like a healthy pointer, resolves to nothing on the next boot, and
raises no error — the reader cannot tell a dead path from a path they simply have not fetched
yet. That lands the diagnosis on the session with the least context to do it.
So the write has a beat before the note. Anything in the working set that meets all three of —
(a) cost real work to produce, (b) the next phase still needs, (c) exists only in ephemeral
storage — moves to durable storage first, and the note cites the new home. **The test is *would I
have to redo this*, not *is it large*.** Extracted text from a binary, a derived dataset, a
scraped corpus, hand-built fixtures: all qualify at any size.
Two obligations travel with the relocation, and skipping them is how a repository accretes orphan
directories nobody dares delete:
- **A README beside it**, giving what it is, what it is for, and **the condition under which it
gets deleted** — a *trigger* ("once X is built"), never a date. The author is the only party who
knows the trigger; a later reader can only guess, and guessing wrong in either direction is
bad. Include how to regenerate it, if that is non-obvious.
- **A provenance and sensitivity line.** Relocation typically moves material out of a private
scratch dir and into version control. If it originated with a client, a customer, or anything
under an agreement, say so where it lands *and* say so to the operator — whether it gets
committed is their call, not the note-writer's.
**Do not relocate as a reflex.** Regenerable output — tool logs, one-off greps, anything a
documented command reproduces in a minute — stays put and dies with the session. That is what the
scratchpad is for, and a memento that hauls it into the repo has misread the rule as "save
everything" rather than "save what a pointer cannot reach".
*Origin, 2026-08-26.* A doer session extracted two long PDFs into scratchpad text, built its whole
analysis on them, and wrote a resume note pointing at the scratchpad path. The dangling reference
was caught only while reporting to the operator, one step before the clear. The extraction itself
was cheap; the *source* files sat behind an OS permission block that had already cost a detour, so
"just redo it" was not the minute it appeared to be. The general shape: what makes an artifact
worth relocating is rarely its size or even its cost — it is the cost of re-acquiring whatever it
was derived FROM.
## Resume file lifecycle (collision safety)
Resume files get confused when more than one session runs in a single directory. Two mechanisms
keep them straight: an **owner** stamped on the file, and a **three-stage lifecycle**. Every file
stays globbable as `resume-*` throughout.
### The owner is the run, not the session
The first instinct is to stamp the session id. **It does not work, and it fails in the most
common case.** A clear mints a *new* session id, so in the ordinary write→clear→read cycle the
session resuming a note never shares an id with the session that wrote it. A boot keyed on
session id matches nothing, ever, and degrades to asking the operator which note to resume on
every single cycle — worse than no stamp at all.
What survives a clear is the **agent process**. Its pid is stable for the life of one
terminal/pane and dies with it, which is exactly the granularity an operator means by "this
window's work". In Claude Code it is `$CLAUDE_PID`; the general form is the pid of the process
the clear runs *inside*. So the run id goes in the filename —
`resume-YYYY-MM-DD-<topic-slug>-r<run-id>.md` — and the full identity goes on line 1:
<!-- memento: run <pid> started "<process start time>" · pane <terminal/pane label> · session <id> · written <ISO-8601 UTC> · cwd <abs path> -->
Three fields, three different jobs, and they are not interchangeable:
- **pid** — the key. Claiming is `ls -t resume-*-r<my-run-id>.md`: filename-only, no file opened,
no ambiguity, no question, however many other runs share the directory.
- **process start time** — the recycle guard. Pids are reused after a reboot, so a boot compares
the recorded start against `ps -o lstart= -p <pid>` before trusting a match. Without it a fresh
run inheriting an old pid silently claims a stranger's hand-off.
- **pane label and session id** — *not* keys. The pane is for the operator's eyes (one pane can
host a new run); the session id resolves to the durable transcript, which is the backstop for
whatever the note was too short to carry.
**Unstamped beats mis-stamped.** If the run id cannot be read, omit the suffix. An unclaimed note
costs one question at the next boot; a wrongly-stamped one routes a session into another run's
work, which is the failure this whole scheme exists to prevent.
### Boot has exactly one branch that asks
| The note's run is… | Then |
|---|---|
| your own run id | **claim it** — silently, no question. This is the ordinary cycle and it must stay frictionless |
| alive, some other id | **leave it pending**, say nothing — that pane claims it on its own next boot |
| dead, or its pid now reports a different start time | **orphan** — *offer* it, never auto-resume |
Orphans are the restart case: the machine rebooted or the run was killed, so nobody but the
operator can say which note is still live. Offering there is right; offering anywhere else is
friction. And **mark `.read` on the one you took and nothing else** — a live run's pending note
is not litter to tidy, and an orphan that is merely stale gets *offered for archiving*, never
marked read to clean up the directory.
### The three stages
1. **Pending (on write)** — `resume-YYYY-MM-DD-<topic-slug>-r<run-id>.md`, never a bare
`resume.md`.
2. **Read (on consume)** — once a session boots from it, **append `.read` to the end of the
filename** (`resume-YYYY-MM-DD-<topic-slug>-r<run-id>.md.read`). `.read` goes *after* `.md`,
which is the whole point: the file stops matching `resume*.md`, so the boot glob needs no
exclusion rule and a stale note can never be re-acted on. This supersedes the older
`…-<topic-slug>.read.md` form, which kept `.md` last for markdown readers but stayed in the
glob; both exist in the archive, only the new form is written going forward.
3. **Archived (after a day or two)** — sweep `.read` files older than ~1–2 days to an archive
directory. The short in-place window keeps a just-consumed resume recoverable and visible; the
sweep keeps the working directory clean.
**Match `.read` literally, with the dot escaped.** An unanchored `.read` also matches al**read**y,
th**read**, sp**read** — silently dropping the pending note, after which a session boots with no
base-frame and no error, indistinguishable from the healthy nothing-to-resume case.
*Origin, 2026-08-26.* An operator running many panes against one repo asked for a session
identifier on resume notes. The first design keyed on session id and was wrong for the reason
above — it would have asked a question on every cycle, which is precisely the cost the memento
practice exists to avoid. Measured on the box: the agent process had survived two days and many
clears on one pid, while the session id had turned over that morning. **When a stamp is meant to
answer "is this mine", check what actually survives the operation that resets identity.**
## Why not just `/compact`
Keep `/compact` as a zero-effort fallback; prefer memento because:
- **It blocks** — a long summarization runs right when you want results (~5 min on a 537k-token
session).
- **It comes back generic** — a coarse ~8k-token "what happened" summary; memento is purpose-shaped
and action-first, so it resumes on-task.
- **It can't do the big case** — `/compact` cannot compact a session larger than one context window;
it re-summarizes a prior summary. memento writes what's in context and points to the rest.
- **It loses on scored recall** — the by-eye round looked like a wash; the scored round (validated
per-transcript fact key, 2026-07-18) was not: `/compact` recovered 58% on the doer transcript at
8.4k carry vs 83% for a dense disposition-aware memento at 4.4k, and scored structurally NULL on
the over-one-window dispatcher session.
## The cost model (metered, not modeled)
Real `claude -p --output-format json` numbers behind the rules:
- **Run in-session:** live context reads as `cache_read` (~0.1× cost). Generating from a *cold
external* transcript cost **~$1.6/run**, and a warm re-run *still* paid full `cache_create` —
fresh external calls don't share cache. In-session is the only cheap path.
- **Keep it small:** output size barely affects generation cost but drives **carry cost every
turn** — a 2k memento doc costs ~$0.115/turn to hold vs ~$0.175 for an 8k `/compact` summary.
- **Fire at seams:** each compaction invalidates the cache; frequency has a real re-cache cost, so
trigger on value-to-next-task, not a clock.
### Turn count dominates the write (measured 2026-08-07)
A ceiling-triggered cycle was decomposed from the raw transcript. The write took **16 turns and
$4.11**, of which **$3.69 (90%) was cache-read** — re-reading ~461k of carried context sixteen
times. Output was **$0.32 (8%)**. Collapsing the same work toward a single call is worth roughly
**87%**, and none of that saving comes from writing a shorter note.
Two consequences:
1. **The note should be writable in ONE call.** Everything it needs is already in context. If a
field would require a lookup to fill in, it becomes a *pointer* instead — the next session can
fetch it, and it will still be there.
2. **Sizing the instructions is a rounding error.** Shrinking the instruction text ~4× saved on the
order of cents. The instructions are worth shrinking for readability, not for cost.
### A ceiling breaker fires at the most expensive possible moment
By construction a ceiling breaker only fires once already over, so the cycle always lands when the
context is at its largest and each turn costs the most. Cheaper cleaning is therefore *earlier*
cleaning, at a target rather than at a limit.
### Getting dirty is lumpy, not gradual
The premise under "cycle when context gets big" is that context accrues steadily. It does not. In
the measured session a **single tool call injected a 962,130-character message**, taking carried
context from 97,576 to 449,153 tokens. One load dwarfed a whole night of conversation, and because
carried context is re-read every turn, it taxed the following 27 turns rather than costing once.
**The first lever is therefore not cycling more often; it is not pulling an unbounded document into
context at all** — fan it out to a subagent, or fetch it bounded. See `@protocol/orchestrate`.
## Lineage
Consolidates the legacy `guides/memento-protocol.md` and the `~/.claude/commands/memento.md`
snapshot. Folds in the one durable idea from the retired **squeeze** experiment (disposition-aware
retention); squeeze's cold-external implementation is dropped as metered too expensive. The mental
model is mpeg4: the memento is the **I-frame**, the transcripts and deltas are the **seekable
tape**. The harness command is a thin snapshot of the kernel — doctrine lives in the protocol, the
command just bootstraps it.
---
*Related: `@content/youtube/sean-kochel/5-claude-cheat-codes-only-the-top-1-use` · `@protocol/auto-memento` · `@integrations/braintrust` · `@knowledge/frameworks/swim-lane-agent-factory` · `@knowledge/frameworks/agentic-engineering-maturity-model`*
---
*You're reading a protocol on [protocol.supply](https://protocol.supply) — hosted, searchable knowledge for AI agents. Think Agent Skills, as an API: bootstrap once (`curl -sL https://api.protocol.supply/bootstrap`), search (`/search?q=…`), fetch (`/@repo/slug`).*
*Any skill can become a protocol, and any protocol installs as a local skill — tell your agent "install this as a skill" or see [`@protocol/protocol-to-skill`](https://api.protocol.supply/@protocol/protocol-to-skill).*