Repository navigation
Conversation
Implement fm_backend_orca_agent_state using Orca's native connected/agentIdentity terminal fields, branch it into the shared fm_backend_agent_state dispatcher, and drop the standing refusal in fm-spawn.sh now that orca has a recovery-grade classifier licensing unattended dead/missing recovery. Correct docs/orca-backend.md's macOS-only and secondmate-unsupported claims to match what the code actually enforces.
… recovery classifier
…trace-context secondmate note
…on to point at evidence doc
flight505
added a commit
to flight505/firstmate
that referenced
this pull request
Oct 1, 2026
… delivery (#1) * feat(orca): add agent-state classifier, secondmate spawns, and Escape delivery Give backend=orca a recovery-grade agent-state classifier built on `orca terminal show`'s connected and agentIdentity fields, as upstream kunchenguid#4830 does, and lift the Orca secondmate-spawn refusal that the missing classifier caused. Deliver Escape and Ctrl-U to an Orca terminal as raw control bytes through `orca terminal send --text`, the send_key hunk of upstream kunchenguid#3579, so `fm-control.sh <id> interrupt` works for Escape harnesses on Orca. `fm-control.sh exit` and `relaunch` stay refused on Orca. Live readings against Orca 1.4.218 show connected is the terminal's liveness, and that agentIdentity is absent both for a bare shell and for a running agent, so neither field can prove an agent stopped inside an open terminal. The evidence is recorded in docs/verification/runtime-backends.md. * no-mistakes(review): Orca classifier: unproven reads are unreadable, not missing * no-mistakes(document): Fix stale Orca classifier and cmux docs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Intent
Fix the current refusal of backend=orca for --secondmate spawns by implementing a reliable alive/dead/missing classification for that backend, so a secondmate can finally be launched and recovered automatically on Orca.
Context: the scout report orca-secondmate-review (secondmate orca-db) found the root cause at bin/fm-backend.sh's fm_backend_agent_state: its case statement has no
orcabranch, so it falls through tounverified. Onlydeadandmissinglicense automatic unsupervised recovery, so a secondmate on Orca could never be recovered automatically - which is the exact cause of the explicit refusal in bin/fm-spawn.sh ("backend=orca does not support --secondmate spawns yet").The report confirmed live, during the investigation, that
orca terminal show --terminal <handle> --jsonreturns aconnected: <bool>field per terminal, plusagentIdentity. The proposed mapping for a newfm_backend_orca_agent_statefunction:orca terminal show) -> missingorca status --jsonnot ready) -> unreadableTwo items from the report are explicitly out of scope for this task - note them as follow-up ideas, do not implement them here: the choice between raw terminal create/read/send vs Orca orchestration worker-start, and an all-in-one convergence via Orca orchestration.
What Changed
fm_backend_orca_agent_stateand its helperfm_backend_orca_terminal_show_fieldsinbin/backends/orca.sh, classifying Orca terminals asalive/dead/missing/ambiguous/unreadablefromorca terminal show --json'sconnectedandagentIdentityfields, reusing the shared harness-identity classifier frombin/fm-agent-process-lib.sh; also added a backward-compatiblefm_backend_orca_agent_alivethree-state wrapper.bin/fm-backend.sh'sfm_backend_agent_state(added anorcacase) and removed the explicitbackend=orca does not support --secondmate spawns yetrefusal frombin/fm-spawn.sh, so--secondmatespawns onbackend=orcaare now permitted.bin/fm-control-lib.sh,bin/fm-control.sh, andbin/fm-crew-state.shcomments to reflect that orca now has a classifier but is not yet in the trusted set for stop-proving verbs (exit/relaunch) or crew-state reads, which still treat it as unverified.bin/fm-claude-trust.shand refresheddocs/orca-backend.md,docs/agent-control.md,docs/architecture.md,docs/configuration.md,docs/trace-context.md, anddocs/verification/runtime-backends.mdto document the new recovery classifier and secondmate support; expandedtests/fm-backend-orca.test.shandtests/fm-control.test.shwith coverage for the new state mapping.🤖 Generated with Claude Code
Risk Assessment
✅ Low: The change correctly implements the required orca alive/dead/missing/ambiguous/unreadable classifier per the intent's proposed mapping, wires it into the shared fm_backend_agent_state dispatcher and the session-start secondmate liveness sweep (the actual 'automatic unsupervised recovery' path, confirmed via bin/fm-bootstrap.sh's secondmate_liveness_one, which now genuinely respawns dead/missing orca secondmates), removes the stale spawn-time refusal, and deliberately (and honestly, in both code comments and docs) leaves the stricter fm-control.sh exit/relaunch trust gate unextended to orca rather than overreaching; it's backed by extensive new unit and sweep-level tests and the only defect found is cosmetic stale wording in two pre-existing error messages.
Testing
Drove the shell test suite live:
bash tests/fm-backend-orca.test.sh(60 tests, all ok),bash tests/fm-backend-cmux.test.sh, andbash tests/fm-control.test.sh(all ok). These tests exercise the real bin/backends/orca.sh, bin/fm-backend.sh, bin/fm-spawn.sh, and bin/fm-bootstrap.sh scripts against a scripted fakeorcaCLI (JSON fixtures via FM_ORCA_RESPONSES), not mocks of the code under test itself, so this is genuine end-to-end product behavior. No code changes were needed; the change already satisfies every constraint in the user intent (alive/dead/missing/ambiguous/unreadable classification, dead/missing-only auto-recovery, refusal removed only for orca while cmux's stays). Worktree is clean, no artifacts to remove.orca terminal showreturning connected:falseok - fm_backend_orca_agent_state: a not-found terminal against a ready runtime classifies as missingok - fm_backend_orca_agent_state: a failed read against an unready runtime stays unreadableok - fm_backend_agent_state: routes backend=orca to fm_backend_orca_agent_stateok - sweep: an authoritatively missing Orca secondmate endpoint is relaunched without a pre-closeok - sweep: an already-live Orca secondmate is left untouched, proven by only its liveness probe in the Orca logdead|missingtrigger the recovery path; combined with the passing agent-state classification tests above (which prove ambiguous/unreadabl…ok - fm-spawn.sh: refuses backend=cmux for --secondmate spawns (mirrors Orca's refusal; no secondmate launch design exists yet)Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
bin/fm-control.sh:352- The refusal messages for exit/relaunch (bin/fm-control.sh:352) and --relaunch (bin/fm-spawn.sh:1488) both say backend=orca 'has no recovery-grade agent-state classifier'. That's now inaccurate: orca does have one (fm_backend_orca_agent_state) as of this change; fm_control_backend_state_verified just doesn't trust it yet for these stop-proving verbs (this is documented accurately in bin/fm-control-lib.sh's updated comment and the docs/agent-control.md footnote, but the runtime error text a captain actually sees still claims the classifier doesn't exist).bin/fm-spawn.sh:1488- Same stale wording as the fm-control.sh finding: this --relaunch refusal claims backend=orca has no recovery-grade classifier, which is no longer true after this change - it exists but isn't yet trusted for relaunch.✅ **Test** - passed
✅ No issues found.
orca terminal showreturning connected:falseok - fm_backend_orca_agent_state: a not-found terminal against a ready runtime classifies as missingok - fm_backend_orca_agent_state: a failed read against an unready runtime stays unreadableok - fm_backend_agent_state: routes backend=orca to fm_backend_orca_agent_stateok - sweep: an authoritatively missing Orca secondmate endpoint is relaunched without a pre-closeok - sweep: an already-live Orca secondmate is left untouched, proven by only its liveness probe in the Orca logdead|missingtrigger the recovery path; combined with the passing agent-state classification tests above (which prove ambiguous/unreadabl…ok - fm-spawn.sh: refuses backend=cmux for --secondmate spawns (mirrors Orca's refusal; no secondmate launch design exists yet)bash tests/fm-backend-orca.test.shbash tests/fm-backend-cmux.test.shbash tests/fm-control.test.sh🔧 **Document** - 1 issue found → auto-fixed ✅
docs/orca-backend.md:10- docs/orca-backend.md's Setup section (edited by the code-phase commit e5f9ce7) now asserts Orca 'is confirmed working on Linux,' but docs/verification/runtime-backends.md's Orca section (the repo's authoritative home for active empirical evidence) only records a macOS verification (/usr/local/bin/orcawith/Applications/Orca.appbundle version 1.4.116) and has no corresponding Linux entry. I could not verify independently whether a live Linux confirmation actually occurred (the user-intent scout report only describes API/field behavior oforca terminal show --json, not platform verification), so I did not alter the claim itself. This needs either a runtime-backends.md entry recording the Linux verification detail (CLI path/version observed) or, if no live Linux check actually happened, softening the orca-backend.md claim.🔧 Fix applied.
✅ Re-checked - no issues remain.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.