Skip to content

feat: add Muse Code crewmate adapter - #1786

Merged
kunchenguid merged 10 commits into
mainfrom
fm/muse-code-crewmate-adapter-r1
Aug 6, 2026
Merged

kunchenguid merged 10 commits into
mainfrom
fm/muse-code-crewmate-adapter-r1

Conversation

@kunchenguid

Copy link
Copy Markdown
Owner

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:

  • ADOPT NOW: implement as far as possible WITHOUT a META_API_KEY. The real-model multi-step credentialed smoke is DEFERRED until the captain provides the key, and must be documented clearly rather than treated as missing work. The scout report recommended WAIT; the captain overrode that and chose to adopt now.
  • Do NOT force-disable muse's auto-update. The captain explicitly accepts the beta/self-update risk, so MUSE_NO_AUTO_UPDATE is optional documentation and must NOT be a mandatory spawn env var. Its absence from the launch command is deliberate, not an oversight.
  • yolo on for this ship.
  • The authoritative investigation is the scout report at data/muse-code-crewmate-harness-s1/report.md (private to the firstmate home, not in this repo).

Required work, in the scout's implementation order:

  1. Detection in bin/fm-harness.sh via prefix match on muse-bin-*, because muse's installed launcher execs a version-suffixed binary whose name changes on every auto-update.
  2. Spawn in bin/fm-spawn.sh: positional brief (the Grok/Pi shape), autonomy flags, --model, --reasoning-effort mapped from firstmate's shared effort vocabulary, trust-dialog handling, detection/escalation of an unauthenticated login hang, and a deliberate sandbox/network posture because a crewmate needs git and network.
  3. Busy source in bin/fm-busy-lib.sh from muse's session JSONL run lifecycle, explicitly NOT the experimental plugin/hook system.
  4. Composer glyph U+27E9 added to bin/fm-composer-lib.sh.
  5. Interrupt path clears the composer after Escape, because muse restores the interrupted prompt as live text.
  6. A deliberate posture on muse's native sub-agents and nested worktrees, including the teardown interaction.
  7. Verified facts recorded in .agents/skills/harness-adapters/SKILL.md, mechanics in fm-spawn; never dispatch on an unverified adapter.
  8. Portable regressions plus a live opt-in guard where applicable.

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:

  • SUPERSESSION, privacy control. The brief and scout both said to pass --no-foreign-personal-context by default. Live verification proved that flag is 'muse exec' ONLY: the interactive TUI rejects it with 'unexpected argument'. The accepted replacement, verified live, is MUSE_EXPERIMENTAL_FOREIGN_PERSONAL_CONTEXT_KILL=on, which drops muse's loading of the operator's foreign ~/.claude personal rules while KEEPING the project's own AGENTS.md rules. So the absence of --no-foreign-personal-context and the presence of that env var are both deliberate and load-bearing, not a substitution error.
  • Login-prompt handling is a SPAWN PREFLIGHT (META_API_KEY, else /muse/auth.json), not a rendered-screen check, because an unauthenticated muse pane never exits: it waits forever on an OAuth device-code prompt, which supervision would misread as a wedged worker.
  • Effort mapping: low/medium/high/xhigh map straight across; firstmate's max maps to muse's 'ultra' ONLY as an explicit captain choice, never as a fallback default, per the brief's 'never select ultra as default max'. muse's none/minimal sit below the shared vocabulary and are deliberately unreachable.
  • Busy state is a PULL source with no writer, no arm, and no gen, because muse's default build ships no usable hook surface. Nothing is armed for muse for the same reason standalone Kimi is not: a seeded busy record with no writer could never be cleared. This deliberately mirrors the existing grok and kimi precedents in bin/fm-busy-lib.sh.
  • The IDLE half of the busy source is intentionally GATED CLOSED behind fm_busy_muse_idle_verified. An open run proves busy, but a settled log only proves no run is open at that instant, and the deferred credentialed smoke is what would prove one real turn stays inside one run. Reporting unknown instead of idle is the safe direction. This dead-looking gate is the deferred smoke's one-line landing point, not incomplete work.
  • The fold is anchored on the full structural run-lifecycle prefix rather than a '"kind":"terminal"' search because muse also emits nested cleanup-effect payloads containing that string which are NOT run terminals, and it is depth-bounded because muse's native sub-agents write independent run lifecycles one directory deeper under subagent//.
  • SCOPE ADDITION found during verification: bin/backends/tmux.sh's liveness classifier did not recognise muse either, so a healthy muse crewmate pane would have classified as a dead endpoint and been torn down or relaunched. Fixing that was required for the adapter to work at all. The muse pattern there is anchored (muse|muse-bin*) rather than globbed like its neighbours because 'muse' is a common English fragment and a muse glob would claim musescore or amuse.
  • C-u was added to the herdr, zellij, and cmux key vocabularies so the interrupt clear works on every spawn-capable backend; Orca deliberately keeps refusing unsupported keys.
  • muse is refused for --secondmate in fm-spawn, because a secondmate is a firstmate instance needing a primary supervision protocol that muse has no hook surface for.
  • Firstmate deliberately does NOT exclude any muse path from fm-teardown.sh's uncommitted-work check. The existing .claude exclusion exists because firstmate writes that file itself; it does not write muse's, so nested muse scratch is the agent's own work product and MUST be able to refuse teardown.
  • Deferred work is documented, not omitted: docs/verification/muse.md carries the dated evidence and the exact credentialed-smoke checklist that opens the idle gate.

