fix(bin): register freshly spawned pi workers as Herdr agents - #3
Merged
Merged
Conversation
Herdr only probes a pane for an agent when its foreground process group changes, or in a short window after the screen has been still. A pane shell that sources the staged launch without job control (fish, or any shell with monitor mode off) runs the agent inside the shell's own process group, so a worker whose launch outlasts that window and then keeps redrawing is never registered: the pane reads no agent, fm-send treats the live worker as exited, and liveness reads misjudge it. On Herdr, fm-spawn now types a line that sources the staged launch file inside a job-controlled /bin/sh, so the agent starts as its own foreground process group and Herdr probes it immediately, whatever the pane shell is. The terminal and the exit status return to the pane shell when the agent exits. Adds a portable pty regression for the process-group guarantee, a token-free live guard against the real Herdr and Pi, the verification record, and updates the Herdr fakes that parsed the old source line.
Unrelated to the Herdr launch fix in this branch. CI installed the latest public Pi, which moved to 0.99.1, and its changed stock rendering fails fm-calm-pi-extension and fm-pi-branch-extension. Pin CI to the Pi release the fleet runs and these tests last passed on; checking compatibility with the latest Pi is a separate follow-up.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Intent
Everything of this Firstmate fleet now runs on the Herdr backend (the captain moved it off tmux on 2026-09-29). Freshly spawned pi worker panes are not registered with Herdr as agents:
herdr pane listshows no agent and agent_status "unknown" for them, while relaunched pi panes and the primary pi pane register as "pi". Seen on 4 of 6 new Herdr workers in the Spire caretaker's home and on the animus kunchenguid#9 worker. Consequence:fm-sendreports the live worker as exited and rings no doorbell, so steers sit unread until someone types into the pane by hand, and watcher liveness/stale checks may misread these panes. The Herdr pi integration is installed and current (v9) at ~/.pi/agent/extensions/herdr-agent-state.ts. Make freshly spawned pi workers on Herdr register as agents so steering and monitoring work.#3 doesn't pass CI!
(That PR is this branch's PR. Its fork CI checks "Behavior portable serial 2" and "Behavior portable serial 4" fail in tests/fm-calm-pi-extension.test.sh and tests/fm-pi-branch-extension.test.sh because CI installs the latest public Pi, 0.99.1, while the fleet runs Pi 0.87.1 and main last passed on 0.87.1. The PR must be green before it is merged.)
What Changed
fm-spawn.shnow types a launch line from the newfm_backend_herdr_launch_lineinbin/backends/herdr.sh. The line sources the staged launch file inside a job-controlled/bin/sh -c 'set -m; ...', so the agent gets its own process group and takes the terminal foreground. Herdr then registers the pane as an agent, andfm-sendand the watchers see the worker as live. Other backends keep the. '<file>'line.fm-test-run.sh, updates the existing Herdr remote tests and fixture for the new launch line, and documents the behavior indocs/herdr-backend.md,docs/configuration.mdanddocs/verification/runtime-backends.md..github/workflows/ci.yml, both jobs that install Pi now pin@earendil-works/pi-coding-agent@0.87.1. Unpinned CI installed Pi 0.99.1, which brokefm-calm-pi-extensionandfm-pi-branch-extensionin the portable serial shards.Risk Assessment
✅ Low: On Herdr, the typed launch line now sources the staged launch file inside a job-controlled /bin/sh, and this is applied only to that backend. It is quoted correctly and covered by pty and live tests. CI pins Pi to 0.87.1, which addresses the stated CI failures. The one behavior change is that launch commands now run under POSIX sh on Herdr, and the change documents this.
Testing
I ran the launch-line unit test and the live end-to-end test against real Herdr 0.9.2 and Pi 0.87.1. In the live test, a Pi started through the new launch line registered as "pi" even when the pane shell had no job control. The counterfactual, a plain sourced launch, stayed unregistered with the shell in the foreground group. Both tests passed. The process-group scenario was covered only by the unit test, which is not live. The CI Pi-version pinning was not driven live, because it only takes effect on GitHub Actions.
Evidence: test run transcript
Source: test run transcript
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 tests/fm-backend-herdr-launch-line.test.shbash tests/fm-herdr-pi-launch-registration-live-e2e.test.sh(real herdr 0.9.2 and pi 0.87.1, in a lab session)✅ **Document** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.