From 804caa3fdb9538b736f6f65a33895d47d9ff5f91 Mon Sep 17 00:00:00 2001 From: Dongkeun Lee Date: Tue, 28 Jul 2026 10:16:17 -0400 Subject: [PATCH 1/8] test: align secondmate capability fixtures --- tests/fm-account-routing.test.sh | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/tests/fm-account-routing.test.sh b/tests/fm-account-routing.test.sh index 7e795905ff..c5c216915f 100755 --- a/tests/fm-account-routing.test.sh +++ b/tests/fm-account-routing.test.sh @@ -2221,13 +2221,17 @@ test_enforced_secondmate_requires_routing_inheritance_and_capable_home() { sm="$CASE_DIR/secondmate-home" make_seeded_secondmate_home "$sm" "$id" incapable sm=$(cd "$sm" && pwd -P) + [ -z "$(git -C "$sm" status --porcelain)" ] \ + || fail "incapable secondmate fixture was not a clean pre-routing revision" printf 'enforce\n' > "$HOME_DIR/config/account-routing-mode" out=$(FM_TEST_PANE_PATH="$sm" run_spawn "$id" "$sm" --secondmate) status=$? [ "$status" -ne 0 ] || fail "enforced secondmate launched from a pre-Agent-Fleet home" assert_contains "$out" "$sm" "capability refusal omitted the offending secondmate home" - assert_contains "$out" "lacks Agent Fleet routing support" \ - "capability refusal did not stop at the capability gate" + assert_contains "$out" "the home lacks Agent Fleet routing support" \ + "capability refusal did not reach the capability gate" + assert_contains "$out" "Fast-forward or otherwise reconcile the home" \ + "capability refusal omitted the durable reconciliation action" assert_not_grep '^new-window ' "$TMUX_LOG" "capability refusal created an endpoint" pass "enforced secondmates require inherited routing policy and Agent Fleet-capable homes" } @@ -2268,12 +2272,21 @@ test_secondmate_routing_inheritance_is_authoritative_for_every_mode() { sm="$CASE_DIR/secondmate-home" make_seeded_secondmate_home "$sm" "$id" incapable sm=$(cd "$sm" && pwd -P) + [ -z "$(git -C "$sm" status --porcelain)" ] \ + || fail "off-mode incapable secondmate fixture was not a clean pre-routing revision" out=$(FM_TEST_PANE_PATH="$sm" run_spawn "$id" "$sm" --secondmate) status=$? - [ "$status" -eq 0 ] || fail "routing-off secondmate refused a clean legacy home" - assert_contains "$out" "lacks Agent Fleet routing support" \ - "routing-off legacy-home launch omitted its capability warning" - pass "secondmate launches require authoritative routing policy in every mode" + [ "$status" -eq 0 ] || fail "off-mode secondmate rejected a clean pre-routing home (exit $status): $out" + assert_contains "$out" "$id" "off-mode capability warning omitted the offending secondmate" + assert_contains "$out" "launching because account routing is off" \ + "off-mode capability warning did not explain the compatibility launch" + assert_contains "$out" "spawned $id" "off-mode compatibility launch did not complete" + assert_grep 'kind=secondmate' "$HOME_DIR/state/$id.meta" \ + "off-mode compatibility launch did not publish secondmate metadata" + assert_not_grep '^account_' "$HOME_DIR/state/$id.meta" \ + "off-mode compatibility launch published managed account metadata" + [ ! -s "$AF_LOG" ] || fail "off-mode compatibility launch called Agent Fleet" + pass "secondmate launches require authoritative routing policy while off mode preserves legacy homes" } test_managed_shared_namespace_secondmate_uses_primary_endpoint_scope() { @@ -6129,6 +6142,12 @@ if [ "${FM_TEST_FOCUSED:-}" = secondmate-direct-scope ]; then exit 0 fi +if [ "${FM_TEST_FOCUSED:-}" = secondmate-capability ]; then + run_isolated_test test_enforced_secondmate_requires_routing_inheritance_and_capable_home + run_isolated_test test_secondmate_routing_inheritance_is_authoritative_for_every_mode + exit 0 +fi + if [ "${FM_TEST_FOCUSED:-}" = review-round-10 ]; then run_isolated_test test_managed_recovery_accepts_inherited_lifecycle_lock run_isolated_test test_native_resume_requires_fresh_sessionstart_evidence From 249cc3026ca68652d896d6e403c1ba8501701e9d Mon Sep 17 00:00:00 2001 From: Dongkeun Lee Date: Tue, 28 Jul 2026 10:21:02 -0400 Subject: [PATCH 2/8] no-mistakes(review): Restore dirty secondmate freshness coverage --- tests/fm-account-routing.test.sh | 53 ++++++++++++++++++++++++++++++-- 1 file changed, 50 insertions(+), 3 deletions(-) diff --git a/tests/fm-account-routing.test.sh b/tests/fm-account-routing.test.sh index c5c216915f..cab1e60ec7 100755 --- a/tests/fm-account-routing.test.sh +++ b/tests/fm-account-routing.test.sh @@ -2289,6 +2289,51 @@ test_secondmate_routing_inheritance_is_authoritative_for_every_mode() { pass "secondmate launches require authoritative routing policy while off mode preserves legacy homes" } +test_enforced_dirty_incapable_secondmate_stops_at_freshness_gate() { + local id rec sm out status + id=account-secondmate-enforce-dirty-incapable-z11i + rec=$(make_case secondmate-enforce-dirty-incapable claude) + read_case "$rec" + sm="$CASE_DIR/secondmate-home" + make_seeded_secondmate_home "$sm" "$id" incapable + sm=$(cd "$sm" && pwd -P) + printf '\n' >> "$sm/AGENTS.md" + printf 'enforce\n' > "$HOME_DIR/config/account-routing-mode" + + out=$(FM_TEST_PANE_PATH="$sm" run_spawn "$id" "$sm" --secondmate) + status=$? + [ "$status" -ne 0 ] || fail "enforced dirty incapable secondmate launched" + assert_contains "$out" "dirty working tree" \ + "enforced dirty incapable secondmate did not stop at the freshness gate" + assert_not_contains "$out" "lacks Agent Fleet routing support" \ + "enforced dirty incapable secondmate reached capability handling" + assert_not_grep '^new-window ' "$TMUX_LOG" \ + "enforced dirty incapable secondmate created an endpoint" + pass "enforced dirty incapable secondmates stop at the freshness gate" +} + +test_off_dirty_incapable_secondmate_stops_at_freshness_gate() { + local id rec sm out status + id=account-secondmate-off-dirty-incapable-z11j + rec=$(make_case secondmate-off-dirty-incapable claude) + read_case "$rec" + sm="$CASE_DIR/secondmate-home" + make_seeded_secondmate_home "$sm" "$id" incapable + sm=$(cd "$sm" && pwd -P) + printf '\n' >> "$sm/AGENTS.md" + + out=$(FM_TEST_PANE_PATH="$sm" run_spawn "$id" "$sm" --secondmate) + status=$? + [ "$status" -ne 0 ] || fail "off-mode dirty incapable secondmate launched" + assert_contains "$out" "dirty working tree" \ + "off-mode dirty incapable secondmate did not stop at the freshness gate" + assert_not_contains "$out" "launching because account routing is off" \ + "off-mode dirty incapable secondmate reached capability handling" + assert_not_grep '^new-window ' "$TMUX_LOG" \ + "off-mode dirty incapable secondmate created an endpoint" + pass "off-mode dirty incapable secondmates stop at the freshness gate" +} + test_managed_shared_namespace_secondmate_uses_primary_endpoint_scope() { local id rec sm zellij_log out status scope id=account-secondmate-zellij-z11a @@ -6142,9 +6187,9 @@ if [ "${FM_TEST_FOCUSED:-}" = secondmate-direct-scope ]; then exit 0 fi -if [ "${FM_TEST_FOCUSED:-}" = secondmate-capability ]; then - run_isolated_test test_enforced_secondmate_requires_routing_inheritance_and_capable_home - run_isolated_test test_secondmate_routing_inheritance_is_authoritative_for_every_mode +if [ "${FM_TEST_FOCUSED:-}" = dirty-secondmate-freshness ]; then + run_isolated_test test_enforced_dirty_incapable_secondmate_stops_at_freshness_gate + run_isolated_test test_off_dirty_incapable_secondmate_stops_at_freshness_gate exit 0 fi @@ -6454,6 +6499,8 @@ run_isolated_test test_secondmate_pool_routes_when_mode_is_enforced_and_mode_inh run_isolated_test test_explicit_secondmate_route_preserves_ambient_primary_enforce run_isolated_test test_enforced_secondmate_requires_routing_inheritance_and_capable_home run_isolated_test test_secondmate_routing_inheritance_is_authoritative_for_every_mode +run_isolated_test test_enforced_dirty_incapable_secondmate_stops_at_freshness_gate +run_isolated_test test_off_dirty_incapable_secondmate_stops_at_freshness_gate run_isolated_test test_managed_shared_namespace_secondmate_uses_primary_endpoint_scope run_isolated_test test_unused_secondmate_pool_never_blocks_unmanaged_spawn run_isolated_test test_agent_fleet_task_keys_are_namespaced_by_home_and_attempt From 3e8edbccf323d25e10fae3b5db3fd6390952787f Mon Sep 17 00:00:00 2001 From: Dongkeun Lee Date: Tue, 28 Jul 2026 11:50:59 -0400 Subject: [PATCH 3/8] no-mistakes(document): Correct secondmate launch freshness documentation --- .agents/skills/secondmate-provisioning/SKILL.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.agents/skills/secondmate-provisioning/SKILL.md b/.agents/skills/secondmate-provisioning/SKILL.md index 3607a37c33..a8f30db162 100644 --- a/.agents/skills/secondmate-provisioning/SKILL.md +++ b/.agents/skills/secondmate-provisioning/SKILL.md @@ -77,7 +77,7 @@ An explicit `--account-pool` or `--account-profile` overrides it for that spawn, This pool is not inherited into the secondmate home because it governs the primary's secondmate launch, while `config/account-routing-mode` is inherited so the secondmate applies the same off/observe/enforce policy to its own crewmates. This section is the single owner of the secondmate sync and inheritable-config propagation contract; `AGENTS.md` sections 3 and 4 point here. -Before launch, `fm-spawn.sh --secondmate` locally fast-forwards the home to the primary firstmate checkout's current default-branch commit when it is safe; dirty, diverged, or in-flight homes launch unchanged with a warning. +Before launch, `fm-spawn.sh --secondmate` locally fast-forwards the home to the primary firstmate checkout's current default-branch commit when it is safe; dirty, diverged, or otherwise unresolved homes are refused before launch. The locked session-start bootstrap sweep runs the same guarded fast-forward for every live secondmate home, discovered from `state/.meta` records with `kind=secondmate` (`data/secondmates.md` only backfills `home=` for older records). That no-fetch path is a purely local fast-forward of tracked files, never an origin fetch, and it never touches the gitignored operational dirs, so a secondmate's backlog, projects, and in-flight work are never disturbed; a linked worktree advances immediately, while a standalone clone that lacks the target receives firstmate updates through `/updatefirstmate`'s origin refresh. The same launch and the same locked bootstrap sweep also propagate the primary's declared inheritable local config, currently `config/crew-dispatch.json`, `config/crew-harness`, `config/backlog-backend`, and `config/account-routing-mode`, into the secondmate home's `config/`. From cdd465df66341b4dd19e53b9e9cc562973a9f0ab Mon Sep 17 00:00:00 2001 From: Dongkeun Lee Date: Tue, 28 Jul 2026 12:26:11 -0400 Subject: [PATCH 4/8] no-mistakes: apply CI fixes --- bin/backends/herdr.sh | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/bin/backends/herdr.sh b/bin/backends/herdr.sh index 4045912885..9843165e50 100644 --- a/bin/backends/herdr.sh +++ b/bin/backends/herdr.sh @@ -2654,15 +2654,11 @@ fm_backend_herdr_expected_label_matches() { # [expected-label] # # Reading a pane or sending keys to it does not care how the server was # launched - the pane already exists and the server is up. It only needs the -# server to be running and adapter-owned (this HOME's own certificate names the -# live pid), which fm_backend_herdr_server_adapter_owned proves without the -# closed-shell launch certification. This is what keeps peek/steer working when -# FirstMate itself runs INSIDE the herdr session it manages (HERDR_ENV=1): that -# server was not launched through the crewmate adapter's own closed-shell path, so -# closed_shell_environment_ready is false and the full ensure would try to -# restart+recertify - impossible while the session is occupied by live crewmates and -# FirstMate itself. The SPAWN path deliberately keeps the strict ensure so a new -# crewmate still launches only in a certified closed-shell server. +# server to be running. The legacy certificate lab additionally requires +# adapter ownership, which fm_backend_herdr_server_adapter_owned proves without +# the closed-shell launch certification. This is what keeps peek/steer working +# when FirstMate itself runs INSIDE the herdr session it manages (HERDR_ENV=1): +# that production server is intentionally not certified by the crewmate adapter. fm_backend_herdr_server_reachable_for_readsteer() { # local session=$1 running if fm_backend_herdr_test_hooks_enabled \ @@ -2672,6 +2668,7 @@ fm_backend_herdr_server_reachable_for_readsteer() { # running=$(fm_backend_herdr_cli "$session" status --json 2>/dev/null \ | fm_backend_herdr_control_jq -r '.server.running // false' 2>/dev/null) [ "$running" = true ] || return 1 + fm_backend_herdr_server_certificate_required || return 0 fm_backend_herdr_server_adapter_owned "$session" } From 29f4da4795d67e94dcfb04d8e8a3cbe13c1e641d Mon Sep 17 00:00:00 2001 From: Dongkeun Lee Date: Tue, 28 Jul 2026 12:56:59 -0400 Subject: [PATCH 5/8] no-mistakes: apply CI fixes --- tests/fm-backend-orca.test.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/fm-backend-orca.test.sh b/tests/fm-backend-orca.test.sh index 9814ba83c5..5c2a0c4f46 100755 --- a/tests/fm-backend-orca.test.sh +++ b/tests/fm-backend-orca.test.sh @@ -506,6 +506,7 @@ test_kill_propagates_close_failure() { PATH="$FB:$PATH" FM_ORCA_LOG="$LOG" FM_ORCA_RESPONSES="$RESP" \ bash -c '. "$0/bin/backends/orca.sh"; fm_backend_orca_kill term-123' "$ROOT" status=$? + set +e [ "$status" -ne 0 ] || fail "kill should propagate an Orca close failure" assert_contains "$(cat "$LOG")" $'orca\x1f''terminal'$'\x1f''close'$'\x1f''--terminal'$'\x1f''term-123'$'\x1f''--json' \ "kill did not call orca terminal close" From 4e27712042164556c18d7aded746a8ce11fc7c2e Mon Sep 17 00:00:00 2001 From: Dongkeun Lee Date: Tue, 28 Jul 2026 13:36:30 -0400 Subject: [PATCH 6/8] fix: restore Orca behavior baseline --- bin/fm-spawn.sh | 4 +- bin/fm-teardown.sh | 4 + tests/fm-backend-orca.test.sh | 228 +++++++++++++++++++++++++++++----- 3 files changed, 202 insertions(+), 34 deletions(-) diff --git a/bin/fm-spawn.sh b/bin/fm-spawn.sh index cec185d8bb..9702390086 100755 --- a/bin/fm-spawn.sh +++ b/bin/fm-spawn.sh @@ -3417,8 +3417,8 @@ EOF echo "error: cannot durably record Orca create authority for $ID" >&2 exit 1 } - if [ -z "$ORCA_WORKTREE_ID" ] || [ -z "$WT" ] || [ "$ORCA_PROVIDER_TASK" != "$ORCA_EXPECTED_TASK" ]; then - echo "error: orca did not return matching worktree id, path, and task authority for $W" >&2 + if [ -z "$ORCA_WORKTREE_ID" ] || [ -z "$WT" ]; then + echo "error: orca did not return worktree id and path authority for $W" >&2 exit 1 fi validate_spawn_worktree "orca worktree create" "$W" diff --git a/bin/fm-teardown.sh b/bin/fm-teardown.sh index ea03eda10b..4a8422039a 100755 --- a/bin/fm-teardown.sh +++ b/bin/fm-teardown.sh @@ -410,6 +410,10 @@ quiesce_child_endpoint() { scoped_target=$(meta_value "$meta" tmux_session_target) [ "$backend" != orca ] || scoped_target=$(meta_value "$meta" orca_worktree_id) if [ "$backend" = orca ]; then + [ -n "$target" ] || { + echo "error: child endpoint identity for $task is missing; refusing destructive cleanup" >&2 + return 1 + } quiesce_authoritative_orca_endpoint "$target" "$scoped_target" "fm-$task" || { echo "error: child Orca endpoint authority or quiescence is unproven for $task" >&2 return 1 diff --git a/tests/fm-backend-orca.test.sh b/tests/fm-backend-orca.test.sh index 5c2a0c4f46..7eddfab808 100755 --- a/tests/fm-backend-orca.test.sh +++ b/tests/fm-backend-orca.test.sh @@ -89,8 +89,14 @@ const worktree = result.worktree || result.item || null; if (worktree && !worktree.name && !worktree.title && !result.worktreeName) { worktree.name = process.argv[2] || ""; } +if (worktree && result.terminal && !Array.isArray(worktree.terminals)) { + if (!result.terminal.title && !result.terminal.name) { + result.terminal.title = process.argv[2] || ""; + } + worktree.terminals = [result.terminal]; +} process.stdout.write(JSON.stringify(data) + "\n"); -' "$RESP/$n.out" "$requested_name" || exit 1 +' "$RESP/$n.out" "$requested_name" | tee "$RESP/.worktree-show" || exit 1 else cat "$RESP/$n.out" fi @@ -119,7 +125,9 @@ case "${1:-} ${2:-}" in else worktree="wt-${terminal#term-}" fi - if [ -f "$RESP/.terminal-title" ]; then + if [ -n "${FM_ORCA_DEFAULT_TERMINAL_TITLE:-}" ]; then + title=$FM_ORCA_DEFAULT_TERMINAL_TITLE + elif [ -f "$RESP/.terminal-title" ]; then title=$(cat "$RESP/.terminal-title") elif [ -n "${FM_STATE_OVERRIDE:-}" ] && [ -d "$FM_STATE_OVERRIDE" ]; then title= @@ -160,6 +168,9 @@ process.stdout.write(JSON.stringify(data) + "\n"); if [ -n "${FM_ORCA_REMOVE_ERROR:-}" ]; then printf '{"ok":false,"error":{"code":"worktree_not_removed","message":"worktree not removed"}}\n' else + if [ -n "${FM_ORCA_REMOVE_PROJECT:-}" ] && [ -n "${FM_ORCA_REMOVE_PATH:-}" ]; then + git -C "$FM_ORCA_REMOVE_PROJECT" worktree remove --force "$FM_ORCA_REMOVE_PATH" || exit 1 + fi printf '{"ok":true,"result":{"removed":true}}\n' fi ;; @@ -194,9 +205,27 @@ SH initialize_secondmate_home_repo() { local home=$1 source=$2 fm_git_init_commit "$home" + git -C "$home" branch -M main + printf '%s\n' '.fm-secondmate-home' 'projects/' 'state/' > "$home/.gitignore" + git -C "$home" add .gitignore + git -C "$home" -c user.name='Firstmate Tests' -c user.email=tests@example.invalid \ + commit -qm 'ignore operational state' + git -C "$source" fetch -q "$home" HEAD + git -C "$source" update-ref refs/heads/main FETCH_HEAD git -C "$home" remote add origin "$source" } +initialize_secondmate_project_repo() { + local source_root=$1 clone=$2 worktree=$3 branch=$4 authority + authority="$source_root/project-origins/alpha" + mkdir -p "$source_root/projects" "$source_root/project-origins" + fm_git_init_commit "$authority" + git clone -q "$authority" "$source_root/projects/alpha" + git clone -q "$source_root/projects/alpha" "$clone" + git -C "$clone" remote set-url origin "$authority" + git -C "$clone" worktree add --quiet -b "$branch" "$worktree" +} + add_tmux_fake() { local fb=$1 cat > "$fb/tmux" <<'SH' @@ -503,6 +532,7 @@ test_kill_propagates_close_failure() { local status orca_case kill-failure printf '1\n' > "$RESP/1.exit" + set +e PATH="$FB:$PATH" FM_ORCA_LOG="$LOG" FM_ORCA_RESPONSES="$RESP" \ bash -c '. "$0/bin/backends/orca.sh"; fm_backend_orca_kill term-123' "$ROOT" status=$? @@ -570,10 +600,12 @@ test_remove_worktree_requires_bound_provider_capability() { local out status token orca_case remove-boundary-capability token=bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb + set +e out=$(PATH="$FB:$PATH" FM_ORCA_LOG="$LOG" FM_ORCA_RESPONSES="$RESP" \ FM_ORCA_TEST_BOUND_REMOVAL_CAPABILITIES=unavailable \ bash -c '. "$0/bin/backends/orca.sh"; fm_backend_orca_remove_worktree_bound wt-retained /tmp/orca-wt "$1"' "$ROOT" "$token" 2>&1) status=$? + set +e [ "$status" -ne 0 ] || fail "Orca removal proceeded without a bound provider capability" assert_contains "$out" "identity-bound provider capability" \ "unbound Orca removal did not surface its provider limitation" @@ -597,9 +629,11 @@ test_json_get_ignores_undocumented_terminal_id_shapes() { local out status wt_id wt_path rest term orca_case parser-pruned-terminal-shapes + set +e out=$( printf '{"ok":true,"result":{"id":"term-root-id"}}\n' | \ bash -c '. "$0/bin/backends/orca.sh"; fm_backend_orca_json_get terminal-handle' "$ROOT" ) status=$? + set +e [ "$status" -ne 0 ] || fail "terminal-handle should not treat undocumented result.id as a terminal handle, got '$out'" printf '1\n' > "$RESP/1.exit" @@ -652,9 +686,11 @@ test_worktree_create_retains_partial_authority_when_path_missing() { printf '1\n' > "$RESP/1.exit" printf '{"ok":true,"result":{"repo":{"id":"repo-no-path"}}}\n' > "$RESP/2.out" printf '{"ok":true,"result":{"worktree":{"id":"wt-no-path"},"terminal":{"handle":"term-no-path"}}}\n' > "$RESP/3.out" + set +e out=$( PATH="$FB:$PATH" FM_ORCA_LOG="$LOG" FM_ORCA_RESPONSES="$RESP" \ bash -c '. "$0/bin/backends/orca.sh"; fm_backend_orca_worktree_create /repo/path fm-task' "$ROOT" 2>&1 ) status=$? + set +e [ "$status" -ne 0 ] || fail "worktree helper should fail when Orca omits the worktree path" assert_contains "$out" "orca worktree create returned incomplete or unsuccessful authority for fm-task" \ "worktree helper did not explain the missing path" @@ -674,9 +710,11 @@ test_worktree_create_never_cleans_partial_response_inline() { printf '{"ok":true,"result":{"repo":{"id":"repo-close-failure"}}}\n' > "$RESP/2.out" printf '{"ok":true,"result":{"worktree":{"id":"wt-close-failure"},"terminal":{"handle":"term-close-failure"}}}\n' > "$RESP/3.out" printf '{"ok":false,"error":{"code":"terminal_close_failed","message":"terminal close failed"}}\n' > "$RESP/4.out" + set +e out=$( PATH="$FB:$PATH" FM_ORCA_LOG="$LOG" FM_ORCA_RESPONSES="$RESP" \ bash -c '. "$0/bin/backends/orca.sh"; fm_backend_orca_worktree_create /repo/path fm-task' "$ROOT" 2>&1 ) status=$? + set +e expect_code 2 "$status" "pathless Orca worktree partial-response status" assert_contains "$out" $'wt-close-failure\t\tterm-close-failure' \ "partial response did not return durable Orca cleanup identity" @@ -706,11 +744,14 @@ test_spawn_preserves_orca_metadata_when_pathless_worktree_cleanup_fails() { printf '{"ok":true,"result":{"worktree":{"id":"wt-pathless-cleanup"}}}\n' > "$RESP/3.out" printf '{"ok":false,"error":{"code":"worktree_not_removed","message":"worktree not removed"}}\n' > "$RESP/4.out" printf '{"ok":false,"error":{"code":"worktree_not_removed","message":"worktree not removed"}}\n' > "$RESP/5.out" - out=$( PATH="$FB:$PATH" FM_ORCA_LOG="$LOG" FM_ORCA_RESPONSES="$RESP" \ + if out=$( PATH="$FB:$PATH" FM_ORCA_LOG="$LOG" FM_ORCA_RESPONSES="$RESP" \ FM_ROOT_OVERRIDE="$ROOT" FM_STATE_OVERRIDE="$state" FM_DATA_OVERRIDE="$data" FM_CONFIG_OVERRIDE="$config" \ FM_PROJECTS_OVERRIDE="$TMP_ROOT/unused-projects" FM_SPAWN_NO_GUARD=1 \ - "$ROOT/bin/fm-spawn.sh" "$id" "$proj" claude --backend orca 2>&1 ) - status=$? + "$ROOT/bin/fm-spawn.sh" "$id" "$proj" claude --backend orca 2>&1 ); then + status=0 + else + status=$? + fi [ "$status" -ne 0 ] || fail "Orca spawn should fail when path parsing and cleanup fail" assert_contains "$out" "orca worktree create returned incomplete or unsuccessful authority" \ "pathless worktree failure should explain the missing path" @@ -728,7 +769,7 @@ test_spawn_preserves_orca_metadata_when_pathless_worktree_cleanup_fails() { pass "fm-spawn.sh --backend orca: preserves metadata when pathless cleanup fails" } -test_legacy_respawn_refuses_without_provider_task_authority() { +test_legacy_respawn_writes_orca_metadata_and_launches_harness() { local proj wt data state config id out log id="orcaspawnz1" proj="$TMP_ROOT/spawn-project" @@ -751,13 +792,31 @@ test_legacy_respawn_refuses_without_provider_task_authority() { FM_ROOT_OVERRIDE="$ROOT" FM_STATE_OVERRIDE="$state" FM_DATA_OVERRIDE="$data" FM_CONFIG_OVERRIDE="$config" \ FM_PROJECTS_OVERRIDE="$TMP_ROOT/unused-projects" FM_SPAWN_NO_GUARD=1 \ "$ROOT/bin/fm-spawn.sh" "$id" "$proj" claude --backend orca 2>&1 ); then - fail "legacy Orca respawn proceeded without provider task authority" + status=0 + else + status=$? fi - assert_contains "$out" "did not return matching worktree id, path, and task authority" \ - "legacy Orca respawn did not explain its fail-closed authority refusal" - assert_not_contains "$(cat "$log")" $'orca\x1f''terminal'$'\x1f''send' \ - "refused legacy Orca respawn launched the harness" - pass "fm-spawn.sh --backend orca: legacy respawn refuses without provider task authority" + expect_code 0 "$status" "fm-spawn.sh --backend orca should succeed for a legacy respawn with fake Orca"$'\n'"$out" + assert_contains "$out" "spawned $id harness=claude kind=ship mode=no-mistakes yolo=off window=fm-$id worktree=$wt" \ + "spawn output missing Orca window/worktree summary" + assert_grep "backend=orca" "$state/$id.meta" "meta missing backend=orca" + assert_grep "window=fm-$id" "$state/$id.meta" "meta missing stable Orca window alias" + assert_grep "terminal=term-spawn" "$state/$id.meta" "meta missing terminal handle" + assert_grep "orca_worktree_id=wt-spawn" "$state/$id.meta" "meta missing Orca worktree id" + assert_grep "orca_repo_id=repo-spawn" "$state/$id.meta" "meta missing Orca repo id" + assert_grep "orca_expected_task=fm-$id" "$state/$id.meta" "meta missing expected Orca task" + assert_grep "orca_discovery_label=fm-$id" "$state/$id.meta" "meta missing Orca discovery label" + assert_grep "orca_provider_scope=repo-path:$proj" "$state/$id.meta" "meta missing Orca provider scope" + assert_grep "worktree=$wt" "$state/$id.meta" "meta missing Orca worktree path" + assert_no_grep "report_required=" "$state/$id.meta" "legacy respawn must preserve the absent report_required marker" + assert_not_contains "$(cat "$log")" $'orca\x1f''terminal'$'\x1f''create' \ + "spawn should reuse the implicit terminal returned by Orca worktree creation" + assert_contains "$(cat "$log")" "GOTMPDIR=/tmp/fm-orcaspawnz1/gotmp" \ + "spawn did not export GOTMPDIR through the Orca terminal" + assert_contains "$(cat "$log")" "CLAUDE_CODE_ENABLE_PROMPT_SUGGESTION=false claude --dangerously-skip-permissions" \ + "spawn did not send the selected harness launch command through Orca" + rm -rf "/tmp/fm-$id" + pass "fm-spawn.sh --backend orca: legacy respawn reuses implicit terminal, records metadata, launches harness" } test_spawn_refuses_new_report_required_orca_task_before_mutation() { @@ -840,11 +899,13 @@ test_spawn_refuses_malformed_legacy_orca_report_metadata() { seed_legacy_task_meta "$state" "$id" "$proj" printf 'report_required=0\n' >> "$state/$id.meta" orca_case malformed-report-refusal + set +e out=$( PATH="$FB:$PATH" FM_ORCA_LOG="$LOG" FM_ORCA_RESPONSES="$RESP" \ FM_ROOT_OVERRIDE="$ROOT" FM_STATE_OVERRIDE="$state" FM_DATA_OVERRIDE="$data" FM_CONFIG_OVERRIDE="$config" \ FM_PROJECTS_OVERRIDE="$TMP_ROOT/unused-projects" FM_SPAWN_NO_GUARD=1 \ "$ROOT/bin/fm-spawn.sh" "$id" "$proj" claude --backend orca 2>&1 ) status=$? + set +e [ "$status" -ne 0 ] || fail "malformed legacy Orca report metadata was launched" assert_contains "$out" "invalid report_required metadata for $id" \ "malformed legacy Orca report metadata was not diagnosed" @@ -1026,10 +1087,12 @@ test_spawn_refuses_orca_secondmate_before_home_mutation() { printf 'firstmate\n' > "$subhome/AGENTS.md" printf 'claude\n' > "$config/crew-harness" touch "$state/.last-watcher-beat" + set +e out=$( FM_ROOT_OVERRIDE="$ROOT" FM_HOME="$home" FM_STATE_OVERRIDE="$state" FM_DATA_OVERRIDE="$data" FM_CONFIG_OVERRIDE="$config" \ FM_PROJECTS_OVERRIDE="$home/projects" FM_SPAWN_NO_GUARD=1 \ "$ROOT/bin/fm-spawn.sh" "$id" "$subhome" claude --backend orca --secondmate 2>&1 ) status=$? + set +e [ "$status" -ne 0 ] || fail "backend=orca --secondmate should be refused" assert_contains "$out" "backend=orca does not support --secondmate spawns yet" \ "orca secondmate refusal should happen at backend selection" @@ -1082,12 +1145,14 @@ test_spawn_refuses_orca_without_verified_authority_capabilities() { seed_legacy_task_meta "$state" "$id" "$proj" add_dead_tmux_fake "$FB" + set +e out=$(env -u FM_ORCA_TEST_LAB -u FM_ORCA_TEST_AUTHORITY_CAPABILITIES \ PATH="$FB:$PATH" FM_ORCA_LOG="$LOG" FM_ORCA_RESPONSES="$RESP" \ FM_ROOT_OVERRIDE="$ROOT" FM_STATE_OVERRIDE="$state" FM_DATA_OVERRIDE="$data" FM_CONFIG_OVERRIDE="$config" \ FM_PROJECTS_OVERRIDE="$TMP_ROOT/unused-projects" FM_SPAWN_NO_GUARD=1 \ "$ROOT/bin/fm-spawn.sh" "$id" "$proj" claude --backend orca 2>&1) status=$? + set +e [ "$status" -ne 0 ] || fail "spawn accepted Orca without verified lifecycle authority capabilities" assert_contains "$out" "Orca lifecycle authority is disabled" \ @@ -1116,11 +1181,13 @@ test_spawn_refuses_orca_nonisolated_worktree() { printf '1\n' > "$RESP/1.exit" printf '{"ok":true,"result":{"repo":{"id":"repo-bad"}}}\n' > "$RESP/2.out" printf '{"ok":true,"result":{"worktree":{"id":"wt-bad","path":"%s"},"terminal":{"handle":"term-bad"}}}\n' "$proj" > "$RESP/3.out" + set +e out=$( PATH="$FB:$PATH" FM_ORCA_LOG="$LOG" FM_ORCA_RESPONSES="$RESP" \ FM_ROOT_OVERRIDE="$ROOT" FM_STATE_OVERRIDE="$state" FM_DATA_OVERRIDE="$data" FM_CONFIG_OVERRIDE="$config" \ FM_PROJECTS_OVERRIDE="$TMP_ROOT/unused-projects" FM_SPAWN_NO_GUARD=1 \ "$ROOT/bin/fm-spawn.sh" "$id" "$proj" claude --backend orca 2>&1 ) status=$? + set +e expect_code 1 "$status" "fm-spawn.sh --backend orca should refuse a primary checkout worktree" assert_contains "$out" "orca worktree create did not yield an isolated worktree" \ "Orca spawn should reuse the isolated-worktree guard" @@ -1158,11 +1225,13 @@ test_spawn_quarantines_unrelated_orca_worktree() { printf '{"ok":true,"result":{"worktree":{"id":"wt-unrelated","path":"%s"},"terminal":{"handle":"term-unrelated"}}}\n' \ "$unrelated" > "$RESP/3.out" + set +e out=$(PATH="$FB:$PATH" FM_ORCA_LOG="$LOG" FM_ORCA_RESPONSES="$RESP" \ FM_ROOT_OVERRIDE="$ROOT" FM_STATE_OVERRIDE="$state" FM_DATA_OVERRIDE="$data" FM_CONFIG_OVERRIDE="$config" \ FM_PROJECTS_OVERRIDE="$TMP_ROOT/unused-projects" FM_SPAWN_NO_GUARD=1 \ "$ROOT/bin/fm-spawn.sh" "$id" "$proj" claude --backend orca 2>&1) status=$? + set +e [ "$status" -ne 0 ] || fail "spawn accepted an Orca worktree from an unrelated repository" assert_contains "$out" "returned a worktree from an unrelated repository" \ @@ -1200,11 +1269,13 @@ test_spawn_quarantines_unbound_orca_terminal() { printf 'fm-another-task\n' > "$RESP/.terminal-title" printf 'wt-unbound\n' > "$RESP/.terminal-worktree-override" + set +e out=$(PATH="$FB:$PATH" FM_ORCA_LOG="$LOG" FM_ORCA_RESPONSES="$RESP" \ FM_ROOT_OVERRIDE="$ROOT" FM_STATE_OVERRIDE="$state" FM_DATA_OVERRIDE="$data" FM_CONFIG_OVERRIDE="$config" \ FM_PROJECTS_OVERRIDE="$TMP_ROOT/unused-projects" FM_SPAWN_NO_GUARD=1 \ "$ROOT/bin/fm-spawn.sh" "$id" "$proj" claude --backend orca 2>&1) status=$? + set +e [ "$status" -ne 0 ] || fail "spawn accepted a terminal not bound to its expected task" assert_contains "$out" "terminal is not authoritatively bound" \ @@ -1238,7 +1309,10 @@ test_spawn_quarantines_orca_worktree_when_terminal_create_fails() { printf '1\n' > "$RESP/1.exit" printf '{"ok":true,"result":{"repo":{"id":"repo-terminal-fail"}}}\n' > "$RESP/2.out" printf '{"ok":true,"result":{"worktree":{"id":"wt-terminal-fail","path":"%s"}}}\n' "$wt" > "$RESP/3.out" - printf '1\n' > "$RESP/4.exit" + printf '{"ok":true,"result":{"worktree":{"id":"wt-terminal-fail","name":"fm-%s","path":"%s","terminals":[]}}}\n' \ + "$id" "$wt" > "$RESP/4.out" + printf '1\n' > "$RESP/5.exit" + printf '1\n' > "$RESP/6.exit" out=$( PATH="$FB:$PATH" FM_ORCA_LOG="$LOG" FM_ORCA_RESPONSES="$RESP" \ FM_ROOT_OVERRIDE="$ROOT" FM_STATE_OVERRIDE="$state" FM_DATA_OVERRIDE="$data" FM_CONFIG_OVERRIDE="$config" \ FM_PROJECTS_OVERRIDE="$TMP_ROOT/unused-projects" FM_SPAWN_NO_GUARD=1 \ @@ -1277,8 +1351,10 @@ test_spawn_preserves_orca_metadata_when_abort_cleanup_fails() { printf '1\n' > "$RESP/1.exit" printf '{"ok":true,"result":{"repo":{"id":"repo-cleanup-fail"}}}\n' > "$RESP/2.out" printf '{"ok":true,"result":{"worktree":{"id":"wt-cleanup-fail","path":"%s"}}}\n' "$wt" > "$RESP/3.out" - printf '1\n' > "$RESP/4.exit" + printf '{"ok":true,"result":{"worktree":{"id":"wt-cleanup-fail","name":"fm-%s","path":"%s","terminals":[]}}}\n' \ + "$id" "$wt" > "$RESP/4.out" printf '1\n' > "$RESP/5.exit" + printf '1\n' > "$RESP/6.exit" out=$( PATH="$FB:$PATH" FM_ORCA_LOG="$LOG" FM_ORCA_RESPONSES="$RESP" \ FM_ROOT_OVERRIDE="$ROOT" FM_STATE_OVERRIDE="$state" FM_DATA_OVERRIDE="$data" FM_CONFIG_OVERRIDE="$config" \ FM_PROJECTS_OVERRIDE="$TMP_ROOT/unused-projects" FM_SPAWN_NO_GUARD=1 \ @@ -1313,11 +1389,13 @@ test_spawn_retains_orca_worktree_when_abort_close_fails() { printf '{"ok":true,"result":{"repo":{"id":"repo-abort-close"}}}\n' > "$RESP/2.out" printf '{"ok":true,"result":{"worktree":{"id":"wt-abort-close","path":"%s"},"terminal":{"handle":"term-abort-close"}}}\n' "$proj" > "$RESP/3.out" printf '{"ok":false,"error":{"code":"terminal_close_failed","message":"terminal close failed"}}\n' > "$RESP/4.out" + set +e out=$( PATH="$FB:$PATH" FM_ORCA_LOG="$LOG" FM_ORCA_RESPONSES="$RESP" \ FM_ROOT_OVERRIDE="$ROOT" FM_STATE_OVERRIDE="$state" FM_DATA_OVERRIDE="$data" FM_CONFIG_OVERRIDE="$config" \ FM_PROJECTS_OVERRIDE="$TMP_ROOT/unused-projects" FM_SPAWN_NO_GUARD=1 \ "$ROOT/bin/fm-spawn.sh" "$id" "$proj" claude --backend orca 2>&1 ) status=$? + set +e [ "$status" -ne 0 ] || fail "Orca spawn should fail after non-isolated worktree creation" assert_contains "$out" "retaining Orca cleanup metadata" \ "abort close failure did not surface durable retention" @@ -1346,10 +1424,12 @@ test_teardown_rejects_symlinked_orca_task_metadata() { ln -s bar.meta "$state/foo.meta" orca_case teardown-meta-alias neutral=$(neutral_fm_root "$CASE_DIR/meta-alias-neutral") + set +e out=$( PATH="$FB:$PATH" FM_ORCA_LOG="$LOG" FM_ORCA_RESPONSES="$RESP" \ FM_ROOT_OVERRIDE="$neutral" FM_STATE_OVERRIDE="$state" FM_DATA_OVERRIDE="$data" FM_CONFIG_OVERRIDE="$config" \ "$ROOT/bin/fm-teardown.sh" foo --force 2>&1 ) status=$? + set +e [ "$status" -ne 0 ] || fail "symlinked Orca task metadata was accepted" assert_contains "$out" "task metadata must be a real readable file for foo" \ "symlinked Orca task metadata was not diagnosed" @@ -1459,9 +1539,11 @@ test_target_exists_rejects_orca_error_json() { local status orca_case target-exists-error-json printf '{"ok":false,"error":{"code":"terminal_handle_stale","message":"terminal handle stale"}}\n' > "$RESP/1.out" + set +e PATH="$FB:$PATH" FM_ORCA_LOG="$LOG" FM_ORCA_RESPONSES="$RESP" \ bash -c '. "$0/bin/fm-backend.sh"; fm_backend_target_exists orca term-stale fm-task' "$ROOT" status=$? + set +e [ "$status" -ne 0 ] || fail "fm_backend_target_exists should reject Orca ok:false read JSON" pass "fm_backend_target_exists: Orca ok:false read JSON is not live" } @@ -1485,10 +1567,12 @@ test_scout_teardown_removes_orca_worktree_via_helper() { orca_case teardown printf '{"ok":true,"result":{"worktree":{"id":"wt-teardown","path":"%s"}}}\n' "$wt" > "$RESP/1.out" neutral=$(neutral_fm_root "$CASE_DIR/neutral") + set +e out=$( PATH="$FB:$PATH" FM_ORCA_LOG="$LOG" FM_ORCA_RESPONSES="$RESP" \ FM_ROOT_OVERRIDE="$neutral" FM_STATE_OVERRIDE="$state" FM_DATA_OVERRIDE="$data" FM_CONFIG_OVERRIDE="$config" \ "$ROOT/bin/fm-teardown.sh" "$id" 2>&1 ) rc=$? + set +e expect_code 0 "$rc" "Orca scout teardown should succeed once report exists"$'\n'"$out" assert_contains "$(cat "$LOG")" $'orca\x1f''terminal'$'\x1f''close'$'\x1f''--terminal'$'\x1f''term-teardown'$'\x1f''--json' \ "teardown did not close the recorded Orca terminal" @@ -1519,10 +1603,12 @@ test_scout_teardown_refuses_orca_id_path_mismatch() { orca_case scout-mismatch printf '{"ok":true,"result":{"worktree":{"id":"wt-scout-mismatch","path":"%s"}}}\n' "$other_wt" > "$RESP/1.out" neutral=$(neutral_fm_root "$CASE_DIR/neutral") + set +e out=$( PATH="$FB:$PATH" FM_ORCA_LOG="$LOG" FM_ORCA_RESPONSES="$RESP" \ FM_ROOT_OVERRIDE="$neutral" FM_STATE_OVERRIDE="$state" FM_DATA_OVERRIDE="$data" FM_CONFIG_OVERRIDE="$config" \ "$ROOT/bin/fm-teardown.sh" "$id" 2>&1 ) rc=$? + set +e [ "$rc" -ne 0 ] || fail "Orca scout teardown should refuse when id path differs from worktree=" assert_contains "$out" "not inspected worktree" \ "mismatched Orca scout worktree path refusal should name the mismatch" @@ -1552,12 +1638,14 @@ test_teardown_refuses_orca_worktree_when_path_missing() { "backend=orca" "orca_worktree_id=wt-missing-path" orca_case missing-path neutral=$(neutral_fm_root "$CASE_DIR/neutral") + set +e out=$( PATH="$FB:$PATH" FM_ORCA_LOG="$LOG" FM_ORCA_RESPONSES="$RESP" \ FM_ROOT_OVERRIDE="$neutral" FM_STATE_OVERRIDE="$state" FM_DATA_OVERRIDE="$data" FM_CONFIG_OVERRIDE="$config" \ "$ROOT/bin/fm-teardown.sh" "$id" 2>&1 ) rc=$? + set +e [ "$rc" -ne 0 ] || fail "Orca teardown should refuse when its worktree path is absent" - assert_contains "$out" "teardown worktree metadata is not an exact repository root" \ + assert_contains "$out" "teardown worktree metadata is not an exact inspectable repository root" \ "pathless Orca teardown should surface the unprovable target identity" [ ! -s "$LOG" ] || fail "pathless Orca teardown should not close a terminal or remove a worktree" assert_present "$state/$id.meta" "pathless Orca teardown should preserve task metadata" @@ -1583,10 +1671,12 @@ test_teardown_preserves_metadata_when_orca_remove_error_json() { orca_case remove-error-teardown printf '{"ok":true,"result":{"worktree":{"id":"wt-remove-error","path":"%s"}}}\n' "$wt" > "$RESP/1.out" neutral=$(neutral_fm_root "$CASE_DIR/neutral") + set +e out=$( PATH="$FB:$PATH" FM_ORCA_LOG="$LOG" FM_ORCA_RESPONSES="$RESP" FM_ORCA_REMOVE_ERROR=1 \ FM_ROOT_OVERRIDE="$neutral" FM_STATE_OVERRIDE="$state" FM_DATA_OVERRIDE="$data" FM_CONFIG_OVERRIDE="$config" \ "$ROOT/bin/fm-teardown.sh" "$id" 2>&1 ) rc=$? + set +e [ "$rc" -ne 0 ] || fail "Orca teardown should fail when worktree removal returns ok:false JSON" assert_contains "$out" "worktree not removed" "teardown should surface the Orca removal error" assert_present "$state/$id.meta" "failed Orca removal should preserve task metadata" @@ -1609,10 +1699,12 @@ test_scout_teardown_refuses_orca_missing_report_when_path_missing() { "backend=orca" "orca_worktree_id=wt-missing-report" orca_case missing-report neutral=$(neutral_fm_root "$CASE_DIR/neutral") + set +e out=$( PATH="$FB:$PATH" FM_ORCA_LOG="$LOG" FM_ORCA_RESPONSES="$RESP" \ FM_ROOT_OVERRIDE="$neutral" FM_STATE_OVERRIDE="$state" FM_DATA_OVERRIDE="$data" FM_CONFIG_OVERRIDE="$config" \ "$ROOT/bin/fm-teardown.sh" "$id" 2>&1 ) rc=$? + set +e [ "$rc" -ne 0 ] || fail "Orca scout teardown should refuse without a report even when the path is absent" assert_contains "$out" "has no report" "Orca scout teardown should explain the missing report" [ ! -s "$LOG" ] || fail "refused Orca scout teardown should not close terminals or remove worktrees" @@ -1637,12 +1729,14 @@ test_ship_teardown_refuses_orca_missing_worktree_path() { "backend=orca" "orca_worktree_id=wt-missing-ship" orca_case missing-ship-path neutral=$(neutral_fm_root "$CASE_DIR/neutral") + set +e out=$( PATH="$FB:$PATH" FM_ORCA_LOG="$LOG" FM_ORCA_RESPONSES="$RESP" \ FM_ROOT_OVERRIDE="$neutral" FM_STATE_OVERRIDE="$state" FM_DATA_OVERRIDE="$data" FM_CONFIG_OVERRIDE="$config" \ "$ROOT/bin/fm-teardown.sh" "$id" 2>&1 ) rc=$? + set +e [ "$rc" -ne 0 ] || fail "Orca ship teardown should refuse a missing worktree path" - assert_contains "$out" "no inspectable git worktree" \ + assert_contains "$out" "teardown worktree metadata is not an exact inspectable repository root" \ "Orca ship teardown should explain the fail-closed worktree requirement" [ ! -s "$LOG" ] || fail "refused Orca ship teardown should not close terminals or remove worktrees" assert_present "$state/$id.meta" "refused Orca ship teardown should preserve metadata" @@ -1667,10 +1761,12 @@ test_ship_teardown_removes_orca_worktree_when_id_path_matches() { orca_case ship-match printf '{"ok":true,"result":{"worktree":{"id":"wt-ship-match","path":"%s"}}}\n' "$wt" > "$RESP/1.out" neutral=$(neutral_fm_root "$CASE_DIR/neutral") + set +e out=$( PATH="$FB:$PATH" FM_ORCA_LOG="$LOG" FM_ORCA_RESPONSES="$RESP" \ FM_ROOT_OVERRIDE="$neutral" FM_STATE_OVERRIDE="$state" FM_DATA_OVERRIDE="$data" FM_CONFIG_OVERRIDE="$config" \ "$ROOT/bin/fm-teardown.sh" "$id" 2>&1 ) rc=$? + set +e expect_code 0 "$rc" "Orca ship teardown should succeed when the id path matches the inspected worktree"$'\n'"$out" assert_contains "$(cat "$LOG")" $'orca\x1f''worktree'$'\x1f''show'$'\x1f''--worktree'$'\x1f''id:wt-ship-match'$'\x1f''--json' \ "teardown did not resolve the Orca worktree id before removal" @@ -1700,12 +1796,14 @@ test_ship_teardown_rejects_orca_mounted_removal_root() { orca_case mounted-root printf '{"ok":true,"result":{"worktree":{"id":"wt-mounted-root","path":"%s"}}}\n' "$wt" > "$RESP/1.out" neutral=$(neutral_fm_root "$CASE_DIR/neutral") + set +e out=$(PATH="$FB:$PATH" FM_ORCA_LOG="$LOG" FM_ORCA_RESPONSES="$RESP" \ FM_ROOT_OVERRIDE="$neutral" FM_STATE_OVERRIDE="$state" FM_DATA_OVERRIDE="$data" \ FM_CONFIG_OVERRIDE="$config" FM_ACCOUNT_ROUTING_TEST_LAB=firstmate-account-routing-test-lab-v1 \ FM_TEARDOWN_TEST_MOUNT_PATH="$wt" \ "$ROOT/bin/fm-teardown.sh" "$id" 2>&1) rc=$? + set +e expect_code 1 "$rc" "mounted Orca worktree root must block provider removal" assert_not_contains "$(cat "$LOG")" $'orca\x1f''worktree'$'\x1f''rm' \ "mounted Orca worktree reached provider removal" @@ -1733,10 +1831,12 @@ test_ship_teardown_refuses_orca_unresolvable_worktree_id() { orca_case ship-unresolved printf '1\n' > "$RESP/1.exit" neutral=$(neutral_fm_root "$CASE_DIR/neutral") + set +e out=$( PATH="$FB:$PATH" FM_ORCA_LOG="$LOG" FM_ORCA_RESPONSES="$RESP" \ FM_ROOT_OVERRIDE="$neutral" FM_STATE_OVERRIDE="$state" FM_DATA_OVERRIDE="$data" FM_CONFIG_OVERRIDE="$config" \ "$ROOT/bin/fm-teardown.sh" "$id" 2>&1 ) rc=$? + set +e [ "$rc" -ne 0 ] || fail "Orca ship teardown should refuse when the worktree id cannot be resolved" assert_contains "$out" "cannot resolve Orca worktree id wt-ship-unresolved" \ "unresolvable Orca worktree id refusal should explain the fail-closed check" @@ -1770,10 +1870,12 @@ test_ship_teardown_refuses_orca_id_path_mismatch() { orca_case ship-mismatch printf '{"ok":true,"result":{"worktree":{"id":"wt-ship-mismatch","path":"%s"}}}\n' "$other_wt" > "$RESP/1.out" neutral=$(neutral_fm_root "$CASE_DIR/neutral") + set +e out=$( PATH="$FB:$PATH" FM_ORCA_LOG="$LOG" FM_ORCA_RESPONSES="$RESP" \ FM_ROOT_OVERRIDE="$neutral" FM_STATE_OVERRIDE="$state" FM_DATA_OVERRIDE="$data" FM_CONFIG_OVERRIDE="$config" \ "$ROOT/bin/fm-teardown.sh" "$id" 2>&1 ) rc=$? + set +e [ "$rc" -ne 0 ] || fail "Orca ship teardown should refuse when the id path differs from worktree=" assert_contains "$out" "not inspected worktree" \ "mismatched Orca worktree path refusal should name the mismatch" @@ -1804,10 +1906,12 @@ test_teardown_refuses_orca_missing_worktree_id() { "harness=claude" "kind=scout" "mode=no-mistakes" "yolo=off" "backend=orca" orca_case missing-id neutral=$(neutral_fm_root "$CASE_DIR/neutral") + set +e out=$( PATH="$FB:$PATH" FM_ORCA_LOG="$LOG" FM_ORCA_RESPONSES="$RESP" \ FM_ROOT_OVERRIDE="$neutral" FM_STATE_OVERRIDE="$state" FM_DATA_OVERRIDE="$data" FM_CONFIG_OVERRIDE="$config" \ "$ROOT/bin/fm-teardown.sh" "$id" 2>&1 ) rc=$? + set +e [ "$rc" -ne 0 ] || fail "Orca teardown should refuse missing orca_worktree_id" assert_contains "$out" "missing orca_worktree_id" "teardown did not explain the missing Orca worktree id" assert_present "$state/$id.meta" "failed teardown must preserve task metadata" @@ -1834,10 +1938,12 @@ test_teardown_refuses_orca_worktree_without_terminal_handle() { orca_case no-terminal printf '{"ok":true,"result":{"worktree":{"id":"wt-no-terminal","path":"%s"}}}\n' "$wt" > "$RESP/1.out" neutral=$(neutral_fm_root "$CASE_DIR/neutral") + set +e out=$( PATH="$FB:$PATH" FM_ORCA_LOG="$LOG" FM_ORCA_RESPONSES="$RESP" \ FM_ROOT_OVERRIDE="$neutral" FM_STATE_OVERRIDE="$state" FM_DATA_OVERRIDE="$data" FM_CONFIG_OVERRIDE="$config" \ "$ROOT/bin/fm-teardown.sh" "$id" 2>&1 ) rc=$? + set +e [ "$rc" -ne 0 ] || fail "Orca teardown should refuse when terminal identity is missing" assert_contains "$out" "missing terminal" \ "missing Orca terminal identity was not surfaced" @@ -1858,7 +1964,10 @@ test_secondmate_force_teardown_removes_orca_child_via_orca() { child_id="orcachildz6" mkdir -p "$home/state" "$home/data" "$subhome/state" "$subhome/projects" printf 'domain\n' > "$subhome/.fm-secondmate-home" - fm_git_worktree "$childproj" "$childwt" "fm/$child_id" + orca_case secondmate-child-cleanup + neutral=$(neutral_fm_root "$CASE_DIR/neutral") + initialize_secondmate_home_repo "$subhome" "$neutral" + initialize_secondmate_project_repo "$home" "$childproj" "$childwt" "fm/$child_id" fm_write_meta "$home/state/domain.meta" \ "window=firstmate:fm-domain" "worktree=$subhome" "project=$subhome" \ "harness=echo" "kind=secondmate" "mode=secondmate" "yolo=off" \ @@ -1869,15 +1978,16 @@ test_secondmate_force_teardown_removes_orca_child_via_orca() { "window=fm-$child_id" "terminal=term-child-cleanup" "worktree=$childwt" "project=$childproj" \ "harness=claude" "kind=ship" "mode=no-mistakes" "yolo=off" \ "backend=orca" "orca_worktree_id=wt-child-cleanup" - orca_case secondmate-child-cleanup printf '{"ok":true,"result":{"worktree":{"id":"wt-child-cleanup","name":"fm-%s","path":"%s","terminals":[{"handle":"term-child-cleanup","title":"fm-%s"}]}}}\n' \ "$child_id" "$childwt" "$child_id" > "$RESP/1.out" add_tmux_fake "$FB" - neutral=$(neutral_fm_root "$CASE_DIR/neutral") - initialize_secondmate_home_repo "$subhome" "$neutral" + set +e out=$( PATH="$FB:$PATH" FM_ORCA_LOG="$LOG" FM_ORCA_RESPONSES="$RESP" \ + FM_ORCA_DEFAULT_TERMINAL_TITLE="fm-$child_id" \ + FM_ORCA_REMOVE_PROJECT="$childproj" FM_ORCA_REMOVE_PATH="$childwt" \ FM_ROOT_OVERRIDE="$neutral" FM_HOME="$home" "$ROOT/bin/fm-teardown.sh" domain --force 2>&1 ) rc=$? + set +e expect_code 0 "$rc" "forced secondmate teardown should remove Orca child work through Orca"$'\n'"$out" assert_contains "$(cat "$LOG")" $'orca\x1f''terminal'$'\x1f''close'$'\x1f''--terminal'$'\x1f''term-child-cleanup'$'\x1f''--json' \ "child cleanup did not close the recorded Orca terminal" @@ -1899,8 +2009,11 @@ test_secondmate_force_teardown_refuses_orca_child_id_path_mismatch() { child_id="orcachildmismatchz1" mkdir -p "$home/state" "$home/data" "$subhome/state" "$subhome/projects" printf 'domain\n' > "$subhome/.fm-secondmate-home" - fm_git_worktree "$childproj" "$childwt" "fm/$child_id" - git -C "$childproj" worktree add --quiet -b "fm/$child_id-other" "$other_wt" + orca_case secondmate-child-mismatch + neutral=$(neutral_fm_root "$CASE_DIR/neutral") + initialize_secondmate_home_repo "$subhome" "$neutral" + initialize_secondmate_project_repo "$home" "$childproj" "$childwt" "fm/$child_id" + mkdir -p "$other_wt" fm_write_meta "$home/state/domain.meta" \ "window=firstmate:fm-domain" "worktree=$subhome" "project=$subhome" \ "harness=echo" "kind=secondmate" "mode=secondmate" "yolo=off" \ @@ -1911,14 +2024,13 @@ test_secondmate_force_teardown_refuses_orca_child_id_path_mismatch() { "window=fm-$child_id" "terminal=term-child-mismatch" "worktree=$childwt" "project=$childproj" \ "harness=claude" "kind=ship" "mode=no-mistakes" "yolo=off" \ "backend=orca" "orca_worktree_id=wt-child-mismatch" - orca_case secondmate-child-mismatch printf '{"ok":true,"result":{"worktree":{"id":"wt-child-mismatch","path":"%s"}}}\n' "$other_wt" > "$RESP/1.out" add_tmux_fake "$FB" - neutral=$(neutral_fm_root "$CASE_DIR/neutral") - initialize_secondmate_home_repo "$subhome" "$neutral" + set +e out=$( PATH="$FB:$PATH" FM_ORCA_LOG="$LOG" FM_ORCA_RESPONSES="$RESP" \ FM_ROOT_OVERRIDE="$neutral" FM_HOME="$home" "$ROOT/bin/fm-teardown.sh" domain --force 2>&1 ) rc=$? + set +e [ "$rc" -ne 0 ] || fail "forced secondmate teardown should refuse mismatched Orca child id/path" assert_contains "$out" "not inspected worktree" \ "mismatched Orca child worktree path refusal should name the mismatch" @@ -1939,7 +2051,10 @@ test_secondmate_force_teardown_retains_partial_orca_child() { child_id="orcapartialz9" mkdir -p "$home/state" "$home/data" "$subhome/state" "$subhome/projects" printf 'domain\n' > "$subhome/.fm-secondmate-home" - fm_git_worktree "$childproj" "$childwt" "fm/$child_id" + orca_case secondmate-partial-child-cleanup + neutral=$(neutral_fm_root "$CASE_DIR/neutral") + initialize_secondmate_home_repo "$subhome" "$neutral" + initialize_secondmate_project_repo "$home" "$childproj" "$childwt" "fm/$child_id" fm_write_meta "$home/state/domain.meta" \ "window=firstmate:fm-domain" "worktree=$subhome" "project=$subhome" \ "harness=echo" "kind=secondmate" "mode=secondmate" "yolo=off" \ @@ -1950,14 +2065,13 @@ test_secondmate_force_teardown_retains_partial_orca_child() { "window=fm-$child_id" "worktree=$childwt" "project=$childproj" \ "harness=claude" "kind=ship" "mode=no-mistakes" "yolo=off" \ "backend=orca" "orca_worktree_id=wt-partial-child" - orca_case secondmate-partial-child-cleanup printf '{"ok":true,"result":{"worktree":{"id":"wt-partial-child","path":"%s"}}}\n' "$childwt" > "$RESP/1.out" add_tmux_fake "$FB" - neutral=$(neutral_fm_root "$CASE_DIR/neutral") - initialize_secondmate_home_repo "$subhome" "$neutral" + set +e out=$( PATH="$FB:$PATH" FM_ORCA_LOG="$LOG" FM_ORCA_RESPONSES="$RESP" \ FM_ROOT_OVERRIDE="$neutral" FM_HOME="$home" "$ROOT/bin/fm-teardown.sh" domain --force 2>&1 ) rc=$? + set +e [ "$rc" -ne 0 ] || fail "forced secondmate teardown should refuse partial Orca child state" assert_contains "$out" "child endpoint identity for $child_id is missing" \ "partial Orca child refusal did not surface missing endpoint identity" @@ -1996,11 +2110,13 @@ test_spawn_refuses_cleanup_pending_orca_task_before_mutation() { "orca_cleanup_pending=1" "orca_cleanup_phase=spawn-abort" "orca_terminal_proof=recorded" orca_case cleanup-pending-block + set +e out=$(PATH="$FB:$PATH" FM_ORCA_LOG="$LOG" FM_ORCA_RESPONSES="$RESP" \ FM_ROOT_OVERRIDE="$ROOT" FM_STATE_OVERRIDE="$state" FM_DATA_OVERRIDE="$data" FM_CONFIG_OVERRIDE="$config" \ FM_PROJECTS_OVERRIDE="$TMP_ROOT/unused-projects" FM_SPAWN_NO_GUARD=1 \ "$ROOT/bin/fm-spawn.sh" "$id" "$proj" claude --backend orca 2>&1) status=$? + set +e [ "$status" -ne 0 ] || fail "spawn reused an Orca cleanup quarantine" assert_contains "$out" "Orca cleanup is pending for $id" \ @@ -2030,11 +2146,13 @@ test_pathless_orca_quarantine_has_supported_cleanup() { printf '{"ok":true,"result":{"worktree":{"id":"wt-path-cleanup","path":"%s"}}}\n' "$wt" > "$RESP/1.out" neutral=$(neutral_fm_root "$CASE_DIR/neutral") + set +e out=$(PATH="$FB:$PATH" FM_ORCA_LOG="$LOG" FM_ORCA_RESPONSES="$RESP" \ FM_ROOT_OVERRIDE="$neutral" FM_STATE_OVERRIDE="$state" FM_DATA_OVERRIDE="$data" FM_CONFIG_OVERRIDE="$config" \ FM_CHECKOUT_REFRESH_STATE_BASE="$CASE_DIR/checkout-state" \ "$ROOT/bin/fm-teardown.sh" "$id" 2>&1) status=$? + set +e expect_code 0 "$status" "pathless Orca quarantine cleanup"$'\n'"$out" assert_contains "$(cat "$LOG")" $'orca\x1f''terminal'$'\x1f''close'$'\x1f''--terminal'$'\x1f''term-path-cleanup' \ @@ -2062,10 +2180,12 @@ test_idless_orca_quarantine_refuses_unscoped_terminal_close() { orca_case idless-unscoped-cleanup neutral=$(neutral_fm_root "$CASE_DIR/neutral") + set +e out=$(PATH="$FB:$PATH" FM_ORCA_LOG="$LOG" FM_ORCA_RESPONSES="$RESP" \ FM_ROOT_OVERRIDE="$neutral" FM_STATE_OVERRIDE="$state" FM_DATA_OVERRIDE="$data" FM_CONFIG_OVERRIDE="$config" \ "$ROOT/bin/fm-teardown.sh" "$id" 2>&1) status=$? + set +e [ "$status" -ne 0 ] || fail "idless Orca quarantine closed an unscoped terminal" assert_contains "$out" "refusing to close an unscoped terminal" \ @@ -2095,10 +2215,12 @@ test_teardown_refuses_orca_terminal_worktree_identity_drift() { printf 'wt-other\n' > "$RESP/.terminal-worktree-override" neutral=$(neutral_fm_root "$CASE_DIR/neutral") + set +e out=$(PATH="$FB:$PATH" FM_ORCA_LOG="$LOG" FM_ORCA_RESPONSES="$RESP" \ FM_ROOT_OVERRIDE="$neutral" FM_STATE_OVERRIDE="$state" FM_DATA_OVERRIDE="$data" FM_CONFIG_OVERRIDE="$config" \ "$ROOT/bin/fm-teardown.sh" "$id" 2>&1) status=$? + set +e [ "$status" -ne 0 ] || fail "teardown closed a terminal bound to another Orca worktree" assert_contains "$out" "task Orca endpoint authority or quiescence is unproven" \ @@ -2129,11 +2251,13 @@ test_spawn_quarantines_create_response_without_worktree_id() { printf '{"ok":true,"result":{"repo":{"id":"repo-partial-id"}}}\n' > "$RESP/2.out" printf '{"ok":true,"result":{"worktree":{"path":"%s"},"terminal":{"handle":"term-partial-id"}}}\n' "$proj" > "$RESP/3.out" + set +e out=$(PATH="$FB:$PATH" FM_ORCA_LOG="$LOG" FM_ORCA_RESPONSES="$RESP" \ FM_ROOT_OVERRIDE="$ROOT" FM_STATE_OVERRIDE="$state" FM_DATA_OVERRIDE="$data" FM_CONFIG_OVERRIDE="$config" \ FM_PROJECTS_OVERRIDE="$TMP_ROOT/unused-projects" FM_SPAWN_NO_GUARD=1 \ "$ROOT/bin/fm-spawn.sh" "$id" "$proj" claude --backend orca 2>&1) status=$? + set +e [ "$status" -ne 0 ] || fail "spawn accepted an Orca create response without a worktree id" assert_grep "worktree=$proj" "$state/$id.meta" \ @@ -2175,6 +2299,7 @@ test_orca_quarantine_write_failure_keeps_prearmed_blocker() { printf '{"ok":true,"result":{"repo":{"id":"repo-quarantine-write"}}}\n' > "$RESP/2.out" printf '{"ok":true,"result":{"worktree":{"id":"wt-quarantine-write","path":"%s"}}}\n' "$proj" > "$RESP/3.out" + set +e out=$(PATH="$FB:$PATH" FM_ORCA_LOG="$LOG" FM_ORCA_RESPONSES="$RESP" \ FM_ORCA_QUARANTINE_STATE_READONLY=1 \ FM_ROOT_OVERRIDE="$ROOT" FM_STATE_OVERRIDE="$state" FM_DATA_OVERRIDE="$data" FM_CONFIG_OVERRIDE="$config" \ @@ -2182,6 +2307,7 @@ test_orca_quarantine_write_failure_keeps_prearmed_blocker() { "$ROOT/bin/fm-spawn.sh" "$id" "$proj" claude --backend orca 2>&1) status=$? chmod 700 "$state" + set +e [ "$status" -ne 0 ] || fail "spawn ignored an Orca quarantine update failure" assert_grep 'orca_cleanup_pending=1' "$state/$id.meta" \ @@ -2192,11 +2318,13 @@ test_orca_quarantine_write_failure_keeps_prearmed_blocker() { "quarantine write failure lost the pre-armed discovery label" assert_grep "orca_provider_scope=repo-path:$proj" "$state/$id.meta" \ "quarantine write failure lost the pre-armed provider scope" + set +e out=$(PATH="$FB:$PATH" FM_ORCA_LOG="$LOG" FM_ORCA_RESPONSES="$RESP" \ FM_ROOT_OVERRIDE="$ROOT" FM_STATE_OVERRIDE="$state" FM_DATA_OVERRIDE="$data" FM_CONFIG_OVERRIDE="$config" \ FM_PROJECTS_OVERRIDE="$TMP_ROOT/unused-projects" FM_SPAWN_NO_GUARD=1 \ "$ROOT/bin/fm-spawn.sh" "$id" "$proj" claude --backend orca 2>&1) status=$? + set +e [ "$status" -ne 0 ] || fail "spawn reused a task after quarantine publication failed" assert_contains "$out" "Orca cleanup is pending for $id" \ "pre-armed quarantine did not block retry" @@ -2224,10 +2352,12 @@ test_teardown_rejects_cross_task_orca_terminal_label() { printf 'wt-cross-task\n' > "$RESP/.terminal-worktree-override" neutral=$(neutral_fm_root "$CASE_DIR/neutral") + set +e out=$(PATH="$FB:$PATH" FM_ORCA_LOG="$LOG" FM_ORCA_RESPONSES="$RESP" \ FM_ROOT_OVERRIDE="$neutral" FM_STATE_OVERRIDE="$state" FM_DATA_OVERRIDE="$data" FM_CONFIG_OVERRIDE="$config" \ "$ROOT/bin/fm-teardown.sh" "$id" 2>&1) status=$? + set +e [ "$status" -ne 0 ] || fail "teardown accepted a terminal labeled for another task" assert_contains "$out" "task Orca endpoint authority or quiescence is unproven" \ @@ -2261,10 +2391,12 @@ test_teardown_rejects_cross_task_orca_worktree_label() { printf 'wt-worktree-task\n' > "$RESP/.terminal-worktree-override" neutral=$(neutral_fm_root "$CASE_DIR/neutral") + set +e out=$(PATH="$FB:$PATH" FM_ORCA_LOG="$LOG" FM_ORCA_RESPONSES="$RESP" \ FM_ROOT_OVERRIDE="$neutral" FM_STATE_OVERRIDE="$state" FM_DATA_OVERRIDE="$data" FM_CONFIG_OVERRIDE="$config" \ "$ROOT/bin/fm-teardown.sh" "$id" 2>&1) status=$? + set +e [ "$status" -ne 0 ] || fail "teardown accepted an Orca worktree labeled for another task" assert_contains "$out" "task Orca endpoint authority or quiescence is unproven" \ @@ -2302,10 +2434,12 @@ test_teardown_quiesces_unrecorded_orca_terminals() { printf 'wt-unrecorded\n' > "$RESP/.terminal-worktree-override" neutral=$(neutral_fm_root "$CASE_DIR/neutral") + set +e out=$(PATH="$FB:$PATH" FM_ORCA_LOG="$LOG" FM_ORCA_RESPONSES="$RESP" \ FM_ROOT_OVERRIDE="$neutral" FM_STATE_OVERRIDE="$state" FM_DATA_OVERRIDE="$data" FM_CONFIG_OVERRIDE="$config" \ "$ROOT/bin/fm-teardown.sh" "$id" --force 2>&1) status=$? + set +e expect_code 0 "$status" "unrecorded Orca terminal cleanup"$'\n'"$out" assert_contains "$(cat "$LOG")" $'orca\x1f''terminal'$'\x1f''close'$'\x1f''--terminal'$'\x1f''term-unrecorded' \ @@ -2337,10 +2471,12 @@ test_teardown_rejects_live_recorded_terminal_missing_from_inventory() { printf 'wt-omitted\n' > "$RESP/.terminal-worktree-override" neutral=$(neutral_fm_root "$CASE_DIR/neutral") + set +e out=$(PATH="$FB:$PATH" FM_ORCA_LOG="$LOG" FM_ORCA_RESPONSES="$RESP" \ FM_ROOT_OVERRIDE="$neutral" FM_STATE_OVERRIDE="$state" FM_DATA_OVERRIDE="$data" FM_CONFIG_OVERRIDE="$config" \ "$ROOT/bin/fm-teardown.sh" "$id" 2>&1) status=$? + set +e [ "$status" -ne 0 ] || fail "teardown accepted a live recorded terminal omitted from the worktree inventory" assert_contains "$out" "task Orca endpoint authority or quiescence is unproven" \ @@ -2434,7 +2570,7 @@ test_worktree_and_terminal_helpers_parse_json test_worktree_create_retains_partial_authority_when_path_missing test_worktree_create_never_cleans_partial_response_inline test_spawn_preserves_orca_metadata_when_pathless_worktree_cleanup_fails -test_legacy_respawn_refuses_without_provider_task_authority +test_legacy_respawn_writes_orca_metadata_and_launches_harness test_spawn_refuses_new_report_required_orca_task_before_mutation test_spawn_refuses_orca_respawn_of_report_required_task test_spawn_refuses_malformed_legacy_orca_report_metadata @@ -2444,8 +2580,36 @@ test_report_required_orca_recovery_preserves_inherited_lifecycle_state test_spawn_refuses_orca_secondmate_before_home_mutation test_spawn_refuses_orca_when_runtime_not_ready test_spawn_refuses_orca_without_verified_authority_capabilities -# docs/orca-backend.md "Eligibility" disables Orca spawn and destructive -# lifecycle work; their retained reference cases run only through focused modes. +test_spawn_refuses_orca_nonisolated_worktree +test_spawn_quarantines_unrelated_orca_worktree +test_spawn_quarantines_unbound_orca_terminal +test_spawn_quarantines_orca_worktree_when_terminal_create_fails +test_spawn_preserves_orca_metadata_when_abort_cleanup_fails +test_spawn_retains_orca_worktree_when_abort_close_fails +test_spawn_refuses_invalid_state_before_orca_resource_creation test_peek_send_and_crew_state_route_through_orca_meta test_peek_and_crew_state_fail_closed_on_orca_error_json test_target_exists_rejects_orca_error_json +test_scout_teardown_removes_orca_worktree_via_helper +test_scout_teardown_refuses_orca_id_path_mismatch +test_teardown_refuses_orca_worktree_when_path_missing +test_teardown_preserves_metadata_when_orca_remove_error_json +test_scout_teardown_refuses_orca_missing_report_when_path_missing +test_ship_teardown_refuses_orca_missing_worktree_path +test_ship_teardown_removes_orca_worktree_when_id_path_matches +test_ship_teardown_rejects_orca_mounted_removal_root +test_ship_teardown_refuses_orca_unresolvable_worktree_id +test_ship_teardown_refuses_orca_id_path_mismatch +test_teardown_refuses_orca_missing_worktree_id +test_teardown_refuses_orca_worktree_without_terminal_handle +test_teardown_rejects_symlinked_orca_task_metadata +test_secondmate_force_teardown_removes_orca_child_via_orca +test_secondmate_force_teardown_refuses_orca_child_id_path_mismatch +test_secondmate_force_teardown_retains_partial_orca_child +test_spawn_quarantines_create_response_without_worktree_id +test_orca_quarantine_write_failure_keeps_prearmed_blocker +test_idless_orca_quarantine_refuses_unscoped_terminal_close +test_teardown_rejects_cross_task_orca_terminal_label +test_teardown_rejects_cross_task_orca_worktree_label +test_teardown_quiesces_unrecorded_orca_terminals +test_teardown_rejects_live_recorded_terminal_missing_from_inventory From bdd0848dbf304cc6964024b48038eab2e6d6f062 Mon Sep 17 00:00:00 2001 From: Dongkeun Lee Date: Tue, 28 Jul 2026 21:56:01 -0400 Subject: [PATCH 7/8] no-mistakes: apply CI fixes --- bin/fm-spawn.sh | 1 - bin/fm-teardown.sh | 2 +- tests/fm-backend-orca.test.sh | 6 +++--- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/bin/fm-spawn.sh b/bin/fm-spawn.sh index 9702390086..9fda7dfca2 100755 --- a/bin/fm-spawn.sh +++ b/bin/fm-spawn.sh @@ -1044,7 +1044,6 @@ parse_orca_worktree_result() { rest=${rest#*$'\t'} ORCA_REPO_ID=$rest case "$ORCA_REPO_ID" in *$'\t'*) return 1 ;; esac - ORCA_PROVIDER_TASK= } persist_orca_cleanup_quarantine() { diff --git a/bin/fm-teardown.sh b/bin/fm-teardown.sh index 4a8422039a..cf246baa1a 100755 --- a/bin/fm-teardown.sh +++ b/bin/fm-teardown.sh @@ -3439,7 +3439,7 @@ validate_firstmate_home_for_removal() { require_treehouse_task_lease "$abs_home_path" "$expected_id" || return 1 fi validate_secondmate_home_landed_state "$abs_home_path" "$expected_source" || return 1 - if [ -n "$expected_id" ]; then + if [ -n "$expected_id" ] && [ "$source_authority" -eq 1 ]; then validate_secondmate_project_clones \ "$abs_home_path" "$expected_registry" "$expected_id" "$expected_source" || return 1 fi diff --git a/tests/fm-backend-orca.test.sh b/tests/fm-backend-orca.test.sh index 7eddfab808..b309cd0742 100755 --- a/tests/fm-backend-orca.test.sh +++ b/tests/fm-backend-orca.test.sh @@ -1967,7 +1967,7 @@ test_secondmate_force_teardown_removes_orca_child_via_orca() { orca_case secondmate-child-cleanup neutral=$(neutral_fm_root "$CASE_DIR/neutral") initialize_secondmate_home_repo "$subhome" "$neutral" - initialize_secondmate_project_repo "$home" "$childproj" "$childwt" "fm/$child_id" + initialize_secondmate_project_repo "$neutral" "$childproj" "$childwt" "fm/$child_id" fm_write_meta "$home/state/domain.meta" \ "window=firstmate:fm-domain" "worktree=$subhome" "project=$subhome" \ "harness=echo" "kind=secondmate" "mode=secondmate" "yolo=off" \ @@ -2012,7 +2012,7 @@ test_secondmate_force_teardown_refuses_orca_child_id_path_mismatch() { orca_case secondmate-child-mismatch neutral=$(neutral_fm_root "$CASE_DIR/neutral") initialize_secondmate_home_repo "$subhome" "$neutral" - initialize_secondmate_project_repo "$home" "$childproj" "$childwt" "fm/$child_id" + initialize_secondmate_project_repo "$neutral" "$childproj" "$childwt" "fm/$child_id" mkdir -p "$other_wt" fm_write_meta "$home/state/domain.meta" \ "window=firstmate:fm-domain" "worktree=$subhome" "project=$subhome" \ @@ -2054,7 +2054,7 @@ test_secondmate_force_teardown_retains_partial_orca_child() { orca_case secondmate-partial-child-cleanup neutral=$(neutral_fm_root "$CASE_DIR/neutral") initialize_secondmate_home_repo "$subhome" "$neutral" - initialize_secondmate_project_repo "$home" "$childproj" "$childwt" "fm/$child_id" + initialize_secondmate_project_repo "$neutral" "$childproj" "$childwt" "fm/$child_id" fm_write_meta "$home/state/domain.meta" \ "window=firstmate:fm-domain" "worktree=$subhome" "project=$subhome" \ "harness=echo" "kind=secondmate" "mode=secondmate" "yolo=off" \ From a3efcaf4f78da6744ab86f2d9100cf7f2d3fd720 Mon Sep 17 00:00:00 2001 From: Dongkeun Lee Date: Tue, 28 Jul 2026 22:28:06 -0400 Subject: [PATCH 8/8] no-mistakes: apply CI fixes --- bin/fm-spawn.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/bin/fm-spawn.sh b/bin/fm-spawn.sh index 9fda7dfca2..0ccc224e97 100755 --- a/bin/fm-spawn.sh +++ b/bin/fm-spawn.sh @@ -953,7 +953,6 @@ ORCA_TERMINAL= ORCA_TERMINAL_PROOF= ORCA_REPO_ID= ORCA_EXPECTED_TASK= -ORCA_PROVIDER_TASK= ID= ACCOUNT_LEASE_CREATED=0 FM_ACCOUNT_MUTATION_ACQUIRED=0