Skip to content

fix: keep persistent secondmates out of landed-work cleanup - #5696

Merged
kunchenguid merged 3 commits into
mainfrom
fm/fm-return-brief-secondmates-r1
Sep 25, 2026
Merged

kunchenguid merged 3 commits into
mainfrom
fm/fm-return-brief-secondmates-r1

Conversation

@kunchenguid

@kunchenguid kunchenguid commented Sep 25, 2026 •

Copy link
Copy Markdown
Owner

Intent

yup

Context: that approved fixing a defect seen in the main home's first real away window on the supervision host (Claude primary, config/supervision-host on, 2026-09-25 07:51Z-16:41Z). The return brief from bin/fm-afk-return.sh listed persistent second mates as finished work: its "Landed, cleanup due" section listed axi-a1, eddies-wallet-e1, mini-default, and sshhip-h7 (kind=secondmate direct reports) with a merged PR each and printed "close it with bin/fm-teardown.sh once catch-up clears". A second mate is persistent and must never be offered for teardown; this likely affects the daemon path too. Fix it so secondmates never appear there, and check whatever else feeds that list. Reproduce end to end in an isolated lab home first, make the minimal root-cause fix, and turn the reproduction into a behavioral regression test.

What Changed

  • Exclude secondmate records from the return brief’s landed-work cleanup list and refuse new PR merge watches on them.
  • Retire legacy merged polls on secondmate records without emitting a merge outcome or wake. Add regression coverage for the return brief, watch refusal, and silent retirement.

Risk Assessment

✅ Low: The change blocks secondmates from the return-brief cleanup list, prevents new PR watches on their records, and silently retires existing merged polls, with behavioral regression coverage.

Testing

The return-brief regression suite ran. The PR-check security suite passed its simulated secondmate watcher case but timed out later. The return and PR-check commands were also driven in disposable lab homes, with CLI output saved. No visual surface was identified.

  • Live validation: ⚠️ inconclusive - 2 of 3 scenarios driven live against the product
Scenario Result Live Evidence
A returning captain sees merged delivery work, but never a secondmate, in cleanup-due recommendations ✅ pass live return-brief-live.txt shows the delivery teardown recommendation and no secondmate recommendation.
A relayed child PR cannot arm a merge watch on its persistent secondmate record ✅ pass live secondmate-pr-check-live.txt records exit 1 and the refusal; no check or poll artifact was created.
The watcher retires an existing merged secondmate poll without a merge notification, wake, or lifecycle change ⏸️ untested no The prior payload recorded only a test using a simulated merged forge response, not a live watcher run against a merged PR. A real merged child PR, an existing secondmate poll, and authority to run th…
Evidence: Live return brief

Source: Live return brief

●━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
●  WATCHER DOWN - SUPERVISION IS OFF
●  2 task(s) in flight, but no watcher has a fresh beacon (last beat: never, grace 300s).
●  Trust the emitted supervision protocol for this harness; do not use shell & for watcher repair.
●  This is a supervision warning only; the guarded operation WILL still run.
●  repair a missing or failed watcher cycle with the Pi tool fm_watch_arm_pi, or restart Pi with -e ~/.no-mistakes/worktrees/52b07e9083e7/01M3CTV3KXCY4T6XMXNVGNQSQA/.pi/extensions/fm-primary-turnend-guard.ts -e ~/.no-mistakes/worktrees/52b07e9083e7/01M3CTV3KXCY4T6XMXNVGNQSQA/.pi/extensions/fm-primary-pi-watch.ts if the extensions are not loaded.
●━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
=== Return brief ===
Supervisor health:
  - GAP: the watcher beat was 999999s old at return (grace 300s)
Your instructions:
  (no away-posture record for this window; legacy away flag only)
Waiting on you:
  (nothing)
Tried and failed, or could not be fixed:
  (nothing)
Landed, cleanup due:
  - delivery: https://github.com/example/landed/pull/7 is merged and the worker is still up; close it with bin/fm-teardown.sh delivery once catch-up clears
Handled while away:
  0 outcome(s) handled by the away session (0 routine, 0 escalated above)
  (no routine outcomes recorded in the store for this window)
