Repository navigation
fix(bin): stop task workers inheriting the primary home and pooled slots - #1092
Closed
willchen95 wants to merge 6 commits into
Closed
willchen95 wants to merge 6 commits into
willchen95 wants to merge 6 commits into
Conversation
A launched agent inherited the launching home's exported environment, so every firstmate script it ran resolved that home's state directory. An audit worker took the primary's own session-owner record and the real primary came back from a suspend locked out of its home, monitoring stopped. Two further defects shared the same root cause: an assertion made once at launch, and a record trusted as if it were live evidence. Four mechanisms, one owner each: - bin/fm-worker-isolation-lib.sh declares the owning home at launch, so ownership is never inferred downstream from cwd, pane, or process tree. A crewmate carries no home; a secondmate carries only its own. fm-lock, fm-primary-scope-lib, fm-spawn, and fm-teardown consume the declaration and refuse, which also keeps project-local startup and turn-end adapters inert for workers. - bin/fm-agent-cwd-lib.sh makes the agent process's own cwd the method of record. A pane field can name an entirely different process, so it stays a hint; a provider with no per-pane process id reports unknown rather than degrading to its pane path. - bin/fm-slot-owner-lib.sh gates slot release on positive evidence of a conflict. A contested lease is retired, not returned, and --force does not waive it: it is authority over this task's work, not another task's slot. - bin/fm-isolation-sweep.sh re-establishes isolation at session start, because a restore resumed every recorded session but resolved worktrees back onto their origin. Findings surface as ISOLATION lines beside TANGLE. docs/worker-isolation.md owns how the four fit together; docs/verification/worker-isolation.md holds the dated evidence. tests/fm-worker-isolation.test.sh covers the declaration for every verified harness, each refusal, the process reading against a deliberately lying pane path, the provider matrix, all three slot-conflict forms, and the four sweep outcomes. The Orca and secondmate-home refusals are covered in the suites that own those fixtures.
…down scope defects
Author
|
Captain approve-all requested. Blockers for willchen95 (read-only on this repo):
no-mistakes gates passed (review/test/document/lint). Pipeline marker is in the PR body. Please approve workflows + merge when ready. |
3 of 4 tasks
Owner
|
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#1092 at |
Author
|
Closing: captain local-only; this PR was an unintended public leftover. |
This was referenced Aug 10, 2026
8 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Task workers could inherit the operational home that launched them, be trusted from a stale record about where they were running, and release a pooled worktree slot another task still held. Three defects were observed live and drive this change.
FM_HOME, so every firstmate script it ran resolved that primary's state directory. It took the primary's own session-owner record, and the real primary came back from a suspend/resume locked out of its home with monitoring stopped.worktree=is not ownership. Ten pooled slots were recorded by more than one task. The hazard fired: tearing down one task released a lease a still-live quarantined-paused task also recorded, and the pool reissued that slot to a new spawn.A fourth finding corrected the investigation method itself: a pane listing reported a worker's cwd as the primary checkout while
/procshowed it correctly isolated, so/proc/<agent-pid>/cwdis the check of record and pane cwd is only a hint.How
Four mechanisms, one owner each, documented in
docs/worker-isolation.md.bin/fm-worker-isolation-lib.shdeclares the owning home at launch, so ownership is never inferred downstream from cwd, pane, or process tree. A crewmate carries no home; a secondmate carries only its own.fm-lock,fm-primary-scope-lib,fm-spawn, andfm-teardownconsume the declaration and refuse, which also keeps project-local startup and turn-end adapters inert for workers.bin/fm-agent-cwd-lib.shmakes the agent process's own cwd authoritative. A pane field can name a different process, so it stays a hint; a provider with no per-pane process id reportsunknownrather than degrading to a pane path. tmux targets resolve to a stable window id first, becausedisplay-messagegiven an unknown window name silently answers for the active client's window.bin/fm-slot-owner-lib.shgates slot release on positive evidence of a conflict. A contested lease is retired, not returned, and--forcedoes not waive it:--forceis authority over this task's work, never another task's slot.bin/fm-isolation-sweep.shre-establishes isolation at session start, surfacingISOLATION:findings beside the existingTANGLE:check.Verification
tests/fm-worker-isolation.test.sh(30 checks) covers the declaration for every verified harness, each consuming refusal, the process-cwd method of record against a deliberately lying pane path, the per-provider matrix, all slot-conflict forms, and the sweep outcomes. Orca and secondmate-home refusals are covered in the suites that own those fixtures.bin/fm-lint.sh,bin/fm-doc-audience-check.sh, and the CI test-partition coverage guard are clean.Two suites fail identically on base
a5fe1bcand are unrelated to this change:fm-session-start.test.sh(Herdr husk emits an unexpectedSECONDMATE_LIVENESS:line) andfm-calm-pi-extension.test.sh(a Pi version pin wanting 0.81.1/0.82.0 against an installed 0.82.1).Note
Opened from a fork because the author lacks write access to this repository. CI may need maintainer approval to run.
Pipeline
Updates from git push no-mistakes
Run
01KYG7DCY2VTZX20CN8WH89KSFon this branch, gates in order:bin/fm-lint.sh)Every validation gate passed. The pipeline's own
pushstep could not publish because the author lacks write access here, so the validated branch was pushed to the author's fork and this PR was raised from it by hand. The commits are exactly the ones the pipeline produced, unchanged: