Repository navigation
feat(orca): add agent-state classifier, secondmate spawns, and Escape delivery - #1
Merged
Merged
Conversation
… 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.
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
It would be good to look into these limitations and see if they are easy to fix. A: go. Three easy gaps now, busy signal later.
The limitations are the Orca runtime backend's "Active limits" in docs/orca-backend.md and docs/architecture notes: Firstmate cannot prove an Orca worker stopped, so
bin/fm-control.sh <id> exit|relaunchrefuse on backend=orca; secondmate spawns are refused on Orca for the same reason; and Escape (interrupt) is unsupported on Orca. The three gaps to close now, on our fork flight505/firstmate (fork main = upstream kunchenguid/firstmate main + our Orca nesting patch):orca terminal show(itsconnectedandagentIdentityfields), as upstream PR fix(backends): implement orca agent-state classifier to unblock secondmate spawns kunchenguid/firstmate#4830 (kunchenguid/firstmate, "fix(backends): implement orca agent-state classifier to unblock secondmate spawns") does, sofm-control.sh exitandrelaunchwork on Orca.fm-control.sh <id> interruptdeliver a real Escape to an Orca terminal (and Ctrl-U where the adapter uses it), as thesend_keyhunk of upstream PR Orca backend parity: secondmate support, real Escape/Ctrl-U, rendered-screen reads kunchenguid/firstmate#3579 ("Orca backend parity") does; take only that hunk, not the rest of that draft PR.Out of scope for now: a native Orca busy signal (
orca terminal wait --for tui-idle,orca worktree ps --json, upstream PR feat(bin): add native Orca supervised workers and Secondmates kunchenguid/firstmate#5348), and upstream PR fix: correct Pi wake ownership and processing-turn handling kunchenguid/firstmate#5835, which only matters for a Pi first mate.Delivered scope for item 1 is the agreed fallback: the classifier is added as upstream PR kunchenguid#4830 does, but
fm-control.sh exitandrelaunchstay refused on Orca, with the reason stated in the docs. A live probe against Orca 1.4.218 showed thatorca terminal showcannot prove an agent stopped while its terminal stays open (connectedis the terminal's liveness, andagentIdentityis absent both for a bare shell and for a running agent), andorca worktree psadds no proof. Upstream PR kunchenguid#4830 itself also leaves exit and relaunch refused. If no sound stop proof exists, exit and relaunch must keep refusing rather than report an unproven stop.What Changed
fm_backend_orca_agent_stateinbin/backends/orca.sh, and wired it intofm_backend_agent_stateinbin/fm-backend.sh. It readsorca terminal show(connected,agentIdentity) and returnsalive,ambiguous,dead,missing, orunreadable. Becauseconnectedis the terminal's liveness and not the agent's,fm-control.sh exitandrelaunchstay refused on Orca (fm_control_backend_state_verifiedis unchanged). The reason is stated in the code comments and docs.bin/fm-spawn.sh.fm_backend_orca_send_keyas raw control bytes sent throughorca terminal send --text.fm_control_backend_supports_keynow accepts the same keys for Orca as for tmux, herdr, zellij, and cmux, sofm-control.sh <id> interruptcan work on Orca.tests/fm-backend-orca.test.shandtests/fm-control.test.shto cover the new behavior.Risk Assessment
✅ Low: The fix round matches the decision: only a refused read (exit 2) with a ready runtime gives
missing, and every other unproven read givesunreadable. The new tests run the real function against a fake CLI.Testing
I ran two test files against a fake Orca CLI. All 102 checks passed. I did not drive the real Orca app. That would change the user's live Orca state. So all scenarios are untested live.
Evidence: orca backend test output
Source: orca backend test output
Evidence: fm-control test output
Source: fm-control test output
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
🔧 **Review** - 1 issue found → auto-fixed ✅
bin/backends/orca.sh:260- fm_backend_orca_agent_state reportsmissing(a recovery-licensing verdict) whenever the show read is not a clean connected=true/false andorca statusis ready. That includes a successful read (exit 0) that hasconnectedabsent or non-boolean (connected=unknown) and unparseable JSON (exit 1). A live terminal whose show output lacks the field gets classed as gone. The liveness sweep (fm-watch.sh:1747/1764, fm-spawn.sh:3431 via fm_backend_agent_alive, which maps missing to dead) can then respawn a duplicate secondmate. The comment claims this never gives a false dead/missing, which does not hold for these two shapes. Narrower form: only treat exit 2 (ok:false / command failure) as authoritative absence and returnunreadablefor exit 0 with unknownconnectedand for exit 1.🔧 Fix applied.
✅ Re-checked - no issues remain.
bash tests/fm-backend-orca.test.sh(61 ok, 0 failed, fake Orca CLI)bash tests/fm-control.test.sh(41 ok, 0 failed, fake Orca CLI)✅ **Document** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.