Repository navigation
fix(bin): accept Orca's composite worktree id when tearing down a task - #4677
Conversation
Teardown refused every Orca-backed task because the endpoint validator checked orca_worktree_id with the simple-atom rule meant for tmux-style window names, which rejects any character outside [A-Za-z0-9._@%+-]. Orca returns that id as `<orca id>::<absolute worktree path>`, so the colon and slashes in every real value made validation fail and finished Orca tasks could never be cleaned up. Validate the field as the composite it is: both halves of the first `::` split present, the path half absolute, and no embedded newline, carriage return, or tab. The terminal field keeps the atom check, which is correct for it, and no other backend's validation changes. The existing Orca fixtures recorded ids like `wt-teardown`, a shape Orca never returns, which is why the suite passed a check the real value fails. They now carry the composite form, so the tests exercise the real value.
…gression entry points
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Speaking as Kun's firstmate: First look on HEAD Attestation: MATCH (body Contract-class: restore — Orca-backed teardown on tip was refusing every well-formed live Orca task because VISION.md per-rule
Checks: CI Outcome: waiting-ci. Auto-merge candidate as restore once CI+NM green on this tip. Firstmate flag no while CI open. |
|
Speaking as Kun's firstmate: this is merged. Thank you @JuanJoseGonGi — really appreciate you taking the time on this. |
…fixes (#19) * fix(bin): clear parent pending-replies on local secondmate retirement (kunchenguid#4680) * fix(bin): clear parent pending-replies on local secondmate retirement Local secondmate teardown left resolved parent pending-reply records behind after home removal (seen after papa-hdds / pxmx retirement). Refuse non-forced retirement while any reply for that id is still unresolved, and delete every matching record plus its delivery confirmation after a successful local or remote retirement, matching the remote cleanup path. * no-mistakes(document): Align secondmate retirement docs with pending-reply cleanup * no-mistakes(review): Lokale Pending-replies-Sicherheitsprüfung vor Home-Entfernung * no-mistakes(review): Pending-replies-corr_id auf 16-Hex absichern * no-mistakes(review): Pending-replies Basename und corr_id abgleichen * no-mistakes(document): Clarify forced retirement pending-reply cleanup --------- Co-authored-by: ladwein <[email protected]> * fix(bin): accept Orca's composite worktree id when tearing down a task (kunchenguid#4677) * fix(bin): accept Orca's composite worktree id at teardown Teardown refused every Orca-backed task because the endpoint validator checked orca_worktree_id with the simple-atom rule meant for tmux-style window names, which rejects any character outside [A-Za-z0-9._@%+-]. Orca returns that id as `<orca id>::<absolute worktree path>`, so the colon and slashes in every real value made validation fail and finished Orca tasks could never be cleaned up. Validate the field as the composite it is: both halves of the first `::` split present, the path half absolute, and no embedded newline, carriage return, or tab. The terminal field keeps the atom check, which is correct for it, and no other backend's validation changes. The existing Orca fixtures recorded ids like `wt-teardown`, a shape Orca never returns, which is why the suite passed a check the real value fails. They now carry the composite form, so the tests exercise the real value. * no-mistakes(document): name Orca's repo id in the composite worktree id * no-mistakes(document): list teardown endpoint safety suite in Orca regression entry points * feat(bin): add opt-in typed dispatch resolution (kunchenguid#4692) * feat(bin): add opt-in typed dispatch resolution through typesafe.ai Add bin/fm-dispatch-resolve.sh, which resolves one concrete crewmate or scout profile from a written brief with typesafe.ai's System One model: one Choice question over the rules' `when` texts, then the confidence floor, the rule's `approval` and `floor`, each profile's `provider` and `floor`, one quota-axi snapshot, and the spendPriority argmax all in code. It is off unless TYPESAFE_API_KEY is in the environment or the home's gitignored .env; off means one stderr line, exit 0, and no network call, so firstmate dispatches exactly as before. The key reaches curl on a file descriptor, never argv. Extract fmx_env_get into bin/fm-env-lib.sh as the one .env accessor and the harness-to-provider table into bin/fm-quota-axi-lib.sh so the new tool and bin/fm-quota-choose.sh share one owner each. Bootstrap validates the four new optional dispatch fields. Document the schema, the operator contract, the AGENTS.md intake step, and the live and benchmark evidence. * no-mistakes(review): Harden typed dispatch resolution and quota bounds * no-mistakes(review): Validate dispatch floors and ranking evidence * no-mistakes(review): Tighten dispatch response and floor evidence * no-mistakes(review): Neutralize none matching and resolve defaults locally * no-mistakes(review): Preserve providerless profiles outside typed resolution * no-mistakes(review): Validate response usage and reject duplicate profiles * no-mistakes(review): Escalate unverifiable floors and validate probabilities * no-mistakes(review): Validate probability mass and unknown profile floors * no-mistakes(review): Simplify resolver interface and preserve fallback routing * no-mistakes(review): Fix constants and rank partial quota evidence * no-mistakes(review): Add authoritative provider mapping and enforce explicit providers * no-mistakes(review): Declare provider for documented Pi profile * no-mistakes(review): Validate provider identifiers and support Gemini dispatch * no-mistakes(review): Strictly anchor provider identifiers * no-mistakes(review): Validate selectors and preserve fallback candidate evidence * no-mistakes(review): Gate typed validation and harden resolver evidence * no-mistakes(review): Preserve opt-in routing and harden candidate evidence * no-mistakes(review): Prioritize known exhaustion over quota uncertainty * no-mistakes(review): Isolate API secrets and preserve no-key diagnostics * no-mistakes(review): Fallback safely when dispatch rules are absent * no-mistakes(review): Prioritize quota vetoes and isolate bootstrap secrets * no-mistakes(document): Document typed dispatch safety and fallback behavior * fix(bin): read the latest status event so buried declarations and open decisions aren't lost (kunchenguid#3753) * test: reproduce buried status declarations in shared readers * fix: share status event reads and preserve open blockers * fix: retain terminal scout and ship status declarations * no-mistakes(review): Fix status chronology, legacy completions, and reader performance * no-mistakes(review): Share terminal decision reconciliation across fleet snapshots * no-mistakes(review): Unify terminal supersession across cached folds and consumers * no-mistakes(review): Filter per-key status history while preserving terminal chronology * no-mistakes(test): Preserve parent lock ownership in Bash 3.2 subshells * no-mistakes(review): Anchor legacy status tokens so prose cannot hide pauses * no-mistakes(document): Document latest-event status read and kind-scoped fold cursor * no-mistakes(lint): Quote literal done in test for-lists for SC1010 * ci: expect 19 snapshot/fleet-view tests This branch adds a fleet-snapshot regression, so the stock macOS Bash lane's hardcoded guard of 18 'ok - ' lines fails on the new count. Bump the guard and its message to 19. * no-mistakes(review): Restore multiline child outcome reporting * no-mistakes(review): Select ledger terminal events through bounded shared reader * no-mistakes(review): Report newest open decision instead of preferring blocked * no-mistakes(review): Require colon before ship/scout terminal supersession in fold * no-mistakes(review): Gate socket-down override on latest event; drop lock matrix * no-mistakes(review): Fold only colon-bearing or keyed lines as decision transitions * no-mistakes(review): Pre-select candidate lines before per-key closing-verb fold * no-mistakes(test): Update fleet-view expectations to newest-open-decision rule * no-mistakes(document): Align status-read docs with fold-resolved crew state * no-mistakes(document): Correct status-reader contracts in classify-lib and crew-state headers * no-mistakes(ci): Greptile P1 (bin/fm-crew-state.sh:729, "Stale socket blocker survives") was a real defect introduced by commit b7c2183 on this branch, and is fixed. Root cause: the daemon-socket-down override took its verb check from `last_status_line "$LOG"` but its evidence and emitted detail from `$LOG_LINE` (status_current_line = the fold's newest still-open decision). Those are different lines whenever a later recognized `blocked:` event is one the decision fold declines. Reproduced by sourcing bin/fm-classify-lib.sh on `blocked: no-mistakes daemon socket is missing` followed by `blocked [key=pending-reply-t3]: still waiting on the answer` (reserved-namespace key whose note does not speak that vocabulary, so _fm_decision_key_transition_allowed rejects it): open set still holds the socket blocker, last_status_line returns the newer line, its verb is blocked, so the gate passed and the stale daemon-down evidence overrode a healthy attributed run. Fix (bin/fm-crew-state.sh): capture LOG_LATEST=$(last_status_line "$LOG") once and read verb, socket-down evidence, and the emitted note all off that same line, so the override fires only while the socket-down declaration is itself the log's latest recognized event — preserving the narrow override the prior round's user instruction asked for. Comment updated to state that contract. No new machinery; the two-line conflation was removed rather than papered over. Regression: extended tests/fm-crew-state.test.sh:test_socket_refusal_override_expires_when_the_crew_moves_on with the reproduced sequence, asserting the run-step reading (state: working, source: run-step) and absence of the override detail. It fails before the fix ("not ok - a later unfolded blocked event also hands the reading back to the run (missing: 'state: working')") and passes after. Verified locally: tests/fm-crew-state.test.sh, tests/fm-fleet-snapshot-view.test.sh, tests/fm-classify-decision-key.test.sh, tests/fm-watch-triage.test.sh, tests/fm-captain-hold-lifecycle.test.sh all pass; bin/fm-lint.sh (shellcheck 0.11.0 + actionlint) exits 0. Changes left uncommitted in the worktree * test: fold terminal-cleanup snapshot coverage into the completed-scout case Keep the ship/scout/secondmate supersession assertions without adding a nineteenth top-level fleet-view test, so CI can stay at the upstream suite count. * no-mistakes(document): Clarify socket-down override expiry in architecture doc * ci: retrigger flaky contribution check --------- Co-authored-by: Sebastian <[email protected]> Co-authored-by: ladwein <[email protected]> Co-authored-by: Juan José González Giraldo <[email protected]> Co-authored-by: Kun Chen <[email protected]> Co-authored-by: Tiago <[email protected]>
Intent
Fix the Orca task teardown that firstmate refuses for every Orca-backed task.
bin/fm-teardown.sh refuses with "REFUSED: Orca endpoint metadata for task is malformed or inconsistent; preserving task state." for any task whose backend is orca. Verified by reading bin/fm-backend.sh: in fm_backend_validate_task_endpoint, the
orca)branch validates orca_worktree_id with fm_backend_endpoint_atom_valid, which rejects any character outside [A-Za-z0-9._@%+-]. But orca_worktree_id is a composite of the form<uuid>::<absolute-worktree-path>(real example: 411226f7-dc91-4d37-975d-32d412bf97a2::~/orca/workspaces/scrap-services/fm-wtaudit), so its:and/characters make that atom check fail and teardown refuses. Spawn, supervision (fm-peek, fm-crew-state, fm-send) and the work itself all function; only teardown is blocked, so finished Orca tasks cannot be cleaned up and keep triggering the inactive-outcome scan. This blocks using Orca as the fleet backend.What Changed
bin/fm-backend.shgainsfm_backend_orca_worktree_id_valid, which checks the<orca repo id>::<absolute worktree path>shape Orca actually returns: no control characters, a non-empty id before the first::, and a path starting with/after it. Theorca)branch offm_backend_validate_task_endpointnow validatesorca_worktree_idwith it instead offm_backend_endpoint_atom_valid, whose character set excluded:and/and so refused teardown for every Orca-backed task.tests/fm-backend-orca.test.sh,tests/fm-control.test.shandtests/fm-teardown-endpoint-safety.test.shnow carry composite worktree ids everywhere the backend returns or records one, so the assertions match what Orca really emits.tests/fm-teardown-endpoint-safety.test.shaddstest_orca_composite_worktree_id_validates, covering a real-shaped id plus the separatorless and newline-carrying cases.docs/orca-backend.mddocumentsorca_worktree_id=as that composite of repo id and worktree path, explains that cleanup validation requires both halves, and lists the teardown endpoint safety suite among Orca's regression entry points.Risk Assessment
✅ Low: One validator swap at the shared cleanup-identity boundary, with every downstream use of the id already quoted and no eval, fixtures updated to the shape Orca really returns, and a regression case that exercises the boundary and fails before the fix.
Testing
I stood firstmate up the way an operator runs it, an isolated fleet home with a git-init project, a git worktree standing in for the Orca worktree, and a recordingorcaon PATH, and drovebin/fm-spawn.shandbin/fm-teardown.shdirectly. The reported bug reproduces at base 9f8ad95 (teardown refuses "Orca endpoint metadata ... is malformed or inconsistent" and preserves the task) and is gone on this branch, where the same record tears down and firstmate hands Orca the composite id verbatim inorca worktree rm --worktree id:<repo id>::<path>. The spawn-to-teardown round trip shows the same story end to end: spawn records the composite id at both commits, only teardown differed. Four malformed id shapes and one identity-mismatch case all refuse before any mutation or Orca call. Against the live Orca runtime,orca worktree list --jsonreturnsrepoId::path, which is what the docs commit now states, and firstmate both accepts and resolves that real id while the base check rejects it. The change's own regression case and the touched fm-control case pass repeatedly in isolation. Two caveats worth stating plainly: this is a shell CLI change, so the reviewer-visible artifacts are command transcripts rather than screenshots, there is no rendered surface to capture; and the fulltests/fm-backend-orca.test.shsuite never completed cleanly on this machine because/usr/bin/perlintermittently exits 139 inside firstmate's realpath helper and aborts the suite at a random case. That flake reproduces at the base commit in this run too, every failure it caused carried the same "task record authorized directory cannot be resolved" signature and no substantive assertion failed, so I drove the scenarios with retries past it and ran the affected cases in isolation instead.bin/fm-teardown.sh orca-live --forceon this branch exits 0, prints "teardown orca-live complete", callsorca worktree rm --worktree id:411226f7-...::<path>and removes the task record; see orca-t…bin/fm-teardown.shexits 1 with "REFUSED: Orca endpoint metadata for task orca-live is malformed or inconsistent; preserving task state.", no O…bin/fm-spawn.sh ... --backend orcawritesorca_worktree_id=411226f7-...::<path>andbin/fm-teardown.sh --forcethen completes on this branch, while the identical round trip at base spawns fine a…bin/fm-teardown.sh --forceon this branch (no::separator, empty repo-id half, relative path half, tab inside the repo-id half) each exit 1 with the malformed-metadata ref…orca worktree show, sees the mismatch and exits 1 with "resolved to uninspectable path ...; preserving metadata", never reachingworktree rm; see orca-teardown-adversarial.txtfm_backend_orca_worktree_id_validaccepts411226f7-dc91-4d37-975d-32d412bf97a2::~/dev/scrap-servicesandfm_backend_worktree_path orcaresolves it to tha…orca worktree list --jsonreturns id411226f7-...::~/dev/scrap-serviceswithrepoId411226f7-...andpath~/dev/scrap-services, matching the docs line…tests/fm-control.test.shcasetest_orca_refuses_an_escape_harness_interruptpasses 3 of 3 in isolation on this branch ("cannot deliver" refusal); the same case run against base code with the compo…Evidence: Orca teardown before and after the fix, real CLI transcript
Source: Orca teardown before and after the fix, real CLI transcript
Evidence: Spawn to teardown round trip on the Orca backend, base versus branch
Source: Spawn to teardown round trip on the Orca backend, base versus branch
Evidence: Malformed and mismatched worktree ids still refuse, real CLI transcript
Source: Malformed and mismatched worktree ids still refuse, real CLI transcript
Evidence: The id shape against the live Orca runtime, and firstmate resolving it
Source: The id shape against the live Orca runtime, and firstmate resolving it
Evidence: Key before/after lines from the teardown transcript
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
bin/fm-control.sh:302- Blast radius is wider than the intent states, and the change is right to fix it at the shared boundary. The intent says "Spawn, supervision (fm-peek, fm-crew-state, fm-send) and the work itself all function; only teardown is blocked", but fm_backend_validate_task_endpoint is also the gate for the control plane (bin/fm-control.sh:302, so interrupt/exit/relaunch refused every Orca task with the same message), for relaunch metadata (bin/fm-spawn.sh:1474) and for the secondmate liveness read (bin/fm-update.sh:127). The single validator swap unblocks all of them. The only one worth checking for a behavior flip is fm-update.sh: an Orca record now passes validation and reaches fm_backend_agent_state, which has no orca arm and returns "unverified", so the routing outcome is identical to the previous refusal. Nothing to change; recorded so the author's mental model of what this fix reaches is accurate.bin/fm-backend.sh:391- The comment above the new validator describes the format as<orca id>::<absolute worktree path>while commit 134ee25 deliberately renamed that same format in docs/orca-backend.md to<orca repo id>::<absolute worktree path>, because the uuid half identifies the repository and not the worktree (the live-runtime evidence shows one uuid shared by two worktrees of the same repo). Naming it "orca id" in the source leaves the one comment a reader hits first vaguer than the doc the change just corrected. Mechanical wording fix, no behavior involved.✅ **Test** - passed
✅ No issues found.
bin/fm-teardown.sh orca-live --forceon this branch exits 0, prints "teardown orca-live complete", callsorca worktree rm --worktree id:411226f7-...::<path>and removes the task record; see orca-t…bin/fm-teardown.shexits 1 with "REFUSED: Orca endpoint metadata for task orca-live is malformed or inconsistent; preserving task state.", no O…bin/fm-spawn.sh ... --backend orcawritesorca_worktree_id=411226f7-...::<path>andbin/fm-teardown.sh --forcethen completes on this branch, while the identical round trip at base spawns fine a…bin/fm-teardown.sh --forceon this branch (no::separator, empty repo-id half, relative path half, tab inside the repo-id half) each exit 1 with the malformed-metadata ref…orca worktree show, sees the mismatch and exits 1 with "resolved to uninspectable path ...; preserving metadata", never reachingworktree rm; see orca-teardown-adversarial.txtfm_backend_orca_worktree_id_validaccepts411226f7-dc91-4d37-975d-32d412bf97a2::~/dev/scrap-servicesandfm_backend_worktree_path orcaresolves it to tha…orca worktree list --jsonreturns id411226f7-...::~/dev/scrap-serviceswithrepoId411226f7-...andpath~/dev/scrap-services, matching the docs line…tests/fm-control.test.shcasetest_orca_refuses_an_escape_harness_interruptpasses 3 of 3 in isolation on this branch ("cannot deliver" refusal); the same case run against base code with the compo…Real CLI:bin/fm-teardown.sh <id> --forceon an Orca-backed task whose record carries411226f7-dc91-4d37-975d-32d412bf97a2::<worktree path>, run against this branch and against agit archived copy of base commit 9f8ad95Real CLI round trip:bin/fm-spawn.sh <id> <project> claude --mode no-mistakes --backend orcathenbin/fm-teardown.sh <id> --force, on this branch and at baseReal CLI adversarial ids throughbin/fm-teardown.sh:worktree-9(no separator),::<path>(empty repo-id half),<uuid>::orca/relative/wt(relative path half),<id-with-tab>::<path>Real CLI boundary: well-shaped id that the Orca stand-in resolves to a different worktree than the task recordLive Orca runtime (orca 1.4.204, read-only):orca worktree list --json, thenfm_backend_orca_worktree_id_validandfm_backend_worktree_path orca <real id>frombin/fm-backend.sh, plusfm_backend_endpoint_atom_validon the same id at basetests/fm-teardown-endpoint-safety.test.shcasestest_supported_backend_endpoint_records_validateandtest_orca_composite_worktree_id_validates, run in isolation 5 times, green every runtests/fm-control.test.shcasetest_orca_refuses_an_escape_harness_interrupt, run in isolation 3 times on this branch and once against base code with the branch's composite-id fixturetests/fm-backend-orca.test.shfull suite, 5 attemptsbin/fm-backend.sh:391- Left alone deliberately, flagging it so the decision is visible rather than silent. The new helper's comment calls the composite<orca id>::<absolute worktree path>while docs/orca-backend.md, after the previous document round, calls the first half the Orca repo id. "orca id" is not wrong but it can be misread as the worktree's own id, which is the whole value. I did not touch it because it is a shell file rather than a documentation surface, the wording is imprecise rather than stale, and editing bin/ here would re-open the lint and test phases for a single word. If someone is already touching that file, changing<orca id>to<orca repo id>would match the owner document.✅ **Push** - passed
✅ No issues found.