Repository navigation
feat(backends): add experimental herdr-core runtime backend - #9
Profreshor wants to merge 6 commits into
Conversation
Add bin/backends/herdr-core.sh so config/backend=herdr-core launches ship and scout workers as herdr-core (hc) terminals, with treehouse still the worktree provider. Each task is one labelled terminal (fm_home, fm_task) pinned to its recorded hc session; ownership is proven by labels before any read, send, kill, or remove. Wire it through backend selection and validation, HC_TERMINAL_ID auto-detection (ancestry decides when HERDR_ENV is also present), the hc version gate, task metadata, the control plane (interrupt, exit, relaunch with proven-absence rebind), busy and liveness classification, and recorded-inventory discovery. Secondmate spawns are refused. Document setup, detection, and limits in docs/herdr-core-backend.md and record the live hc 0.1.13 verification pass.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d130c30664
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| local label=$1 cwd=$2 session=${3:-} id home out addr | ||
| [ -n "$session" ] || session=$(fm_backend_herdr_core_session) | ||
| id=${label#fm-} | ||
| home=$(fm_backend_hometag) |
There was a problem hiding this comment.
Include the operational home in terminal ownership labels
When two independent FM_HOME instances share the same code root and HC_SESSION, this call produces identical ownership labels: fm_backend_hometag hashes FM_ROOT and uses FM_HOME only for the optional secondmate marker. Consequently, matching task IDs cause one home's launch to be refused because the other home's terminal exists, and the ownership check in fm_backend_herdr_core_get accepts that other home's terminal as owned. I reproduced both homes receiving the same tag and the second home accepting the first home's terminal. Include the resolved operational-home path in the discriminator to preserve AGENTS.md's prohibition on claiming another home's work.
AGENTS.md reference: AGENTS.md:L123-L123
Useful? React with 👍 / 👎.
… unknown-backend diagnostic expects the newly registered herdr-core backend. The previously failing assertion now passes during the bootstrap suite; tests/fm-backend-herdr-core.test.sh passed locally. The full bootstrap suite exceeded this environment’s 30s command window after the relevant assertion passed; no unrelated diff hunks were flagged by jev. Risk: only the stale expected diagnostic was changed
db210e3 to
94b9583
Compare
Intent
Heads up, I'm trying the new herdr-core platform that was released today. The subagents you just assigned went to the old server while you're on the new one.
Decision: "Build herdr-core adapter now". The question was whether to build a herdr-core runtime for firstmate so workers launch on the new platform, or keep workers on the old herdr server for now.
What Changed
herdr-core(hc) runtime adapter, including backend selection, auto-detection, dependency/version checks, task-terminal ownership labels, and task metadata.hcregression suite covering the adapter lifecycle.Risk Assessment
Medium: adds a new experimental runtime backend. Existing backends are unchanged apart from the known-backend lists, and herdr-core is used only when
config/backend,FM_BACKEND,--backend herdr-core, orHC_TERMINAL_IDauto-detection selects it. Relaunching a finished hc terminal works:hc geton a finished terminal exits 0 withstate=finishedon live hc 0.1.13, and the live evidence below shows the owned finished terminal removed and rebound fromt1tot2.Activation
Merging does not switch this home to herdr-core. After merge, firstmate sets
config/backend=herdr-coreto activate it.Worker live check
Run on 2026-10-29 with hc 0.1.13 in an isolated hc core (
HC_SESSION=fmhc-live), with a scratch Firstmate home and project; the operator'sdefaultcore was not touched. Steps run:fm-spawn.sh --backend herdr-core(scout, Claude Haiku), anfm-sendsteer answeredPINEAPPLE,fm-peek,fm-control interrupt(verified=agent-alive),fm-control exit(agent then readdead), relaunch adopting the live shell, relaunch afterhc kill+hc rmrebinding to a new terminal in the recorded worktree, and teardown. Exact outputs are indocs/verification/runtime-backends.md#herdr-core.Pre-existing local test failures
Two local failures were checked against an export of
origin/mainat 95495de, without this branch:tests/fm-test-run.test.shunderLANG=en_US.UTF-8comm: file 2 is not in sorted orderfrom--check-coverageLC_ALL=C, which CI usestests/fm-control-relaunch.test.shnot ok - Herdr Pi relaunch should complete (pi registration)pi executable not found on PATHon this hostBoth fail identically without this change.
Testing
Focused regression passed. Live Firstmate spawned a real Codex worker into a named hc core with recorded herdr-core metadata, removed a real finished owned terminal and rebound it to a new live terminal in the same worktree, and refused a foreign-labeled terminal. All labs and worktrees were torn down. The change-scope scan found no unrelated hunks.
Evidence: Live hc spawn and finished-terminal rebind
Source: Live hc spawn and finished-terminal rebind
Evidence: Live foreign-terminal ownership refusal
Source: Live foreign-terminal ownership refusal
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
bin/backends/herdr-core.sh:302-hcretains an exited task terminal asfinished, but this maps todead. Relaunch treatsdeadas adoptable, then its firstcdis refused becausetarget_readyaccepts onlylive; a normal exited worker therefore cannot relaunch. Route finished terminals through a cleanup-and-rebind transition instead of adoption.🔧 Fix applied.
3 issues (1 error, 2 warnings) still open:
bin/fm-spawn.sh:2033- Withset -eactive, a live shell terminal (or an already-missing terminal) makesfm_backend_herdr_core_remove_finishedreturn 1, so the script exits before the followingcase $?can retain adoption/rebind behavior. Capture its status in anif/||-guarded command before branching, so only the helper's status 2 refuses.tests/fm-backend-herdr-core.test.sh:262- The new regression calls the removal helper and creates a terminal directly; it never executesfm-spawn.sh --relaunch, so it passes despite the failing relaunch wiring above. Exercise a recorded finished endpoint through the relaunch entry point and assert replacement session, terminal, and worktree.docs/herdr-core-backend.md:52- The guide says every agent-free terminal is adopted, but the required finished-terminal behavior removes the owned finished terminal and rebinds it. Distinguish a live shell (adopt) from a finished terminal (remove and recreate) to keep the operational contract accurate.🔧 Fix applied.
1 error still open:
bin/backends/herdr-core.sh:160-hc getis documented to exit 11 for a finished terminal, but this accepts only 0 or 3 before parsing JSON. Thus an owned finished terminal is classified unreadable; relaunch neither removes nor rebinds it and refuses. Accept exit 11 as a parseable response, and make the fakegetreturn 11 for finished terminals so the regression covers real CLI behavior.✅ **Test** - passed
✅ No issues found.
bash tests/fm-backend-herdr-core.test.shDisposable named hc core:fm-spawn.sh ... --backend herdr-core --harness codex, realhc kill, thenfm-spawn.sh --relaunchDisposable named hc core: real foreign-labeled terminal checked through the herdr-core adapter✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.