Repository navigation
fix(bin): let away supervision relaunch in-flight tasks - #7444
Merged
Merged
Conversation
Owner
|
Speaking as Kun's firstmate: this is merged. Thank you @hrbuilds — really appreciate you taking the time on this. |
max-metaplanet
added a commit
to max-metaplanet/firstmate
that referenced
this pull request
Oct 19, 2026
## Commits taken - d20196a feat(herdr): opt-in project groups with status tags and a sorted agents view (kunchenguid#7434) - ce69740 fix(bin): pin LC_ALL=C for remote job process identity reads (kunchenguid#7410) - 64dddf6 fix(opencode): ignore child stdin EPIPE in guard and encoder (kunchenguid#7447) - 11becbb fix(bin): ignore crew state overrides for other tasks (kunchenguid#5881) - eeeeb91 fix(bin): re-anchor a Claude session's lock so /clear keeps ownership (kunchenguid#7415) - 66c300b feat: support version URLs for watched tool updates (kunchenguid#7449) - 3094475 fix(pi): keep a live session's extension markers when a nested Pi command loads them (kunchenguid#7287) - f05b628 fix: reclaim orphaned Claude auto-arm claims (kunchenguid#5939) - c4f4333 feat(bin): add Polytoken crewmate/scout worker adapter (kunchenguid#7321) - 11990a2 Fix away branch relaunch admission (kunchenguid#7444) - 56074d0 fix(bin): show reported checks when a pull request's base requires none (kunchenguid#7450) - 0791268 fix: support durable per-secondmate account pins (kunchenguid#7452) - 4e6b9f5 feat(bin): consult operator evidence guards before wedge escalation (kunchenguid#6958) - c7b7798 fix(bin): make inbox listing succeed when the inbox is empty (kunchenguid#7460) - 63fc5eb fix: bound remote secondmate convergence and preserve owed re-reads (kunchenguid#7394) - 8ba34f1 fix: require positive daemon running status in crew-state (kunchenguid#7317) - 1aa2a21 fix(tests): stabilize supervision host drain and offer fixtures (kunchenguid#7467) - 69f9d09 fix(bin): refuse spawn into a project with an unborn HEAD (kunchenguid#6987) - 45dd50a feat(bin): add GitLab --allow-no-pipeline merge waiver and close backlog items for GitLab MRs (kunchenguid#7462) ## Conflict decisions - `.agents/skills/operational-home-layout/SKILL.md`: Fork seat configuration; upstream per-secondmate account configuration. Decision: Keep both configuration entries. - `bin/backends/herdr.sh`: Fork send-failure/recovery semantics and harness variable; upstream Polytoken busy override. Decision: Keep fork send-failed and recovery handling; add Polytoken busy identity without losing the fork harness variable. - `bin/fm-backlog-transition-lib.sh`: Fork cached library directory; upstream GitLab completion support. Decision: Keep cached source path and extend forge ownership comment to GitLab; accept GitLab completion path. - `bin/fm-config-inherit-lib.sh`: Fork Claude/Codex seat inheritance; upstream Herdr project groups. Decision: Union the allowlist; per-secondmate account pins remain local to the primary home. - `bin/fm-control.sh`: Fork pre-stop seat checks; upstream per-mate pins and Polytoken launch checks. Decision: Select the per-mate pin while retaining its returned account for seat conflict validation; keep all Polytoken pre-stop checks. A valid explicit pin supersedes the old recorded Claude store on relaunch. - `bin/fm-harness.sh`: Fork in-process HARNESS_VERDICT result; upstream echo-based Polytoken detection. Decision: Add Polytoken through the fork verdict convention, retaining existing adapter detection. - `bin/fm-lock.sh`: Fork handover reservation and runtime publication; upstream session re-anchor lease/auto-arm locks. Decision: Share the existing claim lock and release helper, add lease/auto-arm locking, then publish runtime and clear an admitted handover before releasing locks. - `bin/fm-pr-state.sh`: Fork shared required-check evaluator from dbe11b1 and 91371c8; upstream 56074d0 adds a second gh pr checks fallback. Decision: Keep one evaluator through fm-pr-checks.sh and fm-pr-checks-lib.sh. It already checks non-advisory reported checks on unprotected bases, includes missing configured requirements, and fails closed on read errors. Adapt upstream regressions to this API; preserve the fork REQUIRED CHECK label and advisory policy. - `bin/fm-spawn.sh`: Fork parked-session resume, seats, unclaimed-worktree guard and ticket hook; upstream Polytoken, per-mate accounts and Herdr groups. Decision: Compose both paths, retain validate_spawn_worktree_unclaimed, seat gates, profile trust and metadata, and both hooks. Extend pin/seat refusal to the selected per-mate pin while retaining the primary-home seat guard. The selected durable Claude pin owns trust and recorded store on relaunch so old seats cannot override it. - `bin/fm-teardown.sh`: Fork merged-at/park record cleanup and isolation protections; upstream generated Polytoken wiring cleanup. Decision: Keep fork cleanup and guards; add only task-owned Polytoken files and generated untracked wiring to existing guarded teardown. - `bin/fm-test-run.sh`: Fork timing entries and pipeline-spend suite; upstream Herdr-group and Polytoken suites. Decision: Union suite entries, preserve fork timing measurements for existing suites. - `bin/fm-wake-lib.sh`: Fork single-read auto-arm ledger parser; upstream session-owner identity fields. Decision: Extend the single-read parser with owner_session_id and the third-line lock identity; retain orphan recovery and lease logic. - `bin/fm-watch.sh`: Fork bounded run-activity deferral and escalation wording; upstream operator evidence guard. Decision: Keep both bounded deferrals and append operator guard evidence to both ordinary and deep-inspection escalations. Keep exact owned watcher termination semantics. - `docs/agent-control.md`: Fork seat relaunch policy; upstream per-mate account selection. Decision: Describe both policies with account pin checked before stopping the live agent. - `docs/configuration.md`: Fork seat sections and ticket timeout; upstream per-mate pins and remote convergence settings. Decision: Keep all sections, place per-mate pins under worker accounts before the seat sections, and retain all timeout entries. - `tests/fm-control-relaunch.test.sh`: Fork fixture cleanup and seat regressions; upstream account and away-admission regressions. Decision: Keep fixture-scoped cleanup and all regression calls; extend the changed-pin case to check trust in the new store and recorded profile. - `tests/fm-crew-state.test.sh`: Fork no-fork metadata parsing test; upstream override-identity tests. Decision: Keep both test bodies and calls, plus upstream positive daemon-status cases. - `tests/fm-pr-merge.test.sh`: Fork named-case local selector; upstream GitLab waiver test definitions. Decision: Place upstream definitions before the named-case selector and retain every case. - `tests/fm-supervision-host.test.sh`: Fork split helper/suite layout; upstream snapshot-aware offer fixture. Decision: Update the shared supervision-host-helpers.sh implementation and retain its split consumers rather than duplicate the helper in one suite. - `tests/fm-teardown.test.sh`: Fork collision/released-claim cases; upstream Polytoken cleanup cases. Decision: Keep all regression calls. - `tests/fm-watch-triage.test.sh`: Fork split classifier/stale/delivery suites; upstream unsplit suite with four new operator-guard cases. Decision: Keep the split and move only new guard fixtures/cases into fm-watch-triage-stale.test.sh; do not resurrect duplicated legacy test bodies. ## Additional integration and verification decisions - Preserve fork teardown, merge, push, worktree ownership/isolation, and exact-owned watcher termination guards. GitLab no-pipeline waiver remains explicit, attended-only, GitLab-only, and only accepts an explicit null pipeline; default and existing-pipeline safety checks remain in force. - Existing pull-request CI selects subsets and cannot prove the requested full suite. Add a manual CI workflow trigger using the existing full-suite fallback, so the feature head can run every required lane before landing; document that entry point. No local full suite or real Herdr lifecycle run is authorized.
max-metaplanet
added a commit
to max-metaplanet/firstmate
that referenced
this pull request
Oct 19, 2026
* feat(herdr): opt-in project groups with status tags and a sorted agents view (kunchenguid#7434) * feat(herdr): opt-in project groups with status tags and a sorted agents view Add config/herdr-project-groups (absent or off: unchanged behavior). When on, Firstmate tags each Herdr task pane, and its own projected workspace, with display-only fm_group/fm_state/fm_task/fm_sort tokens, sets a Herdr agents view sorted by group then status (needs-captain, problem, running, done), and places a new projected task at the end of its own group inside the parent block with the same single verified move as before. The watcher reconciles tags once per poll and a spawn tags its task at once; bin/fm-herdr-groups.sh also previews (plan), clears, and prints or appends suggested sidebar rows with a backup. The agents view helper needs python3. The only test-runner change is the serial weight hint for the new suite. * docs(herdr): record the live lab check of project groups The four hand checks for tags, the sorted agents view, placement at the end of the group, and clear passed against a real Herdr 0.9.5 server (protocol 22) in a guarded lab session. * docs(herdr): align project group verification notes with the live check * fix(bin): pin LC_ALL=C for remote job process identity reads (kunchenguid#7410) ps -o lstart= renders in the caller's locale, so a lock or claim owner recorded under one locale (de_DE renders "Di Okt 13 ...") failed identity verification under another, was declared dead, and a second worker split the queue: two serve loops reclaimed and reaped each other's live jobs, which vanished mid-claim and failed staged jobs with exit 125 and no output. Pin LC_ALL=C in fm_remote_job_process_start and pin the cross-locale invariant with a regression test. Co-authored-by: researchworldwide2026 <[email protected]> * fix(opencode): ignore child stdin EPIPE in guard and encoder (kunchenguid#7447) * fix(bin): ignore crew state overrides for other tasks (kunchenguid#5881) * Guard fm-crew-state overrides by task-name basename bin/fm-crew-state.sh honours FM_CREW_STATE_META_OVERRIDE and FM_CREW_STATE_STATUS_OVERRIDE only when the override's basename is the requested task's own .meta or .status file name. An override naming a different task, for example one inherited through a server started inside another task's snapshot child, falls through to the task's own records under the state directory. A snapshot's own override, which names the task it was captured for, is still honoured. This is complementary to kunchenguid#5622, which keeps the overrides out of the Herdr server launch: whatever path leaks an override, the reader never trusts one that names a different task. Regression tests cover a mismatched override being ignored and a matching one being honoured. * no-mistakes(review): Make metadata override tests behaviorally distinct * fix(bin): re-anchor a Claude session's lock so /clear keeps ownership (kunchenguid#7415) * fix(bin): re-anchor a Claude session's lock so /clear keeps ownership A same-session confirmation over a live lock line 1 outside the current harness ancestry now rewrites line 1 to the session's CLAUDE_PID anchor under the claim lock, so a later /clear re-key in the same process is still proven by ancestry instead of being refused as a foreign owner. Fixes kunchenguid#6820 * fix(bin): move task leases with a session-lock re-anchor A same-session re-anchor rewrote lock line 1 off a live pid while task leases still named that pid, so a lease held by main or the supervision branch read as stale and the other actor could claim the task. The re-anchor now takes the lease-command lock after the claim lock and, in the same critical section as the line-1 write, rewrites leases recorded against the old pid to the new anchor (fm_lease_rekey_holder). If the lease-command lock stays busy past a short bound, the confirmation keeps line 1 as before and a later acquisition re-anchors. The foreign-owner reproduction now asserts the re-anchor contract: the same trusted id from a live process outside the owner's ancestry moves line 1 onto that process's CLAUDE_PID, and a different id is refused against it afterwards. The ancestry membership loop is shared through one session-lock lib helper. The earlier commit dropped the ancestry suite's dead-front-end reclaim phase; that coverage lives in the existing reclaim tests (test_verified_reclaim_keeps_new_sidecar and the Stop auto-arm's test_reclaims_stale_session_lock_before_arming). * fix(bin): record the lock holder for a lease pinned before a re-anchor The supervision host pins FM_LEASE_HOLDER_PID to lock line 1 at the start of each engine turn. A same-session re-anchor inside that turn moved line 1 to a new pid while the pinned holder stayed alive, so a later claim or same-actor refresh in the turn recorded the old pid and the lease read stale, letting main claim the branch's task. A claim now records the live line 1 when the pinned holder is alive but is no longer line 1. Another session takes the lock only from a dead owner, so that state comes from a re-anchor; a dead pin is still recorded as before and its lease stays stale. * no-mistakes(review): Move auto-arm rewake session pid with lock re-anchor * no-mistakes(review): Align startup-network downgrade test and lock-rewrite comment * no-mistakes(review): Correct lock takeover and re-anchor signal-window comments * no-mistakes(review): Record re-anchor rewake and pinned-claim verification evidence * no-mistakes(document): Update network-checks diagnostic for re-anchored lock holder * feat: support version URLs for watched tool updates (kunchenguid#7449) * feat(bin): watch a tool's published version through version_url A watched tool whose CLI never announces its own updates can name a version_url; the document is fetched read-only inside the probe bound, its first dotted number is the published version, and an update is reported when that is newer than the version PATH resolves. Claude Code is the shipped example entry. * no-mistakes(review): Compare published versions against newest installed tool copy * no-mistakes(document): Clarify watched-tool version URL documentation * fix(pi): keep a live session's extension markers when a nested Pi command loads them (kunchenguid#7287) * fix(pi): keep a live session's extension markers when a nested Pi command loads them A short-lived Pi command started from inside a live session, such as the `pi --help` capability probe, auto-loads the two primary extensions. Both treated the session lock as owned because an ancestor holds it, so the child rewrote `.pi-watch-extension-loaded` and `.pi-turnend-extension-loaded` with its own pid and exited. Session start then rejected the markers and printed a false `PI_WATCH_EXTENSION: not loaded` alarm. Before writing, each extension now reads the marker's pid and leaves the marker untouched when that pid is a live strict ancestor of the current process. A missing marker, a dead pid, the current pid, or a live pid outside the ancestry still writes as before, so a fresh start and a relaunch over a dead session bind unchanged. Lock ownership and the reader are untouched. Fixes
Intent
The bug, observed in this home on 2026-10-16/17: while the away-posture record existed, two ship workers' agents died mid-task. The supervision branch (supervision host, Claude home) detected both within minutes and tried
bin/fm-control.sh <id> relaunch. Both relaunches were refused with "spawn refused - the supervision branch under the away-posture record may dispatch only queued unblocked work (already queued, or filed by the branch from the captain's away words); task has no dispatchable backlog item in this home". The tasks' backlog rows werein_flight(correct for a live task), and the relaunch path inbin/fm-spawn.sh(upstream main ce69740, theif [ "$RELAUNCH" -eq 1 ]block near line 3924) requiresqueued no nofor the branch actor, so an away relaunch of any in-flight task always refuses. The same file's header says a relaunch replaces a worker that already counts and only a fresh spawn refuses the branch actor; main's path acceptsin_flight no noviafm_backlog_row_dispatchable. The branch then recorded the refusal as a captain outcome held for return rather than handing the wake back to main, so both workers sat dead for about 10 hours until the captain returned.What Changed
bin/fm-spawn.sh: the away-posture rule that limits the supervision branch toqueued no nobacklog rows now applies only to fresh spawns. A relaunch from the branch goes through the samefm_backlog_row_dispatchablecheck that main uses, sofm-control.sh <id> relaunchnow works for anin_flighttask while the away-posture record exists. Before this, the branch's relaunch of any live task was refused with "may dispatch only queued unblocked work".tests/fm-control-relaunch.test.sh: addstest_away_branch_relaunch_accepts_existing_dispatchable_items. It enters away posture with--spend 1, then runsrelaunchasFM_SUPERVISION_ACTOR=branchfor anin_flightitem and for aqueueditem. Each must exit 0, printrelaunched <id>and leave the rowin_flight. The test is skipped whentasks-axiis missing or too old.Risk Assessment
✅ Low: This is a one-condition change. It makes a branch relaunch while away use the same fm_backlog_row_dispatchable check (
in_flight no noorqueued no no) that main already uses, which matches the documented rule that only a fresh spawn refuses the branch actor. Fresh branch spawns are unchanged: they still get the queued-only check at line 3923 and in spawn_require_relocated_queued_work under the task-set lock. Direct fm-spawn relaunches by the branch are still refused unless they come through fm-control. The new test runs fm-control end to end with a real away record and would fail on the in_flight case without the fix.Testing
I drove the real product in a disposable lab: a marked lab home with a supervision-host opt-in, an active away record with a full spend cap of 1, and a private tmux socket. In that lab,bin/fm-control.sh <id> relaunchrun as the branch started a real Claude agent in the dead task's pane, and the backlog row stayedin_flight. Two adversarial checks in the same lab were refused as intended: relaunching a Done task, and a fresh branch spawn of an in-flight row. I also ran the new regression test against the fix and against basebin/fm-spawn.sh, and the existing fresh-spawn guard test. Those are unit-level checks, not live runs, so that scenario is recorded as untested under the live contract. The lab, its tmux server and its Claude process were torn down, and the worktree is clean. No UI is involved, so the evidence is CLI transcripts and a capture of the tmux pane.Evidence: Regression test on base: reproduces the reported refusal
Source: Regression test on base: reproduces the reported refusal
Evidence: Regression test on the fix: passes
Source: Regression test on the fix: passes
Evidence: Existing fresh-spawn guard test under away: passes
Source: Existing fresh-spawn guard test under away: passes
Evidence: Live lab transcript: away entry, branch relaunch, Done-row refusal, fresh-spawn refusal
Source: Live lab transcript: away entry, branch relaunch, Done-row refusal, fresh-spawn refusal
Evidence: tmux pane after relaunch: real Claude worker running in the task's pane
Source: tmux pane after relaunch: real Claude worker running in the task's pane
Evidence: Lab backlog after the scenarios: live-inflight still In flight
Source: Lab backlog after the scenarios: live-inflight still In flight
Evidence: Key live result
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
bin/fm-spawn.sh:3923- The intent also describes a follow-on behaviour: after the refusal, the branch recorded it as a captain outcome held for return instead of handing the wake back to main. This change does not touch that handling. It removes the refusal for in-flight relaunches, which was the reported trigger, so the 10-hour stall can no longer start this way. Any other relaunch refusal while away would still be held for the captain's return. This is noted for awareness, not as a defect in the diff.tests/fm-control-relaunch.test.sh- The suite's cleanup (rm -rf "$TMP_ROOT") cannot remove the read-onlystate/<id>.git-hooksdirectories that a relaunch creates, so the new test's away-* fixture dirs are left in $TMPDIR. This is the same cleanup path the existing tests use. It does not affect results. I removed the leftovers by hand.tests/fm-control-relaunch.test.shlimited totest_away_branch_relaunch_accepts_existing_dispatchable_items, run on the fix (passes) and on base ce69740'sbin/fm-spawn.sh(fails with the reported 'spawn refused - the supervision branch under the away-posture record may dispatch only queued unblocked work' error)tests/fm-branch-supervision.test.shlimited totest_away_branch_spawn_requires_queued_dispatchable_work(existing guard for fresh spawns under away)Live lab:bin/fm-lab-home.sh createwith a canonical path,config/supervision-host, a markdown backlog via tasks-axi, real git worktrees, and dead-agent windows on a privatetmux -L fm-labsocketLive:bin/fm-afk-contract.sh enter --spend 1, then from inside the lab paneFM_SUPERVISION_ACTOR=branch bin/fm-control.sh live-inflight relaunch --note ..., which started realclaudein the paneLive:FM_SUPERVISION_ACTOR=branch bin/fm-control.sh live-done relaunch(Done row)Live:bin/fm-afk-contract.sh archiveandenter --spend 10, thenFM_SUPERVISION_ACTOR=branch bin/fm-spawn.sh live-fresh --mode no-mistakes --yolo off(fresh spawn of an in-flight row)Teardown:tmux -L fm-lab kill-server, stopped the leftover lab claude process,rm -rfof the lab and temp files, removed the single-test runner copies from the worktree✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.