Skip to content

docs(skills): add remote-secondmate recovery hint for false-negative verdicts - #2456

Merged
kunchenguid merged 2 commits into
mainfrom
fm/fm-dead-remote-mate-recovery-hint-r1
Aug 16, 2026
Merged

kunchenguid merged 2 commits into
mainfrom
fm/fm-dead-remote-mate-recovery-hint-r1

Conversation

@kunchenguid

Copy link
Copy Markdown
Owner

Intent

Add a minimal recovery hint for a seemingly-dead REMOTE second mate, encoding a lesson from a real 2026-08-15 incident: firstmate trusted false-negative liveness/send verdicts (fm-crew-state 'unknown/worktree gone', fm-send 'remote send failed'/'delivery unconfirmed') for a remote secondmate that was actually alive the whole time, and a genuine stuck-agent case was made worse by raw herdr pane close surgery that stranded the endpoint binding. In .agents/skills/stuck-crewmate-recovery/SKILL.md (the recovery playbook), add a short note for the remote-secondmate case capturing exactly two points: (1) pane inspection is the source of truth for a remote second mate - fm-crew-state and fm-send verdicts are unreliable and routinely false-negative for remote mates, do not conclude dead/failed from those alone, confirm against the actual remote pane first; (2) restart only via the official mechanics - bin/fm-spawn.sh --secondmate - never raw herdr pane close/kill surgery, which strands the endpoint binding. Keep it to the minimum needed to convey those two points: no new sections, no verbose prose, matching the existing terse skill style. Also added one cheap one-line pointer in secondmate-provisioning's Recovery section pointing back to this note, without expanding it. This is a firstmate-repo shared/tracked-material change; firstmate-coding-guidelines was already loaded and followed (one-owner rule, inline pointers not duplicated content, size discipline).

What Changed

  • Added a two-point note to stuck-crewmate-recovery's playbook for the REMOTE secondmate case: fm-crew-state's unknown/worktree gone and fm-send's remote send failed/delivery unconfirmed verdicts are unreliable and routinely false-negative, so confirm against the actual remote pane before concluding the mate is dead; and recover a genuinely stuck remote mate only via bin/fm-spawn.sh <id> --secondmate, never raw herdr pane close/kill surgery that strands the endpoint binding.
  • Added a one-line pointer in secondmate-provisioning's recovery guidance referring back to that note as the owner of why the endpoint-dead and send-failed verdicts are themselves unreliable.

Risk Assessment

✅ Low: Documentation-only change adding a terse, accurate recovery note and a one-line cross-reference pointer that fully match the authoritative intent and reference real, verified mechanics.

Testing

This is a natural-language documentation change to two agent-consumed SKILL.md playbooks, so there is no runtime behavior to unit-test and (per the test-quality rule) an instruction is not proven by its source text; I therefore validated via the repo's real doc/link consumer bin/fm-doc-audience-check.sh (passed, all 253 local links resolve and both surfaces remain classified), by confirming every recovery mechanic and verdict the note references actually exists in the codebase (fm-spawn --secondmate, and the fm-crew-state/fm-send false-negative verdicts), and by rendering both changed sections to an HTML page plus a full-page screenshot showing the two required points, terse placement with no new section, and the one-owner back-pointer. All checks passed with no actionable findings.

Evidence: Rendered recovery-hint change in context (HTML)

Source: Rendered recovery-hint change in context (HTML)

<!doctype html><html><head><meta charset=utf-8><title>Remote-secondmate recovery hint - evidence</title>
<style>
body{font:14px/1.5 -apple-system,Segoe UI,Roboto,sans-serif;background:#0d1117;color:#c9d1d9;margin:0;padding:32px;}
h1{font-size:19px;color:#e6edf3} h2{font-size:15px;color:#58a6ff;margin-top:28px;border-bottom:1px solid #21262d;padding-bottom:6px}
.file{font-family:ui-monospace,Menlo,monospace;font-size:12px;color:#8b949e;margin:4px 0 8px}
.code{background:#161b22;border:1px solid #30363d;border-radius:8px;overflow:hidden;font-family:ui-monospace,Menlo,monospace;font-size:12.5px}
.ln{display:flex;white-space:pre-wrap}
.ln .num{width:44px;text-align:right;padding:2px 12px 2px 0;color:#484f58;user-select:none;flex:none;border-right:1px solid #21262d}
.ln .txt{padding:2px 0 2px 14px;flex:1}
.ln.add{background:#12261e} .ln.add .txt{color:#7ee787} .ln.add .num{background:#1a3326;color:#3fb950}
.legend{margin:10px 0 20px;font-size:12px;color:#8b949e}
.chip{display:inline-block;background:#12261e;color:#7ee787;border-radius:4px;padding:1px 8px;margin-right:6px}
.note{color:#8b949e;font-size:12.5px;margin:6px 0 0}
</style></head><body>
<h1>Recovery hint for a seemingly-dead REMOTE second mate</h1>
<div class="legend"><span class="chip">green</span>lines added by this change (rest is surrounding context, unchanged)</div>
<h2>1 &middot; stuck-crewmate-recovery (owner of the note)</h2>
<div class="file">.agents/skills/stuck-crewmate-recovery/SKILL.md</div>
<div class="code"><div class="ln "><span class="num">21</span><span class="txt">## Session-start reconciliation for a dead ordinary direct report</span></div>
<div class="ln "><span class="num">22</span><span class="txt">&nbsp;</span></div>
<div class="ln "><span class="num">23</span><span class="txt">This procedure covers ordinary `kind=ship` and `kind=scout` direct reports.</span></div>
<div class="ln "><span class="num">24</span><span class="txt">Load `secondmate-provisioning` instead for `kind=secondmate` recovery.</span></div>
<div class="ln "><span class="num">25</span><span class="txt">&nbsp;</span></div>
<div class="ln add"><span class="num">26</span><span class="txt">For a REMOTE secondmate, `fm-crew-state`&#x27;s `unknown`/`worktree gone` and `fm-send`&#x27;s `remote send failed`/`delivery unconfirmed` verdicts are unreliable and routinely false-negative; do not conclude the mate is dead or the send failed from those alone, confirm against the actual remote pane first.</span></div>
<div class="ln add"><span class="num">27</span><span class="txt">Recover a genuinely stuck remote mate only through `bin/fm-spawn.sh &lt;id&gt; --secondmate`, never raw herdr pane close/kill surgery, which strands the endpoint binding.</span></div>
<div class="ln "><span class="num">28</span><span class="txt">&nbsp;</span></div>
<div class="ln "><span class="num">29</span><span class="txt">Treat the digest&#x27;s endpoint result as a presence signal, not proof that the task&#x27;s work or validation run is gone.</span></div>
<div class="ln "><span class="num">30</span><span class="txt">Read the targeted current state with `bin/fm-crew-state.sh &lt;id&gt;` before deciding to relaunch.</span></div>
<div class="ln "><span class="num">31</span><span class="txt">A no-mistakes run matched to the crew&#x27;s branch and current code remains authoritative when the endpoint is dead: handle a terminal or parked run through the normal lifecycle, and keep supervising an active run instead of creating a duplicate worker.</span></div></div>
<p class="note">Point (1): pane is source of truth - fm-crew-state / fm-send verdicts are unreliable and routinely false-negative; confirm against the actual remote pane first.<br>
Point (2): recover only via <code>bin/fm-spawn.sh &lt;id&gt; --secondmate</code>, never raw herdr pane close/kill surgery, which strands the endpoint binding.<br>
Placed under the existing "kind=secondmate" pointer - no new section heading, two terse lines matching the one-sentence-per-line style.</p>
<h2>2 &middot; secondmate-provisioning (one-line back-pointer)</h2>
<div class="file">.agents/skills/secondmate-provisioning/SKILL.md &mdash; under "## Recovery"</div>
<div class="code"><div class="ln "><span class="num">211</span><span class="txt">&nbsp;</span></div>
<div class="ln "><span class="num">212</span><span class="txt">Use the recorded `home=` in meta.</span></div>
<div class="ln "><span class="num">213</span><span class="txt">If meta is missing but `data/secondmates.md` still registers the secondmate, respawn from the registry entry and its persistent home.</span></div>
<div class="ln "><span class="num">214</span><span class="txt">For a remote route, the same command probes and relaunches only on the configured host.</span></div>
<div class="ln "><span class="num">215</span><span class="txt">An SSH transport failure or unreadable remote endpoint remains unknown and must be reconciled on that host; never launch a local replacement.</span></div>
<div class="ln add"><span class="num">216</span><span class="txt">`stuck-crewmate-recovery`&#x27;s remote-secondmate note owns why the endpoint-dead and send-failed verdicts that seem to justify this are themselves unreliable.</span></div>
<div class="ln "><span class="num">217</span><span class="txt">Respawn re-resolves the secondmate harness from current config, uses the same guarded pre-launch sync, and re-propagates inherited local material, so recovered secondmates converge inherited config items and shared captain preferences whenever their home validates; tracked-file sync remains guarded separately.</span></div></div>
<p class="note">One inline pointer (line 216) back to the owning note - no duplicated content (one-owner rule).</p>
</body></html>
Evidence: Doc consumer check output
$ bash bin/fm-doc-audience-check.sh
fm-doc-audience-check: ok surfaces=68 local_links=253
EXIT=0

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

✅ **Review** - passed

✅ No issues found.

✅ **Test** - passed

✅ No issues found.

  • bash bin/fm-doc-audience-check.sh — repo's real markdown/doc consumer; passed (surfaces=68, local_links=253 resolved, both changed SKILL surfaces still classified)
  • Verified prescribed recovery mechanics are real: bin/fm-spawn.sh &lt;id&gt; --secondmate is a documented flag (records kind=secondmate)
  • Verified the false-negative verdicts the note cites exist: fm-crew-state emits unknown/worktree gone (torn down?); fm-send emits &lt;backend&gt; send failed/delivery unconfirmed
  • Confirmed placement: note under the kind=secondmate pointer in stuck-crewmate-recovery (lines 26-27), back-pointer under ## Recovery in secondmate-provisioning (line 216)
  • Rendered both changed SKILL sections to an HTML artifact and captured a full-page screenshot as reviewer-visible evidence
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

…tive

fm-crew-state and fm-send routinely misreport a live remote secondmate
as dead; confirm against the pane before relaunching, and relaunch only
through fm-spawn.sh, never raw herdr pane surgery.
@kunchenguid
kunchenguid merged commit 196fb65 into main Aug 16, 2026
13 checks passed
@kunchenguid
kunchenguid deleted the fm/fm-dead-remote-mate-recovery-hint-r1 branch August 16, 2026 05:41
adibirzu added a commit to adibirzu/firstmate that referenced this pull request Aug 16, 2026
…ndoff fixes (#9)

* fix: keep the public promise reachable when work is routed to a second mate (kunchenguid#2457)

The lightweight Relay follow-up link lives in the answering home's own
state/<task-id>.meta, so it can only bind work that home owns. When a
Relay-linked request is routed to a second mate, the task record lives in the
second mate's home, fm-x-link.sh failed with a bare "no such task ...meta", and
nothing else picked the promise up: only the soft acknowledgement was ever
posted. The typed promised-final path already supports --work-home
secondmate:<id>; the playbook simply never chose it.

- fmx-respond now states the routing rule crisply: a task in this home takes the
  lightweight link, and second-mate-routed work takes a promised-final
  commitment bound to that home, registered up front with the brief command
  carried into the routed worker's instructions.
- fm-x-link.sh refuses a task with no local record by naming the registered
  second mate whose home actually holds it and printing the promised-final
  registration command, with the exact --work-home when the match is
  unambiguous. A home with no registered second mates keeps the plain error.
- fm-backlog-handoff.sh reports, after a successful move, any moved key that
  still owes a public reply bound to main/<key>, since that binding no longer
  names the home owning the work. The move itself is never blocked.

Docs and the secondmate handoff prose follow the same rule. Tests cover the
refusal, its scoping, the unchanged local-link path, and both handoff outcomes
at the script boundary.

* docs(skills): add remote-secondmate recovery hint for false-negative verdicts (kunchenguid#2456)

* fix(skills): hint that remote secondmate liveness verdicts false-negative

fm-crew-state and fm-send routinely misreport a live remote secondmate
as dead; confirm against the pane before relaunching, and relaunch only
through fm-spawn.sh, never raw herdr pane surgery.

* no-mistakes: apply CI fixes

* fix(calm): keep Pi's export confirmation visible (kunchenguid#2461)

Pi 0.83.0 added a status line to every tool-expansion change, and Pi
updates the previous status line in place when two status messages
arrive back to back. Calm's post-export redraw cycled tool expansion on
the macrotask right after Pi printed "Session exported to: <path>", so
both expansion status lines coalesced over that confirmation and the
captain was left with no record of where their export landed.

Calm now repaints only the tool rows it presents, by invalidating each
row through the render context Pi hands its render slots, and requests
the surrounding redraw through setStatus. Neither appends to the
transcript. The repaint is still needed because Pi can re-render a row
asynchronously - the built-in edit row invalidates itself once its diff
is ready - and that re-render can land inside the window where /export
forces stock rendering.

The real-terminal /export case now asserts the confirmation is still on
screen after the redraw has settled, and that the redraw restored every
Calm-hidden row, instead of only racing the moment the confirmation
first appeared.

---------

Co-authored-by: Kun Chen <[email protected]>
joliverMI added a commit to joliverMI/firstmate that referenced this pull request Aug 16, 2026
…ng state (#2)

* fix(ci): fail hung Herdr behavior runs in 20 minutes (kunchenguid#2413)

A wedged family-run step was occupying the runner until the 75-minute
job cap; bound that step so cleanup and timing artifacts still upload.

* fix: keep the public promise reachable when work is routed to a second mate (kunchenguid#2457)

The lightweight Relay follow-up link lives in the answering home's own
state/<task-id>.meta, so it can only bind work that home owns. When a
Relay-linked request is routed to a second mate, the task record lives in the
second mate's home, fm-x-link.sh failed with a bare "no such task ...meta", and
nothing else picked the promise up: only the soft acknowledgement was ever
posted. The typed promised-final path already supports --work-home
secondmate:<id>; the playbook simply never chose it.

- fmx-respond now states the routing rule crisply: a task in this home takes the
  lightweight link, and second-mate-routed work takes a promised-final
  commitment bound to that home, registered up front with the brief command
  carried into the routed worker's instructions.
- fm-x-link.sh refuses a task with no local record by naming the registered
  second mate whose home actually holds it and printing the promised-final
  registration command, with the exact --work-home when the match is
  unambiguous. A home with no registered second mates keeps the plain error.
- fm-backlog-handoff.sh reports, after a successful move, any moved key that
  still owes a public reply bound to main/<key>, since that binding no longer
  names the home owning the work. The move itself is never blocked.

Docs and the secondmate handoff prose follow the same rule. Tests cover the
refusal, its scoping, the unchanged local-link path, and both handoff outcomes
at the script boundary.

* docs(skills): add remote-secondmate recovery hint for false-negative verdicts (kunchenguid#2456)

* fix(skills): hint that remote secondmate liveness verdicts false-negative

fm-crew-state and fm-send routinely misreport a live remote secondmate
as dead; confirm against the pane before relaunching, and relaunch only
through fm-spawn.sh, never raw herdr pane surgery.

* no-mistakes: apply CI fixes

* fix(calm): keep Pi's export confirmation visible (kunchenguid#2461)

Pi 0.83.0 added a status line to every tool-expansion change, and Pi
updates the previous status line in place when two status messages
arrive back to back. Calm's post-export redraw cycled tool expansion on
the macrotask right after Pi printed "Session exported to: <path>", so
both expansion status lines coalesced over that confirmation and the
captain was left with no record of where their export landed.

Calm now repaints only the tool rows it presents, by invalidating each
row through the render context Pi hands its render slots, and requests
the surrounding redraw through setStatus. Neither appends to the
transcript. The repaint is still needed because Pi can re-render a row
asynchronously - the built-in edit row invalidates itself once its diff
is ready - and that re-render can land inside the window where /export
forces stock rendering.

The real-terminal /export case now asserts the confirmation is still on
screen after the redraw has settled, and that the redraw restored every
Calm-hidden row, instead of only racing the moment the confirmation
first appeared.

* feat(bin): render the captain's four-section status board from existing state

fm-status-board.sh prints one HTML page (Needs you to continue, In
progress, Waiting, Recently completed) rendered entirely from
fm-bearings-snapshot.sh's already-correct cross-home classification and
fm-fleet-snapshot.sh's untruncated per-item detail, with no second store
for agents to keep in sync.

---------

Co-authored-by: Kun Chen <[email protected]>
Co-authored-by: joliverMI <[email protected]>
joliverMI added a commit to joliverMI/firstmate that referenced this pull request Aug 16, 2026
* fix(ci): fail hung Herdr behavior runs in 20 minutes (kunchenguid#2413)

A wedged family-run step was occupying the runner until the 75-minute
job cap; bound that step so cleanup and timing artifacts still upload.

* fix: keep the public promise reachable when work is routed to a second mate (kunchenguid#2457)

The lightweight Relay follow-up link lives in the answering home's own
state/<task-id>.meta, so it can only bind work that home owns. When a
Relay-linked request is routed to a second mate, the task record lives in the
second mate's home, fm-x-link.sh failed with a bare "no such task ...meta", and
nothing else picked the promise up: only the soft acknowledgement was ever
posted. The typed promised-final path already supports --work-home
secondmate:<id>; the playbook simply never chose it.

- fmx-respond now states the routing rule crisply: a task in this home takes the
  lightweight link, and second-mate-routed work takes a promised-final
  commitment bound to that home, registered up front with the brief command
  carried into the routed worker's instructions.
- fm-x-link.sh refuses a task with no local record by naming the registered
  second mate whose home actually holds it and printing the promised-final
  registration command, with the exact --work-home when the match is
  unambiguous. A home with no registered second mates keeps the plain error.
- fm-backlog-handoff.sh reports, after a successful move, any moved key that
  still owes a public reply bound to main/<key>, since that binding no longer
  names the home owning the work. The move itself is never blocked.

Docs and the secondmate handoff prose follow the same rule. Tests cover the
refusal, its scoping, the unchanged local-link path, and both handoff outcomes
at the script boundary.

* docs(skills): add remote-secondmate recovery hint for false-negative verdicts (kunchenguid#2456)

* fix(skills): hint that remote secondmate liveness verdicts false-negative

fm-crew-state and fm-send routinely misreport a live remote secondmate
as dead; confirm against the pane before relaunching, and relaunch only
through fm-spawn.sh, never raw herdr pane surgery.

* no-mistakes: apply CI fixes

* fix(calm): keep Pi's export confirmation visible (kunchenguid#2461)

Pi 0.83.0 added a status line to every tool-expansion change, and Pi
updates the previous status line in place when two status messages
arrive back to back. Calm's post-export redraw cycled tool expansion on
the macrotask right after Pi printed "Session exported to: <path>", so
both expansion status lines coalesced over that confirmation and the
captain was left with no record of where their export landed.

Calm now repaints only the tool rows it presents, by invalidating each
row through the render context Pi hands its render slots, and requests
the surrounding redraw through setStatus. Neither appends to the
transcript. The repaint is still needed because Pi can re-render a row
asynchronously - the built-in edit row invalidates itself once its diff
is ready - and that re-render can land inside the window where /export
forces stock rendering.

The real-terminal /export case now asserts the confirmation is still on
screen after the redraw has settled, and that the redraw restored every
Calm-hidden row, instead of only racing the moment the confirmation
first appeared.

* fix(procevent): deliver captured results at most once

A Lavish-captured answer reached a secondmate five times because
forwarding it ran fm-send.sh and only afterward, manually, remembered to
call `handled` - so every re-announcement of the still-unacknowledged
capture (a restart, a compaction, a re-read wake) repeated the forward.
The retry loop was ours, not lavish-axi's: fm-procevent.sh already proves
capture is exactly-once, but nothing paired a downstream effect with its
acknowledgement atomically.

Add `fm-procevent.sh deliver <source-id> <sequence> -- <command>...`,
which checks handled status, runs the command, and marks the generation
handled as one call under the source lock, so a repeated delivery attempt
against an already-delivered generation runs the command zero times and a
failed command stays eligible for retry instead of being dropped. Point
the process-event-sources skill and the runner's operating contract at it
for exactly this class of forward.

Five delivery attempts against one captured generation now run the
downstream command once instead of five times - the read-and-discard
cost of the other four is eliminated structurally. The historical
incident's own token cost was not measured at the time and is not
reconstructable after the fact.

---------

Co-authored-by: Kun Chen <[email protected]>
Co-authored-by: joliverMI <[email protected]>
zeeshaanahmad added a commit to zeeshaanahmad/firstmate that referenced this pull request Aug 17, 2026