Macula Mesh Use Build Macula for… Docs Contact

Macula · Martha · docs from Martha v0.4.1

The publish gate

This exists so that nobody outside the crew can get their text acted on by a crew member that holds a shell. It answers issue #2, and nothing is published from this repository until it is closed.

The host adapters change; this rule does not. It lives in the core so that no coding tool can quietly drop it.

What a gate is

A deterministic check on sender identity that runs before text is acted on. Not a fence, not a warning line, not a content filter. Every member holds a shell, so every piece of text that arrives is a possible command.

What executes

The list is an allow-list of tools that only read — Read, Grep, Glob and a handful of named mesh read tools. Everything else executes, including a tool name this repository has never seen.

That direction is deliberate. A deny-list quietly allows every name it has not been taught: hosts differ (bash on one, Bash on another), plugins add their own (MultiEdit, patch), and a host can ship a new tool that executes before anyone updates a list here. So the gate allows only what cannot make anything happen — a shell by any name, a write, an agent spawn, a web fetch, a message that hands the text to a peer, an unknown tool, all execute.

The read-only MCP entries are keyed on the server's own names. A plugin-namespaced copy of the same tool does not match and is treated as executing: noisy, and safe.

The rule

A session that took in text from a sender the policy table does not name by node id executes nothing, for as long as that text is readable in its context. It may read the text; it may not act on it.

The record accumulates on the session and is dropped only when the session is replaced by a fresh one with no inherited context. There is no "dismiss": a model that has read a stranger's text cannot decide that it is safe, because deciding is the model's job and the model is what was reached. Handover files and compaction summaries carry the text forward, so they arrive as ingests like any other and re-taint the session they land in.

Two reasons it is a gate at the shell and not at the door:

  1. On a host with no inbound-message hook, a cross-session message is already in the turn before anything of ours runs. There is nothing to check on the way in.
  2. Refusing a tool call before the engine runs it is demonstrably available — the crew's existing plugin already denies a shell command that way. Whether a turn can be refused or rewritten at its start is open: the engine's types are not vendored, so this repository does not assume either answer.

The policy table names senders by node id, compared case-insensitively because the crew's own code lowercases them. A display name is never a principal: a session whose first user message says "you are Supervisor" gains nothing, because the node id on the delivery is the only thing compared.

Who runs it