What Changed

  • Add Muse Code detection and crewmate/scout spawning with credential preflight, foreign personal-context suppression, model and effort mapping, and explicit secondmate refusal.
  • Derive Muse busy state from workspace-bound session lifecycle logs, recognize Muse pane liveness, and clear restored composer text after interrupts across supported backends.
  • Document verified adapter boundaries and deferred credentialed validation, with portable regressions and a live opt-in signal guard.

Risk Assessment

⚠️ Medium: The adapter spans security-sensitive spawn, liveness, interruption, and supervision paths, but the reviewed implementation is fail-closed and no remaining material source defect was substantiated.

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
FM_TEST_BEGIN 2026-08-06T06:57:05Z tests/fm-muse-harness.test.sh family=pure-contract-unit expected_gate_skip=none
ok - muse is detected through any versioned muse-bin ancestor
ok - muse detection does not claim unrelated muse-containing commands
ok - muse launch clears foreign harness markers before ancestry detection
ok - muse spawn launches with autonomy, privacy control, and a positional brief
ok - muse maps the shared effort vocabulary and reaches ultra only via explicit max
ok - muse spawn refuses when no credential can reach the provider
ok - muse spawn refuses a META_API_KEY that cannot reach the worker
ok - muse spawn accepts a stored credential without META_API_KEY
ok - muse resolves relative XDG roots before preflight and launch
ok - muse is refused as a secondmate harness
ok - muse spawn writes a session binding that teardown removes
ok - every accepted muse Escape alias clears the restored composer
ok - the composer clear is scoped to muse and does not touch other adapters
ok - a failed muse composer clear fails loudly instead of leaving stale input
ok - the run fold tracks open, settled, interrupted, reopened, and run-free logs
ok - a nested terminal record never settles an in-flight run
ok - the session binding folds only the log matching this task's worktree
ok - workspace bindings compare decoded paths literally
ok - spawn-time exclusions select the current session across equal mtimes
ok - the Muse session cache avoids rescans and refreshes safely across incarnations
ok - a changed Muse namespace revalidates cached session uniqueness
ok - sub-agent session logs are excluded from the parent's busy fold
ok - every unproven muse binding classifies unknown rather than idle
ok - a settled log stays unknown until the idle gate opens, then reads idle
ok - muse trusts no busy record source
FM_TEST_END 2026-08-06T06:57:55Z tests/fm-muse-harness.test.sh exit=0 duration_ms=50920 gate_skip=false
FM_TEST_BEGIN 2026-08-06T06:57:56Z tests/fm-tmux-agent-liveness.test.sh family=backend-dispatch expected_gate_skip=none
ok - tmux liveness: a harness-named foreground process classifies alive
ok - tmux liveness: muse's version-suffixed muse-bin-<version> classifies alive
ok - tmux liveness: unrelated muse-containing command names stay ambiguous
ok - tmux liveness: a version-named executable under a harness install path classifies alive
ok - tmux liveness: a version-named executable under a decoy path stays ambiguous
ok - tmux liveness: a process neither name source attributes stays ambiguous rather than inventing an agent
ok - tmux liveness: a launcher whose own identity reads as a bare shell classifies alive from its harness child
ok - tmux liveness: an idle shell pane classifies dead
ok - tmux liveness: a harness-named background process in an idle pane still classifies dead
ok - tmux liveness: an absent window classifies missing rather than inheriting tmux's active-window fallback
FM_TEST_END 2026-08-06T06:58:02Z tests/fm-tmux-agent-liveness.test.sh exit=0 duration_ms=6784 gate_skip=false
FM_TEST_BEGIN 2026-08-06T06:58:02Z tests/fm-composer-lib.test.sh family=pure-contract-unit expected_gate_skip=none
ok - fm_composer_classify_content: a bare shell prompt glyph (>/$/%/#) reads unknown, never empty
ok - fm_composer_classify_content: stripped unbordered content is unknown except verified agent glyphs
ok - fm_composer_classify_content: a bare shell prompt carrying a command is not empty
ok - fm_composer_classify_content: a bare prompt glyph inside a bordered composer box reads empty (claude's own idle composer)
ok - fm_composer_classify_content: agent prompt glyphs (❯ claude, › codex, ⟩ muse) read empty bordered or bare
ok - fm_composer_classify_content: an empty composer reads empty
ok - fm_composer_classify_content: a known idle placeholder reads empty, before and after glyph stripping
ok - fm_composer_classify_content: idle matching preserves the caller's case mode
ok - fm_composer_classify_content: real unsubmitted text reads pending (including a popup argument-hint fill)
FM_TEST_END 2026-08-06T06:58:03Z tests/fm-composer-lib.test.sh exit=0 duration_ms=566 gate_skip=false
FM_TEST_BEGIN 2026-08-06T06:58:03Z tests/fm-composer-ghost.test.sh family=pure-contract-unit expected_gate_skip=none
ok - fm_tmux_strip_ghost drops dim/faint runs, keeps normal and bold text
ok - fm_tmux_strip_ghost handles combined SGR, ESC[22m, and reset-then-dim
ok - fm_tmux_strip_ghost keeps bright colored text with 2 payloads
ok - fm_tmux_strip_ghost drops a dark/muted truecolor foreground (grok placeholder)
ok - fm_tmux_strip_ghost keeps muse's near-threshold glyph and its typed text
ok - fm_pane_input_pending: a dim ghost-only composer is NOT pending
ok - fm_pane_input_pending: dim ghost inside a bordered composer is NOT pending
ok - fm_pane_input_pending: normal-intensity typed text is still pending
ok - fm_pane_input_pending: bright colored text with 2 payloads is still pending
ok - fm_pane_input_pending: a dark truecolor ghost-only composer (grok placeholder) is NOT pending
ok - fm_tmux_composer_state: dark truecolor shell prompts read unknown
ok - fm_pane_input_pending: real text plus a trailing ghost run is still pending
ok - fm_tmux_composer_state: text above an empty cursor row is pending
ok - fm_tmux_composer_state: a message wrapped across three rows is pending
ok - fm_tmux_composer_state: Grok's bottom-border cursor quirk reads an empty box structurally
ok - fm_tmux_composer_state: typed Pi and Grok busy signatures inside a box are pending
ok - fm_tmux_composer_state: non-bordered busy footers retain compatibility behavior
ok - fm_tmux_composer_state: an unbounded bordered box fails closed as unknown
ok - fm_tmux_composer_state: clipped and asymmetric composer edges fail closed
ok - fm_tmux_composer_state: inconsistent box geometry fails closed
ok - fm_tmux_composer_state: misaligned box bounds fail closed
ok - fm_tmux_composer_state: unproved ghost, idle, and border geometry stays unknown
ok - fm_tmux_composer_state: differing widths prefer pending or unknown, never empty
ok - fm_tmux_composer_state: emoji and CJK text remain pending under the C locale
ok - fm_tmux_composer_state: all tmux harnesses share empty and pending classification
ok - fm_pane_input_pending: unrecognized states defer by default
ok - fm_tmux_composer_state: fallback capture races cannot admit unbounded edges
ok - fm_tmux_composer_state: only proven structural and non-bordered empty routes stay empty
ok - fm_tmux_composer_state: panes without bordered structure retain compatibility fallback
ok - fm_tmux_composer_state: interior edge glyphs retain non-bordered fallback
ok - fm-peek output is escape-free (no raw -e bytes reach firstmate context)
FM_TEST_END 2026-08-06T06:58:14Z tests/fm-composer-ghost.test.sh exit=0 duration_ms=10992 gate_skip=false
FM_TEST_BEGIN 2026-08-06T06:58:14Z tests/fm-bootstrap.test.sh family=session-bootstrap expected_gate_skip=none
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git

... [5459 bytes truncated] ...

y of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
ok - bootstrap: backend=orca gates the Orca CLI without requiring it on the default backend
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
ok - bootstrap: session-provider backends require their own CLI + jq + treehouse, never tmux
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
ok - bootstrap: a session-provider backend gates its own CLI, never a false tmux requirement
ok - bootstrap: Herdr manual-install guidance is never executed as a shell command
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
ok - bootstrap: the bundled cmux CLI satisfies the active backend dependency
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
ok - bootstrap: unknown resolved backends fail closed with an actionable diagnostic
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
ok - bootstrap: JSON-emitting backends require jq (their genuine dep), never tmux
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
ok - bootstrap: the treehouse lease check follows the resolved backend's worktree provider
ok - bootstrap computes a fleet-size-aware default timeout and preserves partial fleet-sync output
ok - bootstrap keeps the quick 20s default for small fleets
ok - bootstrap preserves FM_FLEET_SYNC_BOOTSTRAP_TIMEOUT as an explicit override
ok - bootstrap treats a blank timeout override as unset
ok - bootstrap computes the timeout before launching fleet sync
ok - bootstrap keeps routine tasks-axi, harness, dispatch, and already-live liveness confirmations silent
ok - bootstrap routine contract runs under system /bin/bash
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
ok - bootstrap surfaces active crew-dispatch rules only as verbose BOOTSTRAP_INFO
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
ok - bootstrap validates crew-dispatch.json and reports malformed or unverified configs
FM_TEST_END 2026-08-06T07:01:55Z tests/fm-bootstrap.test.sh exit=0 duration_ms=221089 gate_skip=false
FM_TEST_SUMMARY total=5 failed=0 skipped_gate=0 duration_ms=290725
FM_TEST_SUMMARY_FAMILY family=backend-dispatch count=1 duration_ms=6784 failed=0
FM_TEST_SUMMARY_FAMILY family=pure-contract-unit count=3 duration_ms=62478 failed=0
FM_TEST_SUMMARY_FAMILY family=session-bootstrap count=1 duration_ms=221089 failed=0
FM_TEST_SLOWEST rank=1 script=tests/fm-bootstrap.test.sh duration_ms=221089
FM_TEST_SLOWEST rank=2 script=tests/fm-muse-harness.test.sh duration_ms=50920
FM_TEST_SLOWEST rank=3 script=tests/fm-composer-ghost.test.sh duration_ms=10992
FM_TEST_SLOWEST rank=4 script=tests/fm-tmux-agent-liveness.test.sh duration_ms=6784
FM_TEST_SLOWEST rank=5 script=tests/fm-composer-lib.test.sh duration_ms=566
fm-test-run: wrote timing artifact: /var/folders/0k/bf8mwt2n5qddzk24r20gfk0c0000gn/T/no-mistakes-evidence/01KZAQJJ13KHPAVCA5QEZKZQC5/muse-targeted-tests.json
Evidence: Muse live-guard skip transcript
FM_TEST_BEGIN 2026-08-06T07:02:20Z tests/fm-muse-signals-live-e2e.test.sh family=live-harness-optin expected_gate_skip=optin-env
skip: set FM_MUSE_SIGNALS_LIVE=1 to run the real Muse signal drift guard
FM_TEST_END 2026-08-06T07:02:20Z tests/fm-muse-signals-live-e2e.test.sh exit=0 duration_ms=57 gate_skip=true
FM_TEST_SUMMARY total=1 failed=0 skipped_gate=1 duration_ms=192
FM_TEST_SUMMARY_FAMILY family=live-harness-optin count=1 duration_ms=57 failed=0
FM_TEST_SLOWEST rank=1 script=tests/fm-muse-signals-live-e2e.test.sh duration_ms=57
fm-test-run: wrote timing artifact: /var/folders/0k/bf8mwt2n5qddzk24r20gfk0c0000gn/T/no-mistakes-evidence/01KZAQJJ13KHPAVCA5QEZKZQC5/muse-live-guard.json
Evidence: Muse ANSI signal parser self-test

ok - Muse glyph color parser follows effective foreground state

ok - Muse glyph color parser follows effective foreground state

Pipeline

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 &gt; 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 at ws[1] can miss its own log and match another session at ws1, 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, so fm-spawn &lt;id&gt; muse --secondmate treats muse as 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 is muse-bin-*, but muse-bin* also claims unrelated names such as muse-binary and muse-bind. Such a foreground process is misidentified as Muse and as a healthy agent endpoint. Narrow this pattern and the sibling tmux classifier to muse-bin-*, retaining exact muse only 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 another 38;2 foreground 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. Thus XDG_CONFIG_HOME=cfg can pass on cfg/muse/auth.json and 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 because NaN &lt; 128 is 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.json
  • bin/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.json
  • tests/fm-muse-signals-live-e2e.test.sh --ansi-self-test
  • command -v muse || true
  • git status --short
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

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
kunchenguid force-pushed the fm/muse-code-crewmate-adapter-r1 branch from 760c77c to 731d221 Compare August 6, 2026 07:25
@kunchenguid
kunchenguid merged commit 930ca76 into main Aug 6, 2026
13 checks passed
@kunchenguid
kunchenguid deleted the fm/muse-code-crewmate-adapter-r1 branch August 6, 2026 07:36
kaku-san added a commit to kaku-san/firstmate that referenced this pull request Aug 7, 2026