Skip to content

feat: add clean committed worker relaunch - #87

Open
pranaypratyush wants to merge 16 commits into
dnth:mainfrom
pranaypratyush:fm/fm-clean-commit-relaunch-redesign
Open

feat: add clean committed worker relaunch#87
pranaypratyush wants to merge 16 commits into
dnth:mainfrom
pranaypratyush:fm/fm-clean-commit-relaunch-redesign

Conversation

@pranaypratyush

@pranaypratyush pranaypratyush commented Aug 31, 2026

Copy link
Copy Markdown

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

  • Add a manual clean-commit relaunch command that admits only missing, clean, uncustodied local Codex/Herdr ship tasks.
  • Allocate a distinct same-repository worktree, create the successor fm/<destination> branch at the source commit, publish an evidence-only handoff, and launch through a private helper with destination-only cleanup.
  • Document the relaunch boundary and add deterministic coverage for admissions, custody, failures, interruption cleanup, serialization, handoff semantics, and generic-spawn isolation.

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
ok - clean relaunch: linked worktree success preserves source and binds exact destination identity
ok - clean relaunch: lone Treehouse pool configuration remains admissible
ok - clean relaunch: only an authoritatively missing endpoint passes admission
ok - clean relaunch: malformed, foreign, occupied, and colliding admission cases refuse
ok - clean relaunch: dirty, detached, unreachable, and Git-operation sources refuse
ok - clean relaunch: active, parked, and unreadable No-Mistakes custody refuses
ok - clean relaunch: malformed foreign worktree metadata refuses
ok - clean relaunch: symlinked foreign worktree metadata refuses
ok - clean relaunch: allocator, checkout, launch, and acknowledgement failure preserve source
ok - clean relaunch: rejected allocated destination returns its lease
ok - clean relaunch: handoff rendering failure removes staging state
ok - clean relaunch: source-reusing allocator cannot clean the source
ok - clean relaunch: allocator must not reuse existing project worktrees
ok - clean relaunch: failed destination return remains actionable
ok - clean relaunch: concurrent handoff remains foreign
ok - clean relaunch: concurrent metadata remains foreign
ok - clean relaunch: published output failure cleans destination
ok - clean relaunch: concurrent destination branch remains foreign
ok - clean relaunch: interrupted destination publication preserves source
ok - clean relaunch: destination lock serializes concurrent requests
ok - clean relaunch: generic spawn exposes no relaunch carrier

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.sh
  • git diff --check ef8ee4955c343fb46dc7d3ebf474bd252c220ac0 0b4995dd926d28df008b11a295072b5e982f2447
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Aug 31, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-08-31T17:19:18.302166Z 5c7b6c6 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

Comment thread tests/fm-clean-commit-relaunch.test.sh Outdated
Comment on lines +582 to +585
for _ in $(seq 1 100); do
[ -f "$fixture/home/data/destination/relaunch-handoff.json" ] && break
sleep 0.01
done

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

@pranaypratyush pranaypratyush changed the title feat(bin): add guarded clean-commit relaunch command feat: add clean committed worker relaunch Aug 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant