forked from HAL9000/cleveragents-core
2eb31a598c
Added targeted Behave BDD feature files and step definitions to improve unit test coverage for: - decision_service.py: Full coverage of all 7 service methods (18 scenarios) - plan_apply_service.py: Branch coverage for handle_merge_failure (2 scenarios) - plan_executor.py: Edge cases for rollback, checkpoint, and parse_steps (15 scenarios) - cli/commands/plan.py: Uncovered region lines 1950-2273 (23 scenarios) - repositories.py: Remaining missed branches and lines (14 scenarios) - sandbox/checkpoint.py: Full coverage of CheckpointManager (26 scenarios) - langgraph/bridge.py: Remaining uncovered lines and branches (10 scenarios) - cli/commands/config.py: Safety net to maintain 100% coverage (42 scenarios) Total: 150 new scenarios, 596 steps, all passing. Also fixed a step definition collision in plan_lifecycle_coverage by renaming "the delete result should be false" to "the plan delete result should be false". ISSUES CLOSED: #475
145 lines
8.6 KiB
Gherkin
145 lines
8.6 KiB
Gherkin
Feature: PlanExecutor edge-case coverage for checkpoint, rollback, and sandbox proxy paths
|
|
As a developer
|
|
I want tests that exercise the remaining uncovered lines and branches in plan_executor.py
|
|
So that line 378, lines 410-411, and checkpoint-related branches reach full coverage
|
|
|
|
# Targets:
|
|
# - Line 378 / branch 377→378: _try_rollback_to_last_checkpoint with non-empty checkpoints
|
|
# - Lines 410-411: _resolve_sandbox_for_checkpoint falling through to _SandboxRootProxy
|
|
# - Lines 161-163 / branches 160→161, 162→163/164: _parse_steps non-empty path via run_strategize
|
|
# - Lines 417-419: run_strategize function definition exercised
|
|
|
|
# ------------------------------------------------------------------
|
|
# _resolve_sandbox_for_checkpoint → _SandboxRootProxy path
|
|
# ------------------------------------------------------------------
|
|
|
|
Scenario: Resolve sandbox returns SandboxRootProxy when only sandbox_root is set
|
|
Given an edge3 PlanExecutor with checkpoint manager and sandbox root but no execution context
|
|
When I edge3 resolve sandbox for checkpoint with plan id "EDGE3PLAN01"
|
|
Then the edge3 resolved sandbox should not be None
|
|
And the edge3 resolved sandbox should have a synthetic sandbox id
|
|
And the edge3 resolved sandbox context should have the sandbox path
|
|
|
|
Scenario: Resolve sandbox returns SandboxRootProxy when execution context has no sandbox manager
|
|
Given an edge3 PlanExecutor with checkpoint manager and sandbox root and context without sandbox manager
|
|
When I edge3 resolve sandbox for checkpoint with plan id "EDGE3PLAN02"
|
|
Then the edge3 resolved sandbox should not be None
|
|
And the edge3 resolved sandbox should have a synthetic sandbox id
|
|
|
|
Scenario: Resolve sandbox returns SandboxRootProxy when sandbox manager returns empty list
|
|
Given an edge3 PlanExecutor with checkpoint manager and sandbox root and context with empty sandboxes
|
|
When I edge3 resolve sandbox for checkpoint with plan id "EDGE3PLAN03"
|
|
Then the edge3 resolved sandbox should not be None
|
|
And the edge3 resolved sandbox should have a synthetic sandbox id
|
|
|
|
Scenario: Resolve sandbox returns None when no sandbox root and no execution context
|
|
Given an edge3 PlanExecutor with checkpoint manager but no sandbox root and no execution context
|
|
When I edge3 resolve sandbox for checkpoint with plan id "EDGE3PLAN04"
|
|
Then the edge3 resolved sandbox should be None
|
|
|
|
# ------------------------------------------------------------------
|
|
# _try_rollback_to_last_checkpoint with non-empty checkpoints
|
|
# ------------------------------------------------------------------
|
|
|
|
Scenario: Rollback succeeds when checkpoint manager has checkpoints for sandbox root
|
|
Given an edge3 PlanExecutor with checkpoint manager and sandbox root but no execution context
|
|
And the edge3 checkpoint manager has existing checkpoints that rollback successfully
|
|
When I edge3 try rollback to last checkpoint for plan "EDGE3PLANRB"
|
|
Then the edge3 rollback result should be True
|
|
|
|
Scenario: Rollback returns False when rollback_to raises an exception
|
|
Given an edge3 PlanExecutor with checkpoint manager and sandbox root but no execution context
|
|
And the edge3 checkpoint manager has checkpoints but rollback raises an exception
|
|
When I edge3 try rollback to last checkpoint for plan "EDGE3PLANRF"
|
|
Then the edge3 rollback result should be False
|
|
|
|
Scenario: Rollback returns False when checkpoint manager lists no checkpoints
|
|
Given an edge3 PlanExecutor with checkpoint manager and sandbox root but no execution context
|
|
And the edge3 checkpoint manager returns no checkpoints
|
|
When I edge3 try rollback to last checkpoint for plan "EDGE3PLANRE"
|
|
Then the edge3 rollback result should be False
|
|
|
|
# ------------------------------------------------------------------
|
|
# _try_create_checkpoint via _SandboxRootProxy
|
|
# ------------------------------------------------------------------
|
|
|
|
Scenario: Create checkpoint succeeds through SandboxRootProxy path
|
|
Given an edge3 PlanExecutor with checkpoint manager and sandbox root but no execution context
|
|
And the edge3 checkpoint manager accepts checkpoint creation
|
|
When I edge3 try create checkpoint for plan "EDGE3PLANCP" with phase "pre_execute"
|
|
Then the edge3 checkpoint result should not be None
|
|
And the edge3 checkpoint manager should have been called with sandbox path metadata
|
|
|
|
Scenario: Create checkpoint returns None when creation raises exception through proxy
|
|
Given an edge3 PlanExecutor with checkpoint manager and sandbox root but no execution context
|
|
And the edge3 checkpoint manager raises on create_checkpoint
|
|
When I edge3 try create checkpoint for plan "EDGE3PLANCF" with phase "pre_execute"
|
|
Then the edge3 checkpoint result should be None
|
|
|
|
# ------------------------------------------------------------------
|
|
# Stub execute with checkpoint rollback on failure
|
|
# ------------------------------------------------------------------
|
|
|
|
Scenario: Stub execute failure triggers rollback with sandbox root proxy and existing checkpoints
|
|
Given an edge3 mock lifecycle service for execute
|
|
And an edge3 plan in Execute-Queued state with decision root
|
|
And an edge3 PlanExecutor with checkpoint manager sandbox root and failing execute actor
|
|
And the edge3 checkpoint manager has existing checkpoints that rollback successfully
|
|
When I edge3 call run execute expecting failure
|
|
Then an edge3 exception should have been raised
|
|
And the edge3 checkpoint manager rollback_to should have been called
|
|
And the edge3 lifecycle should have called fail_execute for edge3
|
|
|
|
# ------------------------------------------------------------------
|
|
# Runtime execute with checkpoint rollback on failure
|
|
# ------------------------------------------------------------------
|
|
|
|
Scenario: Runtime execute failure triggers rollback with sandbox root proxy
|
|
Given an edge3 mock lifecycle service for execute
|
|
And an edge3 mock execution context for runtime
|
|
And an edge3 plan in Execute-Queued state with decision root
|
|
And an edge3 PlanExecutor with runtime context checkpoint manager sandbox root and failing runtime actor
|
|
And the edge3 checkpoint manager has existing checkpoints that rollback successfully
|
|
When I edge3 call run execute expecting failure
|
|
Then an edge3 exception should have been raised
|
|
And the edge3 checkpoint manager rollback_to should have been called
|
|
|
|
# ------------------------------------------------------------------
|
|
# _parse_steps non-empty path exercised via run_strategize
|
|
# ------------------------------------------------------------------
|
|
|
|
Scenario: Run strategize exercises _parse_steps with multi-line definition
|
|
Given an edge3 mock lifecycle service for strategize
|
|
And an edge3 plan in Strategize phase with multi-line definition "- Build feature\n- Add tests\n- Deploy"
|
|
And an edge3 PlanExecutor for strategize without execution context
|
|
When I edge3 call run strategize successfully
|
|
Then the edge3 strategize result should have 3 decisions
|
|
And the edge3 lifecycle should have called complete_strategize for edge3
|
|
|
|
Scenario: Run strategize exercises _parse_steps with numbered definition
|
|
Given an edge3 mock lifecycle service for strategize
|
|
And an edge3 plan in Strategize phase with multi-line definition "1. First task\n2. Second task"
|
|
And an edge3 PlanExecutor for strategize without execution context
|
|
When I edge3 call run strategize successfully
|
|
Then the edge3 strategize result should have 2 decisions
|
|
|
|
Scenario: Run strategize with empty definition falls back to default step
|
|
Given an edge3 mock lifecycle service for strategize
|
|
And an edge3 plan in Strategize phase with empty definition
|
|
And an edge3 PlanExecutor for strategize without execution context
|
|
When I edge3 call run strategize successfully
|
|
Then the edge3 strategize result should have 1 decisions
|
|
|
|
# ------------------------------------------------------------------
|
|
# Stub execute with checkpoint creation and sandbox root proxy
|
|
# ------------------------------------------------------------------
|
|
|
|
Scenario: Successful stub execute creates pre and post checkpoints via sandbox root proxy
|
|
Given an edge3 mock lifecycle service for execute
|
|
And an edge3 plan in Execute-Queued state with decision root
|
|
And an edge3 PlanExecutor with checkpoint manager and sandbox root for stub execute
|
|
And the edge3 checkpoint manager accepts checkpoint creation
|
|
When I edge3 call run execute successfully
|
|
Then the edge3 execute result should be an ExecuteResult
|
|
And the edge3 checkpoint manager create_checkpoint should have been called at least twice
|