forked from cleveragents/cleveragents-core
b907ccd9f8
When a user cancels a plan after execute, the git worktree branch and directory created during execute are not cleaned up, causing resource leaks (dangling worktrees accumulate over time). Add GitWorktreeSandbox.cleanup_stale() classmethod in the infrastructure layer with idempotent error handling. _cleanup_sandbox_for_plan() in the CLI layer resolves the plan's linked git-checkout resource and delegates to cleanup_stale(). Called after service.cancel_plan() in the cancel CLI handler. ISSUES CLOSED: #9230
18 lines
1015 B
Gherkin
18 lines
1015 B
Gherkin
@cancel-worktree-cleanup
|
|
Feature: Plan cancel cleans up worktree sandbox (#9230)
|
|
Verifies that cancelling a plan after execute removes the
|
|
git worktree branch and directory to prevent resource leaks.
|
|
|
|
Scenario: _cleanup_sandbox_for_plan removes worktree for cancelled plan for cwc
|
|
Given a temp git project with a worktree sandbox for plan "01TESTCANCEL000000000000" for cwc
|
|
And a mocked service that resolves the project for cwc
|
|
When I call _cleanup_sandbox_for_plan for plan "01TESTCANCEL000000000000" for cwc
|
|
Then the branch "cleveragents/plan-01TESTCANCEL000000000000" should not exist for cwc
|
|
And the worktree directory should not exist for cwc
|
|
|
|
Scenario: _cleanup_sandbox_for_plan is a no-op when no sandbox exists for cwc
|
|
Given a temp git project without any worktree for cwc
|
|
And a mocked service with no linked resources for cwc
|
|
When I call _cleanup_sandbox_for_plan for plan "01TESTNOSANDBOX0000000000" for cwc
|
|
Then the call should complete without error for cwc
|