martha start <engine member> --acp: serve ACP upward on stdio for lazymartha; one ask, two answer paths, first wins #361

Closed
opened 2026-12-02 09:30:46 +00:00 by neptunus · 1 comment
Member

Purpose (feature): lazymartha can run an engine member as a child over ACP on stdio, and every ask the owner has to answer reaches lazymartha's queue. Martha keeps the gate, the owner's rules and the dashboard rows.

Raf, DECIDED 2026-12-02: "Yes, build it (Recommended); Real CLI in a pane (Recommended); Whole room (Recommended)". This supersedes DECIDED 2026-11-20 "let's go tmux".
Design: martha-ai/lazymartha#6, comment 8053 (Uranus; Jupiter PASS r=2). This issue is package 1 of that design: §1, §5 row 1, and r=2's "one ask, two answer paths, the first answer wins".

Refs martha-ai/lazymartha#6.

What it does

martha start <engine member> --acp keeps today's engine path (the stand-in or martha-engine as an ACP child, the gate, the rules, the rows, the owner-answers socket) and changes only the owner's side. In place of the chat at the tab, it serves ACP on its own stdio:

  • Upward methods: initialize, session/new (answers the member's engine session), session/prompt (a queued turn, as an owner's line at the tab), and session/cancel (as Ctrl-C). It relays every session/update from the engine unchanged.
  • Asks: only the asks that the gate and rules leave for the owner go up, as session/request_permission, with once-only options (allow_once, reject_once) like answer_a_permission_once. The reply settles the ask through the same asks.answer the tab and martha answer use, and writes the same owner_answers.jsonl line the tab writes.
  • Two answer paths, first wins: martha answer and the upward reply both reach the same held ask. Exclusivity is the existing in-memory held map: close() deletes the key synchronously, so two answers cannot both apply. When the ask is settled any other way (martha answer, withdrawal, cancel), martha sends _martha/ask_settled {key, by} up, which is an ACP extension notification, so lazymartha drops it from its queue at once. A late upward reply is answered answered-nothing and changes nothing.
  • stdout is the protocol. Nothing but ACP frames is written to stdout: the started line, bells and the owner's notes go to stderr. Without a terminal, --acp is allowed. Without --acp, NOT_A_TERMINAL still refuses.

Threat model (before code)

Assets: the owner's yes on a tool call (a member's shell/edit), and the gate's and rules' decisions.
Actors: the owner (lazymartha's user), a member running as the same OS user, a remote party (none: stdio only, no socket, no port).

  1. A member answers its own ask through a new path. martha answer is refused inside a member (isStillRefusedFromInsideAMember, martha#601: "a member answering the owner's ask is a push to main without the yes"). start --acp is a third way to answer, so it gets the same refusal: --acp inside a member is refused by the same check. This is a speed bump as NOT_A_WALL states, the same strength as answer today.
  2. The upward path widens the gate. It must not. Only ask-the-owner asks go up. A refuse-once or run-once decision never goes up and is never changed by the parent. A parent reply naming an unknown or already-settled key changes nothing. Allow-always (keep) is not offered upward in this package.
  3. A stale answer applies to a newer ask. Asks are keyed permission:<toolCallId>@<sessionId>, never "the oldest", so a reply settles only the ask it names.
  4. A double answer. Covered by the single-threaded held map, and tested as a race of the two paths.
  5. stdout pollution breaks the framing. A stray line on stdout would make the parent mis-parse. Tested: every stdout line of an --acp run parses as JSON-RPC.
  6. The parent is untrusted input. Malformed JSON gets -32700, an unknown method -32601, and a prompt starting with ! or / is refused as at the tab. Nothing from the parent reaches a shell.
    Out of scope: same-user forgery of state files (NOT_A_WALL, unchanged), and the room (package 4a).

Done when

  1. martha start <engine member> --acp runs a turn over stdio: initialize, session/new, session/prompt up; the engine's session/updates relayed; session/cancel cancels the turn. Tested with the ACP stand-in, with stdout holding only JSON-RPC lines.
  2. An ask left for the owner goes up as session/request_permission with its key. The parent's allow_once runs the tool and reject_once refuses it, each writing the owner_answers.jsonl line. A gate deny and a rules-allowed call never go up.
  3. Two answer paths, first wins: a test answers one held ask both by martha answer (the socket) and by the upward reply. Exactly one applies, the other gets answered-nothing, and when martha answer wins the parent receives _martha/ask_settled. Both orders are tested.
  4. --acp is refused inside a member, with the same check and message as martha answer; tested.
  5. Without --acp nothing changes: the tab chat and NOT_A_TERMINAL as today (the existing tests stay green).
  6. Mutants on the guards (inside-a-member refusal, only ask-the-owner goes up, first-wins, stdout-only-frames) each turn a test red; the whole npm test is green before the push.
Purpose (feature): lazymartha can run an engine member as a child over ACP on stdio, and every ask the owner has to answer reaches lazymartha's queue. Martha keeps the gate, the owner's rules and the dashboard rows. Raf, DECIDED 2026-12-02: "Yes, build it (Recommended); Real CLI in a pane (Recommended); Whole room (Recommended)". This supersedes DECIDED 2026-11-20 "let's go tmux". Design: martha-ai/lazymartha#6, comment 8053 (Uranus; Jupiter PASS r=2). This issue is package 1 of that design: §1, §5 row 1, and r=2's "one ask, two answer paths, the first answer wins". Refs martha-ai/lazymartha#6. ## What it does `martha start <engine member> --acp` keeps today's engine path (the stand-in or martha-engine as an ACP child, the gate, the rules, the rows, the owner-answers socket) and changes only the owner's side. In place of the chat at the tab, it serves ACP on its own stdio: - **Upward methods:** `initialize`, `session/new` (answers the member's engine session), `session/prompt` (a queued turn, as an owner's line at the tab), and `session/cancel` (as Ctrl-C). It relays every `session/update` from the engine unchanged. - **Asks:** only the asks that the gate and rules leave for the owner go up, as `session/request_permission`, with once-only options (`allow_once`, `reject_once`) like `answer_a_permission_once`. The reply settles the ask through the same `asks.answer` the tab and `martha answer` use, and writes the same `owner_answers.jsonl` line the tab writes. - **Two answer paths, first wins:** `martha answer` and the upward reply both reach the same held ask. Exclusivity is the existing in-memory `held` map: `close()` deletes the key synchronously, so two answers cannot both apply. When the ask is settled any other way (`martha answer`, withdrawal, cancel), martha sends `_martha/ask_settled {key, by}` up, which is an ACP extension notification, so lazymartha drops it from its queue at once. A late upward reply is answered `answered-nothing` and changes nothing. - **stdout is the protocol.** Nothing but ACP frames is written to stdout: the started line, bells and the owner's notes go to stderr. Without a terminal, `--acp` is allowed. Without `--acp`, `NOT_A_TERMINAL` still refuses. ## Threat model (before code) Assets: the owner's yes on a tool call (a member's `shell`/`edit`), and the gate's and rules' decisions. Actors: the owner (lazymartha's user), a member running as the same OS user, a remote party (none: stdio only, no socket, no port). 1. **A member answers its own ask through a new path.** `martha answer` is refused inside a member (`isStillRefusedFromInsideAMember`, martha#601: "a member answering the owner's ask is a push to main without the yes"). `start --acp` is a third way to answer, so it gets the same refusal: `--acp` inside a member is refused by the same check. This is a speed bump as NOT_A_WALL states, the same strength as `answer` today. 2. **The upward path widens the gate.** It must not. Only `ask-the-owner` asks go up. A `refuse-once` or `run-once` decision never goes up and is never changed by the parent. A parent reply naming an unknown or already-settled key changes nothing. Allow-always (keep) is not offered upward in this package. 3. **A stale answer applies to a newer ask.** Asks are keyed `permission:<toolCallId>@<sessionId>`, never "the oldest", so a reply settles only the ask it names. 4. **A double answer.** Covered by the single-threaded `held` map, and tested as a race of the two paths. 5. **stdout pollution breaks the framing.** A stray line on stdout would make the parent mis-parse. Tested: every stdout line of an `--acp` run parses as JSON-RPC. 6. **The parent is untrusted input.** Malformed JSON gets -32700, an unknown method -32601, and a prompt starting with `!` or `/` is refused as at the tab. Nothing from the parent reaches a shell. Out of scope: same-user forgery of state files (NOT_A_WALL, unchanged), and the room (package 4a). ## Done when 1. `martha start <engine member> --acp` runs a turn over stdio: `initialize`, `session/new`, `session/prompt` up; the engine's `session/update`s relayed; `session/cancel` cancels the turn. Tested with the ACP stand-in, with stdout holding only JSON-RPC lines. 2. An ask left for the owner goes up as `session/request_permission` with its key. The parent's `allow_once` runs the tool and `reject_once` refuses it, each writing the `owner_answers.jsonl` line. A gate `deny` and a rules-allowed call never go up. 3. **Two answer paths, first wins:** a test answers one held ask both by `martha answer` (the socket) and by the upward reply. Exactly one applies, the other gets `answered-nothing`, and when `martha answer` wins the parent receives `_martha/ask_settled`. Both orders are tested. 4. `--acp` is refused inside a member, with the same check and message as `martha answer`; tested. 5. Without `--acp` nothing changes: the tab chat and `NOT_A_TERMINAL` as today (the existing tests stay green). 6. Mutants on the guards (inside-a-member refusal, only `ask-the-owner` goes up, first-wins, stdout-only-frames) each turn a test red; the whole `npm test` is green before the push.
Author
Member

Closed. Landed in martha main 28b8909b (PR 363, in Terra's #361+#364 batch; reviewed by Jupiter).

Done-when:

  1. A turn runs over stdio (initialize, session/new, session/prompt up, session/update relayed, session/cancel cancels it), with stdout holding only JSON-RPC lines. Tested in serve_acp_to_the_client_above.node-test.ts and start_an_engine_member.node-test.ts, against the ACP stand-in.
  2. An ask left for the owner goes up as session/request_permission. allow_once runs the tool and reject_once refuses it, each writing its owner_answers.jsonl line. A rules-allowed call never goes up: tested, and the mutant is killed. A gate deny opens no ask, so it takes the same path. (Not tested on its own; named in the PR.)
  3. Two answer paths, first wins: both orders are tested. The second answer gets answered-nothing, and when martha answer wins the parent gets _martha/ask_settled.
  4. --acp is refused inside a member, with martha answer's check and message (..._an_owner_act_from_inside_a_member.node-test.ts).
  5. Without --acp nothing changes: the existing tests stay green.
  6. Mutants killed 6/6: inside-member refusal, a rules-allowed call sent up, a second answer applied, a settled ask not dropped, a command prompt passed, asks not sent up. Whole npm test before the push: 5976 tests, 1 fail. That failure is the unrelated martha#70 loop case under load, filed as #362.
Closed. Landed in martha main 28b8909b (PR 363, in Terra's #361+#364 batch; reviewed by Jupiter). Done-when: 1. A turn runs over stdio (`initialize`, `session/new`, `session/prompt` up, `session/update` relayed, `session/cancel` cancels it), with stdout holding only JSON-RPC lines. Tested in `serve_acp_to_the_client_above.node-test.ts` and `start_an_engine_member.node-test.ts`, against the ACP stand-in. 2. An ask left for the owner goes up as `session/request_permission`. `allow_once` runs the tool and `reject_once` refuses it, each writing its `owner_answers.jsonl` line. A rules-allowed call never goes up: tested, and the mutant is killed. A gate `deny` opens no ask, so it takes the same path. (Not tested on its own; named in the PR.) 3. Two answer paths, first wins: both orders are tested. The second answer gets `answered-nothing`, and when `martha answer` wins the parent gets `_martha/ask_settled`. 4. `--acp` is refused inside a member, with `martha answer`'s check and message (`..._an_owner_act_from_inside_a_member.node-test.ts`). 5. Without `--acp` nothing changes: the existing tests stay green. 6. Mutants killed 6/6: inside-member refusal, a rules-allowed call sent up, a second answer applied, a settled ask not dropped, a command prompt passed, asks not sent up. Whole `npm test` before the push: 5976 tests, 1 fail. That failure is the unrelated martha#70 loop case under load, filed as #362.
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
martha-ai/martha#361
No description provided.