Macula · Martha · docs from Martha v0.4.1
The agent control loop
The loop a member runs inside one work package: the task, its context, the tools it may use, what happens when a step fails, how the work is verified, and what survives a session.
This exists so that “what a member does between taking a package and handing it over” has one reference. It is Martha’s map of the control-loop reference the crew reviewed on 2026-11-16, translated into the slices in this tree. The reference image is not vendored; this page is Martha’s own map, and it changes when the slices do.
The loop
build context → reason / plan → next action?
│ tool │ verify │ ask
▼ ▼ ▼
tools & workspace verify candidate Supervisor / owner
│ result │
▼ ▼
record result evidence sufficient?
ok │ │ error │ yes │ no
▼ ▼ ▼ ▼
check progress failure & recovery complete build context
│ │ bounded retry or replan → build context
▼ │ pause → Supervisor / owner
budget left?
│ yes │ no
▼ ▼
build context save / resume (hand over or park)
Martha runs this per member, per package, inside the crew. The Supervisor owns the package and the owner’s yes; the reviewer owns the verdict; the relay owns the gate. The reference’s single-agent loop is the member’s inner loop, not a replacement for the crew.
The six systems
| System | What it asks | Where it lives in Martha | What is still open |
|---|---|---|---|
| Task & constraints | goal, acceptance criteria, allowed actions, budget, definition of done | the declaration, the package contract, the Supervisor’s brief, the role and mode texts, owner yes, standing items | A package contract: #513 slice 1 keeps it, versions it and hands it; allowed actions are enforced and the budget counted in slices 2 and 3, and it extends the mandate in #3 |
| Context & memory | retrieve, relevant files, current state, prior attempts, progress notes; compact to what this turn needs | the crew text, the handover, refresh; the mesh server’s mesh_recall when configured, whose text stays on the shell gate |
A structured context package; #506 re-reads handover facts on resume |
| Tools & workspace | validate the call, authorize it, pause for approval, execute, capture id, exit status, output and pending work | the tool-call gate, tool results, the shell refusal, what a session took in, every path gated, owner-signed commands, worktrees, batch landing | Package-level allowed actions in #513; a structured tool-result envelope |
| Failure & recovery | classify, inspect the actual state, decide whether a retry is safe, bounded retry, replan or pause; a timeout reconciles the operation | the ledger’s failure words (ACT_NOT_SENT / OUTCOME_NOT_KEPT), one bounded recovery (the named classes, the inspection, the one attempt and the pause), failed reviews, merge clashes, ending a turn, restart, waits |
For an announced outward act, the taxonomy, the inspection, the one attempt and the pause are here (#512 slice 1); every tool call is slice 2 |
| Verification | stable candidate, run checks, test behaviour and scope, tie evidence to this revision; new edits invalidate the affected verification | range verification, each criterion at the tip, the verdict that passed, no disappeared test, CI (its reads paid from the GitHub budget), batch landing | Per-criterion acceptance evidence is on the menu line (#513 slice 1); a criterion judged rather than found is still the reviewer’s, and exact-tip CI stays |
| State & continuity | durable log, tool ids and results, workspace checkpoints, pending work and approval state, save / resume / reconcile | the ledger, row streams, session records, taint across a refresh, the handover, the crew store, standing items, the ask queue, the owner’s list | Workspace checkpoints; a loop-event projection over the existing rows |
What Martha already does better
- Verification is tied to the exact revision.
verify_rangereads a clone’s range and the CI runs on its tip; a PASS names the head;check_no_test_the_base_passed_goes_missingfails CI when a test the base passed is missing at the tip, unless a commit in the range says it dropped it. The reference’s “affected verification” is looser. Keep the exact-tip rule. - A landing stands on a recorded yes, given to that landing.
fast_forward_after_the_owners_yesmoves a default branch only when the declaration'sapprove_landinggrants the caller's role, or grants the owner and the call names an ask the owner said yes to whose question is exactly the oneverify_rangegave for that repository, tip and set of packages (the yes, #605). The landing's ledger row says which yes it stood on. The ask queue checks every id a settle names against the options the owner picked, as the host's own answer to the menu reports them, not the settling member's word (#608). That closes the settle tool, not a write that goes around it: members run as the owner's own OS user, so a process of theirs can still append to the queue's stream itself. Only an OS wall would stop that, and the owner closed that road (#258). It is a speed bump that makes a faked yes awkward and visible, not a boundary. - Every tool call is gated, and text taken in is tainted.
answer_a_tool_call,take_in_a_tool_resultandrefuse_execution_after_ungated_textare the reference’s “authorized?” box, with a stricter model: the owner chooses, per member, whether text taken in costs the shell, enforced, audited or off (read_the_gate_mode; absent means off, #259, #321). The launch recheck, reach widening and raw mesh reads are refused in every mode. - An outward act is written before it runs.
sendOutwardActwrites the row first, so a successor can tell an act that never ran from one that ran with no kept outcome. The loop’s “record result” should use that distinction, not a second log.
What the loop does not change
- The crew stays the unit: Supervisor, builder, reviewer, owner. The loop is per member and per package.
- The host and the model plan. Martha’s job is constraints, gates, evidence and state; this is not a new planner.
- A package contract narrows what a package may do. It never widens a role or the mode table.
- #309 owns the dashboard’s budget gauges; #3 owns the mandate and revalidation; this page does not duplicate them.
Where to start
- #513, the package contract: slice 1 is built — the contract block in the brief, its version in the package's ledger, the version a member is handed at its start and after a refresh, and each criterion checked at the tip on the menu line. The relay enforcing the allowed actions is slice 2, and the counted budget slice 3.
- #512, failure and recovery: the named classes, inspect before retry, one bounded attempt, and timeout reconciliation.
- Then a workspace checkpoint and a structured context package, if the first two show the need.
The reference’s last box, “save / resume / reconcile”, is already close to write_my_handover + refresh_a_member + log_ledger. The missing piece is the working tree, not the context.
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