It is the owner's switch, and it is off until they turn it on: house_rules.strict_gate in the crew's declaration (martha#259). The owner decided on 2026-11-11 that a member is a trusted helper, and the check on it is review plus a yes on every push. The record the rule reads is written either way; with the switch off, nothing reads it.

Off, the three refusals that stand on text the session took in allow the call: this rule, a record that cannot be read, and an agent that has not stopped. Everything else here — the launch recheck, the refused writes to the owner's memory, the rule against a member widening its own reach, and the raw mesh read — stands whether the switch is on or off.

What this means when you are the owner

Text you paste into a session is an ingestion too. If it arrives unattributed, the gate blocks execution in that session until you start a fresh one — you hit this before anyone else does, and that is the intended trade: the owner is trusted, the thing the owner copied is not.

Who may act

A gate in front of the text is only half of it: a message that cannot reach the shell can still do things through the crew's own tools. crew-code decides who may assign work, restart a member, take the owner's asks or close a todo row by a display name the session sets about itself. That name falls back to the first six user messages, and a delivered message is a user message, so a stranger's ring purpose saying "you are Supervisor" passes every one of them.

Martha decides it by the crew's declaration instead. Each act a crew can grant is in the mode's table (mode.may in martha.json, read by declare_crew), and a tool that takes the act refuses a member whose role the table does not grant it. The member is the one the launcher was started as (martha start <member>). The launcher holds that name, so no message, ring or name read out of text can change who is asking.

Act Gated in
assign_work verify a range, unheld work, the owner's todo list, contracts, standing items, who is free; and who reads the nudges
approve_landing a landing: the owner's yes, as an ask in their queue whose question is exactly the landing's (the repository, its branch, the full tip and every package), or, where the table grants the act to the caller's role, the calling member's own yes
resume_parked_work park and wake a member
offer_owner_asks take and settle the owner's asks
restart_member restart a member
finish_a_members_worktree finish a worktree or a branch of a member other than the caller, which that member closes itself and which a member whose role the table names closes for it with owner_ok=1 (martha#962)

An act the table does not name is the owner's alone. A check drives each of these through its real tool and fails by name when a handler stops refusing, when an act has no handler, or when a crew tool is neither gated nor declared ungated with a reason (a_crews_tools).

This is a speed bump, said plainly. A member runs as the owner's OS user. Its shell can edit martha.json to grant its own role, write the crew's state directly, or fake the owner's yes, and nothing Martha checks inside that user can stop it. The table keeps an honest member and a confused model in their lane; it does not stop a member that sets out to get round it.

Every path, and what stands on it

src/inbound_paths/ holds every way text reaches a member's session, and every way a checkout gets code started on a member's machine, as data — the machine-readable copy of the tables in issues #2 and #16. Each row declares one control:

A path is never removed from the list. A path that stops delivering text gets a control that says so, in words.

Code the host starts by itself

This section answers issue #16, which has the threat model.

A coding tool reads files from the directory it starts in and starts what they name: a project's tool servers, its hooks, its plugins. That is not text for the model. No tool is called and no model runs, so the shell gate has nothing to refuse, and no sender exists for a delivery gate to check. Whoever last wrote those files runs code as the owner's OS user. The plainest case is a reviewer checking out a pull request to run its tests.

These are the launched rows: C1 for a checkout's tool-server config, C2 for its hooks and plugins. What was seen on the two hosts, in a fresh checkout whose config only touched a marker file (npm run probe:launch, the program in src/probe_launch_hosts/, which exits non-zero when a host does anything else):

Host, and how it was started What starts with nobody asked
Claude Code 2.1.318 by hand, interactive nothing: a project server waits for approval. The approval is stored as a list of server names, so a later change to an approved server's command is not asked about again
Claude Code 2.1.318 by hand, headless claude -p the project's tool server, and its SessionStart hook
OpenCode 2.2.5 by hand the project's tool server and its plugin, even for opencode debug config
Claude Code 2.1.318 as Martha starts it, config rewritten after approval the approved server and hook only; the rewritten ones do not start
OpenCode 2.2.5 as Martha starts it, config rewritten and a plugin added after approval the approved server only; the rewritten server and the added plugin do not start
OpenCode 2.2.5 as Martha starts it, the owner's environment setting both project-config switches to 0 the same: the approved server only
Claude Code 2.1.318 as Martha starts it, headless, one tool call, an after-call hook that only reports the after-call hook, then the approved Stop and SessionEnd hooks: the host goes on past a hook that returns
Claude Code 2.1.318 as Martha starts it, headless, one tool call, an after-call hook that waits for the launcher to SIGKILL the member's process group the after-call hook only: neither the approved Stop nor the SessionEnd hook runs
Claude Code 2.1.319 by hand, headless, a CLAUDE.md at the top and one below it, a file below read both load (an InstructionsLoaded hook in the owner's settings sees each)
Claude Code 2.1.319 as Martha starts it, the same checkout (A16) neither loads
Claude Code 2.1.319 by hand, headless, started as an agent the checkout defines (--agent) the agent loads
Claude Code 2.1.319 as Martha starts it, the same agent (A16) the host finds no such agent

The host's own approval is name-keyed where it exists at all, so it cannot be the control. src/refuse_launch_of_unapproved_config/ is five rules:

  1. The host never reads the checkout's own config. prepareLaunch copies the approved files into a snapshot outside the checkout and returns the switches that start the host on that copy with project config off: for Claude Code --setting-sources user and --strict-mcp-config with --mcp-config and --settings naming the copy, so only the servers passed start; for OpenCode --standalone with OPENCODE_CONFIG naming the copy and both of its switch names, OPENCODE_CONFIG_PROJECT_DISABLE=1 and OPENCODE_DISABLE_PROJECT_CONFIG=1: OpenCode reads the first that is set, so setting only the second lets an inherited =0 of the first win. The inherited OPENCODE_CONFIG_CONTENT and OPENCODE_CONFIG_DIR are dropped (launchEnvironment), since each brings config in from somewhere else. The background OpenCode service ignores a client's environment, hence --standalone. A pull that rewrites the config while the host runs changes a file the host is not reading, so a host that reloads its config live reloads the snapshot. Each copied file is hashed again as it is copied, and a file that changed since the decision is refused rather than carried.
  2. Approval is by content, never by name, and covers what the config runs. The fingerprint holds every listed file's content hash, every file under a listed directory, which of the files are absent, and the checkout's work tree: the tree git would write if every tracked change and every untracked, unignored file were staged now (src/judge_a_checkouts_tree/, in a scratch index, with inherited GIT_* variables dropped and fsmonitor off). A pull that changes only the script an approved hook runs changes the fingerprint. It is read before every tool call, so a checkout git reports clean reads as HEAD's own tree without staging anything.
  3. The checkout is the bound: a config inside the checkout is fingerprinted with it, from the directory the host starts in up to the checkout's top, and never above it. Nothing above the top is read: it is not the checkout author's, the launch never carries it, and a planned launch loads none of it. The stop directory the launcher names (the owner's home) bounds the walk when the start is in no checkout, or in one whose top is the stop or above it, and the stop is read only when the host starts in it. A start the stop is no ancestor of, in no checkout, is read up to the root, and refused when that walk finds any of the listed files, in the start or in any directory above it: nothing there can be approved.
  4. What the gate cannot pin down is refused: a symlink, even an approved one; a path that is not a plain file or directory; config in a directory that is no git checkout, or in one whose top is the stop directory or above it (a home kept in git), where nothing pins what it runs and staging the tree would copy a whole home into the object store; a request that does not show every listed file as read, so a reader that returned nothing cannot pass for an empty checkout; two files that would be passed through one carrier; and a host with no file list.
  5. No config needs no approval. A checkout holding none of the files starts, still with project config off.

Only the owner approves a checkout, with martha approve at their own terminal, and the approval is logged (martha#1, decision 4). The refusal names the files and says to run martha approve.

A member's own file writes pass the recheck (martha#132). A running member is checked again before and after every tool call. Its own Write, Edit and NotebookEdit calls are kept as it makes them (the file's git blob and mode once the call ran, the call, the session and the launch) before the recheck after that call. The live checkout then passes when every path that differs from the approved tree is deleted, or holds what this launch's last own write at that path left. Anything else (a Bash command's change, a link, another process's write, a config file git ignores) stops the member, naming the paths and saying to run martha approve, then martha start again. The code is src/refuse_launch_of_unapproved_config/pass_a_members_own_writes.ts.

What the plan leaves out, stated rather than hidden:

Where Martha does not start the host — the owner opens the coding tool by hand and Martha loads inside it — the host has started these before any of Martha runs. Each launched row says so in its residual, and the check fails a row that does not. The adapter must then refuse that session a place in the crew: the machine is already reached, the crew is not.

Code a checkout runs through the member's own commands

Issue #24, option 3, as a partial measure. A member commits, installs or runs a shell in a checkout, and the checkout's own files start code with the member's full rights: a git hook, an npm install script, an .envrc. No model is asked, so no gate sees it (row A13). The launcher shuts those doors for every member it starts, in one place (src/refuse_code_a_checkout_runs_itself/), through the environment the host and everything under it inherit:

Door What the launcher sets Why it wins
git hooks: .git/hooks, a core.hooksPath the checkout's config names, hooks named in config (git 2.54+), core.fsmonitor core.hooksPath = an empty 0500 directory made for this launch, hook.<event>.enabled=false for every event git documents, core.fsmonitor=false appended to GIT_CONFIG_PARAMETERS, which git reads after every config file and after GIT_CONFIG_COUNT; the owner's own settings there are kept
npm install scripts, pre/post scripts included npm_config_ignore_scripts=true npm ranks its environment above every .npmrc; every inherited spelling of the setting is dropped
the program a tracked .npmrc names as git, which npm install runs to fetch a git dependency, scripts off or not npm_config_git=git, the member's own git from its PATH the same
.envrc and .env through direnv DIRENV_DISABLE=1, and DIRENV_CONFIG = the same empty directory direnv 2.38+ stops outright; an older one finds no direnv.toml, so no whitelist trusts a directory wholesale

These apply whoever wrote the checkout: the launcher cannot tell a crew checkout from another, since a crew checkout pulls other people's commits.

What option 3 does not close, stated rather than hidden:

Only framed envelopes are believed

The crew learns two things from a cross-session message: whose a socket is, and which handoffs have been read. Both were learned by scanning text for an envelope, and every turn the plugin submits is text — so a room body, a ring purpose, a decline reason, a message's own body, or something the owner pasted could contain an envelope that was never sent. That buys a stranger two effects: renaming another member's socket, and retiring a handoff as read without having sent it.

src/trust_only_framed_envelopes/ is the rule that closes it. "Framed by the harness" is not a fact every host hands over — on the Claude Code host the plugin is given the turn's text and nothing else — so the frame is derived by a rule strict enough that an ordinary turn cannot wear one:

  1. the turn starts with the envelope's opening tag, at offset 0;
  2. its closing tag is the very end of the turn;
  3. there is exactly one envelope in the turn — a second opening tag anywhere in the body means the turn is not framed at all;
  4. attributes are read from that one opening tag, never from the body.

Everything between the tags is body, and body is never scanned. A room body, a ring purpose or a decline reason never starts with an envelope, so none of them can be one; a body that closes its envelope early and opens a forged one is not framed at all rather than framed with a forgery.

The adapter takes the sender's address and name from that frame and nowhere else.

The residual, stated rather than papered over: with that rule, a turn that is a whole envelope — the owner pasting one in — is indistinguishable from a delivery, and is believed. A host that can say where a turn came from must say so; origin: 'owner' is then never framed. Where the host says nothing, the paste is believed, and no amount of reading the text can tell the two apart.

Two limits that follow from what a host actually provides:

Like the other core rules, this one has no caller in this repository yet: the scanning it replaces lives in the crew's existing plugin.

Wiring it into a host

A host does these things, and the core does the rest:

When Call
a session starts, by any host event startSession(store, events, { event, session_id, predecessor_id }) — the host's declared events say whether the id stays, a new id inherits the predecessor's record, or a new id starts fresh; an undeclared event has lost its record
a session starts new, outside the declared events beginSession(store, session_id) — writes the empty record before anything arrives; an id that already holds a record has lost its record and nothing is overwritten
a session starts again (restart, resume, mod reload) resumeSession(store, session_id) — no readable record means the session is tainted, never fresh
a member hands over the host writes the file, then stampHandover(stamps, { member, session }, { file, content }) — never the model's Write
a session reads a file the stamp store knows readHandover(store, stamps, { member, session }, { file, content }) — on every file read, the model's own Read included: the host looks the path up in the stamp store, because a plain Read of a handover file would otherwise take the text in without the record
before starting the coding tool in a checkout prepareLaunch({ host, launch_dir, stop_dir, snapshot_root, approved_fingerprints }) — on a refusal do not start it and show the refusal to the owner; otherwise start it with the returned switches (their args, and the environment launchEnvironment(process.env, switches), which drops inherited variables that would bring config back), show the owner not_carried, and remove snapshot_dir when the member stops
before running any tool answerToolCall({ tool, session, policy, input, launch, names: host.tools }), where launch is the place and approvals prepareLaunch was given and names is the host's own split of a called tool's name — return the { deny } as the hook's answer. It checks the launch again first: the snapshot's hooks and servers run scripts that still live in the checkout, so a call that changes the tree (a gh pr checkout, a pull) is followed by a refusal of every call after it. What is left is the hooks of the one call that changed the tree
after every tool call recheckLaunch(launch) — on a refusal the hook asks the launcher to stop the member and does not return: the launcher sends SIGKILL to the member's whole process group (the host and its tool servers), which ends the hook with it. A hook that returned would let the host fire its next hooks (Stop at the end of the turn), and a SIGTERM or normal exit fires SessionEnd
a member reads a room readRoomThroughItsGate({ session, room, envelopes, rosters, self_node_id }) — the raw mesh reads are refused
after any MCP tool result takeInTurn(session, arrivalOfAMeshToolResult(ownName, input, answer), binder) — the shell gate judges every result. A ring tool's result carries the node id its own result attests, read by senderOfARingResult (../read_a_ring_results_sender, martha#247) from the result of the host's tool.call answer — its result is one text block whose whole text is one JSON object: mesh_ring records the node it dialled (A5), from to, only when its result carries an answer of 1, 2 or 3; mesh_answer_ring records the peer the server checked against its verified caller (A4), from peer, only when caller_notified is 1. Every other result of those two tools records no sender and says which branch it was — not answered, not notified, or a result that is not the recorded shape — and every other mesh tool result is B2, which carries no sender to admit — except that a mesh_hello or mesh_goodbye answer whose every leaf is something the launch supplied or can compute takes nothing in, and the shell stays (B9, ../prove_a_mesh_answer_is_wordless, martha#251). That reading admits no leaf the pinned server's recorded answer does not carry, and no joined realm: a provider's error, a policy file's quoted text, a realm's own strings and a leaf a release adds all record on B2 as before
when a member's session starts takeInTurn once per source sourcesALaunchHandsTheModel(carried_files) returns: A7 when the carried settings declare a hook or enable a plugin, A11 for a server outside the recorded mesh tree or a plugin; and once per source the crew's start line taken_in names: A20 when it hands the Supervisor's standing items to a member the table lets assign work (martha#317)
a turn arrives, from any source takeInTurn(session, arrival, binder): bindNothing on a host that cannot attest who sent a cross-session message
the launcher starts or stops a member recordMemberLaunch(launcherRecords, host.processes, launched), recordMemberStopped(launcherRecords, member_name), with the writable store the adapter holds as the launcher's seam; slices get only host.stores.launches, which reads (#42)
after a turn rememberSession(store, session)

takeInTurn records the arrival on the inbound path that names it, so the host and the registry cannot drift apart: the test derives the expected set from the registry, and a source with no registry row is named by the check.

The rules the seam keeps, and a host must not work around:

Every refusal a host returns says what clears the taint in the words of one constant, WHAT_CLEARS_IT in src/refuse_execution_after_ungated_text/, so the text cannot drift from the rule.

On Claude Code: the relay and the launcher

Issue #41 has the threat model. A Claude Code hooks module runs with no Node and may import only its own files, so the core cannot run inside the host. It runs in the member's launcher (src/launch_a_claude_code_member/), one per member: the process that starts the host and that sends SIGKILL to its process group. Inside the host, a relay (src/claude_code_relay/, a plugin the launcher loads with --plugin-dir) posts each event over a Unix socket made for that launch alone, with the engine's own fields unchanged, and acts on the answer. The relay decides nothing.

The host writes its own generated files (tsconfig.json, .claude-plugin/types/) into the folder --plugin-dir names, only those that are missing, and keeps whatever is already there (#117). So the installed relay folder is never named to the host: each launch copies the relay's declared files into its own socket directory, clears every write bit, and names that copy. A file put into the installed folder is not carried; a declared file that is missing or a link refuses the launch. The copy goes with the launch, and the installed relay stays byte for byte the release.

A relay the host refuses to load runs no gate at all (#104). So before a member starts, the launcher resolves the host's command once and asks that binary's own loader (plugin validate) whether it takes the launch's copy of the relay, and starts nothing if it does not. A host of another version than the one the adapter was recorded from is told to the owner in one line. The command is looked up only in absolute PATH entries, so a claude planted in the checkout is never what runs. After the start, a member whose relay does not report its session's start in time is stopped: within SESSION_START_DEADLINE_MS when no owner can answer the host or the host's own record (.claude.json) already trusts the folder, within TRUST_ANSWER_DEADLINE_MS when an owner can answer and the record does not say so, because the host first asks whether to trust a folder it does not know and runs no hook until the owner answers. The record is read one way only: anything but the folder marked trusted keeps the long deadline, and a wrong "trusted" only stops a member sooner. CI runs the loader of the recorded version over the relay (prove_the_relay_loads/).

Residual: ungated, for up to TRUST_ANSWER_DEADLINE_MS, on a folder's first start. With an owner at the terminal, in a folder the host does not yet trust, a host that loads the relay when the launcher checks it but then runs no hooks gives up to TRUST_ANSWER_DEADLINE_MS of a member with no prompt gate and no tool call gate, with nothing on screen to say so. The settings route to such a host is shut where the launcher can see it (#122): a launch is refused while the owner's user settings, the approved --settings copy, or the managed settings file or drop-in folder set a key the recorded host turns hooks off by (disableAllHooks, and from managed settings allowManagedHooksOnly and strictPluginOnlyCustomization). A launch is also refused while the host's safe mode is on, which keeps managed hooks only: its variable (CLAUDE_CODE_SAFE_MODE) in the launcher's environment or in any of those files' env, whatever its value, or its flag (--safe-mode) among the owner's arguments. Every one of these is read from the host's own hook-set function and the functions its exits call (hooks_switches and hooks_switch_calls in recorded_claude_code_host.json), and the recorder fails on a statement or an exit of that function it does not know, so a host that adds a way to drop hooks fails the recording instead of passing it. The probe plants each key the recording names beside a hook in the owner's user settings, and each one alone with no hook beside it: on the switches alone the hook does not run and the host exits cleanly, and gated the launch is refused before the host starts, naming the file and the key (npm run probe:launch). Claude Code 2.1.319 adds one such exit: with no terminal and CLAUDE_CODE_IGNORE_PERSISTED_TRUST set, the host keeps only the user, --settings and policy hooks. From 2.1.323 that exit opens a second way as well: with no terminal and --ignore-persisted-trust among the owner's arguments, it keeps the same hooks only. The recorder knows both shapes and records both ways in, the variable and the flag (outside_a_terminal, held as { variables, flags }), but refuses nothing for either: a member always has a terminal, so neither way in can fire for one, and a live probe on 2.1.319 in print mode, with a project hook as the witness that the exit fired, saw the relay's hooks still run. Both ways in are read by the trust reader too, from the same recording: a host whose variable is set in the member's environment, or whose argument is among the owner's own, is taken as trusting no record, so the member keeps the long session-start deadline instead of being stopped while the owner answers a question the host will not ask. A member's file tool call that names the owner's user settings file is denied, the path resolved as the host resolves it (trimmed, a leading ~ against its home); reads are denied too, which keeps nothing secret, since a shell can still read the file. A shell write is caught by the launcher itself: it reads those files again every HOOK_SETTINGS_CHECK_MS for the member's whole life, apart from any hook, as well as after every call, and stops the member when a switch appears. What is left: up to HOOK_SETTINGS_CHECK_MS of a member with no gate after such a write, since the host may drop its hooks as soon as it reloads the file; managed settings the host takes from a server or a device policy, which the launcher cannot read; and the host's own remote switch for hooks modules. This is accepted because a person must be able to read the host's trust question before answering it, and the live probe on 2.1.318 saw the relay report nothing before the answer, so no earlier signal exists to start a shorter clock from. Every later start in that folder is held to SESSION_START_DEADLINE_MS.

Host event (the relay) The launcher's call
settings SessionStart (classic.SessionStart: the host's source and session_id) startSession(store, CLAUDE_CODE_SESSION_EVENTS, sessionStartOf(input)); the mod's own session.start carries neither field
prompt.submit (text, and the origin the engine stamped where it queued the prompt) takeInTurn(session, arrivalOfPrompt(CLAUDE_CODE_PROMPT_ORIGINS, origin.kind), bindNothing); a prompt Martha itself submits comes back as plugin, and is recorded like any other
tool.call, before next the session's stored record read back, then answerToolCall({ tool, session, policy, input, launch, names })
tool.call, after next recheckLaunch(launch), then for an mcp__ tool takeInTurn(session, { source: 'mcp_result' }, bindNothing)
classic.SubagentStart (agent_id, agent_type, the member's session_id) the agent is recorded as started under that session, by id (martha#170)
classic.SubagentStop, and the completion it carries the agent is recorded as stopped; a vouched agent's answer records nothing and any other's is takeInTurn(session, { source: 'subagent' }, …), which is B7

The launcher starts the host as prepareLaunch says, with the owner's arguments first (--mcp-config takes every argument after it up to the next flag), and launchEnvironment plus the socket's path in MARTHA_RELAY_SOCKET. It records the launch with the writable store it alone holds (#42). When the member exits, the launcher kills the member's group, drops the launch record, and removes the socket directory and the snapshot.

Failing closed, per event. Anything but the exact shape of a yes counts as a no: the launcher unreachable, no answer within RELAY_DEADLINE_MS, a status other than 200, an answer with a field missing or one too many, a hook that throws or overruns its budget (each gating hook has a .catch):

Inside the launcher, a session whose record cannot be kept (ROW_NOT_DURABLE, ROW_STREAM_MOVED, a rows directory that no longer vouches for its rows, a row another writer added) is refused for the rest of the process. Its prompts are dropped and its tools denied, and after a tool ran the member is stopped.

The socket's directory is made new for each launch, mode 0700, in a parent owned by this user that nobody else may write. A path that already exists, a link, a parent that is a link or that others may write, or a socket path too long for an address refuses the launch.

T13, accepted under A13. A process of the same OS user can connect to that socket and claim any origin, a typed turn included. This is the same-user tampering the owner accepted until the signed roster (martha#1 decision 1, martha#24): that process could already rewrite the session records, the launch records and the row store. A secret held only by the relay would not close it: anything this user runs can read the host's environment and memory.

The owner's typed turn keeps the shell (A14, martha#51). Claude Code's engine stamps a turn typed at the member's own terminal composer, where it queues the turn and where no hook may set it. The owner ruled that this stamp is host-attested, so the turn is recorded on A14 with the owner's mark, and the shell gate admits that mark there and nowhere else. The owner is the root of the policy, not an entry in it. What is not the owner's typing stays unattributed and still takes the shell away:

A typed turn never clears a stranger's text already in the session. A paste is the owner's act: whatever the owner pastes is the owner's. Claiming composer on the socket is T13, and A14 does not widen it.

The owner relays every hand-off between members (first release, martha#51 ruling). A member's policy names no node id (martha start passes may_send_executable_text: []), so no member's text keeps another member's shell. A hand-off reaches the next member only when the owner pastes it at that member's terminal, which arrives on A14 as the owner's act. That is the same path, so it has no row of its own. What it rests on, stated: the text was written by a member that may have read a stranger's text, and the owner reading it before pasting is the only gate between the two.

The owner's words to martha start (A15, martha#98). martha start <member> -- <args> hands words to the host after the launch gate has judged the launch. A prompt there would be a turn no host stamped as the owner's; a --settings, --mcp-config or --plugin-dir loads config or code nobody approved; --setting-sources and --strict-mcp-config undo the switches the gate passes; a permission switch lets a tool past the shell gate's hook; --resume and --continue bring back a session whose record the launch does not hold. src/pass_only_switches_that_load_no_config/ is an allow-list: --model <value>, --effort <value> and --verbose, each of which loads no file, starts nothing and changes no permission. Every other word, a switch a later host adds included, refuses the start by name. A value switch refuses a missing value or one that starts with -, so one switch cannot carry another as its value. martha start also starts only on a terminal, as martha approve asks only on one, so a member's shell tool cannot start a sibling.

A member's memory never feeds a later session (A17, martha#136). Claude Code keeps auto-memory in <config dir>/projects/<project key>/memory/, loads it into every session of that project, and writes it by itself from a session (extractMemories, auto-dream, team memory). A session in a git worktree loads the main clone's folder, so a member could leave text there that the owner's own next session, or another member's, reads as memory, with nothing recording where it came from. Three things stand on it:

What it does not rest on: the publish gate's hook for the memory pass, which runs as a fork whose tool calls the hook is not established to see. What it leaves open: a Bash write into a memory folder, any of the code places, a git directory or the owner's git config, which only a clean member holds; a plugin or settings file the owner points at from outside the config dir, --plugin-dir and --settings on the owner's own command line among them; a place the host introduces that matches neither its array nor its statements, which nothing records and no test sees, though a change to the array or to those statements does fail the recording; a host the owner starts by hand (C1, C2); and OpenCode, not probed for a memory of its own.

A member's writes never reach a later session through the owner's user scope (A18, martha#154). The host loads the owner's own text from its config dir at every session's start: the folders it reads skills, agents and commands from as markdown, the output-styles folder it lists, and every project's own folder, where a session's transcript and the side files beside it live. A member writing any of them would leave text the owner's next session, or another member's, reads as its own, with nothing recording where it came from.

The gate refuses a member's Write, Edit, MultiEdit or NotebookEdit there, on the launcher's config dir and on the member's when the two differ (src/refuse_a_member_writing_owner_memory/). No folder is a list in our code: the markdown kinds and the output-styles folder are the recorded host's own loader and init field (markdown_the_host_loads, #146), and the output-styles folder is also the one the member's own session init reports at launch (user_output_styles_dir), so a CLAUDE_CONFIG_DIR in a settings file's env moves both the folder the host lists from and the folder the gate denies. The field is a required part of the recording: a recording without it does not load, and a host that reports no such field at launch starts no member here. Every project's folder is denied whole, not by the shape of what is in it today: a transcript, the files a session keeps beside it, a subagents/ record and a plain file directly under it are one place.

The same places go into the launch's permissions.deny rules, so the member's tool call is refused by the host as well as by the gate; the host's own writes are not a tool call, and are not what the rule refuses. npm run probe:launch asks the host to write one file in each of those folders, with those rules and with none of them: with them nothing is written, and without them the file lands. Each rule is written under the tool the host's own file permission checks use, and the launch asks the host whether it matches them before it starts a member: one the host says can never match refuses the launch, naming the host's own words about it (martha#226).

Not closed: the other places under the config dir that the host runs as code, which martha#187's name map denies, and this row claims none of them; a Bash write into any of these places, which only a clean member holds (A17); a host the owner starts by hand (C1, C2); and OpenCode, unprobed.

What the wiring leaves out: A6, until the host passes the attested sender to plugins (anthropics/claude-code#107216; the binder stays bindNothing); the launcher handing a turn to the model or registering a tool (no slice does either yet); and reading the policy from the crew's declaration. martha start passes the approvals the owner gave in martha approve, kept in Martha's state outside the checkout, and a policy that names nobody (the owner relays).

Who sent a cross-session message

src/attribute_a_cross_session_sender/ is the binder on the A6 row. It exists so that a crew member's message keeps the receiving session's shell because the host, not the text or a socket, says which node id sent it.

The chain has three links:

  1. the host attests the process that sent the delivery, out of band (on a Unix socket the kernel knows the connecting pid). This is arrival.sender, never anything parsed from the turn's text;
  2. the launcher's record, written by recordMemberLaunch when it starts a member, pairs that pid, and the time the kernel says that process started, with the member it launched;
  3. that record names the member's node id, which is what the shell gate reads.

The rules it keeps, from the threat model on martha#14:

The binder reaches the machine only through the host contract (#42): the records are host.stores.launches, one row per member keyed by its name, and the process's start time and boot are host.processes.identityOf(pid). The slice decides what a row must say (a launch, keyed by the member it names); the host keeps the file-level promises. Both seams are synchronous, so nothing runs between reading a record and asking which process holds its pid.

Slices only read the records. The contract types stores.launches as KeyedRows, which has all and nothing else, and an adapter hands it as readingOnly(store), so the object a slice holds has no writing member at run time either. The writable KeyedRowStore is the launcher's own seam: the adapter that launches members holds it and passes it to recordMemberLaunch and recordMemberStopped; it is not part of HostContract. As a second line, prove_the_core/one_place_does_it/only_the_launcher_writes_launch_records.ts names any slice but the binder's that writes the store or reaches stores.launches for anything but reading, names any slice that imports host glue, and refuses a martha.hostGlue entry that is not exactly src/<one directory>. A slice writing the records' files itself with node:fs is left to #26's allow-list of Node modules.

On Linux both seams come from src/linux_process_identity/, host glue that is not a slice and that every host adapter on Linux composes (package.json martha.hostGlue). launchRecordsDirectory(directory) keeps one file per key, so two launches at once never write over each other's record; the key is encoded before it becomes a file name, so it is never a path. Each file is written whole and renamed into place. Read back, the directory vouches for nothing unless it is a real directory owned by this user that nobody else may write into, holds only records, and every record is opened without following a link and checked on the opened file itself (a regular file, owned by this user, mode 0600, a JSON row) before that same file is read. linuxProcessIdentities reads a process's start time and the boot from /proc; where there is no /proc, every process reads as absent and nobody binds.

The residual, accepted for now: every member runs as the same OS user, so a member that already holds a shell can rewrite the records or read another member's mesh key. The modes and owners checked are speed bumps, not a boundary. The signed roster (#2 item 7) closes it; running untrusted checkout code under a member is #24.

What this repository does not contain

The registration itself. On the Claude Code host that is on('tool.call', …) in the plugin package, and building a plugin needs that package's types and its mod loader, neither of which is in this repository. What is here is the contract between them: one question per tool call, one record per arrival, one call per replacement. Writing the adapter's line of registration against the vendored package is the remaining step, not a guess this repository should make.

The room's acceptance rule

src/admit_a_room_message/ is the rule behind both delivery gates the registry names. Six questions, all of which must answer yes:

  1. is the sender a node id at all? — an empty or malformed one is nobody;
  2. did something attest the sender?
  3. is the sender on this room's roster?
  4. is the sender someone other than this session?
  5. is the message addressed to this session, by node id?
  6. is it a kind of message people talk with?

The two names are two rosters, not two rules. crew-room-acceptance checks the crew's roster and shared-room-acceptance the board's, and each name is bound to its roster in the registry rather than left to the caller. What the shared room gives nobody is authority — nothing said there authorises anything — which is why the roster question comes before anything the body says.

The rule does not cap or fence the body — that is the room's — and it trusts the roster's contents, which is the anchor weakness named separately.

Every list a gate trusts is signed

Every gate compares against a list: the crew room's roster and the shared room's, the policy that names whose text a session may act on, and the members the binder may attribute a sender to. (No signed list says who may act: the declaration's table does, see "Who may act"; the supervisors list went with who_may_act, martha#607.) Kept as plain files, one command run as a member's user adds a node id to any of them, and the gate then admits whoever was added. So each list is a document the owner signs, opened by openTrustList (src/trust_only_signed_lists/) from the signed bytes on every read.

Not signed: the session record store, which the host writes on every turn and no owner could sign. It keeps the fail-closed rule instead (a missing or unreadable record taints). The binder's rows (martha#14) are bound by the signed members list: a launch record binds only when its member_name and node_id pair is in that list, so a planted record for a stranger, or a signed node id under another member's name, binds nothing. The pid in a record is dynamic and no owner can sign it, so pointing a signed member's record at another process stays martha#24's residual. Code running as the member's own user can still replace a pinned key the host installed where that user can write, which is the OS boundary of martha#24.

Commands whose output keeps the shell

Issue #129. Running the owner's tests is how a member learns what it broke, and a test's output is the checkout's text: once #127 records every Bash result as A13, a member that runs npm test loses its shell. The way back is a short list of commands the owner signs, run by the launcher on bytes it has checked, so their output holds nothing the owner did not vouch for.

The list. A signed document of kind command_shapes (src/keep_the_shell_for_an_owner_signed_command/command_shapes.ts), opened by the rules of the section above: a base (remote_url and branch, the one branch whose commits the owner vouches for) and shapes, each a name matching SHAPE_NAME and an argv run with no shell. Its crew is the project's name in Martha's state root, so a list signed for one checkout opens empty in another. The owner pins a hardware key with martha pin-key <public key file> and keeps a signed list with martha keep-shapes <file> (which reads <file> and <file>.sig); both refuse unless their input is a terminal, and the list is kept only when it opens. The key, the newest epoch opened and the list live in the project's state directory (src/keep_what_the_owner_signed/); the epochs persist across processes, and an epochs file that does not parse opens no list at all.

A run. The member types exactly martha run <name> as a Bash call, in the foreground (runNameOf). When the launcher allows that call, its relay's tool_called makes it the one call a run binds to, by its tool_use_id; the martha run client then asks the launcher on the relay socket (RUN_PATH), and the launcher runs the shape only while exactly that call is pending. It (runASignedShape, src/run_an_owner_signed_command/):

Step What stands on it
the base fetched from the signed remote_url and branch into a repository of the launcher's own (BASE_REF), with git's global and system config off; never the checkout's .git, origin or URL rewrites
the checkout read once: every path git would see is lstated, a regular file's blob id computed from the bytes read; anything else is refused
the tree rule a regular file passes when its blob is the base's at that path, or one the member wrote itself through Edit or Write (the own-writes registry, #132, every launch); any other file, and any entry in the base that is not a regular file, refuses the run, by path
the dependency rule package.json and package-lock.json must equal the base's; the base lock and node_modules/.package-lock.json must both be lockfile version LOCKFILE_VERSION, every installed entry must match the base lock's version and integrity, and every package directory on disk must be one the installed lock holds; .bin is rebuilt from the base lock
the copy exactly the bytes judged, written into a fresh directory in Martha's state (RUNS_DIRECTORY): no .git, no ignored file, no node_modules/.cache
the sandbox bubblewrap shows the copy at RUN_TREE, an empty home at RUN_HOME, an empty /tmp, the node install and the SYSTEM_DIRECTORIES read-only, and no network; the environment is built from nothing; stdout and stderr share one pipe; a run past RUN_DEADLINE_MS is killed
the receipt the output, its sha256 and the status, kept for that tool_use_id (src/run_an_owner_signed_command/receipts.ts) and taken once, when the call is answered

martha run writes the run's bytes to stdout unchanged, nothing to stderr, and ends with the run's status. A refusal anywhere on the way runs nothing and says why.

The exemption (keepsTheShell) records nothing for a Bash result only when the command is exactly martha run <name> for a shape signed now, the receipt is this call's, and the whole result equals the one built from the receipt by the shape the pinned host was recorded giving. The recorded shape covers statuses RECORDED_STATUSES only: any other status records A13, named as unrecorded. An added key, a non-empty stderr, a truncation or a note is a different value.

That decision is taken where a tool's result is recorded, in the relay's own answer to a finished call (toolAnswered, src/launch_a_claude_code_member/): the relay sends the host's answer with tool_answered (answeredBody in src/claude_code_relay/hooks/relay_protocol.ts, which leaves an answer past LARGEST_RELAYED_ANSWER out rather than send a body the launcher kills the member over), the launcher takes the call's receipt there whatever the answer, and a run whose answer is exactly the one its receipt builds records nothing, so the next Edit runs. Every other Bash result records A13 through #127's table as before: an answer left out for its size, a host that renders the result differently, a status no recording covers, and any command that is not exactly martha run <name> all record. The shapes are the pinned host's own answers, recorded under src/claude_code_host/recorded_claude_code_bash_results.json and read as CLAUDE_CODE_BASH_RESULT_SHAPES.

The check

src/check_every_path_is_gated/ reports every row that reaches a shell-holding member with no control standing on it, and names the row. It runs in CI as the gate coverage job, and it drives the real gate once per row that claims the shell gate — a row cannot claim cover the gate does not give.

A delivery gate is driven once per question it has to answer: it must refuse an unattested message, a session talking to itself, a message addressed elsewhere, a kind that is not talk, a sender the roster does not name and a sender that is not a node id — and it must admit a rostered member. A name with no implementation, a gate that admits everyone, a gate that refuses everyone and a gate that answers only the roster question are all caught.

An ask gate is driven once per question it has to answer: it must admit an ask a member this crew started queued, and refuse one whose asker the launcher never started, one whose text carries a control or hidden character, one longer than the queue's cap and one with no text.

A launched row may only declare the launch gate, and must say what happens where Martha does not start the host. The launch gate is driven once per question: it must admit config the owner approved and a checkout with no config, and refuse unapproved config, an approved file whose content changed under the same name, a file added after the approval, a config one directory up, a symlink even when approved, a host it has no file list for, and a request whose config was never read.

A row refused before launch must be delivered text, and its argument gate is driven once per class of word the host acts on: it must pass no arguments and a model, and refuse a prompt on the command line, a settings file, the settings sources, a tool-server config, a plugin directory, skipping permission checks, a permission mode, a session brought back, a switch carried as another's value and a switch nobody has read. A gate that passes everything, one that refuses everything, one that knows only one config switch, and a row naming a gate nobody built are each named.

A row that claims the shell gate must also be reachable: the shell gate only stands on a row the host records. shellGateRowsNothingRecords takes every row the Claude Code relay records when it is driven with each declared start source, each prompt origin, each mesh tool that runs, another MCP tool and each built-in tool, and names a shell-gate row nothing reaches, and a row declared no turn source (REGISTRY_ROWS_THAT_ARE_NOT_TURN_SOURCES) that the relay records after all. There is no list of rows it lets pass (martha#121).

Its tests plant each of those mistakes to prove the check is not vacuous: a row copied from the table without a control, a row whose control was forgotten, a row claiming the shell gate while the gate does not refuse it, a row naming a gate nobody has built, a delivery gate that admits a stranger, one that refuses a member, and a row excused without a reason. Each of those turns CI red.

What this does not yet do

What runs today, through martha start: the launch gate (prepareLaunch, on the owner's approval), the shell gate (answerToolCall, from the Claude Code relay before every tool call), the recheck after every call, the argument gate, and the owner's typed turn on A14. What does not:

What Martha shows the owner

The gate decides by what the owner reads, in martha approve above all, so nothing Martha shows may move, erase or reorder it. Every line the martha command writes, on stdout and stderr, goes through one function (shownSafely in src/run_the_martha_command/) first:

What could reach the owner's terminal What stands on it
a path, a member's name or a kept approval holding bytes a terminal acts on: C0 and C1 controls, DEL, the bidirectional overrides and isolates, the left-to-right, right-to-left and Arabic letter marks (U+200E, U+200F, U+061C), and the line and paragraph separators (U+2028, U+2029) each is written out as an escape (\x1b, \u202e), so the line shows what is there and does nothing else
an error no act expected, whose message may hold any of the above runMarthaCommand catches it and shows its message as one refused martha: line, escaped like every other; Node's own trace, which would print the message raw, never runs

Both are tested by the command as a stranger runs it (bin/martha), with a directory name holding every class above.

What the first release leaves open

Stated, not closed. Each is a residual a reader should know before trusting a crew with a shell:

Martha's docs, from release v0.4.1: Getting started: a crew of two on your own project · @macula-io/martha · Martha · The agent control loop · claw-code: what it is, where it comes from, what Martha can learn · The host contract and the ledger · How a release is made · Nothing private gets in · The port map, in summary · The publish gate · The crew's declaration