Skip to content

feat(control): add guarded legacy worker handoff - #2

Closed
ryannmicua wants to merge 4 commits into
mainfrom
fm/firstmate-guarded-worker-handoff
Closed

ryannmicua wants to merge 4 commits into
mainfrom
fm/firstmate-guarded-worker-handoff

Conversation

@ryannmicua

Copy link
Copy Markdown
Owner

Intent

resolve the safe handoff then

I know the worker is no longer running there.

This is the stranded Firstmate worker for the Paseo backend change intended for #1. Its former terminal session is unreachable after reboot, while its local copy and unpublished work remain. Make it safe to hand that work to a replacement so the existing PR can later be completed without discarding work or bypassing review. This task delivers only the necessary handoff support, not a merge or a duplicate Paseo implementation PR.

What Changed

  • Add an attended handoff for paseo-backend-adapter that checks the recorded endpoint, worktree, and HEAD, requires typed worker and run attestations, and rebinds the same task and worktree to a unique tmux session.
  • Have fm-spawn validate the handoff transaction and task identity again; reject conflicting owners and keep ordinary tmux missing-endpoint recovery fail-closed while preserving local work and the original task record if launch fails before publication.
  • Document the one-task recovery procedure and add regression coverage and captured handoff/refusal validation artifacts.

Risk Assessment

⚠️ Medium: The handoff is narrowly pinned and preserves the worktree, but depends on operator attestations because tmux cannot prove the old endpoint is gone.

Testing

Confirmed tmux and jq availability, then drove the guarded handoff and three refusal paths using real isolated tmux servers; all assertions passed and CLI evidence was saved. This change has no rendered UI surface, so screenshot evidence was not applicable.

  • Live validation: ✅ go - 4 of 4 scenarios driven live against the product
Scenario Result Live Evidence
Operator confirms the stranded worker is stopped and its run is terminal; a replacement starts in the recorded worktree with tracked and untracked changes preserved. ✅ pass live Isolated live tmux handoff proof
Operator supplies a conflicting worktree identity; handoff refuses, durable task state matches its before snapshot, and no replacement endpoint exists. ✅ pass live Isolated live tmux handoff proof
Operator supplies an incorrect confirmation; handoff refuses, durable task state matches its before snapshot, and no replacement endpoint exists. ✅ pass live Isolated live tmux handoff proof
Operator attempts handoff while the original endpoint is still live; handoff refuses and leaves the task state and endpoint inventory unchanged. ✅ pass live Isolated live tmux handoff proof
Evidence: Isolated live tmux handoff proof

Source: Isolated live tmux handoff proof

Command: /bin/bash .validation-tmp/run-live-handoff.sh refusal-proof-verification-20260927
Product surface: bin/fm-control.sh handoff over real isolated tmux servers
Fixtures: disposable under .validation-tmp; no shared or default tmux server used.

=== successful guarded handoff ===
Accepted inputs: STOP paseo-backend-adapter; TERMINAL paseo-backend-adapter
handed-off paseo-backend-adapter from=firstmate:fm-paseo-backend-adapter to=fm-handoff-paseo-backend-adapter-353502-20260926222006-25421:fm-paseo-backend-adapter harness=codex backend=tmux worktree=~/.no-mistakes/worktrees/ff5e17b6f5de/01M3F8JET9SEC9H6AFSR173VCH/.validation-tmp/live/refusal-proof-verification-20260927/success/wt
replacement_recorded_endpoint=fm-handoff-paseo-backend-adapter-353502-20260926222006-25421:fm-paseo-backend-adapter
replacement_window_state=fm-paseo-backend-adapter ~/.no-mistakes/worktrees/ff5e17b6f5de/01M3F8JET9SEC9H6AFSR173VCH/.validation-tmp/live/refusal-proof-verification-20260927/success/wt codex
recorded_branch=fm/paseo-backend-adapter
recorded_HEAD=efa328393f54b23a480f5745946fdf08f11ae35b
preserved_worktree_status:
 M README.md
?? untracked-handoff.txt
journal_phase=complete
journal_worker_attestation=stopped
journal_run_attestation=terminal

=== live original endpoint refusal ===
=== LIVE ADVERSARIAL CHECK ===
error: attested handoff requires the original endpoint to read missing; a live, dead, ambiguous, or unreadable endpoint refuses
old_endpoint_state=codex
sessions_after_refusal=firstmate
task_record=unchanged
brief=unchanged
worktree_HEAD=unchanged
tracked_and_untracked_changes=unchanged

=== conflicting worktree identity refusal: full before/after snapshots ===
=== conflicting-identity REFUSAL ===
error: --expect-worktree must match the exact path recorded for the local copy
before:
task_meta_sha256=2af53ff62795d9ddb1c882eff46155ac1bef8da45ccd67e363d9e05245167bea
brief_sha256=b794b02c3959a2010bdb3ddbcd8cf8aef42ace03185f2c59188fb5cf92e9d922
branch=fm/paseo-backend-adapter
HEAD=185c09251e3394e6c785f84764edc40eb0227f8b
worktree_status= M README.md|?? untracked-handoff.txt|
README_sha256=2aa5aa152a08f48444c8f11f45bd79c6649ab4d1c0ba2a76676ff4b7a1b0f793
untracked_sha256=58a15886eeef37d4b6f45550c41b0adfeba0ab835bc2391f7c2d6929395d6074
state_file=paseo-backend-adapter.meta:2af53ff62795d9ddb1c882eff46155ac1bef8da45ccd67e363d9e05245167bea
sessions=firstmate
windows=firstmate:sentinel ~/.no-mistakes/worktrees/ff5e17b6f5de/01M3F8JET9SEC9H6AFSR173VCH/.validation-tmp/live/refusal-proof-verification-20260927/conflicting-identity/firstmate sleep
after:
task_meta_sha256=2af53ff62795d9ddb1c882eff46155ac1bef8da45ccd67e363d9e05245167bea
brief_sha256=b794b02c3959a2010bdb3ddbcd8cf8aef42ace03185f2c59188fb5cf92e9d922
branch=fm/paseo-backend-adapter
HEAD=185c09251e3394e6c785f84764edc40eb0227f8b
worktree_status= M README.md|?? untracked-handoff.txt|
README_sha256=2aa5aa152a08f48444c8f11f45bd79c6649ab4d1c0ba2a76676ff4b7a1b0f793
untracked_sha256=58a15886eeef37d4b6f45550c41b0adfeba0ab835bc2391f7c2d6929395d6074
state_file=paseo-backend-adapter.meta:2af53ff62795d9ddb1c882eff46155ac1bef8da45ccd67e363d9e05245167bea
sessions=firstmate
windows=firstmate:sentinel ~/.no-mistakes/worktrees/ff5e17b6f5de/01M3F8JET9SEC9H6AFSR173VCH/.validation-tmp/live/refusal-proof-verification-20260927/conflicting-identity/firstmate sleep
replacement_endpoint=absent; original_fixture_window=firstmate:sentinel

=== wrong confirmation refusal: full before/after snapshots ===
=== wrong-confirmation REFUSAL ===
Confirm the original worker has stopped (type STOP paseo-backend-adapter): Confirm the no-mistakes run is terminal and no active run owns the branch (type TERMINAL paseo-backend-adapter): error: handoff confirmation did not match; no task files or endpoint were changed
before:
task_meta_sha256=427ab3242b542fd70e637bc1572a7f82872a8563cebbf06f300e285873da1280
brief_sha256=b794b02c3959a2010bdb3ddbcd8cf8aef42ace03185f2c59188fb5cf92e9d922
branch=fm/paseo-backend-adapter
HEAD=185c09251e3394e6c785f84764edc40eb0227f8b
worktree_status= M README.md|?? untracked-handoff.txt|
README_sha256=2aa5aa152a08f48444c8f11f45bd79c6649ab4d1c0ba2a76676ff4b7a1b0f793
untracked_sha256=58a15886eeef37d4b6f45550c41b0adfeba0ab835bc2391f7c2d6929395d6074
state_file=paseo-backend-adapter.meta:427ab3242b542fd70e637bc1572a7f82872a8563cebbf06f300e285873da1280
sessions=firstmate
windows=firstmate:sentinel ~/.no-mistakes/worktrees/ff5e17b6f5de/01M3F8JET9SEC9H6AFSR173VCH/.validation-tmp/live/refusal-proof-verification-20260927/wrong-confirmation/firstmate sleep
after:
task_meta_sha256=427ab3242b542fd70e637bc1572a7f82872a8563cebbf06f300e285873da1280
brief_sha256=b794b02c3959a2010bdb3ddbcd8cf8aef42ace03185f2c59188fb5cf92e9d922
branch=fm/paseo-backend-adapter
HEAD=185c09251e3394e6c785f84764edc40eb0227f8b
worktree_status= M README.md|?? untracked-handoff.txt|
README_sha256=2aa5aa152a08f48444c8f11f45bd79c6649ab4d1c0ba2a76676ff4b7a1b0f793
untracked_sha256=58a15886eeef37d4b6f45550c41b0adfeba0ab835bc2391f7c2d6929395d6074
state_file=paseo-backend-adapter.meta:427ab3242b542fd70e637bc1572a7f82872a8563cebbf06f300e285873da1280
sessions=firstmate
windows=firstmate:sentinel ~/.no-mistakes/worktrees/ff5e17b6f5de/01M3F8JET9SEC9H6AFSR173VCH/.validation-tmp/live/refusal-proof-verification-20260927/wrong-confirmation/firstmate sleep
replacement_endpoint=absent; original_fixture_window=firstmate:sentinel
- Outcome: 🔧 2 issues found → auto-fixed → no changes applied (2) ✅ across 4 runs (1h37m18s)

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

⚠️ **Review** - medium risk

✅ No issues found.

🔧 **Test** - 2 issues found → auto-fixed → no changes applied (2) ✅

🔧 No changes applied.
2 issues (1 error, 1 warning) still open:

  • ⚠️ The Test agent did not finish within its invocation budget. Reported: agent run tests timed out after 30m0s: agent last produced output 28s ago (43 observed); agent reported: codex exited: signal: terminated: 2026-09-26T17:29:45.112970Z ERROR codex_core::tools::router: error=exec_command failed: CreateProcess { message: "Rejected(&fix(watcher): make check wakes lossless via watcher-side suppression kunchenguid/firstmate#34;/bin/bash -lc 'rm -rf .validation-tmp/live/active-endpoint .validation-tmp/live/active-endpoint-retry .validation-tmp/live/round2 .validation-tmp/task-tmp/round2' rejected: rm -f style commands are not permitted. Use a safer approach&fix(watcher): make check wakes lossless via watcher-side suppression kunchenguid/firstmate#34;)" }. This is a budget or provider-slowness cut, not a code failure. Re-running the same request costs another full budget, so no further attempt is made automatically. If this repository's targeted tests or evidence gathering routinely approach the default 30m0s, raise test_agent_timeout in global config. Respond with fix to spend another budget: a repair turn runs only for selected findings other than this budget cut, then validation re-runs. Or abort and retry after raising the budget.
  • 🚨 Approval is refused: the run worktree at ~/.no-mistakes/worktrees/ff5e17b6f5de/01M3F8JET9SEC9H6AFSR173VCH holds work no Test turn validated, and the steps after Test would commit and publish it. It holds uncommitted changes to .validation-tmp/ (inspect with git -C ~/.no-mistakes/worktrees/ff5e17b6f5de/01M3F8JET9SEC9H6AFSR173VCH status and git -C ~/.no-mistakes/worktrees/ff5e17b6f5de/01M3F8JET9SEC9H6AFSR173VCH diff). Respond with fix to validate it, or abort.

🔧 No changes applied.
1 warning still open:

  • ⚠️ live validation verdict: inconclusive (2 of 3 scenarios were driven live against the product); untested: Operator supplies conflicting handoff identity or incorrect confirmation; no replacement endpoint is created and durable task state remains unchanged.
  • Live validation: ⚠️ inconclusive - 2 of 3 scenarios driven live against the product
Scenario Result Live Evidence
Operator confirms handoff of the stranded Paseo task; the replacement Codex starts in a unique tmux session at the recorded worktree, and the existing branch, HEAD, and dirty files remain intact. ✅ pass live Live transcript artifact
Operator attempts handoff while the original endpoint still has a live Codex process; Firstmate refuses and leaves the task record, brief, and worktree unchanged. ✅ pass live Live transcript artifact
Operator supplies conflicting handoff identity or incorrect confirmation; no replacement endpoint is created and durable task state remains unchanged. ⏸️ untested no The prior payload records only a fixture-based lifecycle test for this scenario and does not establish a result driven against the live product.
  • bash .validation-tmp/run-live-handoff.sh handoff-before-fix2-20260927 reproduced the wrong-directory refusal before the fix.
  • REAL_CODEX=1 bash .validation-tmp/run-live-handoff.sh handoff-real-codex-adversary-20260927 exercised success and live-endpoint refusal with real tmux and Codex; credential and XDG config variables were unset.
  • bash tests/fm-control-relaunch.test.sh with a fresh external TMPDIR, FM_TEST_SKIP_ORPHAN_REAP=1, and task temp redirected into .validation-tmp/live/test-suite-20260927/task-tmp.
  • Saved the live transcript to the evidence artifact.

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

  • Live validation: ✅ go - 4 of 4 scenarios driven live against the product
Scenario Result Live Evidence
Operator confirms the stranded worker is stopped and its run is terminal; a replacement starts in the recorded worktree with tracked and untracked changes preserved. ✅ pass live Isolated live tmux handoff proof
Operator supplies a conflicting worktree identity; handoff refuses, durable task state matches its before snapshot, and no replacement endpoint exists. ✅ pass live Isolated live tmux handoff proof
Operator supplies an incorrect confirmation; handoff refuses, durable task state matches its before snapshot, and no replacement endpoint exists. ✅ pass live Isolated live tmux handoff proof
Operator attempts handoff while the original endpoint is still live; handoff refuses and leaves the task state and endpoint inventory unchanged. ✅ pass live Isolated live tmux handoff proof
  • command -v tmux && command -v jq
  • /bin/bash .validation-tmp/run-live-handoff.sh refusal-proof-verification-20260927
  • Captured success, live-endpoint refusal, conflicting-identity refusal, and wrong-confirmation before/after evidence at ~/.no-mistakes/evidence/01M3F8JET9SEC9H6AFSR173VCH/handoff-live-proof.txt
⚠️ **Document** - 1 warning
  • ⚠️ .validation-tmp/ - The documentation audience check exits 1 because it reports retained .validation-tmp/**/*.txt validation evidence as unclassified. These are not maintained prose, and this document phase cannot alter or remove them; resolving the checker scope is out of scope.
🔧 **Lint** - 1 issue found → no changes applied (2) ✅
  • ⚠️ linter found issues (exit code 1)

🔧 No changes applied.
1 warning still open:

  • ⚠️ linter found issues (exit code 1)

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

✅ **Push** - passed

✅ No issues found.

@ryannmicua

Copy link
Copy Markdown
Owner Author

Superseded by #4, which landed the same handoff support from a clean branch.

@ryannmicua ryannmicua closed this Sep 27, 2026
@ryannmicua
ryannmicua deleted the fm/firstmate-guarded-worker-handoff branch September 28, 2026 21:27
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.

1 participant