Skip to content

Commit fd325b1

Browse files
tiago-peixotoclaudecursoragentkunchenguid
authored
feat(bin): add opt-in config/wait-no-turns so a waiting worker spends no turns (kunchenguid#4859)
* fix(dod): drive no-mistakes with one foreground call, not a background poll The brief told workers to background the drive call and poll `axi status` because one call "routinely outlives what your harness lets a single command run". That advice contradicts the tool it drives: `no-mistakes axi run --help` documents `--wait` with an 8m default, existing precisely "so an agent harness with a 10-minute tool cap gets a structured return instead of an unbounded hang". Following the old text, a worker could never idle - a backgrounded call returns in milliseconds, so it does not wait at all - and each attempt leaked a live timer that later fired as a paid wake. Tell workers to make one foreground call, let it block, and repeat it when it returns on elapsed wait rather than on a gate or outcome. Also drops the generalisation that told workers on any unestablished harness to assume a command cap and use the same shape, which exported the defect to harnesses with no such cap. * fix(bin): let a waiting worker spend no turns until it is answered A worker waiting on a decision, a pipeline gate, CI, or a heavy-test slot kept taking model turns: the brief told it to list its inbox at any natural checkpoint, and six automatic senders nudged secondmates whatever their open decisions. - The ship and scout briefs gain one Waiting section: end the turn after needs-decision or blocked, and hold an external wait inside ONE blocking command bounded by the harness's own command ceiling. The checkpoint clause is deleted. Forbidding the wrong shapes is not enough on its own, so the section also names the blocking foreground `until` loop as the wait a Claude Code worker may use, because that harness can refuse a sleep-then-check command while pointing at backgrounding, which is the one shape a waiting worker must not take. - fm-send --automatic defers (exit 4, nothing written or rung) while the target has an open decision or blocker of its own; every automatic sender passes it and keeps its retry state, and the pending-reply recovery waits the same way. - The two senders that report the result classified it by matching the text of the send's captured output against `deferred:*`. fm-send runs bin/fm-guard.sh as a supervision warning, and that guard prints its worktree-tangle banner whenever the primary checkout is on a feature branch, which is exactly what a CI pull-request checkout is. The banner lands ahead of the `deferred:` line, so the match fell through and a waiting mate was reported as a failed send, with the banner as the reason. Both senders now classify on fm-send's exit status, which is the contract the deferral is actually stated in, and select the `deferred:` line out of the output rather than assuming it came first. The third root cause, a no-mistakes definition of done that backgrounded the drive call and polled axi status, is fixed by this branch's parent commit "drive no-mistakes with one foreground call, not a background poll"; this commit takes that text as is and adds the regression test. Upstream's spawn abort path no longer calls the lease-return helper at all, so the fork's missing-helper guard and its pin-feature test line are moot here and are not ported. The command ceilings each harness enforces, and the probes behind the named Claude Code wait, are recorded in docs/verification/runtime-backends.md. * no-mistakes(review): Exempt captain holds, quiet deferred reconcile, clarify worker pauses * no-mistakes(document): Document deferred automatic nudges, rereads, and reply recovery * no-mistakes(document): Ring unlanded fire-and-forget steers exactly once more * no-mistakes(ci): The failing check, "PR must be raised via no-mistakes", reads the pipeline's attestation record, which says document=skipped. No file in the repository can change that record, so I did not touch the check or the PR body. As you said, the no-mistakes rerun after this run finishes will re-execute the document step and record document=completed. The one change is the documentation sentence you ordered. It adds a line to docs/remote-secondmates.md, right after the line saying the remote host runs no re-ring ladder of its own: "A fire-and-forget record, such as a reconcile ask, gets its single retry ring only on the local plane: the remote steer leg owes no re-ring, so a swallowed remote doorbell for one waits for the next ring into that inbox, and a remote-side retry is known follow-up scope." No behavior changed. Checks: tests/fm-documentation-audiences.test.sh passes (4/4) and bin/fm-lint.sh is clean. The change is left uncommitted in the working tree for the pipeline to pick up * no-mistakes(review): Hold automatic wakes until a mate's own decision closes * no-mistakes(document): Document watcher delivery of deferred remote re-read nudges * no-mistakes(review): Merge duplicate elapsed-wait reattach instructions in DOD * no-mistakes(test): Resolve merged default decision in remote-reply recovery fixture * no-mistakes(test): Source classify lib so config-push retry-deferred honors open decisions * no-mistakes(ci): Fixed a flaky test that also fails on main. Neither this PR's bin/fm-brief.sh nor its bin/fm-dod-lib.sh change is involved: bin/fm-dispatch-resolve.sh sources neither file. Another branch (fm-attended-cutover-smoothing-s1, run 36343879084) failed the same shard 8 check the same way, on a different case ("a rule-criterion match prints one diagnostic line, got 2"). Root cause: `fm_quota_single_provider_for_harness` in bin/fm-quota-axi-lib.sh returned from its `while read` loop as soon as it found a match. That closed the pipe while `fm_quota_single_provider_table`'s `printf` was sometimes still writing. GitHub Actions runners ignore SIGPIPE, so bash printed `fm-quota-axi-lib.sh: line 138: printf: write error: Broken pipe` to the resolver's stderr. That is the extra line. I reproduced it locally by running the test with SIGPIPE ignored: 2 of 20 runs failed, one with the resolver's diagnostic line plus two broken-pipe lines. Invariant: looking up a harness in the provider table must never make the table writer fail. The only reader of that table is this function, and all of the resolver's lookups (line 208 without stderr redirected, line 222 with it) go through it. So the fix is in that one place: read the whole table, then print the match. The same file now shows it reads the full table first, like `fm_control_harness_supported` does. Return values and output are unchanged. Verification: with SIGPIPE ignored, tests/fm-dispatch-resolve.test.sh failed 0 of 30 runs after the fix (2 of 20 before). tests/fm-dispatch-resolve.test.sh, tests/fm-brief.test.sh, tests/fm-send-inbox.test.sh, tests/fm-quota-choose.test.sh and tests/fm-quota-array-dispatch-live-e2e.test.sh all pass, and shellcheck is clean. tests/fm-procevent-quota.test.sh fails locally with or without the change ("process-event state root is not a private directory"), so that failure comes from the local environment, not from this fix. No new test was added: the existing one-diagnostic-line assertions already catch this whenever SIGPIPE is ignored, as it is in CI * Revert "no-mistakes(ci): Fixed a flaky test that also fails on main. Neither this PR's bin/fm-brief.sh nor its bin/fm-dod-lib.sh change is involved: bin/fm-dispatch-resolve.sh sources neither file. Another branch (fm-attended-cutover-smoothing-s1, run 36343879084) failed the same shard 8 check the same way, on a different case ("a rule-criterion match prints one diagnostic line, got 2"). Root cause: `fm_quota_single_provider_for_harness` in bin/fm-quota-axi-lib.sh returned from its `while read` loop as soon as it found a match. That closed the pipe while `fm_quota_single_provider_table`'s `printf` was sometimes still writing. GitHub Actions runners ignore SIGPIPE, so bash printed `fm-quota-axi-lib.sh: line 138: printf: write error: Broken pipe` to the resolver's stderr. That is the extra line. I reproduced it locally by running the test with SIGPIPE ignored: 2 of 20 runs failed, one with the resolver's diagnostic line plus two broken-pipe lines. Invariant: looking up a harness in the provider table must never make the table writer fail. The only reader of that table is this function, and all of the resolver's lookups (line 208 without stderr redirected, line 222 with it) go through it. So the fix is in that one place: read the whole table, then print the match. The same file now shows it reads the full table first, like `fm_control_harness_supported` does. Return values and output are unchanged. Verification: with SIGPIPE ignored, tests/fm-dispatch-resolve.test.sh failed 0 of 30 runs after the fix (2 of 20 before). tests/fm-dispatch-resolve.test.sh, tests/fm-brief.test.sh, tests/fm-send-inbox.test.sh, tests/fm-quota-choose.test.sh and tests/fm-quota-array-dispatch-live-e2e.test.sh all pass, and shellcheck is clean. tests/fm-procevent-quota.test.sh fails locally with or without the change ("process-event state root is not a private directory"), so that failure comes from the local environment, not from this fix. No new test was added: the existing one-diagnostic-line assertions already catch this whenever SIGPIPE is ignored, as it is in CI" This reverts commit c719928. * no-mistakes(review): Retry deferred local instruction nudges via the watcher * no-mistakes(review): Document watcher retry for deferred local instruction nudges * no-mistakes(ci): I fixed both review findings you selected (ci-1 and ci-3). I did not touch the deferral check in bin/fm-send.sh. ci-1 (bin/fm-config-push.sh, retry_deferred_rereads) - Rule that must hold: a deferred reread stays flagged until it is actually delivered. - Before the fix, the flag was removed before any of the steps that can skip a mate: the remote lock-path lookup, validate_secondmate_home, the local lock-path lookup, and the lock acquire. A skip at any of those dropped the flag, so the watcher lost track of the reread. - Now the flag is removed in one place only, when the send succeeds (rc 0). A skipped home, a busy lock, a deferred send (rc 4) or a failed send all leave it in place. The re-mark calls on a busy lock and on rc 4 were no longer needed, so I removed them. I updated the comment above the function to match. - Side effect: a send that keeps failing now stays flagged, so the watcher retries it on every poll and logs each failure. That follows your "don't clear until delivered" rule, but it replaces the old behaviour of leaving a failed send to the next config push or session start. - New test in tests/fm-secondmate-sync.test.sh: T8j "a deferred flag survives a skipped invalid home and is retried once it validates". It takes the home's marker away to make validation fail, checks that nothing is sent and the flag stays, then puts the marker back and checks that the nudge is delivered and both the flag and the retry marker are cleared. It fails on the old code and passes now. ci-3 (bin/fm-secondmate-restart.sh) - Rule that must hold: no automatic send wakes a mate that is waiting on its own open decision. - The two automatic sends in this script are the fallback reread nudge (fall_back_to_nudge) and the persist request. Both now pass --automatic. If a persist request is deferred, its correlation is discarded and the mate goes to the fallback nudge, which is also deferred, so the mate is reported as unreached. - New test in tests/fm-secondmate-restart.test.sh: T3b. It gives a mate an open needs-decision and runs a restart. It checks that both sends report as deferred, the mate's doorbell is never rung, its inbox gets no message, nothing is stopped, and the mate is reported as unreached with exit status 3. It fails on the old code and passes now. - The test marks the watcher as alive first. Without that, the watcher-down warning is printed first and becomes the reported reason instead of the deferral message. Verification - tests/fm-secondmate-sync.test.sh passes. - tests/fm-secondmate-restart.test.sh passes. - tests/fm-secondmate-harness.test.sh (the other test that exercises --retry-deferred) passes. - The fm-send-inbox test that covers automatic deferral passes. I only looked at the last lines of that run, not the whole file. - `shellcheck -x` on the four changed files is clean * Pin autoarm supervision model in secondmate restart T3b The fresh watcher beat the test writes proves a live watcher only under the autoarm model; on CI hosts with no detected harness the persistent model demands a lock-holding watcher, so the watcher-down banner became the reported reason and the deferral assertion failed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Keep deferred secondmate nudges retryable under the inheritance lock. A bootstrap instruction nudge could write its deferral flag outside the lock the watcher retry holds, so a concurrent retry could delete a flag that had just been set. A restart fallback that is deferred now records the same marker and flag, so the watcher delivers it once the decision closes. * no-mistakes(document): Document watcher retry of deferred restart re-read nudges * Send secondmate reread and restart nudges immediately again. Deferring those nudges let a later config push drop an incomplete transfer once the decision closed. They now send as they do on main. * Make the no-turn wait opt-in behind config/wait-no-turns. Homes that do not create the file keep the previous briefs, drive text, and sends. * no-mistakes(document): Document wait-no-turns inbox wording change in configuration * no-mistakes(review): Keep checkpoint inbox check; forbid only polling while waiting * no-mistakes(ci): Fixed ci-2 (Greptile: a concurrent retry marker gets lost). The rule that was broken: the watcher may remove only the `.retry-ring` mark for the record it just processed. A newer mark written in the meantime is owed its own retry. `fm_task_inbox_clear_retry` is the one shared function that removes the mark, and I fixed it there. In `bin/fm-task-inbox-lib.sh` it now takes the record path. It compares the mark's content with that record's name and removes the mark only when they match. When the mark names a different record it returns success and leaves the mark alone. It still fails only when the processed record's own mark can't be removed. Both callers in `bin/fm-watch.sh` now pass `"$rec"`: the dead or missing pane path and the path after a retry ring. So the fix holds at both removal sites. Tests, in `tests/fm-task-inbox.test.sh`: - I added an optional `FM_RING_MARKS_RETRY` hook to the fake tmux. It writes a newer record's mark while the doorbell is being typed, which reproduces the race deterministically. - I added `test_watcher_retry_keeps_a_newer_mark`. The owed retry rings once, the newer mark survives, and a later check rings the newer record once and then clears its mark. The test fails without the fix ("the spent retry removed a newer record's mark written during its ring") and passes with it. - I updated the direct `clear_retry` call in the existing unit test to pass the record. Results: `tests/fm-task-inbox.test.sh` passes in full and `tests/fm-send-inbox.test.sh` passes 15/15. Shellcheck reports only SC1091 "not following sourced file" notices. As instructed, I didn't change the brief inbox wording * no-mistakes(document): Fix stale wait-no-turns inbox wording in inbox lib comment --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: Kun Chen <kunchenguid@users.noreply.github.com>
1 parent 23e5584 commit fd325b1

16 files changed

Lines changed: 573 additions & 20 deletions

‎.agents/skills/operational-home-layout/SKILL.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ config/trace-context optional presence flag enabling default-off native W3C tra
3939
config/lavish-axi-host optional one-line per-machine Lavish server address; LOCAL, gitignored, inherited by secondmate homes, and exported into every worker launch; see docs/configuration.md "Lavish server address" for opening versus polling
4040
config/brief-include.md optional standing worker instructions appended verbatim as the last section of every ship and scout scaffold; LOCAL, gitignored, and not inherited; keep its text out of `## Firstmate spec`; see docs/configuration.md "Home brief include"
4141
config/fleet-ledger optional presence flag opting this home in to the default-off fleet activity ledger state/fleet-ledger.jsonl that outside tools can follow; LOCAL, gitignored, and not inherited; see docs/fleet-ledger.md
42+
config/wait-no-turns optional presence flag opting this home into default-off waiting-worker behavior (brief waiting section, foreground pipeline drive, pending-reply hold, one fire-and-forget retry ring); LOCAL, gitignored, and not inherited; see docs/configuration.md "Waiting worker spends no turns"
4243
config/turnend-churn-absorb optional presence flag opting this home into the default-off absorb of bare turn-end wakes on pane churn; LOCAL, gitignored, and not inherited; see docs/configuration.md "Turn-end pane-churn absorb"
4344
config/wedge-defer-parked-gate optional presence flag opting this home into the default-off deferral of a wedge escalation for a lane parked at a validation gate awaiting the supervisor's own still-open decision; LOCAL, gitignored, and not inherited; see docs/configuration.md "Parked-gate wait deferral"
4445
config/cmux-socket-password optional cmux control-socket password; LOCAL, gitignored; read fresh on every cmux CLI call and passed through without ever overriding an operator's own ambient CMUX_SOCKET_PASSWORD when absent (docs/cmux-backend.md "Setup")

‎bin/fm-brief.sh‎

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -350,16 +350,46 @@ INBOX_DIR=$(shell_quote "$STATE/$ID.inbox")
350350
# scaffold kind. The record format, doorbell line, and re-ring ladder are
351351
# owned by bin/fm-task-inbox-lib.sh. The doorbell names the inbox as
352352
# "$FM_TASK_INBOX", which bin/fm-spawn.sh exports into every launch; the full
353-
# path here remains the fallback for a worker launched without that export,
354-
# plus the natural-checkpoint habit.
353+
# path here remains the fallback for a worker launched without that export.
354+
# The doorbell itself is self-describing, so this section is reinforcement
355+
# for the natural-checkpoint habit, not the only carrier of the instruction.
356+
# config/wait-no-turns (docs/configuration.md) adds the line that a waiting
357+
# worker does not poll the inbox: checkpoint checks happen during active work,
358+
# so waiting still spends no turns.
355359
IFS= read -r -d '' INBOX_SECTION <<EOF || true
356360
# Firstmate instruction inbox
357361
Firstmate steers you through durable message files in $INBOX_DIR.
358362
When a terminal message says an instruction is waiting there - and at any natural checkpoint when you are unsure - list $INBOX_DIR/*.msg, read and act on each message in numeric order, then acknowledge each handled message by moving it: \`mv $INBOX_DIR/NNN.msg $INBOX_DIR/handled/\`.
359363
The move IS the acknowledgement: without it firstmate rings again and eventually treats you as stuck. An empty or absent inbox needs no action.
360364
EOF
365+
if [ -e "$CONFIG/wait-no-turns" ]; then
366+
INBOX_SECTION+="Do not poll or list the inbox while waiting; a waiting instruction rings."$'\n'
367+
fi
361368
INBOX_SECTION=${INBOX_SECTION%$'\n'}
362369

370+
# How a crewmate or scout waits. Every model turn resends the whole context, so
371+
# a wait must cost no turns: a decision wait ends the turn, and an external
372+
# wait sleeps in one bounded blocking shell command sized to the harness.
373+
# Emitted only when config/wait-no-turns is present.
374+
IFS= read -r -d '' WAIT_SECTION <<'EOF' || true
375+
# Waiting
376+
Every turn you take resends your whole context, so a wait must cost no turns.
377+
After you append `needs-decision:` or `blocked:`, end your turn at once: do not check the inbox, the status file, or anything else, because the answer arrives as a terminal message that starts your next turn.
378+
Wait on anything external - a pipeline gate, PR checks, a heavy-test slot - with ONE blocking shell command that returns when the state changes: `no-mistakes axi run` or `respond` with `--wait`, `gh pr checks <pr> --watch`, or `until <condition>; do sleep 30; done` for anything else.
379+
Never spend turns on `sleep` followed by a status check, and never background a command in order to poll it.
380+
In Claude Code that `until` loop in a single Bash call is the sanctioned foreground wait: when the harness refuses a sleep-then-check command and points you at backgrounding instead, reissue the wait as the loop rather than accepting the background.
381+
Bound that command by what your harness lets one command run: in Pi pass the bash tool a `timeout` of at most 2700 seconds, because Pi sets none by default; in Claude Code pass the Bash tool its maximum `timeout` of 600000 ms, because its default is 2 minutes; in Codex keep waiting on a still-running command with empty `write_stdin` polls of up to 300000 ms; elsewhere pass your shell tool its largest timeout and assume at most 10 minutes.
382+
Give any `--wait` a duration a little under that bound.
383+
When the bound passes with nothing changed, run the same blocking command again, with no status check in between.
384+
The one exception is `respond`: it sent its answer before it began waiting, so reattach with `no-mistakes axi run --wait` instead, and never send the same `respond` again, because it would answer whichever gate parks next without you reading it.
385+
A wait your shell can watch this way needs no `paused:` line, except your own pipeline run, a long foreground command, or your own validation round, which you declare once just before its blocking hold: append `paused:` once just before its first blocking command, then stay in the command, and never append it again as you reissue that command.
386+
EOF
387+
WAIT_SECTION=${WAIT_SECTION%$'\n'}
388+
WAIT_BLOCK=
389+
if [ -e "$CONFIG/wait-no-turns" ]; then
390+
WAIT_BLOCK="$WAIT_SECTION"$'\n\n'
391+
fi
392+
363393
if [ "$KIND" = secondmate ]; then
364394
SECONDMATE_PROJECTS=""
365395
idx=1
@@ -577,7 +607,7 @@ $CREWMATE_PAUSE_INSTRUCTIONS
577607
Firstmate's reply normally writes that closing line at answer time; when a blocker or wait clears WITHOUT a firstmate reply, append \`resolved [at=<epoch>]: {how it cleared}\` yourself (same \`[key=<slug>]\` if you opened it with one) as you resume.
578608
$SHARED_INFRA_RULE
579609
580-
$INBOX_SECTION
610+
$WAIT_BLOCK$INBOX_SECTION
581611
582612
# Definition of done
583613
Write your findings to \`$DATA/$ID/report.md\`.
@@ -655,7 +685,7 @@ $ASK_USER_BLOCK
655685
Firstmate's reply normally writes that closing line at answer time; when a blocker or wait clears WITHOUT a firstmate reply, append \`resolved [at=<epoch>]: {how it cleared}\` yourself (same \`[key=<slug>]\` if you opened it with one) as you resume.
656686
$SHARED_INFRA_RULE
657687
658-
$INBOX_SECTION
688+
$WAIT_BLOCK$INBOX_SECTION
659689
660690
# Project memory
661691
A project's \`AGENTS.md\` or \`CLAUDE.md\` is loaded into every agent session in that project, so edit it only to correct information that is factually wrong - including information your own change made wrong - and never to add knowledge because it is missing.

‎bin/fm-classify-lib.sh‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -922,6 +922,25 @@ EOF
922922
printf '%s\n' "$current"
923923
}
924924

925+
# The subset of status_open_decisions the task raised about its own work: a
926+
# reserved-namespace key is raised by a supervisor library about the task (a
927+
# pending-reply escalation), a `remote-reply-continuity-` key is the parent's
928+
# own blocker about a broken remote reply mirror
929+
# (bin/fm-procevent-remote-reply.sh), and a `captain-hold-` key relays a child
930+
# decision a secondmate escalated to the captain (bin/fm-captain-hold.sh) while
931+
# it keeps working, so the task is not waiting on any of them. Pending-reply
932+
# recovery and a fire-and-forget retry ring consult this set and leave a task
933+
# alone while it is non-empty.
934+
status_own_open_decisions() { # <status-file>
935+
local line prefix
936+
status_open_decisions "$1" | while IFS= read -r line || [ -n "$line" ]; do
937+
for prefix in ${FM_CLASSIFY_RESERVED_KEY_PREFIXES:-$FM_CLASSIFY_RESERVED_KEY_PREFIXES_DEFAULT} remote-reply-continuity- captain-hold-; do
938+
case "$line" in "$prefix"*) continue 2 ;; esac
939+
done
940+
printf '%s\n' "$line"
941+
done
942+
}
943+
925944
# 0 when the fold above still holds at least one decision OPENED by
926945
# `needs-decision` - the status side's own record that a human was asked
927946
# something and has not answered. A `blocked` record is deliberately not this: a

‎bin/fm-dod-lib.sh‎

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -280,12 +280,28 @@ EOF
280280
# Written once; only the two sentences about a green PR depend on the forge,
281281
# because on gerrit the ci step is skipped and there is no PR to report.
282282
fm_nm_driving_block() { # <forge>
283-
local pr_return_line='' pr_reattach_clause=';'
283+
local pr_return_line='' pr_reattach_clause=';' drive_block wait_cfg
284284
if [ "$1" != gerrit ]; then
285285
pr_return_line="Only a drive call's return reports the green PR: \`no-mistakes axi status\` shows progress but never reports \`checks-passed\` while the ci step is still monitoring the PR for merge, so never wait on a status poll for the next gate or outcome.
286286
"
287287
pr_reattach_clause="; once checks are green it returns \`checks-passed\` immediately, and"
288288
fi
289+
# config/wait-no-turns selects the foreground drive. Absent, the text matches
290+
# the backgrounded drive a home had before that flag.
291+
wait_cfg=${CONFIG:-${FM_CONFIG_OVERRIDE:-${FM_HOME:-}/config}}
292+
if [ -e "$wait_cfg/wait-no-turns" ]; then
293+
drive_block="Drive the run with ONE foreground \`no-mistakes axi run\` and let it block.
294+
It bounds its own hold for you: \`--wait\` (default 8m) exists precisely so a harness with a ten-minute command cap gets a structured return instead of being killed mid-hold.
295+
Declare that wait using the brief's status-reporting rule before the foreground drive call.
296+
Never background a wait, and never arm a timer to stand in for one: a backgrounded call returns in milliseconds, so it does not wait at all, and every timer left behind fires later as a paid wake for nothing.
297+
${pr_return_line}Whenever a drive call returns without a gate or an outcome - its own wait elapsed, or it was killed or timed out - that is not a failure: reattach at once by re-running \`no-mistakes axi run\` without flags, and issue the same foreground call again, one at a time, until a gate or outcome comes back${pr_reattach_clause} if it refuses because no run is active, read the finished outcome from \`no-mistakes axi status\`."
298+
else
299+
drive_block="One drive call blocks until the next gate or outcome, which routinely outlives what your harness lets a single command run: Claude Code kills a command at ten minutes maximum, while one fix round is capped around thirty minutes and up to three rounds chain.
300+
So background the drive call instead of sitting in one blocking hold your harness will kill, and read its return when it finishes.
301+
Declare that wait using the brief's status-reporting rule before waiting on the backgrounded drive call.
302+
Where a harness's own command limit is not established, assume it bounds commands and use that same backgrounded shape.
303+
${pr_return_line}Whenever a drive call returns without a gate or an outcome - its own wait elapsed, or it was killed or timed out - reattach at once by re-running \`no-mistakes axi run\` without flags, backgrounded the same way${pr_reattach_clause} if it refuses because no run is active, read the finished outcome from \`no-mistakes axi status\`."
304+
fi
289305
cat <<EOF
290306
You drive no-mistakes by responding to its gates, not by implementing fixes.
291307
Follow the guidance no-mistakes itself provides for the mechanics: it loads when you invoke /no-mistakes, and \`no-mistakes axi run --help\` plus the \`help\` lines in each \`axi\` response are authoritative and version-matched to the installed binary.
@@ -299,11 +315,7 @@ When the captain's intent refers to a report, decision, or PR ("do items 1, 2, 3
299315
This replaces the no-mistakes skill's advice to enrich \`--intent\` with decisions and tradeoffs; that advice does not apply to Firstmate-dispatched work.
300316
Do not hand-edit, commit, or fix findings yourself while a run is active - the pipeline applies every fix.
301317
302-
One drive call blocks until the next gate or outcome, which routinely outlives what your harness lets a single command run: Claude Code kills a command at ten minutes maximum, while one fix round is capped around thirty minutes and up to three rounds chain.
303-
So background the drive call instead of sitting in one blocking hold your harness will kill, and read its return when it finishes.
304-
Declare that wait using the brief's status-reporting rule before waiting on the backgrounded drive call.
305-
Where a harness's own command limit is not established, assume it bounds commands and use that same backgrounded shape.
306-
${pr_return_line}Whenever a drive call returns without a gate or an outcome - its own wait elapsed, or it was killed or timed out - reattach at once by re-running \`no-mistakes axi run\` without flags, backgrounded the same way${pr_reattach_clause} if it refuses because no run is active, read the finished outcome from \`no-mistakes axi status\`.
318+
$drive_block
307319
A killed or timed-out call is never evidence the daemon died: the daemon accepts your response immediately and runs the round in the background, so the call was only ever waiting for a read while the run kept working.
308320
Reattach and keep going rather than reporting the pipeline blocked; rule 7 owns the checks that decide when a pipeline block is real.
309321

‎bin/fm-pending-reply-lib.sh‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@
1111
# Safety property (captain direction 2026-07-22): a secondmate agent may ignore
1212
# the marker and answer only in its visible conversation. The parent must notice
1313
# the missing correlated report without scraping that conversation, send exactly
14-
# one automatic recovery request asking for a repost through the parent channel,
15-
# and escalate once if the recovery turn also completes without a correlated
14+
# one automatic recovery request asking for a repost through the parent channel
15+
# (held back, when config/wait-no-turns is present, while the mate waits on its
16+
# own open decision or blocker), and
17+
# escalate once if the recovery turn also completes without a correlated
1618
# report. Never loop, never repeatedly inject, never silently expire unresolved
1719
# records, and never treat wrong-home or structured-home heuristics as
1820
# acknowledgement. A same-basename restatement-copy of the mate home's
@@ -963,6 +965,11 @@ fm_pending_reply_send_recovery() { # <state-dir> <corr_id>
963965
task_id=$(fm_pending_reply_get "$rec" task_id)
964966
# A remote mate's report may exist and simply not have been mirrored yet.
965967
fm_pending_reply_missing_report_is_evidence "$state" "$task_id" "$completed" || return 1
968+
# config/wait-no-turns: a mate waiting on its own open decision or blocker
969+
# is never poked. The recovery stays unattempted until the answer lands.
970+
if [ -e "${FM_CONFIG_OVERRIDE:-${FM_HOME:-}/config}/wait-no-turns" ]; then
971+
[ -z "$(status_own_open_decisions "$state/$task_id.status")" ] || return 1
972+
fi
966973
status_file=$(fm_pending_reply_get "$rec" parent_status)
967974
parent_home=$(fm_pending_reply_get "$rec" parent_home)
968975
msg=$(fm_pending_reply_recovery_message "$rec")

‎bin/fm-send.sh‎

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@
5151
# watcher re-rings an unacknowledged message while its endpoint remains
5252
# available, escalates after the bounded ladder, and instead routes a positively
5353
# dead or missing endpoint directly to recovery without typing. An explicit
54-
# fire-and-forget record is excluded from that ladder.
54+
# fire-and-forget record is excluded from that ladder; when config/wait-no-turns
55+
# is present and its ring here was skipped or failed, the watcher rings it
56+
# exactly once more.
5557
# bin/fm-task-inbox-lib.sh owns the record format, the doorbell line, and the
5658
# re-ring ladder. The composer pre-check before the ring is ADVISORY only: when
5759
# the composer visibly holds pending text the ring is skipped with a notice and
@@ -1085,9 +1087,22 @@ else
10851087
# bounded re-ring ladder or direct unavailable-endpoint recovery.
10861088
ring_rc=0
10871089
fm_task_inbox_ring "$TARGET_BACKEND" "$T" "$INBOX_RECORD" "$EXPECTED_LABEL" || ring_rc=$?
1090+
ring_retry="the watcher will re-ring"
1091+
if [ -n "$FIRE_AND_FORGET_ID" ] \
1092+
&& [ -e "${FM_CONFIG_OVERRIDE:-$FM_HOME/config}/wait-no-turns" ]; then
1093+
case "$ring_rc" in
1094+
1|2)
1095+
if fm_task_inbox_mark_retry "$STATE" "$INBOX_TASK_ID" "$INBOX_RECORD"; then
1096+
ring_retry="the watcher will ring it once more"
1097+
else
1098+
ring_retry="its one retry ring could not be recorded, so nothing will ring it again"
1099+
fi
1100+
;;
1101+
esac
1102+
fi
10881103
case "$ring_rc" in
1089-
1) echo "fm-send: doorbell skipped (composer visibly holds pending text); the steer is durably recorded at $INBOX_RECORD and the watcher will re-ring" >&2 ;;
1090-
2) echo "fm-send: doorbell did not reach $T; the steer is durably recorded at $INBOX_RECORD and the watcher will re-ring" >&2 ;;
1104+
1) echo "fm-send: doorbell skipped (composer visibly holds pending text); the steer is durably recorded at $INBOX_RECORD and $ring_retry" >&2 ;;
1105+
2) echo "fm-send: doorbell did not reach $T; the steer is durably recorded at $INBOX_RECORD and $ring_retry" >&2 ;;
10911106
3) echo "fm-send: doorbell not typed because the agent in $T has exited; the steer is durably recorded at $INBOX_RECORD for recovery (stuck-crewmate-recovery), and the watcher will not re-ring a dead pane" >&2 ;;
10921107
esac
10931108
exit 0

0 commit comments

Comments
 (0)