Macula Mesh Use Build Macula for… Docs Contact

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

What the loop does not change

Where to start

  1. #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.
  2. #512, failure and recovery: the named classes, inspect before retry, one bounded attempt, and timeout reconciliation.
  3. 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