Amnestic Trace (amtr)

A one-to-one replacement of short-term working memory across a context
boundary. Two cases only: a session surviving its own compaction, and an
explicit handoff to another session. What remains relevant is kept, the rest is
dropped, and the result overwrites what came before — there is no history, no
generations, and no shared memory.
What must survive
Carrying everything that matters, in full, is the goal — and it is not
attainable: the delivered memory is budgeted at about 2,000 tokens, and a
working session does not reduce to that without loss. So the design commits to
the next-best thing it can actually keep: what cannot cross whole crosses as
a key. A topic named is enough for the waking session to know the thing
existed and to go recover the words — from the journal, the repository, or the
user.
Compression is survivable; absence is not. A memory that leaves no fragment
leaves nothing to even miss, so nothing ever triggers the recovery — which
makes silent, total loss of a needed memory the one failure with no path back.
Everything downstream is this ranking applied: the extraction prompt shrinks
before it deletes and drops rulings last, and the injected preamble tells the
reader its memory is lossy and where to go for the rest.
Commands
amtr synthesize # PreCompact payload on stdin
amtr recall SessionStart # hook payload on stdin
amtr recall PreToolUse # hook payload on stdin
amtr recall UserPromptSubmit # hook payload on stdin
amtr recall Handoff --amtr-key <key> [--clone] # explicit handoff
amtr peek [--session-id <id>] [--amtr-key <key>] [--json]
amtr key <session_id> # this session's own key
The hook-facing commands accept the host's JSON object intact. The shell
adapter does not parse it or touch delivery state; it only repairs the minimal
hook PATH, forwards stdin/stdout, and makes failures non-fatal to the host.
There are no legacy positional forms.
A key is a capability, not a name: whoever holds it can move a snapshot away
from the session that owns it, and moving is the default. So none is placed in
the injected memory — nothing about continuing the work needs one, and a
session wired into a channel of other agents cannot pass on what it was never
given. amtr key reads it back when a handoff is actually wanted, from the
store rather than from whatever a model remembers.
synthesize writes a marker, detaches by double fork, and returns, so
extraction runs in parallel with compaction itself.
peek is the debugging surface. With no filters it prints every stored row and
all delivery metadata, including the marker, deadline, remaining budget and
orphan claim files. --session-id and --amtr-key combine with AND. The
default is a labeled view for a person at a terminal; --json emits the same
fixed projection as compact JSON. It is a pure observation and does not create
a store or repair state. Both forms intentionally expose every matching
handoff and its AMTR key; peek is a local same-user diagnostic surface, not a
redacted sharing format.
The marker is an undelivered snapshot, not a "compaction happened" flag. It
names the snapshot it owes, so one debt can be told from another:
ongoing synthesize started -> reader polls
ready:<amtr_key> row written -> reader injects, then deletes the marker
gone delivered, or the attempt failed
The distinction matters because extraction usually finishes long before the
user's next prompt. A worker that deleted its own marker on success would leave
the next turn with nothing to deliver against, so the snapshot would never be
injected — the marker has to outlive the worker and be discharged by whoever
consumes it. A worker that lands after a timed-out reader gave up rewrites
ready, and the turn after that delivers it.
A failing synthesize deletes the marker and says so in the log. That is the
whole of it: the memory is ephemeral, so a failed extraction means there is no
memory this time, not that an older one is kept alive. The transcript survives
and the next compaction rebuilds from it.