Session capture for Miadi hosts, as a Claude Code plugin. Install it once on a host and every
Claude Code session there is captured. Nobody edits settings.json by hand.
jgwill/miadi-orchestration-kit#56.
<root>/<session_id>/, the layout the token
counter, the /token-usage page and the session observers read.<root>/data/terminal_bindings.jsonl and to the session’s own _terminal_binding.jsonl. The line holds the session id, the tmux
session:window.pane and pane id, the agent’s command line, its name and name history, and
its team, the chronicle episode it works in, and the miadi-run mission that started it (the
pinned tracing prompt and its trace, from the seat’s prompt that names the mission’s
prompt.md, or from MIADI_RUN_MISSION). Since 0.1.26 it also holds account_person, the
person on the wheel the local account acts for (MIADI_ACCOUNT_PERSON, else
~/.miadi/person.env, jgwill/Miadi#887). tmux restore and tide agents restore read
these lines to bring agents back._transcript_final.jsonl, and only at the
turn’s end. Each one is now written to images/<message_uuid>/<NN>-<name> in the session
folder, one folder per transcript line, with a line in _claude_images.jsonl: prompt id,
message uuid, the start of the prompt’s text (prompt_text), how many of the person’s lines
carry that prompt id (prompt_lines), position, media type, bytes, sha256, kept_from and
read_from. A reader joins an image to its prompt by id and text, because one id can sit on
many lines: a forked session’s copied history carries one id on every copied prompt.
~/.claude/uploads/<session_id>/ while it exists, found through the inlined_image_paths
attachment and the attachments between it and the prompt’s line. The transcript copy may
be downscaled for the model (the 14th of 14 photos on 2026-11-19: 357,156 bytes uploaded,
234,840 in the transcript). A pasted image has no original and is decoded from the
transcript, strictly: base64 the secret sanitizer changed in the archived copy is listed
with that reason, not written as broken bytes..images.state
takes the transcript’s mtime from the start of each pass, and two builtin -nt tests
compare them. Reading the 38 MB transcript takes 2 s. Measured on gaia, 2026-11-19: the
first 0.1.52 sweep took 218 s with the archive, and the image check over 645 unchanged
sessions now costs no process.images/<prompt_id>/, 0.1.50 and 0.1.51) is moved to
images/v1/ with its index, never deleted, and captured again. A session started before
0.1.52 keeps its loaded hooks and may add layout 1 lines until it restarts. The reader
takes both.python3. tests/user-images.sh, 33 checks. Found by an adversarial review of
0.1.50: originals skipped in 24 of 42 uploads, fork images overwritten, slash-command
images dropped, a 165 s sweep.stc-workspaces.json maps to a working
directory is not written, committed or pushed from its second clone under the auto-clone
root (/workspace/repos on gaia). hooks/workspace_clone_guard.sh refuses and names the
working directory. It reads $MIADI_SRC/config/stc-workspaces.json, so a host without a
Miadi checkout gets the capture and no guard. jgwill/workspace#60. Since 0.1.48 a mapped
folder counts as the working directory only when it is a git checkout: on eury /src/Miadi
is a folder of another repository, and the only jgwill/Miadi clone there was refused.<root>/<session_id>/ was already
redacted, but a credential printed in a tool’s output reaches the model and Claude Code’s
own transcript before any hook runs, and Claude Code lets a hook replace only an MCP tool’s
output. Since 0.1.31 the alert says only what it knows. When the output holds the value of
a credential this host holds (a variable in the session environment named *TOKEN*,
*SECRET*, *PASSWORD*, *API_KEY* and the like), the person is told the variable’s name
(action: "rotate"), and since 0.1.33 to mask the local copies with miadi-scrub-secrets.py. A string shaped like a vendor credential (ghp_,
sk-ant-, mwt_, AKIA, a JWT, a private key, a password in a URL) that no held
credential matches is named by kind and redacted prefix, to check (action: "check").
Fixtures stay quiet: values holding test, fake, example, dummy, sample, fixture,
placeholder, redacted or changeme, six ascending or equal characters, or under 3 bits of
entropy per character. Bearer <x> and token: <x> count only when <x> is a held
value. Earned 2026-11-04, when the fixture Bearer review-token in Miadi’s connector
tests was announced as a credential to rotate. Each finding is a line in
_claude_secret_exposures.jsonl with held (variable names) and shaped (kind, prefix),
never the value. Since 0.1.32 a session is told once per finding, the message names the word
before the value so the claim can be checked at a glance
($X (X="***)), variables named like credentials that hold an author, a URL or a name are
left out, and a clean call costs 46 ms instead of 267 ms. tests/secret-exposure-alert.sh, 41 checks.hooks/secret_print_guard.sh refuses a Bash, Read or Grep
call that would print a credential, before it runs. It runs the command’s own filters over a
fake copy of the credentials (the environment’s, or the file with each value replaced) and
refuses when a fake value comes out, so no mask is trusted by its look. Open, because no value
comes out: X=$(grep ^X= .env | cut -d= -f2-), cut -d= -f1 .env, grep -c, grep ^PORT= .env,
[ -n "$X" ], a value handed to another program. Earned 2026-11-04, replayed over 46,023 calls
of 30 days: of the 15 that printed a held credential it refuses 12 (the other 3 printed it from
a script or curl -w, and the alert still reports those). It refuses 7 others, one of them for
a path it could not resolve. A call that names nothing relevant costs 21 ms.
MIADI_SECRET_PRINT_GUARD=off in the session’s environment turns it off. tests/secret-print-guard.sh,
87 checks.scripts/miadi-scrub-secrets.py counts the credentials this host
holds (environment and .env files) wherever a session recorded them, and --apply masks them:
~/.claude/projects, ~/.claude/history.jsonl and the capture root’s session folders. Each value
is overwritten in place by as many * as it has bytes, so a file keeps its inode, size, offsets
and mtime, and a running session can keep appending. Prints names and counts, never a value. No
backup and no undo. A config or credential file met there is listed and left alone. It reaches
neither the model API nor a git history. On gaia it masked 2,551 occurrences of 65 credentials in
336 files, in under 30 s. A running session may write a value again: run it again after it ends.
tests/scrub-secrets.sh.find from /, a recursive search over the
session capture, and a reader (cat, jq, grep, tail…) on a session’s raw
_claude_* files are refused, and the refusal names the tools that answer the question:
tide agents list, miadi-hooks-interpret join, digest, fleet, the binding line.
The binding line stays readable. MIADI_SESSION_LOOKUP_GUARD=off in the session’s
environment turns it off for work on the capture itself. Earned 2026-11-01, when a seat
ran find / -name terminal_bindings.jsonl for 120 s instead of tide agents list.
Since 0.1.44 a relative path is read against the folder the command cds to before it, so
cd <repo> && grep -r … <dir> from a shell whose folder is in the capture is allowed, and
cd <session folder>; cat _claude_… is refused. A cd ends at a pipe, a background & or
the ) of its subshell, and one the guard cannot read falls back to the shell’s folder.
Since 0.1.46 a Codex session’s raw _codex_* and last_codex_* files are refused the same way,
and the Codex plugin carries this guard as the same text.tmux kill-server and tmux kill-session -a without -L or -S, pkill or killall on
tmux, kill of the server’s pid, systemctl stop or restart of tmux-server. TMUX_TMPDIR
alone does not count as a server of its own, because $TMUX wins over it. It reads the command
text, so a program that calls tmux itself, such as node --test, is not seen.
MIADI_TMUX_SERVER_GUARD=off in the session’s environment turns it off. Earned 2026-11-05, when
a test reached the live server with kill-server and 69 running agents stopped.
tests/tmux-server-guard.sh, 48 checks.codex-setup (0.1.47). The steps an agent in Claude Code runs to set up Codex on its
person’s account so Codex sessions are observed too: the Codex version, the kit’s Codex
marketplace and plugin, the terminal title, the hook review in /hooks that is the person’s, the
proof, and the legacy hook cutover after it. Future ceremonies require Codex sessions
(Guillaume, 2026-11-14).session-continuity carries T1’s practice: the binding line, tmux save and
restore, tide, and rebuilding what each pane held after a crash.Since 0.1.34 every session has a steering inbox (jgwill/Miadi#930). A person’s correction, sent through
the Miadi connector, waits in <factory>/steering/<session_id>/pending/. At the next tool end the hook
gives it to the model as additionalContext, in the same turn. If the turn ends with no further tool,
Stop continues it with the correction. If it lands while the turn is ending, a background watcher
(asyncRewake, 30 seconds after each turn) wakes the model with it. It goes to the main thread only, once, and is checked again
for its session, hash, expiry and revocation when it is consumed. With nothing pending the hook costs
one bash glob and starts no node. Hooks load at session start, so a session started before 0.1.34
answers unsupported. MIADI_STEERING_DIR moves the folder, and a host without the factory folder has
no inbox and notices nothing.
claude plugin marketplace add jgwill/miadi-orchestration-kit # or the path of a checkout
claude plugin install miadi-session-observability@miadi-orchestration-kit
Then remove the hooks block from ~/.claude/settings.json on that host, in the same step. If
both are wired, every event fires twice and every capture line is written twice.
The plugin’s hooks load when a session starts. Removing the hooks block takes effect at once,
so a running session captures nothing from that edit until it is restarted. Restart it right
after the edit (seen on gaia, 2026-09-30).
To try the plugin without installing it: claude --plugin-dir <path to this folder>.
<root> is CLAUDE_SESSIONDATA_ROOT, else MIADI_SESSION_DIR, MIADI_SESSIONDATA_ROOT,
SESSION_DATA_ROOT, else /src/_sessiondata when it exists, else _sessiondata beside this
folder (hooks/claude_hooks/lib.sh).
Every file a tool call creates, changes or moves is copied to
<root>/<session_id>/written/<its absolute path>, sanitized, and listed in
_claude_files_written.jsonl with the call that touched it. Since 0.1.11,
jgwill/miadi-orchestration-kit#82.
files_written.sh copies each file whose
inode changed between the two marks. It scans the cwd the call started in, the cwd it ended
in and the session’s scratchpad, and one level of each directory the command names.
.git, node_modules, dist, build, target, virtualenvs and caches are skipped.proposed/ still
receives what the tool is about to write, as before.tool_use_id, tool_name, agent_id, prompt_id (the user prompt the call answered), kind (created, changed, or
moved for a rename, a move or a chmod), path, size, sha256, copy, note and the
first 240 characters of the command.<name>.~N~. A file that only grew (a log) replaces its copy.sha256. A scan stops after 5 s, and a cwd
that slow (/workspace, a home folder) is then scanned three levels deep
(CLAUDE_WRITTEN_MAX_BYTES, CLAUDE_WRITTEN_MAX_FILES, CLAUDE_WRITTEN_MAX_LINES,
CLAUDE_WRITTEN_SCAN_SECONDS)..env* except
.example, .sample and .template, keys, .netrc, .pgpass, .npmrc, cloud
credentials, Terraform state) is listed without a copy or a hash. Passwords inside
scheme://user:password@host URLs are redacted in every copy.run_in_background
command writes after its PostToolUse. A file written by another process during the call is
listed as if the call wrote it.Claude Code keeps a project’s memory in <config>/projects/<key>/memory/ (~/.claude unless
CLAUDE_CONFIG_DIR says otherwise), one file per memory and MEMORY.md as its index. Only the
user that ran the session can read that folder, and other agents never look there. Each memory
file a call writes is copied like any other file, and also listed in _claude_memory.jsonl
with project (the key), file, index (true for MEMORY.md), name, description,
type and origin_session_id read from the copy’s frontmatter, plus kind, tool_use_id,
prompt_id, sha256 and copy. A memory file that is removed is not listed. Since 0.1.25,
jgwill/miadi-orchestration-kit#111.
A person can open a running subagent in the agent view and talk to it, or fork a /btw side
question with f. Those words reach the subagent or fork, never the main session. At every
SubagentStop the hook archives the agent’s transcript to
<root>/<session_id>/agents/<agent_id>.transcript.jsonl, beside .meta.json, .launch.json
(when the main session launched it) and .output.md (its last reply only).
scripts/agent-talk.mjs reads them back for any agent that can run node:
node scripts/agent-talk.mjs list <session> # each subagent and fork, person messages, replies
node scripts/agent-talk.mjs show <session> <agent> # directive, each person message, each reply
node scripts/agent-talk.mjs person <session> # only what the person said, across all of them
<session> is an id, a prefix, a tmux name or a session name. A fork with no launch manifest is
listed as btw-fork: the person made it. An image pasted into a subagent arrives as the text
[Image #N] only, and show says so. Since 0.1.15, after three messages from Guillaume to the
witness-editor sat unread on 2026-10-15.
No hook fires for /btw. Claude Code keeps the question in ~/.claude/history.jsonl only (its
pasted text in paste-cache/), and the answer in its panel only. Pressing f forks it, and the
fork’s transcript keeps the question, the answer and everything after. Each archive pass (Stop,
SubagentStop, SessionEnd, the SessionStart sweep) writes the events of the session’s /btw
questions to <root>/<session_id>/_claude_btw.jsonl, each once, in time order. Since 0.1.17,
jgwill/miadi-orchestration-kit#95.
| kind | the line holds |
|---|---|
asked |
every /btw question, forked or not: btw_id (btw-<history ms>), at, question, pasted, cwd |
forked |
agent_id, name, question, directive, and parent_last_uuid, the main transcript message it branched after |
answered |
the panel’s answer, as the fork keeps it |
person |
each message the person sent the fork, with its prompt_id |
reply |
each reply, with tools_before, the tools called since the previous reply |
notified |
each time the main session was told the fork completed or was resumed |
delivered |
the result reaching the main session: via: "prompt" with its prompt_id, or via: "attachment" inside a running turn |
Every line of a fork carries the btw_id of its question, so asked without forked is a side
question that was closed. Its answer is not kept anywhere: only a fork keeps the answer. A fork
the Agent tool launched has no question and writes no line. SubagentStop names a /btw fork by
its question in agents/<id>.output.md and trace.log, from Claude Code’s meta.json.
tests/btw.sh holds the rules.
Not wired since 0.1.24. A Stop hook that stops a turn makes the agent write a second reply, and
that reply is what tan then annotates. A hook cannot change the reply itself, so the check is
off. The script and its test stay here; the rest of this section says what it did.
At each Stop, hooks/claude_hooks/uncommitted_not_written.sh reads git status in the repository
the session runs in and in every repository it wrote a file into, and lists the uncommitted files
that neither the session nor its subagents wrote (_claude_files_written.jsonl) in
<root>/<session_id>/_claude_uncommitted_not_written.json. The session’s own capture folder is
left out, an untracked folder is the session’s when it wrote inside it, and a repository reached
through a link is named by its real path. When the reply that ends the turn counts one of those
files as work done (a sentence that names it, by path or by a file name with an extension only
one of them carries, says wrote, updated, committed and does not say not, another, someone), the
hook stops the turn once, names them, and asks for those sentences corrected with nothing else.
A reply that only mentions them is never stopped, so the agent never answers the check.
MIADI_UNCOMMITTED_IGNORE (shell patterns separated by :, matched against the absolute path,
set in the shell or in settings.json env) leaves files out of the list and the check, for
example */.claude/skills/*:*/.mino/session-inventory/*.
It never stops a turn twice in a row. R6 of the requirements of 2026-10-19, lane K6e.
tests/uncommitted-not-written.sh holds the rules. On gaia’s largest trees a Stop takes 1 to 3 s,
most of it git status in /home/mia/workspace.
What a session put where other people can see it is one line in
<root>/<session_id>/_claude_publications.jsonl, with the tool call and the prompt
(prompt_id) that produced it. Since 0.1.12, jgwill/miadi-orchestration-kit#82.
| kind | from | the line holds |
|---|---|---|
artifact, artifact-asset |
an Artifact publish | url, path (the source file), title, artifact_id, updated |
issue, issue-comment, pr, pr-comment, release, gist |
gh issue, gh pr, gh release, gh gist that write, and gh api that writes |
url, repo, number, action (issue create, pr comment, api) |
issue |
inquiry-weave open, issue and inquire, which call gh themselves (0.1.18): each owner/repo#N [created] line |
url, repo, number, action (inquiry-weave inquiry, inquiry-weave actions, inquiry-weave issue) |
pr |
Claude Code’s gitOperation.pr |
url, number, action |
commit |
gitOperation.commit, or git’s output ([branch sha] subject, a git log --oneline -1 after a quiet commit) |
the full sha, repo, dir, subject, url, verified |
push |
gitOperation.push, or git’s To <remote> and a..b src -> dst lines |
repo, branch, from, to, and a compare url |
npm |
npm, pnpm or yarn publish |
package, version, url |
Each commit is checked in the tree the command worked in (git -C, a cd, then the cwd). A
commit read from output must be in such a tree and committed during the call, and one read
from git log or git show after a quiet commit must be that tree’s HEAD. A gh URL counts
only when it ends its line (alone, or after a label in a batch) and the command ran the gh
write that makes that kind of URL. A command that only reads (gh issue view,
git log --grep, gh api -X GET) records nothing, and neither does a push or publish whose
every invocation in the command is a --dry-run. A chain that publishes, then fails, is read from
PostToolUseFailure. PostToolUse matches the raw input first, so a
call that cannot have published costs nothing, and a call that may have costs one jq call
before the parse runs detached.
The threads people open on a published Artifact page are lines of
<root>/<session_id>/_claude_artifact_comments.jsonl, keyed by artifact_url and
thread_id, with the tool call or prompt that brought them in. Since 0.1.16,
jgwill/miadi-orchestration-kit#56.
| kind | from | the line holds |
|---|---|---|
sent |
a prompt headed [Artifact comment sent to Claude] |
sent_at, the comment text without its > quote marks, the anchor context |
auto-reply |
an artifact-auto-react task notification |
the posted comment_id, artifact_title |
thread |
ArtifactComments read, or resolve |
anchor_label, anchor_path, span_quote, resolved, claude_activated, comments (count) |
comment |
ArtifactComments read, or reply |
comment_id, author (the viewer’s name, or Claude), role, sent_to_claude, created_at, text |
A read hands the hook every thread with its full text, even when the model is shown a capped
list. Each comment is written once. A thread line is written when the thread is first seen and
again when it is resolved or activated for Claude. A comment that nobody reads in the session
and nobody sends to Claude never reaches it: read the artifact’s comments
(ArtifactComments, action read) to bring every thread in. One thread in order:
jq -c 'select(.thread_id == "<thread id>")' _claude_artifact_comments.jsonl
The binding line’s team is {"id": "T1", "source": "session"}. It is resolved in this
order:
MIADI_TEAM in the agent’s environment, or the tmux session option
(tmux set-option -t <session> @miadi-team T1)teams/teams.json, matched against the tmux session name and the agent
session’s nameunassignedThe list is MIADI_TEAMS_FILE, else $MIADI_ORCHESTRATION_KIT_ROOT/teams/teams.json. An
installed plugin is a copy of this folder, so it cannot reach the kit by a relative path.
teams/README.md is the text people read, and the two are kept in step.
hooks/claude_hooks/ is the only Claude Code capture. The hand-wired hooks it replaced are
deprecated (the kit’s AGENTS.md).hooks/secret_capture_sanitizer.sh and hooks/git_command_validator.sh are copies bundled
from /opt/binscripts/hooks/. The plugin’s copies are canonical for Claude capture.
binscripts keeps its own for the other agents’ suites until they join (A6,
jgwill/binscripts#158)./inventory-exit (0.1.42): before the person closes a session, its own agent writes the
record’s facts with inventory.mjs write, adds the meaning from what it did (mission,
work_completed, held_decisions, next_steps, team_fit from miadi-witness team-fit.mjs,
disposition), commits only that record in the inventory’s repository and pushes, then tells
the person to type /exit. It never runs /exit itself./inventory-exit-reason [reason] (0.1.49): the same record for a session the person exits
before its work is done, with their reason in an exit block (aborted, wrong_model,
wrong_setup, superseded or other, their words verbatim, the models the session ran and
the line that restarts it) and status: "aborted". Without a reason it asks for one. It lists
the session’s uncommitted files in the record and commits none of them.scripts/inventory.mjs write --session <id>, no model call,
from the installed miadi-witness plugin (a user install, or a project install whose folder
holds the session’s cwd), else from $MIADI_ORCHESTRATION_KIT_ROOT/claude/miadi-witness.
Nothing is written without either, without node, on a host with no inventory folder
(WITNESS_INVENTORY_DIR, else ~/workspace/.mino/session-inventory), or for a headless
claude -p child. The run’s output goes to the session’s trace.log. Since 0.1.43 it then runs
inventory-at-exit.mjs decide beside it, which decides how the record gets its meaning (counted,
or one Jev call that may start one detached Haiku reader under a dollar and a daily cap) and
commits the record by path. An installed miadi-witness older than 0.7.43 has no such script.plans/session_<id>_<yyMMddHHmm>.md. Until 0.1.19 the hook also ran
/opt/binscripts/plan-insight/miette_claude_plan_perspective_claude.sh. Miette’s perspective is
now the miette-plan-insight plugin’s: a session that loads it opens a
Miette seat beside itself on the same event.jq and perl are required. The sanitizer is written in perl.bash tests/team-resolution.sh
bash tests/episode-resolution.sh
bash tests/transcript-archive.sh
bash tests/files-written.sh
bash tests/publications.sh
bash tests/artifact-comments.sh
bash tests/binding-agent.sh
bash tests/binding-mission.sh
bash tests/workspace-clone-guard.sh
bash tests/uncommitted-not-written.sh
bash tests/session-end-inventory.sh
CLAUDE_SESSIONDATA_ROOT=$(mktemp -d) claude --restricted --plugin-dir . --model haiku
--restricted ignores the user’s settings files, so only this plugin’s hooks run. One prompt
that starts a subagent, a /rename and an exit write the same files as today’s capture, with
each event written once.