Skip to content

Prevent cleanup from deleting active agent cwd#536

Merged
NagyVikt merged 1 commit intomainfrom
agent/codex/protect-active-cwd-during-cleanup-2026-05-07-15-13
May 7, 2026
Merged

Prevent cleanup from deleting active agent cwd#536
NagyVikt merged 1 commit intomainfrom
agent/codex/protect-active-cwd-during-cleanup-2026-05-07-15-13

Conversation

@NagyVikt
Copy link
Copy Markdown
Collaborator

@NagyVikt NagyVikt commented May 7, 2026

Automated by gx branch finish (PR flow).

Cleanup and finish commands can be launched through wrappers that run their destructive worktree prune subprocesses from a repo root instead of the caller's nested agent cwd. The finish/prune path now forwards the original cwd, resolves it back to the managed worktree for the same git common dir, and skips any worktree containing that cwd.

Constraint: Codex and Claude hooks reload skills after tool use and fail with os error 2 when their cwd disappears.

Rejected: Only pivot finish to repo root | wrapper and cleanup entrypoints still lose the caller cwd before prune.

Confidence: high

Scope-risk: narrow

Directive: Do not remove GUARDEX_FINISH_ACTIVE_CWD or GUARDEX_PRUNE_ACTIVE_CWD propagation without reproducing finish/cleanup from a nested active worktree cwd.

Tested: node --test test/worktree.test.js test/finish.test.js test/metadata.test.js

Tested: bash -n scripts/agent-branch-finish.sh

Tested: bash -n scripts/agent-worktree-prune.sh

Tested: openspec validate --specs
@NagyVikt NagyVikt merged commit bc3607b into main May 7, 2026
@NagyVikt NagyVikt deleted the agent/codex/protect-active-cwd-during-cleanup-2026-05-07-15-13 branch May 7, 2026 13:24
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