Skip to content

Support persistent secondmate homes on Orca - #7397

Closed
Cubatica wants to merge 10 commits into
kunchenguid:mainfrom
Cubatica:fm/orca-secondmate-build
Closed

Cubatica wants to merge 10 commits into
kunchenguid:mainfrom
Cubatica:fm/orca-secondmate-build

Conversation

@Cubatica

Copy link
Copy Markdown

Orca secondmates can now launch in their separately seeded persistent homes, with a chat terminal in the home's registered root workspace.
Their workers use independent Orca worktrees under each project repository, with 2ndmate-<id> · fm-<task-id> labels on both worktrees and terminals.
Guarded retirement closes the recorded terminal and removes only owned, empty registrations before retiring the home.

Relates to #2083.

Behavior and boundaries

  • Reuse the seeded home; do not allocate or remove it as a disposable worker worktree.
  • Preserve normal home isolation, parent-channel steering, correlated replies, child-work guards, and pending-reply guards.
  • Bind registration receipts to exact identities and require complete scoped inventories before proving absence.
  • Keep registrations owned if a late teardown recheck fails; serialize concurrent first registrations so an owned receipt cannot be downgraded to reused.
  • Use labels for grouping. Orca 1.4.224 rejected cross-repository parenting with LINEAGE_PARENT_CONTEXT_CONFLICT, so this change does not claim parent/child lineage in Orca.
  • Keep Pi agent state unverified and preserve exit/relaunch refusal. Terminal presence, completed work, and closed-terminal history do not prove Pi process liveness.

Backend defaults, SSH remote-secondmate transport, home-seeding policy, registry format, harness/account selection, and the supervision architecture retain their existing contracts.

Validation

The original live proof ran on Orca 1.4.224 and Pi 1.2.0 from an isolated code worktree, using a disposable primary home and a separately seeded olilit-orca-test home with a fresh olilit clone.
A read-only scout reported GitHub pull requests, branches, and deployment status without Railway credentials, CLI, or API access.
The secondmate and labelled worker were confirmed in the remote M1 Orca UI under M6 clean, and correlated replies returned to the parent.
Guarded child-first retirement passed; scoped checks confirmed the proof terminals, worktrees, owned registrations, home, and routing records were removed.
The operational primary fleet was untouched.

The following maps all eight no-mistakes Test scenarios to their actual evidence.
The named live-proof artifacts are retained privately; the reusable measured verification record and live test entry point are committed in docs/verification/runtime-backends.md and tests/fm-orca-secondmate-live-e2e.test.sh.
Hermetic tests below execute the real scripts against fake runtime boundaries; they are not live Orca scenarios.

Scenario Evidence Limit
1. Seeded home/root terminal, own FM_HOME, duplicate refusal Earlier live-verify-labels.json; fm-backend-orca.test.sh:test_spawn_orca_secondmate_reuses_seeded_home checks launch, environment and duplicate refusal Duplicate refusal is hermetic; no new live launch after pipeline fixes
2. Independent labelled worker and rejection of false labels/parenting Earlier live-verify-labels.json, visual-check-confirmation.txt; test_spawn_secondmate_worker_labels, test_home_worker_stays_independent, test_worker_label_postconditions_fail_closed Rejection paths are hermetic
3. Late pending-reply change retains registrations, then retry retires Pipeline regression in test_spawn_orca_secondmate_reuses_seeded_home New adversarial path tested hermetically only
4. Concurrent first registrations preserve ownership Pipeline regression test_concurrent_first_registrations_keep_ownership Deterministic hermetic interleaving; no live registration race
5. Child/inventory/identity retirement guards, owned-only removal and retry Earlier live-scout-retirement.md, live-cleanup-resolved-record, live-retire-labels.json, proof-scoped-after-retirement.json; test_spawn_orca_secondmate_reuses_seeded_home, test_home_close_requires_complete_scoped_inventory, test_home_registration_uncertainty_and_binding, test_home_setup_identity_refuses_mismatch, test_home_retirement_ownership_and_retry Successful cleanup was live; injected failures and retry cases are hermetic
6. Real Orca JSON parser contracts Current pipeline live-orca-readonly-contract.txt: real Orca 1.4.224 reads plus crafted negative parser inputs Read-only contract checks, not a new lifecycle
7. Marked steering, inbox acknowledgement and correlated replies Earlier live-labelled-parent-reply.status, live-labelled-scout-report.md, live-cleanup-resolved-record; fm-send-secondmate-marker.test.sh:test_orca_secondmate_inbox_and_correlated_reply Live proof predates pipeline fixes
8. Full Orca/Pi lifecycle, remote UI visibility and clean retirement Earlier live-verify-labels.json, visual-check-confirmation.txt, live-retire-labels.json, proof-scoped-after-retirement.json Full lifecycle and visual check were not repeated after pipeline fixes

