feat: adopt existing cmux workspaces for supervision - #261
Conversation
|
Thanks for the PR! It looks like this branch has a merge conflict with the base branch right now. When you get a chance, could you rebase onto (or merge in) the latest base branch, resolve the conflict, and push? Once GitHub shows the PR as mergeable again, it'll be picked back up for review. Noted for firstmate#261 at |
sure, will do! |
b2f4d9f to
930f4f4
Compare
|
@kunchenguid ready for review 🫡 |
930f4f4 to
b049988
Compare
|
Thanks for the PR! It looks like this branch has a merge conflict with the base branch right now. When you get a chance, could you rebase onto (or merge in) the latest base branch, resolve the conflict, and push? Once GitHub shows the PR as mergeable again, it'll be picked back up for review. Noted for firstmate#261 at |
0ab7314 to
fcab951
Compare
|
Rebased onto the latest I also followed up on the triage note flagging that the two review bugs were reported as auto-fixed but hadn't actually landed. That was correct: both were still present in the diff. Fixed both now, each with a regression test:
Local verification: shellcheck clean; |
fcab951 to
58ed83f
Compare
58ed83f to
095fb41
Compare
|
Thanks for the PR! This branch currently has a merge conflict with the base branch. When you get a chance, please rebase onto (or merge) the latest base branch, resolve the conflict, and push. After that, checks will re-run and the PR will get looked at again. Noted for firstmate#261 at |
095fb41 to
7a2e8ed
Compare
|
Thanks for the PR! This branch currently has a merge conflict with the base branch. When you get a chance, please rebase onto (or merge) the latest base branch, resolve the conflict, and push. After that, checks will re-run and the PR will get looked at again. Noted for firstmate#261 at |
7a2e8ed to
f1db4f6
Compare
|
Rebased onto the latest main after your last note — conflicts are resolved and the PR has been mergeable with all 4 checks green since then. Ready for review whenever you get a chance. |
|
Automated reminder: thanks for the PR! This branch currently has a merge conflict with the base branch. When you get a chance, please rebase onto (or merge) the latest base branch, resolve the conflict, and push. After that, checks will re-run and the PR will get looked at again. Noted for firstmate#261 at |
f1db4f6 to
f70012d
Compare
|
The Behavior-tests failure on this PR is inherited from Root cause: #593's unresolved-decision completion gate has I've pushed the one-line fix here ( |
Register an already-running cmux workspace as a kind=adopted task with no worktree and no branch. Teardown un-registers without ever closing the workspace, the watcher exempts it from stale-pane wakes, and peek/send target it by pure UUID so the human's title is preserved. cmux-only and experimental; supervise-only (no delivery mode or PR). Refs kunchenguid#260
…tart and crew-state reads
…and restore lock recovery The kind=adopted branch was added ahead of validate_worktree_teardown_safety but as an elif AFTER it, which caused two defects: 1. validate_worktree_teardown_safety emits REFUSED as a side effect, so calling it before the adopted check printed a spurious REFUSED when tearing down an adopted task (whose worktree= is the human's own live, unlanded cwd). Fixed by checking kind=adopted first, so the safety function never runs for adopted tasks. 2. safety_rc=$? then captured the [ "$KIND" = adopted ] test's exit code instead of the safety function's (shellcheck SC2319), which silently killed the stale-lock recovery path (safety_rc was always 1, never LOCK_BLOCKED). Fixed by capturing the code with 'validate... || safety_rc=$?' - set -e-safe and unambiguous - restoring lock-blocked recovery. Verified: shellcheck clean, tests/fm-teardown.test.sh (25) and tests/fm-adopt.test.sh (9) all pass.
docs/cmux-backend.md's empirical verification transcript captured a real personal absolute path (/Users/thescoho/Developer/reddit-hackathon), which tests/fm-kimi-harness.test.sh's repo-wide /Users/ scan correctly flags.
|
Automated reminder: thanks for the PR! This branch currently has a merge conflict with the base branch. When you get a chance, please rebase onto (or merge) the latest base branch, resolve the conflict, and push. After that, checks will re-run and the PR will get looked at again. Noted for firstmate#261 at |
…s adopted tasks upstream/main's endpoint-cleanup hardening (fbece9c) now requires every non-tmux backend's meta to carry endpoint_task_id, matching what fm-spawn.sh has always written. fm-adopt.sh never wrote it, so an adopted cmux task's teardown was refused as a legacy/unbound endpoint. Write endpoint_task_id the same way fm-spawn.sh does, and update the test fixture and assertion to match.
eb895c5 to
8c407d3
Compare
Intent
Add an fm-adopt command so firstmate can supervise an already-running cmux workspace (kind=adopted) without spawning a new worktree or branch; peek/send/watcher work on it and teardown un-registers it without ever closing the workspace. Implements issue #260. cmux-only, experimental, supervise-only.
What Changed
bin/fm-adopt.shand tests for registering an existing cmux workspace askind=adoptedso firstmate can supervise it without spawning a new worktree, branch, or process.Risk Assessment
✅ Low: Captain, the change is scoped to cmux adoption paths and the shared watch/peek/send/teardown integrations look consistent with the intended supervise-only behavior.
Testing
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
🔧 **Review** - 2 issues found → auto-fixed ✅
bin/fm-adopt.sh:79-fm-adoptonly rejects an existing task id, but it never rejects an existingwindow=<workspace>:<surface>already registered under another id. The watcher andwindow_to_taskresolve a window to the first matching meta file, so double-adopting a surface or adopting a firstmate-spawned cmux task can make stale handling, peek/send ownership, and teardown bookkeeping attach to the wrong task or skip stale wakes entirely. After resolvingT, scanstate/*.metafor the samewindow=and refuse it.bin/fm-adopt.sh:98- Adoption accepts a live cmux surface based onlist-panes, butfm-crew-state.shlater treats non-tmux liveness asfm_backend_capture, which for cmux callsread-screen. The cmux adapter documents thatread-screenfails on fresh never-written surfaces, so an adopted live workspace can immediately reportbackend target gone. Usefm_backend_target_existsfor the adopted cmux liveness probe before falling through to busy/log classification.🔧 Fix: Harden adopted cmux supervision
✅ Re-checked - no issues remain.
⏭️ **Test** - skipped
Step was skipped.
✅ **Document** - passed
✅ No issues found.
⏭️ **Lint** - skipped
Step was skipped.
✅ **Push** - passed
✅ No issues found.