Repository navigation
fix(spawn): refuse herdr task ids over the 32-char agent-name cap - #8231
LorenzoMinghini wants to merge 3 commits into
Conversation
Herdr's `agent start <NAME>` caps agent names at 32 characters and rejects over-cap names with `invalid_agent_name`. A task id past the cap therefore reported a successful spawn or relaunch while the replacement agent's inner agent-start silently errored and never booted: the endpoint looked alive, the worker did not exist, and the relaunch path reported success on a silently dead agent. fm-spawn.sh now refuses an over-cap id on the fresh spawn path (before any pane, tab, workspace, or agent is created) and on the --relaunch path (before the recorded endpoint is inspected or touched), and fm-control.sh refuses on its relaunch path before stopping the old agent or mutating any durable record. The refusal names the cap, the offending id and its length, and the shorter-id hint; ids within the cap and every non-herdr backend are untouched. The one-line length predicate is defined locally in each script and cross-referenced, since a shared home in bin/fm-backend.sh would grow this change's file surface. tests/fm-spawn-herdr-name-cap.test.sh pins the exact 32/33 boundary and the 40-char live-failure shape through the three entry points, with tmux cases proving the cap stays herdr-only. A herdr stub keeps the pass-through cases hermetic: a real CLI could answer a nonexistent session by starting a real server. Without the guard the refusal assertions fail, which is what makes the suite a guard. The new suite carries a provisional serial duration hint in bin/fm-test-run.sh's hint table (provenance in docs/fm-test-portable-shards.md) so the coverage guard's 15 percent unhinted bound stays satisfied, and docs/herdr-backend.md names the new preflight refusal alongside the tool and protocol-floor refusals.
[Low impact] The PR appears safe to merge. Reviews (1) · Last reviewed commit: "no-mistakes(review): Fix stale comment a..." · Reviewed by Greptile |
|
Speaking as Kun's firstmate: thank you @LorenzoMinghini. I read tip What I checked: the shared Contract-class: restore. Herdr already rejects names over 32 with VISION: One captain aligns (no silent-dead endpoints) · Authority aligns (no new autonomy) · Scripts own the mechanics aligns (length predicate, fail-closed) · Restart is a non-event aligns · Delegation aligns (field incident → regression) · Vendor aligns (Herdr adapter honors vendor limit) · Scope aligns (spawn/control only). Gates: no-mistakes binds Next: author work is done. The next step is ours — run the full suite; if green this can land as a restore. Nothing more needed from you for the label-gate red. |
Intent
Re-raise the Herdr agent-name-cap guard against the upstream firstmate repository as a clean, minimal pull request.
Context: Herdr caps agent names at 32 characters. When a firstmate task id exceeds that cap, the relaunch path reports success while the replacement agent never boots - a silent death that firstmate has hit in practice. A guard for this was written and merged on our fork (fork PR #1, "fm-spawn/fm-control: refuse task ids over 32 chars on herdr backend (silent relaunch death)"), but that pull request carries 434 files of unrelated drift, because the fork's main is an upstream mirror taken at a different commit; the fork also force-wipes fork-only commits, so nothing that lives only on the fork is a durable home. Upstream main today has no such guard in bin/fm-spawn.sh or bin/fm-control.sh and no tests/fm-spawn-herdr-name-cap.test.sh.
The captain ruled on 2026-11-06 to re-raise it upstream cleanly, and to keep the pull request free of everything except the guard itself.
Acceptance: one upstream pull request that changes only the guard and its test, ported onto current upstream main, with the guard's behaviour proven by a test that fails without it.
What Changed
FM_HERDR_AGENT_NAME_MAX=32andfm_herdr_agent_name_within_cap) inbin/fm-control-lib.sh, and enforce it fail-closed on all three spawn/relaunch paths —bin/fm-spawn.shfresh spawn and--relaunch, andbin/fm-control.shrelaunch — before any pane, tab, workspace, or old agent is created/stopped, so an over-cap task id is refused with an explicit error instead of reporting success while Herdr'sagent startrejects the name (invalid_agent_name) and the replacement never boots.tests/fm-spawn-herdr-name-cap.test.shcovering the exact 32/33-character boundary on the fresh-spawn, spawn--relaunch, and control-relaunch paths, including herdr-specific refusal messages, 32-char pass-through at the cap, and non-herdr (tmux) negative controls proving the cap does not apply elsewhere.bin/fm-test-run.shanddocs/fm-test-portable-shards.md(provisional 25000 ms serial hint), and document the cap refusal indocs/herdr-backend.md.Risk Assessment
✅ Low: The change is a small, well-bounded guard: one shared predicate, three fail-closed call sites placed before any side effect, plus behavioral boundary tests; prior findings were resolved correctly and no new defects were found.
Testing
Drove the change live end-to-end: real herdr 0.9.5 in an isolated fm-lab-capg2 lab session confirmed the 32/33 agent-name boundary (33-char agent start returns invalid_agent_name; 32-char boots a real agent), and the real fm-spawn.sh/fm-control.sh entry points were run in a disposable marked lab home where all three guard paths (fresh spawn, fm-spawn --relaunch, fm-control relaunch) refused a 33-char herdr task id with the cap message before any endpoint or old agent was touched, while 32-char and tmux cases passed through the cap. The focused 9-test suite passes with the guard and demonstrably fails without it in a guard-stripped disposable copy. Lab and disposable homes were torn down and the worktree left clean; all scenarios passed.
Evidence: Live validation report: real herdr 0.9.5 oracle + live guard scenarios on fm-lab-capg2
Source: Live validation report: real herdr 0.9.5 oracle + live guard scenarios on fm-lab-capg2
Evidence: Regression proof: focused suite run against a disposable copy with the guard stripped (first 33-char assertion fails; spawn falls through to an unrelated downstream cd failure)
Source: Regression proof: focused suite run against a disposable copy with the guard stripped (first 33-char assertion fails; spawn falls through to an unrelated downstream cd failure)
1..9 not ok - fresh herdr refusal must name the 32-char cap (missing: 'herdr caps agent names at 32 characters') --- output --- .../bin/fm-spawn.sh: cd: .../projects/none: No such file or directoryPipeline
Updates from git push no-mistakes
✅ **Intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
bin/fm-spawn.sh:995- Simplification: the guard introduces the concept 'herdr agent-name cap' as a second definition. FM_HERDR_AGENT_NAME_MAX=32 and fm_herdr_agent_name_within_cap() are defined independently in bin/fm-spawn.sh:995-1000 and bin/fm-control.sh:232-237, yet both scripts already source the same shared library (bin/fm-spawn.sh:949 sources bin/fm-control-lib.sh, which fm-control.sh also uses). No intent requirement forces duplication; the strictly narrower form is one definition of the constant plus predicate in bin/fm-control-lib.sh (or another lib both entry points source), with three call sites unchanged. The change's own comments argue for locality ('it is a one-line length comparison'), so this is a deliberate-intent question, not an auto-fix: the smallest honest remedy would move the definition into the shared lib, touching a third file beyond 'only the guard and its test'.docs/herdr-backend.md:67- Intent says the PR changes 'only the guard and its test'; this change also adds a one-line behavioral doc to docs/herdr-backend.md:67 and registers the test in bin/fm-test-run.sh:916 + docs/fm-test-portable-shards.md:32. The test registration is required for the test to exist in the suite; the herdr-backend.md line documents the new refusal in the section that already enumerates spawn preflight refusals, so it reads as part of delivering the guard rather than unrelated drift. Flagging for awareness only; no action recommended.🔧 Fix applied.
2 infos still open:
docs/herdr-backend.md:67- Intent says the PR changes 'only the guard and its test'; this change also adds a one-line behavioral doc to docs/herdr-backend.md:67 and registers the test in bin/fm-test-run.sh:916 + docs/fm-test-portable-shards.md:32. The test registration is required for the test to exist in the suite; the herdr-backend.md line documents the new refusal in the section that already enumerates spawn preflight refusals, so it reads as part of delivering the guard rather than unrelated drift. Flagging for awareness only; no action recommended.tests/fm-spawn-herdr-name-cap.test.sh:27- Stale comment left by the fix round that consolidated the guard into bin/fm-control-lib.sh: the suite header still says "The cap predicate is defined locally in each of the two scripts (it is a one-line length comparison)" (tests/fm-spawn-herdr-name-cap.test.sh:25-27), which is now false — the predicate lives once in bin/fm-control-lib.sh:409-413. Comment-only accuracy fix; no behavior change.🔧 Fix applied.
1 info still open:
docs/herdr-backend.md:67- Intent says the PR changes 'only the guard and its test'; this change also adds a one-line behavioral doc to docs/herdr-backend.md:67 and registers the test in bin/fm-test-run.sh:916 + docs/fm-test-portable-shards.md:32. The test registration is required for the test to exist in the suite; the herdr-backend.md line documents the new refusal in the section that already enumerates spawn preflight refusals, so it reads as part of delivering the guard rather than unrelated drift. Flagging for awareness only; no action recommended.bin/fm-herdr-lab.sh:596- bin/fm-herdr-lab.sh provision's else-branch calls fm_herdr_lab_prepare, which refuses with 'tripwire already exists' when the caller ran prepare first as its documented usage suggests (prepare then provision in sequence fails; provision alone works). Pre-existing helper behavior unrelated to this change; noted only because it surfaced during lab setup.bash tests/fm-spawn-herdr-name-cap.test.sh (9/9 ok, FM_TEST_COMPLETE)bin/fm-herdr-lab.sh prepare/provision/teardown of fm-lab-capg2; herdr agent start 33-char vs 32-char oracle in the lablive ./bin/fm-spawn.sh <33-char-id> ... --backend herdr with marked lab home (refusal, no endpoint created)live ./bin/fm-spawn.sh <32-char-id> --backend herdr and <33-char-id> --backend tmux (no cap refusal, downstream failure)live ./bin/fm-control.sh <33-char-id> relaunch and ./bin/fm-spawn.sh <33-char-id> --relaunch with herdr meta (refusal before endpoint/old-agent touch)guard-stripped disposable copy: tests/fm-spawn-herdr-name-cap.test.sh fails at the first 33-char assertion (regression proof)✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.
CI note and full-ci label request
The only red check on this pull request is the Full suite job, which is this repository's documented maintainer-label gate, not a code failure: in its run (42331229101) the job started and finished within two seconds, executed exactly two steps ("Set up job" and "Require the full-ci go-ahead and passing lanes"), and ran no project code at all. The eight lane jobs were skipped for the same label reason (their names carry the "Not run for label" prefix), and the fast tiers that do run for outside pull requests - "Test coverage guard" and "Repo invariants" - both pass.
FM_CI_LANES_FAILED=false: no actual lane failed.Per CONTRIBUTING.md, the full suite runs for an outside pull request once a maintainer adds the
full-cilabel. We cannot apply labels from this fork, so: please add thefull-cilabel if you want the full suite executed here; the check will then report real lane results. We have made no workflow, gate, threshold, or test changes to work around the gate, and will not.What the guard fixes, in one paragraph
Herdr caps agent names at 32 characters. Before this change, a task id longer than that cap made spawn or relaunch report success while Herdr's inner
agent startrejected the name (invalid_agent_name) and the replacement agent never booted - a silently dead endpoint that still looked alive to supervision. With this change, all three entry points (fresh spawn,fm-spawn --relaunch,fm-control relaunch) refuse an over-cap id before any pane, tab, workspace is created or any old agent is stopped, naming the cap, the offending id and length, and the shorter-id hint. Ids within the cap and every non-herdr backend are untouched, andtests/fm-spawn-herdr-name-cap.test.shproves the refusal at the exact 32/33 boundary (it fails without the guard).