Cost: 0 supervision outcome(s) recorded (0 routine, 0 captain); 2 task(s) live at return.
catch-up health: GAP: the watcher beat was 999999s old at return (grace 300s)
catch-up wake: STATUS OUTCOME BACKSTOP (newest captain-facing task event has no covering branch outcome):
catch-up wake: axi-mate done [at=1]: merged child
catch-up wake: delivery done [at=1]: merged
fm-afk-return: catch-up clear; ordinary captain work may proceed
Evidence: Live secondmate PR-check refusal

Source: Live secondmate PR-check refusal

error: axi-mate is a secondmate, not a delivery lane - https://github.com/example/child/pull/7 was reported on its status channel but belongs to a task in the mate's own home, which arms its own merge watch
exit=1
- Outcome: ⚠️ 1 warning across 1 run (6m56s)

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

✅ **Review** - passed

✅ No issues found.

⚠️ **Test** - 1 warning
  • ⚠️ live validation verdict: inconclusive (2 of 3 scenarios were driven live against the product); untested: The watcher retires an existing merged secondmate poll without a merge notification, wake, or lifecycle change
  • Live validation: ⚠️ inconclusive - 2 of 3 scenarios driven live against the product
Scenario Result Live Evidence
A returning captain sees merged delivery work, but never a secondmate, in cleanup-due recommendations ✅ pass live return-brief-live.txt shows the delivery teardown recommendation and no secondmate recommendation.
A relayed child PR cannot arm a merge watch on its persistent secondmate record ✅ pass live secondmate-pr-check-live.txt records exit 1 and the refusal; no check or poll artifact was created.
The watcher retires an existing merged secondmate poll without a merge notification, wake, or lifecycle change ⏸️ untested no The prior payload recorded only a test using a simulated merged forge response, not a live watcher run against a merged PR. A real merged child PR, an existing secondmate poll, and authority to run th…
  • tests/fm-afk-return.test.sh && tests/fm-pr-check-security.test.sh (second suite timed out after the simulated secondmate watcher case passed)
  • FM_HOME="$LAB" bin/fm-afk-return.sh check with merged delivery and secondmate records in a disposable lab home
  • FM_HOME="$LAB" bin/fm-pr-check.sh axi-mate https://github.com/example/child/pull/7 in a disposable lab home; checked exit status and absence of poll artifacts
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

The return brief's "Landed, cleanup due" scan listed every state/*.meta
record carrying a pr= and a merge-notified marker without regard to kind, so
a secondmate record holding a relayed child's merged PR put the mate itself
up for "bin/fm-teardown.sh <mate>" cleanup. A secondmate is a persistent
worker, never landed work.

- bin/fm-afk-return.sh: skip kind=secondmate in the landed-cleanup scan.
- bin/fm-pr-check.sh: refuse to record pr= or arm a merge watch on a
  kind=secondmate record before any side effect; a PR reported on its routed
  status channel belongs to a task in the mate's own home, which arms its
  own watch.
- bin/fm-watch.sh: a merged result from a poll already armed on a secondmate
  retires the poll silently - no merge outcome, marker, or wake.
…e three-second wait was sensitive to runner load. Increased the wait for both state- and home-deletion cases without changing watcher behavior. The full fm-watch-arm suite passed locally; syntax and diff checks passed
@kunchenguid
kunchenguid merged commit 0154324 into main Sep 25, 2026
19 checks passed
@kunchenguid
kunchenguid deleted the fm/fm-return-brief-secondmates-r1 branch September 25, 2026 22:01
mehulbhagwani pushed a commit to mehulbhagwani/firstmate that referenced this pull request Sep 26, 2026
…uid#5696)

* fix(bin): never offer a persistent secondmate for teardown

The return brief's "Landed, cleanup due" scan listed every state/*.meta
record carrying a pr= and a merge-notified marker without regard to kind, so
a secondmate record holding a relayed child's merged PR put the mate itself
up for "bin/fm-teardown.sh <mate>" cleanup. A secondmate is a persistent
worker, never landed work.

