Repository navigation
feat: add Muse Code crewmate adapter - #1786
Merged
Merged
Conversation
Muse Code joins the fleet as a crewmate/scout adapter, verified live against Muse Code 0.1.0-R708.1 in an isolated lab. Detection matches the anchored prefix muse-bin*, because the installed launcher execs a version-suffixed binary whose name changes on every auto-update and whose install path carries no muse component to fall back on. The same identity is taught to the tmux liveness classifier, without which a healthy muse pane would have read as a dead endpoint. Busy state folds muse's own durable session event log, bound per task by a sessions-root/worktree sidecar. It is a pull source with no writer, so nothing is armed and no record is ever seeded. The fold is anchored on the full run lifecycle prefix so muse's nested cleanup "terminal" payloads cannot settle an in-flight run, and it is depth-bounded so muse's native sub-agent logs cannot be mistaken for the parent's. The idle half stays gated: an open run proves busy, but a settled log reads unknown until a credentialed multi-step run proves one turn stays inside one run. Two findings corrected the scout report. The exec-only --no-foreign-personal-context flag is rejected by the interactive TUI, so the privacy control that actually reaches a pane worker is MUSE_EXPERIMENTAL_FOREIGN_PERSONAL_CONTEXT_KILL, verified to drop the operator's foreign personal rules while keeping the project's own AGENTS.md. And an unauthenticated muse pane never exits, it waits on a device-code prompt, so credentials are a spawn preflight rather than a screen check. muse is refused for secondmates: it has no primary supervision protocol and its hook dialect rejects the reawakening handlers that protocol needs. Per the captain's decision, auto-update is not pinned, and the credentialed multi-step smoke is deferred with an explicit checklist in docs/verification/muse.md.
kunchenguid
force-pushed
the
fm/muse-code-crewmate-adapter-r1
branch
from
August 6, 2026 07:25
760c77c to
731d221
Compare
Intent
Ship a verified Muse Code crewmate harness adapter for Firstmate. Muse Code is CREWMATE/SCOUT ONLY, deliberately not a firstmate primary and not a secondmate.
Captain decisions that shaped this work:
Required work, in the scout's implementation order:
Constraints: this is firstmate's own shared tracked material, so the firstmate-coding-guidelines skill governs it (one-owner rule, AGENTS.md size discipline, one sentence per line in tracked Markdown, plain dash never em dash, shellcheck-clean bin scripts, colocated tests named .test.sh, no test may assert implementation source bytes, and harness-dependent checks need both a portable regression and a live opt-in guard).
Decisions and findings made while doing the work, which a reviewer reading only the diff would not know:
What Changed
Risk Assessment
Testing
No baseline results were supplied. All targeted adapter, composer, bootstrap, and real-tmux process checks passed and CLI evidence was captured; the ANSI parser passed its negative-control self-test. The opt-in real Muse guard skipped as designed, and Muse is not installed on this machine, so no new real-harness run or visual artifact was possible. This is a CLI-only change, and the accepted credentialed multi-step smoke remains deliberately deferred with the idle gate closed.
Evidence: Targeted Muse adapter behavior transcript
Evidence: Muse live-guard skip transcript
Evidence: Muse ANSI signal parser self-test
ok - Muse glyph color parser follows effective foreground statePipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
🔧 **Review** - 2 issues found → auto-fixed (8) ✅
bin/fm-spawn.sh:1025- The required "SPAWN PREFLIGHT (META_API_KEY, else <config>/muse/auth.json)" checks the fm-spawn process environment, but the worker is created by a long-lived backend daemon and the launch command forwards neither META_API_KEY nor XDG_CONFIG_HOME. A command-scoped key or credential in a custom config root therefore passes preflight, then the pane sees no credential and hangs on OAuth. Make the preflight evaluate the worker-effective environment or securely hand the credential/config root across the spawn boundary.bin/fm-bootstrap.sh:900- Muse is documented and launched as verified, but the dispatch-profile validator still omits it from verified($h), so any crew-dispatch.json profile selecting muse is rejected as "unverified harness." Add muse to this registry and validate its supported effort set low|medium|high|xhigh|max.🔧 Fix: Accept Muse dispatch profiles and shared efforts
2 errors still open:
bin/fm-spawn.sh:1025- The required "SPAWN PREFLIGHT (META_API_KEY, else <config>/muse/auth.json)" still checks fm-spawn's environment, although the pane is created by a long-lived backend daemon that does not inherit it (as fm-spawn itself documents at line 2209). Neither META_API_KEY nor XDG_CONFIG_HOME is forwarded in the launch command. A command-scoped key or custom config root therefore passes preflight, then the worker hangs on OAuth. XDG_DATA_HOME has the same split, causing the busy sidecar to point at a log root the worker does not use. Evaluate credentials against the worker-effective environment or securely hand the credential and XDG roots across the launch boundary.bin/fm-busy-lib.sh:347- Session selection ranks matching logs using integer-second mtime and retains the first path on ties. If a restarted Muse session creates its active log in the same second as an older settled log, find may return the old log first and the strict>comparison keeps it. The active turn then reports unknown instead of busy, allowing stale/wedge escalation; once the idle gate opens it can report false idle. Bind the task to the exact main session log during spawn readiness, or use a collision-free ordering backed by Muse session metadata.🔧 Fix: Bind Muse busy state to current session
3 errors still open:
bin/fm-spawn.sh:1025- The credential preflight still checks fm-spawn's environment, but the long-lived backend daemon does not inherit it and the launch command forwards neither META_API_KEY nor XDG_CONFIG_HOME. A command-scoped key or custom credential root therefore passes preflight, then Muse waits indefinitely for OAuth. XDG_DATA_HOME has the same split, leaving busy-state binding pointed at the wrong session root. Evaluate the worker-effective environment or securely transfer the credential and XDG roots across the spawn boundary.bin/fm-busy-lib.sh:335- Workspace matching interpolates the worktree path into a shell case pattern, so valid glob characters are interpreted rather than compared literally. For example, a task atws[1]can miss its own log and match another session atws1, potentially importing that session's busy state. Decode the metadata workspace_root and compare it literally at this binding boundary.docs/verification/muse.md:185- The required constraint says harness-dependent checks need both a portable regression and a live opt-in guard, but the documented Muse refresh command validates only process liveness. The new busy fold and composer classifier depend on vendor-controlled JSONL structure, glyphs, and colors, with only fixtures covering them. Add an env-gated real-Muse echo-provider guard for those signals while keeping the explicitly deferred credentialed real-model idle smoke separate.🔧 Fix: Compare Muse workspace bindings literally
4 issues (3 errors, 1 warning) still open:
bin/fm-spawn.sh:1025- The Muse preflight checks META_API_KEY and XDG_CONFIG_HOME in fm-spawn's environment, but the long-lived backend daemon does not inherit them and the launch command forwards neither. A command-scoped key or custom credential root therefore passes preflight, then the worker waits on OAuth; XDG_DATA_HOME likewise points the busy binding at a different session root. Evaluate the worker-effective environment or securely transfer the credential and XDG roots across the launch boundary.bin/fm-spawn.sh:926- The new Muse secondmate guard is bypassed by the documented positional harness form: the parser at line 789 omits muse, sofm-spawn <id> muse --secondmatetreatsmuseas a home path. If that directory exists, the command can launch a secondmate with the configured harness instead of refusing the requested Muse adapter. Recognize muse as a positional adapter so this guard receives and rejects it.bin/fm-harness.sh:69- The required installed-binary prefix ismuse-bin-*, butmuse-bin*also claims unrelated names such asmuse-binaryandmuse-bind. Such a foreground process is misidentified as Muse and as a healthy agent endpoint. Narrow this pattern and the sibling tmux classifier tomuse-bin-*, retaining exactmuseonly if needed.docs/verification/muse.md:185- The required harness-dependent verification includes portable regressions plus a live opt-in guard, but the documented guard exercises only process liveness. The busy fold and composer classifier depend on vendor-controlled JSONL structure, glyphs, and colors and currently have fixture coverage only. Add an env-gated real-Muse echo-provider guard for those signals while keeping the explicitly deferred credentialed real-model idle smoke separate.🔧 Fix: Harden Muse worker credentials and live signal verification
2 warnings still open:
docs/configuration.md:210- This user-facing guidance says a caller launch environment is sufficient, but fm-spawn now deliberately rejects caller-only META_API_KEY values unless the backend worker already has the key. Document the worker-reachable requirement and identify the stored credential as the portable fleet path.bin/fm-busy-lib.sh:364- Every Muse busy classification starts Node, traverses the entire unbounded historical sessions tree, and opens every main log's metadata before folding one file. Watch and supervision paths call this synchronously, so accumulated Muse history can increasingly delay fleet supervision. Persist the uniquely resolved current session log at the binding boundary, then fold that exact path on subsequent checks.🔧 Fix: Cache Muse session bindings and clarify worker credentials
2 issues (1 error, 1 warning) still open:
bin/fm-spawn.sh:875- The Muse launch inherits foreign primary-harness markers even though fm-harness checks CLAUDECODE, PI_CODING_AGENT, and GROK_AGENT before process ancestry. For example, a native Claude firstmate starting the tmux server passes CLAUDECODE=1 into Muse, so Muse tool children report claude instead of muse despite the muse-bin-* ancestor. Clear foreign harness markers at the worker launch boundary or provide an authoritative Muse marker.bin/fm-send.sh:97- The post-interrupt clear recognizes only the exact key spelling Escape, while every backend accepts aliases such as Esc and escape. Sending an accepted alias interrupts Muse but skips C-u, leaving the restored prompt to corrupt the next steer. Normalize the key before applying Muse's post-interrupt behavior.🔧 Fix: Clear Muse marker inheritance and normalize interrupt aliases
1 error still open:
tests/fm-muse-signals-live-e2e.test.sh:111- The required live guard does not actually prove the prompt glyph's effective foreground color. Its regex permits another38;2foreground escape between the captured RGB and⟩, so Muse could change the glyph to a dark color and this guard would still pass using an earlier bright color on the same row. Parse the ANSI state through the glyph, or reject intervening foreground/reset escapes, then assert the color active at⟩.🔧 Fix: Verify Muse glyph effective foreground color
3 errors still open:
bin/fm-spawn.sh:1113- Relative XDG roots are checked from fm-spawn's cwd but forwarded unchanged to a worker running in the task worktree. ThusXDG_CONFIG_HOME=cfgcan pass oncfg/muse/auth.jsonand then leave Muse unauthenticated, while relative XDG_DATA_HOME similarly splits busy-state binding. Require absolute roots or resolve them before preflight and launch.bin/fm-busy-lib.sh:468- Once a log is cached, the resolver never checks whether another non-prior main session for the same workspace has appeared. Starting a second Muse session after initial resolution therefore bypasses the required ambiguity-to-UNKNOWN invariant and can retain stale busy state from the old log. Invalidate or revalidate the cache when the relevant session namespace changes, then require unique resolution again.tests/fm-muse-signals-live-e2e.test.sh:39- The live glyph parser accepts incomplete truecolor sequences because[].every(Number.isFinite)is true. For example,ESC[38;2m⟩records an empty RGB tuple, computes NaN luminance, and passes becauseNaN < 128is false. Require exactly three integer channels in 0-255 and add this malformed sequence to the negative controls.🔧 Fix: Harden Muse XDG paths, session cache, and glyph parsing
✅ Re-checked - no issues remain.
✅ **Test** - passed
✅ No issues found.
bin/fm-test-run.sh tests/fm-muse-harness.test.sh tests/fm-tmux-agent-liveness.test.sh tests/fm-composer-lib.test.sh tests/fm-composer-ghost.test.sh tests/fm-bootstrap.test.sh --json /var/folders/0k/bf8mwt2n5qddzk24r20gfk0c0000gn/T/no-mistakes-evidence/01KZAQJJ13KHPAVCA5QEZKZQC5/muse-targeted-tests.jsonbin/fm-test-run.sh tests/fm-muse-signals-live-e2e.test.sh --json /var/folders/0k/bf8mwt2n5qddzk24r20gfk0c0000gn/T/no-mistakes-evidence/01KZAQJJ13KHPAVCA5QEZKZQC5/muse-live-guard.jsontests/fm-muse-signals-live-e2e.test.sh --ansi-self-testcommand -v muse || truegit status --short✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.