Files
cleveragents-core/features/sandbox_cleanup_conditional.feature
HAL9001 1789f6323b
CI / benchmark-publish (pull_request) Has been skipped
CI / helm (pull_request) Successful in 33s
CI / push-validation (pull_request) Successful in 28s
CI / lint (pull_request) Successful in 1m14s
CI / quality (pull_request) Successful in 1m36s
CI / typecheck (pull_request) Successful in 1m37s
CI / build (pull_request) Successful in 1m42s
CI / security (pull_request) Successful in 1m53s
CI / e2e_tests (pull_request) Successful in 3m49s
CI / integration_tests (pull_request) Successful in 3m53s
CI / unit_tests (pull_request) Successful in 6m33s
CI / docker (pull_request) Successful in 1m29s
CI / coverage (pull_request) Successful in 11m1s
CI / status-check (pull_request) Successful in 4s
fix(plan): only cleanup worktree sandbox on execute failure, not success
Replace unconditional sandbox cleanup in execute_plan's finally block
with conditional cleanup gated on an explicit execute_succeeded flag.
On success the worktree branch survives until plan apply merges it
into the project (spec §13256-13260).

- Add execute_succeeded flag set after successful execution
- Guard finally-block cleanup with 'if not execute_succeeded'
- Remove unused _commit_exc variable in _commit_worktree_changes
- Add BDD test scenarios (sandbox_cleanup_conditional.feature)

ISSUES CLOSED: #10872
2026-04-30 10:03:08 +00:00

38 lines
2.0 KiB
Gherkin

@sandbox-cleanup-conditional
Feature: Sandbox cleanup only on execute failure (#10872)
Verifies that the execute_plan command's finally block only calls
sandbox_obj.cleanup() when execution fails. On success the worktree
branch survives until ``plan apply`` merges it (spec §13256-13260).
Scenario: Execute success prevents sandbox cleanup for scco
Given a mocked lifecycle service with a strat-complete plan for scco
And the executor completes successfully for scco
And sandbox_infos contains two active sandboxes for scco
When I invoke plan execute for plan "01TESTSCCPASS0000000000" for scco
Then the CLI exit code should be zero for scco
And sandbox cleanup should NOT have been called for scco
Scenario: Execute exception triggers sandbox cleanup for scef
Given a mocked lifecycle service with a strat-complete plan for scef
And the executor raises RuntimeError during run_execute for scef
And sandbox_infos contains two active sandboxes for scef
When I invoke plan execute for plan "01TESTSCCFAIL0000000000" for scef
Then the CLI exit code should be non-zero for scef
And sandbox cleanup should have been called for scef
Scenario: Error recovery reversion triggers sandbox cleanup for sceef
Given a mocked lifecycle service with an execute-errored plan for scef-er
And the executor raises ValueError during error recovery for scef-er
And sandbox_infos contains two active sandboxes for scef-er
When I invoke plan execute for plan "01TESTSCEFERR000000000" for scef-er
Then the CLI exit code should be non-zero for scef-er
And sandbox cleanup should have been called for scef-er
Scenario: Execute with empty sandbox_infos skips cleanup for sccs
Given a mocked lifecycle service with a strat-complete plan for sccs
And the executor completes successfully for sccs
And sandbox_infos is empty for sccs
When I invoke plan execute for plan "01TESTSCCSKIP000000000000" for sccs
Then the CLI exit code should be zero for sccs
And sandbox cleanup should NOT have been called for sccs