Unqualified test function names in this table are in tests/fm-backend-orca.test.sh.
Pi alive/dead recovery, restart and relaunch remain unproven and unsupported by the control plane.

Local validation before the pipeline:

  • 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 the feature head but timed out on base; captain-hold lifecycle and public followup timed out on both.
  • The broader local run did not complete or pass. Matching failures/timeouts do not establish a full-suite pass or complete behavioral equivalence. The follow-up broad sweep was explicitly cancelled.
  • Real tmux/Herdr live suites were excluded; no local tmux/Herdr lifecycle or shared Orca restart was performed.

No-mistakes run 01M51TJ64M49SC7HAQVP67XNBR reviewed this change, fixed the late-retirement ordering and concurrent-registration receipt race, and completed Document and Lint.
Its focused fm-backend-orca, fm-spawn-orca-worktree, and fm-send-secondmate-marker suites passed; the opt-in live lifecycle suite was skipped.
Test classified the automated live verdict as inconclusive because only the read-only real-runtime scenario ran in that validation pass.
An explicit operator exception accepted the earlier live proof plus deterministic hermetic regressions; this is not a fresh all-scenarios live pass.
The run then failed at Push because the authenticated account lacked upstream write permission.
Publication from the fork was explicitly authorized afterward using the exact pipeline head 9eb029be8afac2efda3f0c0ae4000580004c8ab4, preserving both safety fixes and the documentation update.
This is not a completed no-mistakes publication or CI-green attestation.

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.
Those design ideas informed this implementation; neither branch was imported wholesale.
No supervised-worker implementation was imported, and no recovery parity is claimed.

@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: first look on head 9eb029be.

Contract-class: new-default — removes the hard refuse (backend=orca does not support --secondmate spawns yet) and lands persistent seeded-home registration, labelled workers, and guarded retirement for Orca secondmates (bin/backends/orca-home.js, orca.sh, fm-spawn.sh, fm-teardown.sh). Unconfigured Orca --secondmate now takes that path; not a restore of a previously working default.

VISION: aligns on fleet-outlives-vendor (Orca adapter), restart/durability (receipts under the home), and refusal paths; Authority — enabling a previously refused spawn surface is new capability on the Orca secondmate path (captain merge-or-leave when otherwise ready).

Attestation: MISSING — body says this is not a completed no-mistakes publication / CI-green attestation, and there is no no-mistakes-pipeline-attestation HTML bound to this HEAD. no-mistakes is blocking.

Live validation: body reports Test classified the automated live verdict as inconclusive (read-only scenario only in that pass; earlier live proof retained privately). Please live-test the Orca secondmate lifecycle (seeded home, labelled worker, correlated replies, guarded retirement) on a disposable home, post evidence on this PR, or re-raise through no-mistakes so attestation MATCHES 9eb029be… (or the new tip).

workflow-zero. Security: none for fork CI approve — careful refuse/receipt binding; no workflows. (Will re-check if tip changes.)

