Skip to content

feat(bin): support local Orca secondmates with guarded home retirement - #7401

Open
Cubatica wants to merge 12 commits into
kunchenguid:mainfrom
Cubatica:fm/orca-secondmates-v2
Open

Cubatica wants to merge 12 commits into
kunchenguid:mainfrom
Cubatica:fm/orca-secondmates-v2

Conversation

@Cubatica

@Cubatica Cubatica commented Oct 16, 2026 •

Copy link
Copy Markdown

What Changed

  • fm-spawn.sh --secondmate now works on the Orca backend instead of refusing it. The seeded home is registered as an Orca repository, and a 2ndmate-<id> terminal is opened in the home's root workspace. The helpers for this live in the new bin/backends/orca-home.js and in bin/backends/orca.sh. A state/orca-secondmate-launch receipt is held during launch. That receipt, or existing secondmate metadata, makes spawn refuse a duplicate or uncertain launch. The receipt stays in place whenever terminal creation, workspace binding, or close can't be confirmed. Workers spawned from an Orca secondmate stay independent in their own project repos and are labelled 2ndmate-<id> · fm-<task-id> in both the worktree display name and the terminal title.
  • fm-teardown.sh closes an Orca secondmate's exact terminal and confirms it is gone, including during forced cleanup of child homes. Only after the final teardown gates pass does it retire the registrations the adapter created, then remove the home. It never calls worktree removal on the persistent home and leaves pre-existing registrations alone. Registration receipts are serialized with a per-home lock. fm-backend.sh refuses secondmate metadata whose home and workspace binding don't match.
  • Orca docs, skills and verification notes now describe local secondmates, orca serve runtimes and the label-only worker grouping. They also state that agent-process recovery for Orca is still unverified. Tests added: new Orca backend cases, a send-marker test and an opt-in live end-to-end test (tests/fm-orca-secondmate-live-e2e.test.sh).

🤖 Generated with Claude Code

Risk Assessment

⚠️ Medium: The change adds a new Orca secondmate lifecycle, including destructive retirement of persistent homes and registrations. Every uncertain path traced fails closed and keeps the home and records: incomplete inventory, an unbound or partially created terminal, a pending or foreign registration, a missing setup identity, and a late pending-reply change. The round-1 fix is verified: the launch receipt is kept when the terminal binding is not proven. Real-runtime behavior beyond the measured live proof (Pi restart and recovery) remains intentionally unverified and refused.

Testing

I ran the two changed Orca test suites (fm-backend-orca and fm-send-secondmate-marker) with fake runtimes, a restricted PATH and an isolated fixture home. Both passed with no gate skips, including the round-1 test that a terminal not bound to its home keeps the launch receipt. That test is not a live run, so the scenario is marked untested. Against the real Orca 1.4.224, I drove the product's runtime check and fm-spawn --secondmate from a disposable marked lab home with a seeded secondmate home. Base code refuses Orca secondmates. Head removes that gate and still refuses safely when a leftover launch receipt or existing parent metadata is present, keeping both untouched and leaving Orca's inventory unchanged. I tore down the lab afterwards. I did not re-run the full Orca/Pi lifecycle, the M1 visual check or retirement here, because that would change the captain's real Orca and the plan says not to. Those scenarios rely on the earlier measured proof, so the verdict is inconclusive. There are no screenshots because none of the scenarios I ran shows a UI.

  • Live validation: ⚠️ inconclusive - 4 of 8 scenarios driven live against the product
