fix(runtime): isolate detached worktrees and recover orphan groups#61
Conversation
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 80a8dd28f7
ℹ️ 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".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f87e5cfbe5
ℹ️ 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".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 57f2358df0
ℹ️ 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".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2f4a4bea94
ℹ️ 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".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 966b863d44
ℹ️ 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".
|
@codex review |
|
Codex Review: Didn't find any major issues. Nice work! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
## <small>3.3.3 (2026-07-09)</small> * Merge pull request #61 from hack-dance/codex/event-agent-runtime-repair ([f1de71e](f1de71e)), closes [#61](#61) * fix(cli): preserve usage code for lifecycle json ([f50f408](f50f408)) * fix(runtime): clean descendant lifecycle groups ([57f2358](57f2358)) * fix(runtime): isolate detached worktrees and recover orphan groups ([80a8dd2](80a8dd2)) * fix(runtime): persist wrapped command process group ([2f4a4be](2f4a4be)) * fix(runtime): retain session proof for lifecycle cleanup ([f87e5cf](f87e5cf)) * docs(cli): explain detached worktree targeting ([966b863](966b863))
Summary
--branchandworktree.auto_branch=falseopt-out behaviorhack doctorand terminate them through normalhack downcleanupProblem evidence
An Event Agent detached linked worktree silently resolved to the base Compose project and produced mixed containers under
event-agent: canonical-checkout containers and partially created linked-worktree replacements shared one Compose project. A prior lifecycle proxy group also survived after leader PID41981exited; members remained in PGID41981, but doctor/down only recovered groups through a live saved pane PID and missed the orphan.Root causes:
resolveEffectiveBranchintentionally mapped detached linked worktrees tosource: "none", which is indistinguishable from a primary checkout and selects the base instance.Behavior and compatibility
worktree.auto_branch=falsebehavior are unchanged.E_USAGEunless the caller supplies--branchor explicitly opts into the base instance via config.up,down, andrestart --jsonpreserve that failure as stableE_USAGEenvelopes rather thanE_UNEXPECTED.hack downrecovery additionally requires a matching live lifecycle mux session as ownership proof.setsid(), resolves its real PGID, and removes the transient PID handoff;sh -cexecution remains unchanged.sh -c, interactive stdin/TTY behavior, singleton adoption, and partial-listener rejection are unchanged and remain covered.Verification
bun test ...focused runtime/worktree/doctor/status suites...— 100 passed, 0 failed after review hardeningbun testplus DB tests — 830 passed, 5 intentionally skipped, 0 failed after command-PGID hardeningbun run test:e2e:local— 8 passed, 3 Docker-tier skippedbun run test:e2e:local:docker— 11 passed before the final PGID hardening; the final rerun hit a host Docker create timeout before fixture containers were created20436, persisted wrapped command PID/PGID20447, live Bun sleeper in PGID20447, and tmux teardown removed group20447bun run typecheck— 2/2 packages passedbun run lint— privacy check plus CLI/DB Ultracite checks passedbun run build— compiled 515 modulesup/down/restart --jsonbun run docs:cli-referenceproduced no driftbun run build:release --skip-tests --no-clean --out=/tmp/hack-runtime-repair-release-smokepassed; the packaged binary reportshack v3.3.2and contains the detached-worktree guardRelease Signal
fix(runtime): isolate detached worktrees and recover orphan groupsfixyesSemantic Surfaces
hack run,hack exec, worktree branch resolution, runtime-state reconciliation, and lifecycle process cleanup:yestests/branches-effective-branch.test.ts,tests/run-exec-branch-default.test.ts,tests/e2e/scenarios/worktree-branch-default.ts,tests/project-lifecycle-processes.test.ts,tests/project-lifecycle-hygiene.test.tsdocs/core.md,docs/architecture.md,src/agents/instruction-source.ts, and synchronized generated guidanceRisks / Follow-up