Repository navigation
feat(bin): add fleet launcher menu backed by a single-owner launch library - #1288
sbracewell64 wants to merge 14 commits into
Conversation
2032c40 to
06a6fbd
Compare
…#1288) feat(bin): add fleet launcher menu backed by a single-owner launch library
|
Automated reminder: thanks for the PR! This branch currently has a merge conflict with the base branch. When you get a chance, please rebase onto (or merge) the latest base branch, resolve the conflict, and push. After that, checks will re-run and the PR will get looked at again. Noted for firstmate#1288 at |
A fleet launcher will soon open PRIMARY firstmate sessions alongside the crewmate sessions fm-spawn.sh opens, so both need the same verified launch commands. Today that knowledge lives only inside bin/fm-spawn.sh, and the drift a second copy causes is not hypothetical: a downstream registry hand-copied claude's command as `claude --dangerously-skip-permissions`, dropping CLAUDE_CODE_ENABLE_PROMPT_SUGGESTION=false - the ghost-text suppression that keeps firstmate from reading predicted-prompt text as real typed input when it captures a pane. Extract launch_template, model_flag_for_harness, and effort_flag_for_harness (plus the shell_quote both flag resolvers depend on) into a new sourced bin/fm-launch-lib.sh, and have fm-spawn.sh source it. Every crewmate, scout, and secondmate template is byte-identical to before, so spawn behavior is unchanged on all six verified adapters. launch_template also gains a `primary` kind for the launcher. A primary session has no task, no worktree, no brief, and no status file, so it launches bare and is greeted by the session-start adapters already installed in the home; each primary template keeps its adapter's verified autonomy flag and claude's ghost-text prefix. An unrecognized kind still resolves to the crewmate shape, and an unverified adapter still returns non-zero for every kind. tests/fm-launch-lib.test.sh pins both arms directly, including a proof that fm-spawn.sh redefines none of the functions and that no other script under bin/ hand-writes a launch command. Existing suites that read the template bytes now read them from their new owner.
…ighten launch-lib ownership
bin/fm-launch.sh is the captain's front door: it renders a five-entry harness menu, starts one firstmate primary session in this home, and attaches to it. The menu is derived and probed, never declared. An entry is available only when its harness binary resolves on PATH, or - for a Pi-routed entry - when the provider named in its model appears in pi's local auth record. Unavailable entries stay visible and dim, each with one actionable line, so the menu never changes shape under the captain's muscle memory. Both probes are local file reads, so the menu touches no network and executes no binary at all. Menu entries carry no launch command. They name a harness plus an optional model and effort, and the command is resolved through bin/fm-launch-lib.sh at launch time - the single owner a downstream registry has already drifted from once by hand-copying a launch string and dropping claude's ghost-text suppression prefix. The launcher states on every render, before the choice, that the session it starts runs without permission prompts. That discharges the consumer obligation bin/fm-launch-lib.sh's header binds on every consumer of a primary template. Herdr is mandatory with no silent fallback to a bare shell, and the gate runs after selection so no socket round trip sits on the critical path. Before creating anything the launcher looks for a primary already running in this home and offers to reattach, so two sessions can never contend for one home's session lock. Selection is one keypress. A human who mistypes gets a redrawn prompt; a scripted caller keeps the refuse-don't-reprompt behavior, and a blank line or EOF refuses rather than launching whatever the default happens to be - taking the default there once started an unattended session nobody chose. Presets live in gitignored config/launch-presets.json and the built-in five need no configuration. They are deliberately not inherited into secondmate homes: a secondmate is provisioned and launched by the primary through bin/fm-spawn.sh, never through this front door, so there would be no consumer for an inherited menu. The Windows entry point and WSL bridge are out of scope here and land separately.
…coverage tests/fm-launch-lib.test.sh's one-owner guards grepped bin/fm-spawn.sh for function definitions and its literal source line, and git-grepped bin/ for launch-command markers - implementation-source assertions the coding guidelines now forbid. Prove the same guarantee behaviorally instead: a sandboxed copy of bin/ shows fm-spawn's launch decision follows a swapped fm-launch-lib.sh in both directions and that fm-spawn cannot take a launch decision without the library, so the launch knowledge has exactly one live owner. The byte-for-byte template pins already go through the public launch_template interface and stay. Co-Authored-By: Claude Fable 5 <[email protected]>
…esh evidence anchors
06a6fbd to
d0c2e12
Compare
sbracewell64
left a comment
There was a problem hiding this comment.
Rebased onto current main (1e247571) and force-with-lease updated the existing contributor branch to d0c2e121. The merge conflict is resolved; the sole semantic conflict in tests/fm-backend.test.sh preserves both the newer upstream fm-secondmate-registry-lib.sh fixture dependency and this PR's fm-launch-lib.sh dependency. Local validation passed for the launcher suites, backend suite, docs audience check, coverage classification, git diff --check, and pinned ShellCheck. GitHub now reports the PR mergeable. The two Actions runs are currently action_required, so they appear to be awaiting repository-side approval before jobs start.
|
Automated reminder: thanks for the PR! This branch currently has a merge conflict with the base branch. When you get a chance, please rebase onto (or merge) the latest base branch, resolve the conflict, and push. After that, checks will re-run and the PR will get looked at again. Noted for firstmate#1288 at |
|
Speaking as Kun's firstmate: closing this as stale. It has been waiting on a contributor update for 14+ days with no author push or comment. Reopen if you want to pick it back up. |
Intent
Build
bin/fm-launch.sh, the firstmate fleet launcher, per an already-reviewed design: a probed five-entry harness menu, a Herdr-mandatory gate, a primary session started atFM_HOME, a reattach guard, tests and docs. Several points were ruled before implementation and are deliberate rather than oversights. All five menu entries ship with availability PROBED rather than declared - an entry is available only when its binary resolves on PATH, or, for a Pi-routed entry, when the provider named in its model appears in Pi's local auth record - and both probes are local filesystem reads with no network at menu time, which is what holds the design's sub-150ms first-paint target. Unavailable entries render dim, visible and unselectable with one actionable fix line each, deliberately not hidden, so the menu never changes shape and the numbering stays stable. The launcher must state at the front door that the session it starts runs WITHOUT permission prompts; that is a binding obligation recorded inbin/fm-launch-lib.sh's header, binding on the session posture rather than on any particular flag, and it is placed in the menu header so it appears before the choice. The Windows surface (firstmate.batand the WSL bridge) is explicitly out of scope and lands separately. This branch is stacked on thebin/fm-launch-lib.shextraction and deliberately builds on it rather than duplicating it: menu entries carry no launch command, and every command is resolved through the library at launch time, because a downstream registry has already drifted once by hand-copying a launch string and dropping Claude's ghost-text suppression prefix. Two decisions were taken during the run and are recorded here: the rebase absorbed main's newpi-signedharness into the extracted library, moving theFM_PI_HARNESSprefix into the library as its single owner rather than leaving it duplicated inbin/fm-spawn.sh, while keepingpi-signeda distinct executable identity that never silently falls back topi; and the launcher now refuses at the door when the home's effective runtime backend is not Herdr, instead of assuming it.What Changed
bin/fm-launch.sh, an interactive fleet launcher: it renders a harness preset menu with live availability probes, refuses non-Herdr backends up front, guards against reattaching over a live primary, holds astate/.launch.lockthrough session startup so concurrent launches can't husk-replace a booting primary, and rejects malformed selections (out-of-range, leading-zero, EOF) with one-line guidance.bin/fm-spawn.shintobin/fm-launch-lib.shas its single owner (verified primary shapes, trust/bypass flags, consumer obligations), with refreshed evidence-anchor citations;fm-spawn.shandfm-backend.shnow consume the library.tests/fm-launch.test.shandtests/fm-launch-lib.test.sh(stubbed end-to-end launch, reattach guard, launch lock, Herdr gate, behavioral library coverage) plus newdocs/launcher.mdand ownership-pointer updates across the harness-adapters skill, README, and configuration docs. One known, documented tradeoff remains: a brief post-lock-release window before the harness registers as an agent, scoped honestly indocs/launcher.md.Risk Assessment
✅ Low: All four requested fixes are correctly implemented with colocated behavioral regression tests and verified citation anchors, the launch lock reuses the established fm-wake-lib primitive exactly as fm-spawn does, and the only remaining item is a documented, deliberately scoped tradeoff.
Testing
Ran the five targeted suites (new launch-lib and launcher suites, changed backend, documentation-audiences, and spawn dispatch-profile) — all passed, proving byte-level launch-command ownership moved to fm-launch-lib.sh without behavior change — then manually exercised the launcher's real CLI surface end-to-end: menu render with autonomy notice, clean quit, all scripted refusals (leading-zero, out-of-range, unavailable harness, EOF), the non-Herdr backend door, and a live launch-lock refusal against a held lock; the full transcript is the evidence artifact since a terminal transcript is this CLI product's rendered surface (no GUI exists to screenshot).
Evidence: fm-launch.sh end-user CLI transcript (menu render, quit, all refusal surfaces, backend door, launch-lock refusal)
$ bin/fm-launch.sh --print-menu Firstmate Sessions start without permission prompts. 1 Claude high ← default 2 ChatGPT Sol gpt-5.6-sol · high via pi 3 Grok grok-4 · high via pi - sign in: pi /login 4 Codex high not installed - install codex 5 OpenCode - not installed - install opencode ⏎ Claude 1-5 select q quit [exit 0] $ printf '01\n' | bin/fm-launch.sh ...menu... '01' is not one of the menu choices. Choose 1-5, or q to quit. [exit 1] $ printf '1\n' | bin/fm-launch.sh # launch lock held by live concurrent pid ...menu... › 1 Claude · high Another launch is already starting a session here. Wait for it to finish, then reattach or retry. [exit 1]Known tradeoff and reconsideration trigger
The launch lock closes the check-and-create race, but it is released immediately after the launch command is sent, before the harness registers as a Herdr agent. A second launcher started inside that residual window can still pass the reattach check and husk-replace a booting primary.
That scope is deliberate rather than an oversight: holding the lock past the send would let an attached launcher's own live pid wedge later relaunches, which is the worse failure.
docs/launcher.mdscopes the guarantee to the lock-held span instead of overstating it.This ships as a documented tradeoff, not a defect. The trigger for reconsidering it is an actually observed husk-replacement of a booting primary, not anticipation of one. If that is ever seen, the closure is a bounded post-send poll for agent registration before the lock is released.
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
🔧 **Rebase** - 3 issues found → auto-fixed ✅
bin/fm-test-run.sh- merge conflict rebasing onto origin/maintests/fm-captain-translation-contract.test.sh- merge conflict rebasing onto origin/maintests/fm-kimi-harness.test.sh- merge conflict rebasing onto origin/main🔧 Fix applied.
✅ Re-checked - no issues remain.
bin/fm-launch.sh:561- Reattach-guard TOCTOU race during primary startup: live_primary_pane only blocks a second launch when fm_backend_herdr_pane_agent_state reports 'live' (a herdr-registered agent). In the window between tab creation/command send and the harness TUI registering as an agent, the primary's pane reads 'no-agent', so a concurrent second fm-launch.sh passes the guard and fm_backend_herdr_create_task's husk-replacement path (dead/no-agent panes are closed and replaced) closes the just-started primary's tab, silently killing it. No lock is taken between the check and the create, and docs/launcher.md claims 'two sessions can never contend for the same home's session lock', which overstates the guarantee for this window. Consider a short-lived launch lock in state/, or having the launcher re-check/refuse instead of relying on create_task's husk replacement for the 'firstmate' label.bin/fm-launch-lib.sh:106- Stale line-number citations in the new library's evidence comments (several invalidated by this branch's own doc edits): SKILL.md:272 for 'pi has no permission system' is actually :277; SKILL.md:276-278 for pi's trust dialog points at the permission-system/pi-signed lines; SKILL.md:304 for grok --always-approve is actually :314; SKILL.md:345 for the fails-open trust fact is actually :355; README.md:105/:106 for once-per-clone trust and extension auto-load are actually :107/:108; docs/configuration.md:177 for the primary-set deferral is actually :191; docs/turnend-guard.md:63 is actually :71; and the header's bin/fm-spawn.sh:446/:450 are actually :466/:470. tests/fm-launch-lib.test.sh comments repeat several of the same stale anchors. Since the header says the tests 'pin each one against those same citations', the anchors should be corrected.bin/fm-launch.sh:520- select_entry_pipe accepts leading-zero input via the [0-9][0-9] pattern: with an 8- or 9-entry preset menu, a scripted selection of '08' or '09' passes the test-builtin range check (decimal) but then crashes inbin/fm-launch.sh:582- The final attach step usesherdr session attach "$session", a CLI form used nowhere else in the repo and never exercised by the suite (every test sets FM_LAUNCH_NO_ATTACH=1), so the launcher's last step has no in-repo verification or recorded empirical evidence, unlike every other herdr CLI fact in bin/backends/herdr.sh. Failure would strand the captain unattached after the session already started. Worth recording the verified syntax (e.g. in docs/herdr-backend.md or a comment citing a live run).🔧 Fix: add launch lock, reject leading-zero input, refresh evidence anchors
1 info still open:
bin/fm-launch.sh:616- Residual (deliberate) startup window after the launch lock: attach() releases state/.launch.lock immediately after the launch-line send, so a second fm-launch.sh started after release but before the harness TUI registers as a herdr agent can still pass live_primary_pane and husk-replace the booting primary's tab. This scope was explicitly prescribed (hold through the send; release before exec so an attached launcher's live pid cannot wedge relaunches), and docs/launcher.md now honestly scopes the guarantee to the lock-held span, so this is a recorded tradeoff rather than a defect. If the window ever matters in practice, a bounded post-send poll for agent registration before releasing would close it.✅ **Test** - passed
✅ No issues found.
bin/fm-test-run.sh tests/fm-launch-lib.test.sh tests/fm-launch.test.sh tests/fm-backend.test.sh tests/fm-documentation-audiences.test.sh tests/fm-spawn-dispatch-profile.test.sh(all 5 suites passed, 0 failures; fm-launch.test.sh covers the stubbed end-to-end launch, reattach guard, launch lock, and Herdr gate)Manual:bin/fm-launch.sh --print-menu— live menu render with availability probes, default marker, and the no-permission-prompts autonomy noticeManual: piped selectionsq,01,9,4, and EOF — clean quit (exit 0) and each refusal surface (leading-zero, out-of-range, unavailable harness, no-selection) with actionable one-line guidanceManual:FM_BACKEND=tmux bin/fm-launch.sh --print-menu— non-Herdr backend refused at the door before the menuManual: heldstate/.launch.lockwith a live pid and selected entry 1 — second launch refused with "Another launch is already starting a session here" before any herdr mutation✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.