- bin/fm-afk-return.sh: skip kind=secondmate in the landed-cleanup scan.
- bin/fm-pr-check.sh: refuse to record pr= or arm a merge watch on a
  kind=secondmate record before any side effect; a PR reported on its routed
  status channel belongs to a task in the mate's own home, which arms its
  own watch.
- bin/fm-watch.sh: a merged result from a poll already armed on a secondmate
  retires the poll silently - no merge outcome, marker, or wake.

* no-mistakes(document): Document secondmate merge-watch and return-brief exclusions

* no-mistakes(ci): CI failed in an unchanged watcher-shutdown test whose three-second wait was sensitive to runner load. Increased the wait for both state- and home-deletion cases without changing watcher behavior. The full fm-watch-arm suite passed locally; syntax and diff checks passed
kunchenguid added a commit that referenced this pull request Sep 26, 2026
Main has been red since fm-pr-check.sh began refusing to arm a merge poll
on a kind=secondmate record (#5696): the relaunch-ordering case in
tests/fm-remote-secondmate-relaunch.test.sh armed its fixture through that
entry point and could no longer be set up.

The ordering guarantee still matters: a secondmate record armed before the
refusal can legitimately carry a trailing pr=/pr_head= identity block until
the watcher retires it, and fm-remote-secondmate-relaunch.sh must still keep
that block last when republishing harness/model/effort. Seed the fixture the
way such a record was really written - pr= appended last to the meta, then
the poll artifacts published through the same
fm_pr_poll_prepare/fm_pr_poll_publish_prepared pair fm-pr-check.sh uses, a
pattern tests/fm-pr-check-security.test.sh already follows - and drop the
now-unused fake gh fixture. The #5696 refusal itself stays pinned by the
security suite's secondmate-record case.
mehulbhagwani pushed a commit to mehulbhagwani/firstmate that referenced this pull request Sep 26, 2026
…uid#5696)

* fix(bin): never offer a persistent secondmate for teardown

The return brief's "Landed, cleanup due" scan listed every state/*.meta
record carrying a pr= and a merge-notified marker without regard to kind, so
a secondmate record holding a relayed child's merged PR put the mate itself
up for "bin/fm-teardown.sh <mate>" cleanup. A secondmate is a persistent
worker, never landed work.

- bin/fm-afk-return.sh: skip kind=secondmate in the landed-cleanup scan.
- bin/fm-pr-check.sh: refuse to record pr= or arm a merge watch on a
  kind=secondmate record before any side effect; a PR reported on its routed
  status channel belongs to a task in the mate's own home, which arms its
  own watch.
- bin/fm-watch.sh: a merged result from a poll already armed on a secondmate
  retires the poll silently - no merge outcome, marker, or wake.

* no-mistakes(document): Document secondmate merge-watch and return-brief exclusions

* no-mistakes(ci): CI failed in an unchanged watcher-shutdown test whose three-second wait was sensitive to runner load. Increased the wait for both state- and home-deletion cases without changing watcher behavior. The full fm-watch-arm suite passed locally; syntax and diff checks passed
kunchenguid added a commit that referenced this pull request Sep 26, 2026
)

Main has been red since fm-pr-check.sh began refusing to arm a merge poll
on a kind=secondmate record (#5696): the relaunch-ordering case in
tests/fm-remote-secondmate-relaunch.test.sh armed its fixture through that
entry point and could no longer be set up.

The ordering guarantee still matters: a secondmate record armed before the
refusal can legitimately carry a trailing pr=/pr_head= identity block until
the watcher retires it, and fm-remote-secondmate-relaunch.sh must still keep
that block last when republishing harness/model/effort. Seed the fixture the
way such a record was really written - pr= appended last to the meta, then
the poll artifacts published through the same
fm_pr_poll_prepare/fm_pr_poll_publish_prepared pair fm-pr-check.sh uses, a
pattern tests/fm-pr-check-security.test.sh already follows - and drop the
now-unused fake gh fixture. The #5696 refusal itself stays pinned by the
security suite's secondmate-record case.
ashkonmousavi added a commit to ashkonmousavi/firstmate that referenced this pull request Sep 26, 2026