CI: approved fork runs CI 38873773995 + Require no-mistakes 38873773738 so you get signal; stamping waiting-author until a completed no-mistakes raise binds this HEAD (and live evidence is posted or carried in that raise). Not escalating while attestation/live are open.

@Cubatica

Copy link
Copy Markdown
Author

Measured live lifecycle evidence from Orca 1.4.224 / Pi 1.2.0, with UTC timestamps below. This used a disposable primary home, a separately seeded olilit-orca-test home and a fresh project clone; it did not use the operational fleet.

Commands used by the proof (private paths replaced by variables; the remaining FM_ORCA_PROOF_* variables select those disposable homes and the named scout):

FM_HOME="$PROOF_PRIMARY" bash bin/fm-home-seed.sh olilit-orca-test "$PROOF_HOME" olilit
FM_HOME="$PROOF_PRIMARY" FM_SKIP_SECONDMATE_SYNC=1 bash bin/fm-spawn.sh olilit-orca-test --secondmate --backend orca --harness pi
FM_HOME="$PROOF_PRIMARY" bash bin/fm-send.sh olilit-orca-test '<commission the read-only Orca/Pi scout; report through the correlated parent channel>'
FM_ORCA_SECONDMATE_LIVE=1 FM_ORCA_PROOF_PHASE=verify bash bin/fm-test-run.sh tests/fm-orca-secondmate-live-e2e.test.sh --json "$EVIDENCE/verify.json"
# After the secondmate guarded-cleaned its scouts and the parent resolved the cleanup reply:
FM_ORCA_SECONDMATE_LIVE=1 FM_ORCA_PROOF_PHASE=retire FM_ORCA_PROOF_VISUAL_CONFIRMED=1 bash bin/fm-test-run.sh tests/fm-orca-secondmate-live-e2e.test.sh --json "$EVIDENCE/retire.json"

Observed spawn output (path redacted): spawned olilit-orca-test harness=pi kind=secondmate mode=secondmate yolo=off window=fm-olilit-orca-test worktree=<seeded-home>.
The home was registered as its own repository/root workspace.

UTC observation Recorded evidence
2026-10-15 23:38:28–23:38:31 Live verify exited 0, zero skips: ok - real scout report exists and Orca confirms both worker labels with no parent; inspect both terminals before retirement. Worktree displayName and terminal title both equalled 2ndmate-olilit-orca-test · fm-orca-proof-labels; parentWorktreeId=null, lineage=null, terminal agentIdentity=pi.
2026-10-15 23:38:56 Parent received the correlated completion for orca-proof-labels: the read-only scout had listed pull requests, branches and GitHub deployment status. No Railway credentials, CLI or API were used.
2026-10-15 23:49:20 Operator confirmed the secondmate terminal π - olilit-orca-test and labelled scout in the M1 Orca UI under M6 clean.
2026-10-16 04:54:56–04:55:12 Guarded retirement exited 0: ok - guarded Orca secondmate retirement completed; FM_TEST_SUMMARY total=1 failed=0 skipped_gate=0 duration_ms=16532.

Post-retirement scoped inventories reported terminals=[], totalCount=0, truncated=false, hostScope.omittedHostIds=[]. Both scouts' worktrees, both owned repository/setup registrations, the test home and its routing records were gone; the assigned code workspace was unchanged. Historical terminal records remained operator-closed, not live.

Scope: this is the earlier measured proof, not a claim of a new live run at the current tip. The subsequent late-retirement recheck and registration-race fixes have deterministic hermetic regressions; all six focused suites also passed after local integration. Pi process liveness/restart/recovery remains unverified and refused. The reusable commands and observations are recorded in docs/verification/runtime-backends.md.

The fork target is now configured in no-mistakes; revalidation/publication will let the pipeline bind its own attestation to the PR head.

@Cubatica

Copy link
Copy Markdown
Author

Superseded by #7401.

@Cubatica Cubatica closed this Oct 19, 2026
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