FE-883: Cook run worktree/branch GC#231
Conversation
PR SummaryMedium Risk Overview
Removes the unused Reviewed by Cursor Bugbot for commit 593032a. Bugbot is set up for automated code reviews on this repo. Configure here. |
b902c7a to
3890b32
Compare
be0eadf to
ba2562d
Compare
3890b32 to
6b3aaba
Compare
6b7b1ab to
918bd08
Compare
6b3aaba to
4df8c49
Compare
Replaces the operator-owned `git worktree remove` / `git branch -D` cleanup that worktree.ts documents. After a run, gcCookRun removes every worktree registered under the run dir (run worktree + nested slice / __epic__ worktrees, deepest first), deletes the intermediate brunch/slice/<runId>/* branches (their work is folded into the run branch), and removes the on-disk run dir — while keeping the brunch/run/<runId> artifact branch the user reviews/merges, and every other run's state. Best-effort + idempotent. Canonicalizes runDir via realpathSync so it matches git's realpath-resolved worktree-list paths (macOS /var → /private/var). Primitive only; wiring it into cook-cli (auto-GC after a completed promotion, keep-on-failure) is the remaining slice-2 step. 🍳 Built with brunch Co-Authored-By: Opus 4.8 <noreply@anthropic.com>
Wire gcCookRun into cook-cli's brownfield promotion success path: once the run completed and the result is promoted onto brunch/run/<runId> (and optionally landed), reclaim the run's worktrees + intermediate brunch/slice/<runId>/* branches. Best-effort — cleanup never fails a promoted run. Halted/conflicted runs return before this point, so they keep their worktrees for inspection (keep-on-failure). Auto, no flag: no leaks by default. 🍳 Built with brunch Co-Authored-By: Opus 4.8 <noreply@anthropic.com>
Slice 1 (1b) replaced the brownfield promotion path with harvestCookRun's merge-tree fold, leaving promoteBrownfieldRun (file-copy commit-tree of a composed tree) used only by its own tests. Delete it + BrownfieldPromoteOptions + its test block, and clean the now-unused imports (mkdtempSync/tmpdir/rmSync/join). The landCookBranch test built its promoted-branch fixture via promoteBrownfieldRun; rebuild it with a plain commit on brunch/run/r1 through a throwaway worktree — the same branch shape landCookBranch merges. mergeSlicesIntoEpicSandbox and promoteGreenfieldRun stay (the greenfield path). 🍳 Built with brunch Co-Authored-By: Opus 4.8 <noreply@anthropic.com>
c361f84 to
4cc6d23
Compare
918bd08 to
593032a
Compare
Stacks on #230 (FE-883 slice 1). Replaces the operator-owned
git worktree remove/git branch -Dcleanup thatworktree.tsdocumented, and retires the dead code slice 1 orphaned.Worktree/branch GC (slice 2)
gcCookRunreclaims a finished run's transient state: removes every worktree registered under the run dir (run worktree + nested slice/__epic__worktrees, deepest-first), deletes the intermediatebrunch/slice/<runId>/*branches (their work is folded into the run branch), and removes the on-disk run dir — while keeping thebrunch/run/<runId>artifact branch the user reviews/merges, and every other run untouched. Best-effort + idempotent; realpath-safe so it matches git's worktree-list paths (macOS/var→/private/var).Wired into cook-cli: auto-GC on a completed + promoted brownfield run, best-effort (never fails a good run). Halted/conflicted runs return earlier and keep their worktrees for inspection (keep-on-failure). No flag — no leaks by default.
Retire dead promoteBrownfieldRun (1d)
Slice 1 replaced the brownfield promotion path with
harvestCookRun's merge-tree fold, leavingpromoteBrownfieldRun(file-copycommit-tree) used only by its own tests. Deleted it +BrownfieldPromoteOptions+ its test block, cleaned the now-unused imports, and rebuilt thelandCookBranchtest fixture (it had usedpromoteBrownfieldRunto construct a promoted branch) with a plain commit onbrunch/run/r1.mergeSlicesIntoEpicSandboxandpromoteGreenfieldRunstay (the greenfield path).Tests
run-refs.test.ts(GC keeps the run branch; unrelated runs untouched),promote-run.test.ts(rewired fixture). Full orchestrator suite green (677).Remaining
A multi-slice end-to-end runCook test of the promotion + GC wiring — the merge logic is unit-tested (
run-artifact.test.ts) and the 1-slicebrownfield-smokeexercises the engine path, so this is the one coverage gap. Tracked inmemory/CARDS.md.