Repository navigation
Auto-finish: agent/codex/remove-detached-worktree-after-successfu-2026-08-31-13-36 - #748
Conversation
NagyVikt
left a comment
There was a problem hiding this comment.
🛡️ GitGuardex code-assist
1 finding(s) — 🟠 1 high
⛔ Merge gate: blocked — 1 blocking finding(s) (blocks on high/critical).
| Severity | Location | Finding |
|---|---|---|
| 🟠 high | src/finish/post-branch-finish-cleanup.js:42 |
Implicit branch detection reads the branch from the resolved repository root instead of the targeted worktree. |
Provider codex · commit 6efebf0
- HIGH src/finish/post-branch-finish-cleanup.js:42 Implicit branch detection reads the branch from the resolved repository root instead of the targeted worktree. When the main worktree has the base branch checked out and `branch finish` is run without `--branch` for another worktree, the cleanup plan selects the base branch, fails to find the finished worktree, and silently skips cleanup; the added test appears to cover only an explicitly supplied branch.
NagyVikt
left a comment
There was a problem hiding this comment.
🛡️ GitGuardex code-assist
1 finding(s) — 🟠 1 high
⛔ Merge gate: blocked — 1 blocking finding(s) (blocks on high/critical).
| Severity | Location | Finding |
|---|---|---|
| 🟠 high | src/finish/post-branch-finish-cleanup.js:78 |
The cleanup forcibly deletes the worktree after a non-atomic cleanliness check. |
Provider codex · commit d8dec14
NagyVikt
left a comment
There was a problem hiding this comment.
🛡️ GitGuardex code-assist
✅ No findings. Nothing worth an inline comment in this diff.
Provider codex · commit 9e3692e
NagyVikt
left a comment
There was a problem hiding this comment.
🛡️ GitGuardex code-assist
1 finding(s) — 🟡 1 medium
✅ Merge gate: pass — no blocking findings (blocks on high/critical).
| Severity | Location | Finding |
|---|---|---|
| 🟡 medium | test/finish.test.js:1257-1263 |
The destructive worktree cleanup is tested only on its successful path. |
Provider codex · commit 9e3692e
NagyVikt
left a comment
There was a problem hiding this comment.
🛡️ GitGuardex code-assist
1 finding(s) — 🟠 1 high
⛔ Merge gate: blocked — 1 blocking finding(s) (blocks on high/critical).
| Severity | Location | Finding |
|---|---|---|
| 🟠 high | src/finish/post-branch-finish-cleanup.js:56 |
The cleanliness check ignores ignored files, allowing automatic worktree removal to delete them. |
Provider codex · commit 9e3692e
NagyVikt
left a comment
There was a problem hiding this comment.
🛡️ GitGuardex code-assist
✅ No findings. Nothing worth an inline comment in this diff.
Provider codex · commit 9956f33
NagyVikt
left a comment
There was a problem hiding this comment.
🛡️ GitGuardex code-assist
1 finding(s) — 🟠 1 high
⛔ Merge gate: blocked — 1 blocking finding(s) (blocks on high/critical).
| Severity | Location | Finding |
|---|---|---|
| 🟠 high | src/finish/post-branch-finish-cleanup.js:58 |
The cleanup specifically selects the worktree containing the caller's active working directory for deletion. |
Provider codex · commit 9956f33
NagyVikt
left a comment
There was a problem hiding this comment.
🛡️ GitGuardex code-assist
2 finding(s) — 🟠 1 high · 🟡 1 medium
⛔ Merge gate: blocked — 1 blocking finding(s) (blocks on high/critical).
| Severity | Location | Finding |
|---|---|---|
| 🟠 high | src/finish/post-branch-finish-cleanup.js:189 |
Deferred cleanup expires after only two minutes, so the normal interactive-shell case leaves the worktree permanently orphaned. |
| 🟡 medium | src/finish/post-branch-finish-cleanup.js:72 |
Cleanup can never succeed on non-Linux platforms because an unavailable /proc is unconditionally interpreted as a live process. |
Provider codex · commit 6fdb97f
- HIGH src/finish/post-branch-finish-cleanup.js:189 Deferred cleanup expires after only two minutes, so the normal interactive-shell case leaves the worktree permanently orphaned. A shell commonly retains the finished worktree as its cwd until the developer changes directories, which may happen well after this worker's 120 one-second attempts; no later process retries the cleanup.
NagyVikt
left a comment
There was a problem hiding this comment.
🛡️ GitGuardex code-assist
1 finding(s) — 🟡 1 medium
✅ Merge gate: pass — no blocking findings (blocks on high/critical).
| Severity | Location | Finding |
|---|---|---|
| 🟡 medium | src/finish/post-branch-finish-cleanup.js:157 |
The scheduler creates a permanently running detached process on every non-Linux host. |
Provider codex · commit ab6dbff
Prevent cleanup workers from expiring while a shell still holds the worktree, and avoid spawning an unmonitorable worker when process cwd detection is unavailable.\n\nTested: node --test --test-name-pattern='post-finish cleanup' test/finish.test.js\nTested: node --test --test-name-pattern='branch finish removes' test/finish.test.js\nTested: npm run format:check:changed && npm run lint
NagyVikt
left a comment
There was a problem hiding this comment.
🛡️ GitGuardex code-assist
1 finding(s) — 🟠 1 high
⛔ Merge gate: blocked — 1 blocking finding(s) (blocks on high/critical).
| Severity | Location | Finding |
|---|---|---|
| 🟠 high | src/finish/post-branch-finish-cleanup.js:82-84 |
Permission errors while reading a process cwd are incorrectly treated as if the process were absent. |
Provider codex · commit 288478e
- HIGH src/finish/post-branch-finish-cleanup.js:84 Permission errors while reading a process cwd are incorrectly treated as if the process were absent. On systems with restricted `/proc` visibility, this can produce a false inactive result and remove a worktree that is still in use; only errors indicating that the process disappeared should be ignored.
NagyVikt
left a comment
There was a problem hiding this comment.
🛡️ GitGuardex code-assist
1 finding(s) — 🟠 1 high
⛔ Merge gate: blocked — 1 blocking finding(s) (blocks on high/critical).
| Severity | Location | Finding |
|---|---|---|
| 🟠 high | src/finish/post-branch-finish-cleanup.js:222-226 |
The deferred worker can delete a different worktree later created at the same path. |
Provider codex · commit e5b689d
Record a token in the linked-worktree git metadata and verify it before removal, so a reused path cannot cause deletion of a replacement worktree. Fall back to lsof when proc cwd inspection is incomplete.\n\nTested: node --test --test-name-pattern='post-finish cleanup' test/finish.test.js\nTested: node --test --test-name-pattern='branch finish removes' test/finish.test.js\nTested: npm run format:check:changed && npm run lint
NagyVikt
left a comment
There was a problem hiding this comment.
🛡️ GitGuardex code-assist
2 finding(s) — 🟡 2 medium
✅ Merge gate: pass — no blocking findings (blocks on high/critical).
| Severity | Location | Finding |
|---|---|---|
| 🟡 medium | src/finish/post-branch-finish-cleanup.js:159 |
Cleanup is permanently disabled on platforms without both /proc and lsof. |
| 🟡 medium | src/finish/post-branch-finish-cleanup.js:294 |
The detached cleanup worker retries forever by default. A long-lived shell in a finished worktree leaves one Node process waking every |
Provider codex · commit 9a277b0
NagyVikt
left a comment
There was a problem hiding this comment.
🛡️ GitGuardex code-assist
1 finding(s) — 🟡 1 medium
✅ Merge gate: pass — no blocking findings (blocks on high/critical).
| Severity | Location | Finding |
|---|---|---|
| 🟡 medium | src/finish/post-branch-finish-cleanup.js:259-268 |
An asynchronous worker spawn failure is unhandled and can crash the successfully completed CLI. |
Provider codex · commit 9a277b0
Attach an error listener before unref so an asynchronous child-process startup failure cannot crash an otherwise successful finish command.\n\nTested: node --test --test-name-pattern='post-finish cleanup' test/finish.test.js\nTested: npm test\nTested: npm run format:check:changed && npm run lint
NagyVikt
left a comment
There was a problem hiding this comment.
🛡️ GitGuardex code-assist
1 finding(s) — 🟡 1 medium
✅ Merge gate: pass — no blocking findings (blocks on high/critical).
| Severity | Location | Finding |
|---|---|---|
| 🟡 medium | src/finish/post-branch-finish-cleanup.js:123-128 |
The live-process scan silently ignores processes owned by other users. |
Provider codex · commit 72f0d7f
Summary
Test plan