A member whose host dropped Martha's relay is restarted once, then stopped with a plain message #180

Closed
opened 2026-11-25 10:42:00 +00:00 by saturnus · 2 comments
Member

Purpose (fix): a member whose host dropped Martha's relay is restarted once with the relay, and stopped with a plain message if that fails too, so it never goes on working without the owner's approvals.

DECIDED 2026-11-25 (Raf): "Yes, build it (Recommended)".

The harm. Claude Code runs every plugin's hooks module in one worker. When the worker answers no heartbeat within 5000 ms while Martha's relay is loading, the host unloads the relay ("martha was unloaded: it crashed the hooks worker") and goes on with the session without it (found in #171). No prompt or tool call then reaches the launcher, so none of Martha's gates runs. The member acts without the owner's approvals until the launcher's backstop (#104) stops it: SESSION_START_DEADLINE_MS (30 s) with no owner at the terminal, or TRUST_ANSWER_DEADLINE_MS (10 min) with one. Today the backstop only stops the member, so the owner then has to start it again by hand. A stall like that can hit any owner's machine under heavy disk load, not only CI.

The shape.

  • The trigger is the existing backstop: the relay did not report the session's start within the deadline that applies today. No new timer.
  • On the first miss, the launcher stops the member's host and starts it again once, on the same approval and launch.
  • On a second miss, it stops the member with a plain message saying the host ran without Martha's relay twice and the member is stopped, with nothing restarted after that.
  • A start that the relay reports, on either attempt, goes on as today.

Threat model and the tests come first in the package. Tests run on a fake host (a stand-in that never reports its start, and one that reports it on the second start). Mutants go on the restart-once path and on the stop path.

Done when: a member whose relay never reports its start is restarted exactly once and then stopped with that message, a member whose relay reports on the restart runs on, and both are pinned by tests on a fake host.

Refs #171, #104.

Purpose (fix): a member whose host dropped Martha's relay is restarted once with the relay, and stopped with a plain message if that fails too, so it never goes on working without the owner's approvals. DECIDED 2026-11-25 (Raf): "Yes, build it (Recommended)". **The harm.** Claude Code runs every plugin's hooks module in one worker. When the worker answers no heartbeat within 5000 ms while Martha's relay is loading, the host unloads the relay ("martha was unloaded: it crashed the hooks worker") and goes on with the session without it (found in #171). No prompt or tool call then reaches the launcher, so none of Martha's gates runs. The member acts without the owner's approvals until the launcher's backstop (#104) stops it: SESSION_START_DEADLINE_MS (30 s) with no owner at the terminal, or TRUST_ANSWER_DEADLINE_MS (10 min) with one. Today the backstop only stops the member, so the owner then has to start it again by hand. A stall like that can hit any owner's machine under heavy disk load, not only CI. **The shape.** - The trigger is the existing backstop: the relay did not report the session's start within the deadline that applies today. No new timer. - On the first miss, the launcher stops the member's host and starts it again once, on the same approval and launch. - On a second miss, it stops the member with a plain message saying the host ran without Martha's relay twice and the member is stopped, with nothing restarted after that. - A start that the relay reports, on either attempt, goes on as today. Threat model and the tests come first in the package. Tests run on a fake host (a stand-in that never reports its start, and one that reports it on the second start). Mutants go on the restart-once path and on the stop path. Done when: a member whose relay never reports its start is restarted exactly once and then stopped with that message, a member whose relay reports on the restart runs on, and both are pinned by tests on a fake host. Refs #171, #104.
Author
Member

Threat model (before code), base main 740ed295.

What we protect: the owner's rule that a member never acts without Martha's gates. The harm is a host running ungated (#171). The restart must not widen it.

# Threat Guard in the design Test / mutant
T1 Restart loops: a host that keeps dropping the relay is restarted again and again, each time running ungated until the deadline. One counter per launch, set once, never reset. The second miss goes straight to the stop path, never to a restart. Fake host that never reports: exactly 2 spawns, then stopped. Mutant "restart on every miss" → 3+ spawns, killed.
T2 A stop for another reason turns into a restart: the run went away, a hook-settings switch, the owner's stop, a recorded refusal. Only the backstop's own miss restarts. Any stoppedBecause set before or during the miss wins, and the member stays stopped. Fake host stopped by its run going away within the window: 1 spawn, no restart. Mutant "restart on any stop" killed.
T3 A late session_started from the killed first host counts for the second, so an ungated second host is let through. The first host's group is killed and its exit awaited before the second spawns. The backstop's reported is armed fresh per attempt. Fake host whose first start reports only after being signalled: still restarted, and the second is judged on its own report. Mutant "reported carried over" killed.
T4 The restart runs on something other than what the owner approved. Same starting (args + env as recorded, martha#135), same snapshot, same relay server and directories. Nothing is re-read or re-prepared. The fake host records its argv/env on both starts; asserted equal.
T5 The ungated window doubles (two deadlines). Accepted by the ruling (no new timer). The message names both misses, so the owner knows the member ran without gates. Message text asserted.
T6 Cleanup on restart deletes what the second start needs (relay dir, snapshot, server), or the final stop leaks them. A restart kills and awaits only the host group, and keeps what the launch made. The final stop removes everything once. The launch record names the live pid (sweeps keep the relay dir while either lives). After the final stop: relay directory gone, server closed, launch record dropped, as today.
T7 The owner's terminal: a restarted foreground job fails to take the terminal back and hangs the owner's shell. A restart that cannot start goes to the stop path with its own refusal. No second try. Fake host that fails to spawn on attempt 2: stopped with that refusal.

Plain message on the final stop: <member> is stopped: its host ran without Martha's relay twice (no report of the session's start within <n> s, on the first start and on the restart), so it was not started again.
Out of scope: why the host drops the relay (host-side, #171's residual). Any new timer.

**Threat model (before code), base main 740ed295.** What we protect: the owner's rule that a member never acts without Martha's gates. The harm is a host running ungated (#171). The restart must not widen it. | # | Threat | Guard in the design | Test / mutant | |---|---|---|---| | T1 | Restart loops: a host that keeps dropping the relay is restarted again and again, each time running ungated until the deadline. | One counter per launch, set once, never reset. The second miss goes straight to the stop path, never to a restart. | Fake host that never reports: exactly 2 spawns, then stopped. Mutant "restart on every miss" → 3+ spawns, killed. | | T2 | A stop for another reason turns into a restart: the run went away, a hook-settings switch, the owner's stop, a recorded refusal. | Only the backstop's own miss restarts. Any `stoppedBecause` set before or during the miss wins, and the member stays stopped. | Fake host stopped by its run going away within the window: 1 spawn, no restart. Mutant "restart on any stop" killed. | | T3 | A late `session_started` from the killed first host counts for the second, so an ungated second host is let through. | The first host's group is killed and its exit awaited before the second spawns. The backstop's `reported` is armed fresh per attempt. | Fake host whose first start reports only after being signalled: still restarted, and the second is judged on its own report. Mutant "reported carried over" killed. | | T4 | The restart runs on something other than what the owner approved. | Same `starting` (args + env as recorded, martha#135), same snapshot, same relay server and directories. Nothing is re-read or re-prepared. | The fake host records its argv/env on both starts; asserted equal. | | T5 | The ungated window doubles (two deadlines). | Accepted by the ruling (no new timer). The message names both misses, so the owner knows the member ran without gates. | Message text asserted. | | T6 | Cleanup on restart deletes what the second start needs (relay dir, snapshot, server), or the final stop leaks them. | A restart kills and awaits only the host group, and keeps what the launch made. The final stop removes everything once. The launch record names the live pid (sweeps keep the relay dir while either lives). | After the final stop: relay directory gone, server closed, launch record dropped, as today. | | T7 | The owner's terminal: a restarted foreground job fails to take the terminal back and hangs the owner's shell. | A restart that cannot start goes to the stop path with its own refusal. No second try. | Fake host that fails to spawn on attempt 2: stopped with that refusal. | Plain message on the final stop: `<member> is stopped: its host ran without Martha's relay twice (no report of the session's start within <n> s, on the first start and on the restart), so it was not started again.` Out of scope: why the host drops the relay (host-side, #171's residual). Any new timer.
Author
Member

Landed in main 9985cba3 (PR 185, tip c33d1ce0, Mars VERDICT PASS r=4, ci=forgejo:4580-4583 green).

Purpose met: a member whose host dropped Martha's relay is started again once, and if the restart also misses the deadline it is stopped with a plain message ("its host ran without Martha's relay twice ..."). T1-T7 each have a test; mutants on the guards were killed, including asked = false (the r=3 fold-in).

Residuals, accepted, no package:

  • Between the two starts the launch record still names the first pid, so a martha stop inside that ~one-spawn window says "not running".
  • A failed second start resolves with the first host's exit code.
  • The second start places the mesh-server config again, from the same approved bytes.
  • MemberStarted.pid stays the first start's; launchNow() names the live one.
  • The ungated window can be two deadlines (T5, accepted).
  • The backstop.anew() call site survives the launch tests (fable F5): pinning it needs a report landing between the second spawn and arm().
Landed in main 9985cba3 (PR 185, tip c33d1ce0, Mars VERDICT PASS r=4, ci=forgejo:4580-4583 green). Purpose met: a member whose host dropped Martha's relay is started again once, and if the restart also misses the deadline it is stopped with a plain message ("its host ran without Martha's relay twice ..."). T1-T7 each have a test; mutants on the guards were killed, including `asked = false` (the r=3 fold-in). Residuals, accepted, no package: - Between the two starts the launch record still names the first pid, so a `martha stop` inside that ~one-spawn window says "not running". - A failed second start resolves with the first host's exit code. - The second start places the mesh-server config again, from the same approved bytes. - `MemberStarted.pid` stays the first start's; launchNow() names the live one. - The ungated window can be two deadlines (T5, accepted). - The `backstop.anew()` call site survives the launch tests (fable F5): pinning it needs a report landing between the second spawn and arm().
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#180
No description provided.