Scenario Result Live Evidence
The product's Orca runtime gate accepts the real ready Orca runtime ✅ pass live live-orca-lab-refusals.txt S1: fm_backend_orca_runtime_check exit=0 against Orca 1.4.224
fm-spawn --secondmate --backend orca is no longer refused as unsupported (base refuses, head proceeds to the secondmate path) ✅ pass live live-orca-lab-refusals.txt S2 vs S3: base prints 'backend=orca does not support --secondmate spawns yet'; head reaches the seeded-home receipt check
Adversarial: a retained partial-launch receipt in the seeded home blocks a duplicate Orca secondmate launch and is preserved ✅ pass live live-orca-lab-refusals.txt S3: 'unfinished Orca secondmate launch; reconcile …' exit=1, receipt contents intact, no parent meta written, Orca inventory digest unchanged
Adversarial: existing parent secondmate metadata refuses relaunch (recovery unverified) without touching the record ✅ pass live live-orca-lab-refusals.txt S4: 'existing Orca secondmate metadata … refusing duplicate launch' exit=1, meta unchanged
Adversarial (review fix): returned terminal absent from the home inventory keeps the launch receipt and refuses a duplicate spawn, while other Orca home/registration/retirement guards hold ⏸️ untested no The earlier payload did not show a live result for this scenario. It was checked only with fake runtimes (focused-tests.log: 'ok - Orca secondmate spawn retains its receipt when the returned terminal…
Seeded home registered in Orca with Pi chat terminal visible in the captain's M1 Orca under M6 clean, plus a labelled independent read-only olilit scout (2ndmate-&lt;id&gt; · fm-&lt;task&gt;, no parent) ⏸️ untested no Not re-driven in this run. It would register new repos and open Pi terminals in the captain's real Orca app, a shared operator service, and needs human visual confirmation on the M1. The verification…
Guarded retirement closes the exact home terminal, removes only owned registrations, then the home and route ⏸️ untested no Retirement needs a live secondmate created first (previous scenario), which would change the captain's real Orca. The plan forbids resurrecting the retired proof identities. Fake-runtime tests cover i…
Orca secondmate steers go through the durable inbox and correlated parent channel ⏸️ untested no This needs a running Pi secondmate in real Orca, so it has the same shared-service and authorization limits as the lifecycle scenario above. It was covered by a fake-runtime test and by the earlier me…
Evidence: Live real-Orca lab transcript: runtime gate, base vs head secondmate spawn, receipt/metadata refusals, unchanged Orca inventory

Source: Live real-Orca lab transcript: runtime gate, base vs head secondmate spawn, receipt/metadata refusals, unchanged Orca inventory

# Live lab: real Orca 1.4.224; marked canonical lab FM_HOME; seeded secondmate home 'labmate' (registry route above)
Orca structural inventory (repo paths + worktree ids) before: 93393c55b6c0eaf6; lab-path mentions: 0

## S1 product runtime gate vs real Orca: fm_backend_orca_runtime_check
exit=0

## S2 BASE 5f2b81b: fm-spawn labmate --secondmate --backend orca --harness pi, with launch receipt planted
error: backend=orca does not support --secondmate spawns yet
exit=1

## S3 HEAD: same spawn with retained partial-launch receipt in seeded home
error: unfinished Orca secondmate launch; reconcile /private/var/folders/mq/wz0rqb2x45x3lpk876pv0n1c0000gn/T/fm-lab-mate.B0i3G3/home/state/orca-secondmate-launch before retrying
exit=1
receipt still present: attempt=lab-probe-planted-receipt
parent state/labmate.meta: none

## S4 HEAD: spawn with pre-existing parent metadata state/labmate.meta (no receipt)
●  watcher supervision needs Stop-owned automatic recovery; inspect the hook registration and startup status before ending the turn.
●━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
error: existing Orca secondmate metadata for labmate; recovery is unverified, refusing duplicate launch
exit=1
parent meta unchanged: window=lab-planted

Orca structural inventory after: 93393c55b6c0eaf6 (unchanged: yes); lab-path mentions: 0
Evidence: Hermetic focused suite log (fm-backend-orca, fm-send-secondmate-marker)

Source: Hermetic focused suite log (fm-backend-orca, fm-send-secondmate-marker)

FM_TEST_BEGIN 2026-10-16T11:07:49Z tests/fm-backend-orca.test.sh family=orca expected_gate_skip=optional-binary
ok - fm_backend_orca_capture: parses result.terminal.tail and calls terminal read
ok - fm_backend_orca_capture: falls back to result text fields
ok - fm_backend_orca_capture: fails closed on Orca read error JSON
ok - fm_backend_orca_runtime_check: accepts reachable ready runtime
ok - fm_backend_orca_runtime_check: fails closed when runtime is not ready
ok - fm_backend_orca_send_text_submit: verifies empty composer after Enter with one bounded read
ok - fm_backend_orca_send_text_submit: a borderless claude composer confirms delivery (the missing #2029 shape)
ok - fm_backend_orca_composer_state: a stale startup banner cannot outrank the live composer row
ok - fm_backend_orca_send_text_submit: retries Enter while composer remains pending
ok - fm_backend_orca_composer_state: a slash-command popup's argument-hint placeholder still reads pending
ok - fm_backend_orca_composer_state: a bare dead-shell prompt reads unknown (unsafe-for-injection), never empty
ok - fm_backend_orca_send_text_submit: a slash-command popup's placeholder fill on Enter #1 does not short-circuit as submitted; Enter #2 is retried and lands it
ok - fm_backend_orca_send_literal: sends text without submitting
ok - fm_backend_orca_send_text_submit: reports send-failed when Orca send fails
ok - Orca send helpers: fail closed on ok:false JSON
ok - fm_backend_orca_send_key: Enter maps to empty enter, C-c maps to interrupt
ok - fm_backend_orca_send_key: refuses unsupported keys loudly
ok - fm_backend_orca_send_key: refuses Escape instead of mapping it to interrupt
ok - fm_backend_orca_kill: calls terminal close and stays best-effort
ok - fm_backend_orca_kill: a close its missing CLI never attempted reports the failure instead of a success
ok - fm_backend_orca_remove_worktree: refuses empty worktree ids
ok - fm_backend_orca_remove_worktree: fails closed on ok:false JSON
ok - fm_backend_orca_worktree_path: resolves an Orca worktree id to its path
ok - fm-backend dispatcher: accepts orca and routes capture through bin/backends/orca.sh
ok - fm_backend_orca_json_get: ignores undocumented terminal id shapes
ok - Orca lifecycle helpers: register repo, create worktree, create terminal, parse stable ids
ok - fm_backend_orca_worktree_create: removes created worktree when path is missing
ok - fm-spawn.sh --backend orca: preserves metadata when pathless cleanup fails
ok - fm-spawn.sh --backend orca: reuses implicit terminal, records metadata, launches harness
ok - Orca secondmate launches once, preserves child/close guards, and retires its persistent home safely
ok - Orca secondmate spawn retains its receipt when the returned terminal is not bound to its home
ok - fm-spawn.sh --backend orca: refuses before mutation when Orca runtime is not ready
ok - fm-spawn.sh --backend orca: refuses non-isolated worktrees and closes implicit terminals
ok - fm-spawn.sh --backend orca: removes worktree when terminal creation fails
ok - fm-spawn.sh --backend orca: preserves metadata when abort cleanup fails
ok - fm-spawn.sh --backend orca: releases terminal and worktree on later aborts
●━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
●  WATCHER DOWN - SUPERVISION IS OFF
●  1 task(s) in flight, but no live watcher process holds this home lock (last beat: 0s ago).
●  Trust the emitted supervision protocol for this harness; do not use shell & for watcher repair.
●  This is a supervision warning only; the guarded operation WILL still run.
●  repair missing watcher supervision according to the session-start block for this harness; do not use shell &.
●━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
WARNING: watcher still down (same stale episode; last beat: 1s ago, grace 300s) - full banner already printed this episode.
ok - fm-peek/fm-send/fm-crew-state route through backend=orca metadata and its durable inbox
ok - fm-peek/fm-crew-state: Orca read error JSON fails closed
ok - fm_backend_target_exists: Orca ok:false read JSON is not live
ok - fm-teardown.sh backend=orca: scout report gate then helper-backed worktree removal
ok - fm-teardown.sh backend=orca: scout teardown refuses id/path mismatches
ok - fm-teardown.sh backend=orca: releases terminal/worktree when path is absent
ok - fm-teardown.sh backend=orca: preserves metadata on remove ok:false JSON
ok - fm-teardown.sh backend=orca: scout report gate precedes pathless helper cleanup
ok - fm-teardown.sh backend=orca: ship teardown fails closed when worktree path is missing
ok - fm-teardown.sh backend=orca: ship teardown requires a matching Orca id path
ok - fm-teardown.sh backend=orca: ship teardown fails closed when id resolution fails
ok - fm-teardown.sh backend=orca: ship teardown refuses id/path mismatches
ok - fm-teardown.sh backend=orca: refuses missing worktree ids before cleanup
ok - fm-teardown.sh backend=orca: refuses incomplete worktree-only endpoint metadata before runtime dispatch
ok - fm-teardown.sh --force: removes Orca secondmate children through Orca
ok - fm-teardown.sh --force: refuses Orca child id/path mismatches
ok - fm-teardown.sh --force: refuses partial Orca secondmate children before runtime dispatch
ok - Orca homes preserve uncertain registrations and reject root identity drift
ok - Orca home registration serializes concurrent first workers and keeps the created registration owned
ok - Orca roots bind the separate project setup inventory and refuse missing, ambiguous, or changed identities
ok - Orca home close refuses incomplete inventories and requires positive disappearance
ok - Orca retirement removes only owned empty registrations and retries idempotently
ok - secondmate workers stay independent in their registered project repository
ok - fm-spawn labels both secondmate worker surfaces and confirms no false parent
ok - Orca worker labels refuse false or missing parent postconditions and mismatched visible identities
ok - failed secondmate terminal creation retains its returned identity for exact cleanup
FM_TEST_END 2026-10-16T11:08:48Z tests/fm-backend-orca.test.sh exit=0 duration_ms=59518 gate_skip=false
FM_TEST_BEGIN 2026-10-16T11:08:48Z tests/fm-send-secondmate-marker.test.sh family=secondmate expected_gate_skip=none
ok - fm-send: a kind=secondmate target gets the from-firstmate marker and corr prepended
ok - fm-send: an exact kind=secondmate task id is marked with corr exactly once
ok - fm-send: exact-id and stable-label kind=ship selectors are sent unmarked
ok - fm-send: explicit endpoints stay unmarked with or without local metadata
ok - fm-send: the --key path carries no marker (no literal text is typed)
ok - fm-send: the marker is '[fm-from-firstmate]' + terminal-safe U+2063, while direct captain text stays unmarked
ok - fm-marker: from-firstmate transformation is idempotent
ok - fm-send: marked secondmate payload preserves trailing newline bytes in its record
ok - Orca secondmate steers acknowledge the durable inbox and resolve through the existing parent channel
FM_TEST_END 2026-10-16T11:08:55Z tests/fm-send-secondmate-marker.test.sh exit=0 duration_ms=6591 gate_skip=false
FM_TEST_SUMMARY total=2 failed=0 skipped_gate=0 duration_ms=66204
FM_TEST_SUMMARY_FAMILY family=orca count=1 duration_ms=59518 failed=0
FM_TEST_SUMMARY_FAMILY family=secondmate count=1 duration_ms=6591 failed=0
FM_TEST_SLOWEST rank=1 script=tests/fm-backend-orca.test.sh duration_ms=59518
FM_TEST_SLOWEST rank=2 script=tests/fm-send-secondmate-marker.test.sh duration_ms=6591
fm-test-run: wrote timing artifact: ~/.no-mistakes/evidence/01M525KWAFFWPX30ZX8QEZK2AS/focused-tests.json
exit=0
Evidence: Hermetic focused suite timing JSON

Source: Hermetic focused suite timing JSON

{
  "families": [
    {
      "count": 1,
      "duration_ms": 59518,
      "failed": 0,
      "name": "orca"
    },
    {
      "count": 1,
      "duration_ms": 6591,
      "failed": 0,
      "name": "secondmate"
    }
  ],
  "finished_at": "2026-10-16T11:08:55Z",
  "run_id": "fm-test-run-1792148868988-35759",
  "scripts": [
    {
      "duration_ms": 59518,
      "exit": 0,
      "expected_gate_skip": "optional-binary",
      "family": "orca",
      "gate_skip": false,
      "gate_skip_reason": "",
      "path": "tests/fm-backend-orca.test.sh"
    },
    {
      "duration_ms": 6591,
      "exit": 0,
      "expected_gate_skip": "none",
      "family": "secondmate",
      "gate_skip": false,
      "gate_skip_reason": "",
      "path": "tests/fm-send-secondmate-marker.test.sh"
    }
  ],
  "selection": "scripts;jobs=1",
  "started_at": "2026-10-16T11:07:48Z",
  "summary": {
    "duration_ms": 66204,
    "failed": 0,
    "skipped_gate": 0,
    "total": 2
  }
}

Evidence scope and accepted exception

Relates to #2083.

The automated live verdict is inconclusive: 4 of 8 scenarios driven live in this run.
Firstmate explicitly accepted that Test exception using the earlier measured Orca/Pi lifecycle and M1 visual proof plus the hermetic regressions.
This is not an all-scenarios live pass.
The earlier sanitized live-proof record covers the separately seeded home, Pi terminal, independently labelled read-only olilit scout, correlated reply, M1 visibility under M6 clean, and guarded retirement.
The scout used GitHub deployment status without Railway credentials, CLI or API access; the operational primary fleet was untouched.
Those proof identities were retired and were not resurrected by this run.

The complete scenario mapping, including what the generated tables mean by “untested”, is:

Scenario Actual evidence Limit
1. Ready Orca runtime gate Current published live lab transcript S1; runtime check exits 0 on Orca 1.4.224 Live read-only check
2. Orca secondmate path is supported Current transcript S2/S3: base rejects the backend, head reaches the seeded-home receipt guard Live refusal-path comparison; no successful new launch
3. Partial-launch receipt blocks duplicates Current transcript S3: planted receipt retained, parent metadata absent, inventory unchanged Live CLI against a disposable lab fixture
4. Existing parent metadata blocks duplicates/relaunch Current transcript S4: refusal and metadata unchanged Live CLI refusal; recovery remains unverified
5. Missing or misbound returned terminal preserves receipt Current focused suite and actual spawn/abort regression, failing before the fix and passing afterward Hermetic fault injection only; no live fault induced
6. Seeded home, Pi terminal and labelled independent scout visible on M1 Earlier linked live/UI proof; current worker-label and independent-worktree regressions Earlier live lifecycle, not repeated after the pipeline fixes
7. Guarded retirement removes exact terminal and owned registrations, then home and route Earlier linked live retirement proof; current ownership, retry, inventory, late-recheck and registration-race regressions Successful retirement was live; adversarial/race cases are hermetic
8. Durable steering and correlated parent reply Earlier linked live reply proof; current fm-send-secondmate-marker integration suite Earlier live reply; current run uses a fake runtime

Before pipeline validation, six affected suites passed with zero gate skips: fm-backend-orca, fm-backend, fm-secondmate-safety, fm-send-secondmate-marker, fm-control, and fm-pending-reply.
Lint and documentation-audience checks passed.
Eleven bounded base/head comparisons found no head-only assertion failure: six assertion failures occurred on both revisions; reconciliation and backlog atomicity passed on both; teardown passed on head but timed out on base; captain-hold lifecycle and public followup timed out on both.
The broader local suite did not finish or pass, and further broad reruns were cancelled.
These comparisons do not establish a full-suite pass or complete behavioral equivalence.
Real tmux/Herdr live suites were excluded; no such lifecycle or shared Orca restart was performed.

Orca 1.4.224 rejects cross-repository parenting (LINEAGE_PARENT_CONTEXT_CONFLICT), so worker grouping uses labels, not Orca lineage.
Pi alive/dead state, restart and recovery remain unverified; control-plane exit/relaunch refusal remains in place.
The latest pipeline fix retains the launch receipt when a returned terminal cannot be proven bound to the expected home, in addition to the earlier late-retirement ordering and concurrent receipt-update fixes.

Prior art

Thanks to #3579 for the persistent-home terminal-reuse approach, and #5348 for exact workspace identity, persistent-home protection and explicit unknown-state handling.
These design ideas informed the implementation; neither branch was imported wholesale.
No supervised-worker implementation was imported and no recovery parity is claimed.

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

🔧 **Review** - 1 issue found → auto-fixed → no changes applied ✅
  • ⚠️ bin/backends/orca.sh:95 - fm_backend_orca_close_confirmed treats an 'absent' result from the home-scoped terminal inventory as a confirmed close and returns success without ever sending orca terminal close. That is safe in teardown, where the recorded terminal has already been validated against the home workspace. It is not safe in the secondmate spawn abort path. Concrete sequence: orca terminal create returns handle H (it is written to the launch receipt). The binding check at bin/fm-spawn.sh:4284 then finds H absent from the home workspace inventory, because H is bound elsewhere or not yet listed, and prints 'new Orca secondmate terminal is not bound to its home workspace' and exits. The abort at bin/fm-spawn.sh:1492 calls close_confirmed with the same workspace scope, gets 'absent', returns 0 without closing H, sets SPAWN_ENDPOINT_CLOSED=1 and deletes state/orca-secondmate-launch. So the one condition this check exists to detect ends up reported as a confirmed close. The retained receipt that should block a duplicate launch is removed while H may still be live. This contradicts the intent that 'uncertain identities ... and failed closes ... preserve the home and records'. The same helper is also used at bin/fm-spawn.sh:4637 (rovo endpoint cleanup), but there the terminal had already passed the binding check. Remedy: when the post-create binding check fails, keep the attempt receipt and mark the endpoint not closed. Alternatively, have the abort path always issue orca terminal close --terminal H before trusting a scoped 'absent', and remove the receipt only when that close returns an authoritative success or not-found.

🔧 Fix applied.
✅ Re-checked - no issues remain.

🔧 No changes applied.
✅ Re-checked - no issues remain.

⚠️ **Test** - 1 warning
  • ⚠️ live validation verdict: inconclusive (4 of 8 scenarios were driven live against the product); untested: Adversarial (review fix): returned terminal absent from the home inventory keeps the launch receipt and refuses a duplicate spawn, while other Orca home/registration/retirement guards hold, Seeded home registered in Orca with Pi chat terminal visible in the captain's M1 Orca under M6 clean, plus a labelled independent read-only olilit scout (2ndmate-&lt;id&gt; · fm-&lt;task&gt;, no parent), Guarded retirement closes the exact home terminal, removes only owned registrations, then the home and route, Orca secondmate steers go through the durable inbox and correlated parent channel
  • Live validation: ⚠️ inconclusive - 4 of 8 scenarios driven live against the product
Scenario Result Live Evidence
The product's Orca runtime gate accepts the real ready Orca runtime ✅ pass live live-orca-lab-refusals.txt S1: fm_backend_orca_runtime_check exit=0 against Orca 1.4.224
fm-spawn --secondmate --backend orca is no longer refused as unsupported (base refuses, head proceeds to the secondmate path) ✅ pass live live-orca-lab-refusals.txt S2 vs S3: base prints 'backend=orca does not support --secondmate spawns yet'; head reaches the seeded-home receipt check
Adversarial: a retained partial-launch receipt in the seeded home blocks a duplicate Orca secondmate launch and is preserved ✅ pass live live-orca-lab-refusals.txt S3: 'unfinished Orca secondmate launch; reconcile …' exit=1, receipt contents intact, no parent meta written, Orca inventory digest unchanged
Adversarial: existing parent secondmate metadata refuses relaunch (recovery unverified) without touching the record ✅ pass live live-orca-lab-refusals.txt S4: 'existing Orca secondmate metadata … refusing duplicate launch' exit=1, meta unchanged
Adversarial (review fix): returned terminal absent from the home inventory keeps the launch receipt and refuses a duplicate spawn, while other Orca home/registration/retirement guards hold ⏸️ untested no The earlier payload did not show a live result for this scenario. It was checked only with fake runtimes (focused-tests.log: 'ok - Orca secondmate spawn retains its receipt when the returned terminal…
Seeded home registered in Orca with Pi chat terminal visible in the captain's M1 Orca under M6 clean, plus a labelled independent read-only olilit scout (2ndmate-&lt;id&gt; · fm-&lt;task&gt;, no parent) ⏸️ untested no Not re-driven in this run. It would register new repos and open Pi terminals in the captain's real Orca app, a shared operator service, and needs human visual confirmation on the M1. The verification…
Guarded retirement closes the exact home terminal, removes only owned registrations, then the home and route ⏸️ untested no Retirement needs a live secondmate created first (previous scenario), which would change the captain's real Orca. The plan forbids resurrecting the retired proof identities. Fake-runtime tests cover i…
Orca secondmate steers go through the durable inbox and correlated parent channel ⏸️ untested no This needs a running Pi secondmate in real Orca, so it has the same shared-service and authorization limits as the lifecycle scenario above. It was covered by a fake-runtime test and by the earlier me…
  • env -i HOME=<fixture> TMPDIR=<fixture> FM_LIVE=0 PATH=<restricted hermetic-bin without tmux/herdr/orca/treehouse> bash bin/fm-test-run.sh tests/fm-backend-orca.test.sh tests/fm-send-secondmate-marker.test.sh --json <evidence>/focused-tests.json
  • Live: . bin/fm-backend.sh; fm_backend_source orca; fm_backend_orca_runtime_check against real Orca 1.4.224
  • Live: bin/fm-lab-home.sh create &lt;canonical LAB&gt; + bin/fm-brief.sh labmate --secondmate --no-projects + bin/fm-home-seed.sh labmate &lt;home&gt; --no-projects (disposable seeded secondmate home, registry route)
  • Live: base 5f2b81b fm-spawn.sh labmate --secondmate --backend orca --harness pi (from git archive) → old refusal
  • Live: head fm-spawn.sh labmate --secondmate --backend orca --harness pi with planted state/orca-secondmate-launch receipt → refusal, receipt retained
  • Live: head same spawn with pre-existing parent state/labmate.meta → duplicate-launch refusal, metadata unchanged
  • Before/after structural digest of orca repo list --json paths + orca worktree list --json ids, plus grep for lab paths
  • Teardown: removed lab home, seeded home, fixture dirs; git status --porcelain clean
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thanks @Cubatica, and thanks for re-raising this through no-mistakes. The attestation now binds head 09a42d92. I reviewed it against main 63fc5ebd (17 files). The new Orca secondmate lifecycle is in bin/backends/orca-home.js (only fs/path/crypto, no network and no child processes) and bin/backends/orca.sh. The Orca-gated branches in fm-spawn.sh and fm-teardown.sh keep the receipt and refuse when anything is uncertain, fm-backend.sh checks that a secondmate's home and workspace binding agree, and fm-test-run.sh only classifies the new live-e2e file. Nothing touches .github/, secrets or the network, so I approved fork CI for this head: CI 38893557717 and Require no-mistakes 38894032657.

Contract-class: new-default (my own read, same as on #7397). An Orca --secondmate spawn used to be refused outright. Now it registers the home in Orca, opens a terminal, relabels that home's workers, and retires owned registrations at teardown. That's a new path, not a restore of one that used to work, so it won't auto-merge. Once it's otherwise ready it goes to Kun for a merge-or-leave decision. VISION.md: it aligns. It extends the fleet across another session manager, keeps durable receipts so a restart is a non-event, and every uncertain path refuses instead of guessing.

What I need from you: the live validation on this head is inconclusive (4 of 8). The labelled-worker / M1 visual check, guarded retirement, durable-inbox steering, and the unbound-terminal receipt case still lean on the earlier proof from 9eb029be, and the retirement and registration code has changed since then. When you have a chance, could you run those scenarios live on a disposable seeded home in your own Orca setup and post the evidence here? Re-raising through no-mistakes so it records a live go for the current head works just as well. I'm marking this waiting on you until then.

Overlap notes: this looks like the no-mistakes re-raise of your #7397 (same lifecycle, and 9eb029be is one of this PR's commits). If #7401 replaces it, feel free to close #7397. Nearby but separate work: #7464 (secondmate Treehouse pool routing, which leaves Orca alone), #7382 (restored second mates on their own home), and #7394 (remote secondmate convergence, now merged). GitHub still shows this PR as mergeable with main.

…1" fail. Both were in files this PR changed. 1. **`bin/backends/orca.sh:97` (SC2034):** the retry loop in `fm_backend_orca_close_confirmed` had a counter variable `attempt` that was never read. I renamed it to `_` in the `local` declaration and in the `for` loop. That is the only unused counter in this file, and behaviour is unchanged. 2. **`tests/fm-orca-secondmate-live-e2e.test.sh:17` (SC1091):** ShellCheck could not resolve the sourced `lib.sh`. I added `# shellcheck source=tests/lib.sh` above that line, which is how the other test scripts do it. Checks run: - `shellcheck -x` on both files: no findings. - `bin/fm-lint.sh` on both files: rc=0. - `tests/fm-backend-orca.test.sh`: the last four checks shown passed. I only looked at the tail of the output and didn't capture the exit code, so I haven't confirmed the whole file passed. I didn't run the live Orca test; it only runs when someone opts in
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thanks @Cubatica for the lint fix. The new head 2dc5f5ae changes only two things since 09a42d92: an unused loop counter in bin/backends/orca.sh is renamed to _, and a # shellcheck source= hint goes into the live-e2e test. The attestation binds this head, and nothing touches .github/, secrets or the network. I approved fork CI for this head: CI 39092698561 and the no-mistakes/body-compliance run 39092698426. Both are queued.

Contract-class stays new-default (my own read). VISION.md: it still aligns.

Still waiting on you, same ask as before: the live validation on this head is still inconclusive (4 of 8). The M1 labelled-worker visual check, guarded retirement, durable-inbox steering and the unbound-terminal receipt case haven't been run live on the current code. When you can, please run those on a disposable seeded home in your own Orca setup and post the evidence here, or re-raise through no-mistakes so it records a live go for this head. Once that and CI are green, this goes to Kun as a merge-or-leave decision.

#7397 is still open. If this PR replaces it, feel free to close it.

@Cubatica

Copy link
Copy Markdown
Author

Intent

Finish live validation for #7401 at 2dc5f5ae07f8ef9248bfed2f64578e50824570e7.

What Changed

  • Added live validation evidence only; no source changes.
  • Rechecked steering and guarded retirement against real Orca 1.4.224 / Pi 1.2.0 on the M6 on 2026-10-19.
  • Exercised the unbound-terminal receipt guard with real Orca endpoints and an explicit CLI fault injection.

Risk Assessment

⚠️ Medium: persistent-home retirement remains guarded; automatic Pi process recovery is still unverified and outside this proof.

Testing

The three fresh checks passed at the exact head. The M1 visual check is prior measured evidence, reconfirmed by the operator today, not a fresh visual inspection of this head.

Scenario Result ✅/❌ Live or fixture Evidence
M1 labelled independent worker ✅ prior proof accepted Prior live + human visual confirmation 2026-10-15T23:49:20Z confirmation; M1 “M6 clean” showed the home and labelled worker; operator reconfirmed on 2026-10-19
Guarded retirement ✅ Live, exact head Extra terminal blocked registration/home removal; exact secondmate terminal closed; retry succeeded after extra terminal cleanup
Durable inbox and correlated parent reply ✅ Live Pi, exact head 001.msg moved to handled/; nonce reply matched corr=b27e14ea3a619d15; parent expectation resolved via status
Unbound-terminal receipt ✅ Live Orca with deliberate CLI fault injection, exact head Real terminal created in the other disposable workspace; spawn refused, retained receipt, wrote no parent metadata; duplicate spawn refused
Prior M1 visual evidence and current confirmation

The preserved 2026-10-15T23:49:20Z firstmate confirmation records screenshots plus CLI checks:

  • M1 environment: M6 clean.
  • Home: olilit-orca-test; terminal π - olilit-orca-test (term_48e76916).
  • Independent worker: 2ndmate-olilit-orca-test · fm-orca-proof-labels (term_43e5139c).

The operator reconfirmed today: “the visual check worked we proved it in the past”.
The exact-head verification documentation also records both worker labels and parentWorktreeId=null / lineage=null at docs/verification/runtime-backends.md:2082.
The private source is data/orca-secondmate-build/visual-check-confirmation.txt, with the original report at data/orca-secondmate-build/report.md:32.
This is historical visual acceptance, not a claim that someone inspected the M1 again today.

Exact-head live setup, steering, retirement and fault injection

A fresh standalone seeded home was created beneath /private/tmp/fm-orca-7401.KZHQs1, using the same product entry points as tests/fm-orca-secondmate-live-e2e.test.sh.
The run was narrowed to project-less lifecycle checks because worker labels already have accepted visual proof; the complete launch/verify/retire test script was not rerun verbatim.
Both seeded homes reported 2dc5f5ae07f8ef9248bfed2f64578e50824570e7; no tracked code was edited.

git fetch https://github.com/Cubatica/firstmate 2dc5f5ae07f8ef9248bfed2f64578e50824570e7
git checkout --detach 2dc5f5ae07f8ef9248bfed2f64578e50824570e7
# FM_HOME was the disposable primary throughout:
bash bin/fm-brief.sh lab7401 --secondmate --no-projects
bash bin/fm-home-seed.sh lab7401 "$LAB/mate" --no-projects
FM_SKIP_SECONDMATE_SYNC=1 bash bin/fm-spawn.sh lab7401 --secondmate --backend orca --harness pi
bash bin/fm-send.sh lab7401 'Lifecycle proof nonce ORCA7401-STEER-20261019. Acknowledge this durable inbox message and reply with exactly this nonce through the correlated parent channel, then idle. Do not spawn workers or update code.'

Observed durable acknowledgement: primary/state/lab7401.inbox/handled/001.msg.
Actual parent reply:

done [at=1792372943]: corr=b27e14ea3a619d15 ORCA7401-STEER-20261019
phase=resolved
resolved_via=status

For lab7401ub, a narrow PATH wrapper changed only the terminal create --worktree argument to the first disposable home's workspace.
It forwarded the real Orca response unchanged, and all inventory reads used real Orca.
No fabricated handles or inventory responses were used.
The unchanged spawn guard observed the mismatch:

error: new Orca secondmate terminal term_71711129-1702-4914-8637-c8d3d79f0f1f is not bound to its home workspace
unbound_spawn_exit=1
worktree=25e31f96-bc56-4cd6-b9d8-4738561f89d9::/private/tmp/fm-orca-7401.KZHQs1/unbound
terminal=term_71711129-1702-4914-8637-c8d3d79f0f1f
error: unfinished Orca secondmate launch
 duplicate_spawn_exit=1

The home and receipt survived, parent metadata was absent, and the returned terminal remained live in the other lab workspace.
This proves the guard under live fault injection; it does not claim a spontaneous Orca misbinding occurred.

bash bin/fm-teardown.sh lab7401 first returned:

error: Orca workspace still has terminals
guarded_retire_with_extra_terminal_exit=1
extra_terminal_state=present

Home and parent metadata still existed.
The injected terminal was closed through fm_backend_orca_close_confirmed against its actual workspace; state became absent.
Retrying the same guarded teardown returned:

teardown lab7401 complete (window term_a494e706-fd9a-4076-b13e-3a5b9425c9b4, worktree /private/tmp/fm-orca-7401.KZHQs1/mate)
guarded_retire_completed=yes

The unbound home's empty owned registration was released with fm_backend_orca_home_retire.
Post-retirement scoped inventory: terminals=[], totalCount=0, truncated=false, hostScope.omittedHostIds=[].
Both lab repository queries returned repo_not_found.
No child worktrees were created; both terminals and both owned registrations were cleaned up, as were the disposable home files.
No shared runtime was stopped or restarted.

This replaces #7397, which is superseded and being closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants