feat: add clean committed worker relaunch - #87
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5c7b6c6515
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| case "$workspace" in *$'\t'*) seeded_tab=${workspace#*$'\t'}; workspace=${workspace%%$'\t'*} ;; esac | ||
| FM_CLEAN_RELAUNCH_LAUNCH_STATE=$state | ||
| trap fm_clean_relaunch_defer_window_creation_signal HUP INT TERM | ||
| if task_ids=$(fm_backend_herdr_create_task "$session:$workspace" "fm-$id" "$worktree" "$seeded_tab"); then |
There was a problem hiding this comment.
Keep relaunch creation behind the authorized spawn path
Captain, this directly creates a Herdr task instead of using bin/fm-spawn.sh, bypassing the repository's sole authorized spawn entry point and its profile, backend, isolation, metadata, and lifecycle guards. Either route the relaunch through that owner or first define a narrow repository-level exception that preserves the equivalent guarantees.
AGENTS.md reference: AGENTS.md:L300-L302
Useful? React with 👍 / 👎.
| case "$workspace" in *$'\t'*) seeded_tab=${workspace#*$'\t'}; workspace=${workspace%%$'\t'*} ;; esac | ||
| FM_CLEAN_RELAUNCH_LAUNCH_STATE=$state | ||
| trap fm_clean_relaunch_defer_window_creation_signal HUP INT TERM | ||
| if task_ids=$(fm_backend_herdr_create_task "$session:$workspace" "fm-$id" "$worktree" "$seeded_tab"); then |
There was a problem hiding this comment.
Preserve partially created Herdr endpoints on failure
When replacing a same-labeled Herdr husk, fm_backend_herdr_create_task can create the replacement and then return status 2 because husk-removal verification failed. This call uses the default preserve partial policy and assigns FM_CLEAN_RELAUNCH_LAUNCH_WINDOW_ID only on success, so the outer failure cleanup cannot kill the replacement but still returns its worktree and deletes its branch and handoff, leaving a live endpoint in a removed working directory. Propagate partial-creation state so ambiguous endpoints retain their lease and branch until reconciled.
Useful? React with 👍 / 👎.
| for _ in $(seq 1 100); do | ||
| [ -f "$fixture/home/data/destination/relaunch-handoff.json" ] && break | ||
| sleep 0.01 | ||
| done |
There was a problem hiding this comment.
Wait robustly for handoff publication
On slower hosts, this fixed roughly one-second polling window expires before the background relaunch publishes its handoff, causing the newly added focused test to fail at the following assertion even though the operation is still progressing. The canonical test runner and a direct invocation both reproduced interrupt fixture did not reach destination publication; use the suite's bounded wait helper or a substantially safer timeout tied to a deterministic readiness event.
Useful? React with 👍 / 👎.
Intent
Implement the captain-approved dedicated-owner clean-commit relaunch from current Firstmate main. Add an explicit manual-only owner that admits only a local ordinary ship task whose recorded Codex/tmux endpoint is authoritatively missing, whose source checkout is clean and stable, and whose No-Mistakes custody is absent; refuse every ambiguous, live, parked, malformed, foreign, or occupied case before allocating a destination. Allocate a normal distinct Treehouse worktree in the same physical repository, create exactly fm/ at the source commit, launch the destination through a source-only private helper, and publish a single evidence-only handoff containing stable identities. Preserve the source task and its committed branch in every success, refusal, failure, and interruption path; clean up only newly-created destination artifacts. Do not add relaunch authority or an allocated-worktree mode to generic fm-spawn, do not add automatic callers, do not drive Herdr, and do not reuse the historical failed relaunch implementation or PR 69. The initial supported profile is Codex/tmux; other profiles must refuse. Provide deterministic behavioral tests covering success, admission refusal, custody refusal, destination failures and interruption cleanup, serialization, generic-spawn isolation, and handoff semantics, plus concise architecture documentation.
What Changed
fm/<destination>branch at the source commit, publish an evidence-only handoff, and launch through a private helper with destination-only cleanup.Risk Assessment
✅ Low: Captain, the review found the new owner’s cleanup and admission paths internally consistent; the Herdr-only profile follows the later recorded decision that supersedes the conflicting original wording.
Testing
Exercised the executable owner end to end with deterministic linked-worktree, Treehouse, No-Mistakes, and backend fixtures; verified successful stable handoff publication, admission and custody refusals, destination-only cleanup across failures/interruption/races, serialization, and generic-spawn isolation. Captured the CLI behavior transcript as reviewer-visible evidence; no live Herdr lifecycle was driven.
Evidence: Focused clean-commit relaunch CLI behavior transcript
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
✅ **Review** - passed
✅ No issues found.
✅ **Test** - passed
✅ No issues found.
bash tests/fm-clean-commit-relaunch.test.shgit diff --check ef8ee4955c343fb46dc7d3ebf474bd252c220ac0 0b4995dd926d28df008b11a295072b5e982f2447✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.