Files
cleveragents-core/features/plan_cli_uncovered_region_coverage.feature
T
freemo 2eb31a598c
CI / benchmark-publish (pull_request) Has been skipped
CI / lint (pull_request) Successful in 15s
CI / build (pull_request) Successful in 16s
CI / quality (pull_request) Successful in 19s
CI / security (pull_request) Successful in 36s
CI / typecheck (pull_request) Successful in 38s
CI / integration_tests (pull_request) Successful in 2m44s
CI / lint (push) Successful in 12s
CI / quality (push) Successful in 16s
CI / build (push) Successful in 23s
CI / typecheck (push) Successful in 31s
CI / security (push) Successful in 32s
CI / benchmark-regression (push) Has been skipped
CI / integration_tests (push) Successful in 3m25s
CI / unit_tests (pull_request) Successful in 13m3s
CI / docker (pull_request) Successful in 1m2s
CI / benchmark-publish (push) Successful in 16m35s
CI / benchmark-regression (pull_request) Successful in 22m21s
CI / unit_tests (push) Successful in 24m45s
CI / docker (push) Successful in 8s
CI / coverage (pull_request) Successful in 1h1m47s
CI / coverage (push) Successful in 1h11m37s
test(coverage): add Behave BDD tests for 8 under-covered modules
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
2026-03-01 03:09:51 +00:00

196 lines
11 KiB
Gherkin

Feature: Plan CLI uncovered region coverage (lines 1950-2273)
As a developer
I want targeted tests for the uncovered lines and branches in plan.py
So that coverage gaps at lines 1950-1954, 1956-1957, 2132, 2135-2143,
2146-2184, 2202-2233, and 2231-2273 are closed
# ===================================================================
# lifecycle_list_plans empty result after filtering (lines 1950-1954)
# ===================================================================
Scenario: uncov-rgn lifecycle-list shows "No plans found" when action filter excludes all
Given an uncov-rgn CLI runner and mocked lifecycle service
And the uncov-rgn lifecycle service returns plans that do not match an action filter
When I uncov-rgn invoke lifecycle-list with action filter "nonexistent/action"
Then the uncov-rgn command should exit normally
And the uncov-rgn output should contain "No plans found"
# ===================================================================
# lifecycle_list_plans — non-rich format output (lines 1956-1957)
# ===================================================================
Scenario: uncov-rgn lifecycle-list outputs JSON when format is json
Given an uncov-rgn CLI runner and mocked lifecycle service
And the uncov-rgn lifecycle service returns a single plan for listing
When I uncov-rgn invoke lifecycle-list with format "json"
Then the uncov-rgn command should exit normally
And the uncov-rgn output should contain "plan_id"
Scenario: uncov-rgn lifecycle-list outputs YAML when format is yaml
Given an uncov-rgn CLI runner and mocked lifecycle service
And the uncov-rgn lifecycle service returns a single plan for listing
When I uncov-rgn invoke lifecycle-list with format "yaml"
Then the uncov-rgn command should exit normally
And the uncov-rgn output should contain "plan_id"
# ===================================================================
# revert_plan — CleverAgentsError handler (line 2132)
# ===================================================================
Scenario: uncov-rgn revert_plan raises CleverAgentsError
Given an uncov-rgn CLI runner and mocked lifecycle service
And the uncov-rgn lifecycle service revert raises CleverAgentsError
When I uncov-rgn invoke revert for plan "01ARZ3NDEKTSV4RRFFQ69G5FAA"
Then the uncov-rgn command should abort
And the uncov-rgn output should contain "Error"
# ===================================================================
# _get_apply_service — function body (lines 2136-2143)
# ===================================================================
Scenario: uncov-rgn _get_apply_service creates a PlanApplyService instance
Given an uncov-rgn mocked lifecycle service for apply service creation
When I uncov-rgn call _get_apply_service directly
Then the uncov-rgn apply service should be returned successfully
# ===================================================================
# plan_diff — correction parameter branch (lines 2149-2184)
# ===================================================================
Scenario: uncov-rgn plan diff with correction flag shows stub panel
Given an uncov-rgn CLI runner and mocked lifecycle service
When I uncov-rgn invoke diff for plan "PLAN-001" with correction "CORR-001"
Then the uncov-rgn command should exit normally
And the uncov-rgn output should contain "Correction Attempt"
And the uncov-rgn output should contain "CORR-001"
Scenario: uncov-rgn plan diff without correction calls apply service
Given an uncov-rgn CLI runner and mocked lifecycle service
And the uncov-rgn apply service diff returns formatted output "--- a/main.py"
When I uncov-rgn invoke diff for plan "PLAN-002" without correction
Then the uncov-rgn command should exit normally
And the uncov-rgn output should contain "main.py"
Scenario: uncov-rgn plan diff raises PlanError
Given an uncov-rgn CLI runner and mocked lifecycle service
And the uncov-rgn apply service diff raises PlanError "missing changeset"
When I uncov-rgn invoke diff for plan "PLAN-003" without correction
Then the uncov-rgn command should abort
And the uncov-rgn output should contain "Diff Error"
Scenario: uncov-rgn plan diff raises CleverAgentsError
Given an uncov-rgn CLI runner and mocked lifecycle service
And the uncov-rgn apply service diff raises CleverAgentsError "service down"
When I uncov-rgn invoke diff for plan "PLAN-004" without correction
Then the uncov-rgn command should abort
And the uncov-rgn output should contain "Error"
# ===================================================================
# plan_artifacts — full command coverage (lines 2202-2233)
# ===================================================================
Scenario: uncov-rgn plan artifacts success in rich format
Given an uncov-rgn CLI runner and mocked lifecycle service
And the uncov-rgn apply service artifacts returns "changeset-id: cs-100"
When I uncov-rgn invoke artifacts for plan "PLAN-005" in rich format
Then the uncov-rgn command should exit normally
And the uncov-rgn output should contain "cs-100"
Scenario: uncov-rgn plan artifacts success in json format
Given an uncov-rgn CLI runner and mocked lifecycle service
And the uncov-rgn apply service artifacts returns '{"changeset": "cs-200"}'
When I uncov-rgn invoke artifacts for plan "PLAN-006" with format "json"
Then the uncov-rgn command should exit normally
And the uncov-rgn output should contain "cs-200"
Scenario: uncov-rgn plan artifacts raises PlanError
Given an uncov-rgn CLI runner and mocked lifecycle service
And the uncov-rgn apply service artifacts raises PlanError "no changeset"
When I uncov-rgn invoke artifacts for plan "PLAN-007" in rich format
Then the uncov-rgn command should abort
And the uncov-rgn output should contain "Artifacts Error"
Scenario: uncov-rgn plan artifacts raises CleverAgentsError
Given an uncov-rgn CLI runner and mocked lifecycle service
And the uncov-rgn apply service artifacts raises CleverAgentsError "timeout"
When I uncov-rgn invoke artifacts for plan "PLAN-008" in rich format
Then the uncov-rgn command should abort
And the uncov-rgn output should contain "Error"
# ===================================================================
# correct_decision — full command coverage (lines 2231-2273+)
# ===================================================================
Scenario: uncov-rgn correct revert with --yes succeeds in rich format
Given an uncov-rgn CLI runner and mocked lifecycle service
And the uncov-rgn correction service returns a revert result with reverted decisions
When I uncov-rgn invoke correct in revert mode with --yes and guidance "Use Flask instead"
Then the uncov-rgn command should exit normally
And the uncov-rgn output should contain "Correction applied"
And the uncov-rgn output should contain "Reverted"
Scenario: uncov-rgn correct append with --yes succeeds in rich format
Given an uncov-rgn CLI runner and mocked lifecycle service
And the uncov-rgn correction service returns an append result with new decisions
When I uncov-rgn invoke correct in append mode with --yes and guidance "Add caching layer"
Then the uncov-rgn command should exit normally
And the uncov-rgn output should contain "Correction applied"
And the uncov-rgn output should contain "New decisions"
Scenario: uncov-rgn correct revert with --yes succeeds in json format
Given an uncov-rgn CLI runner and mocked lifecycle service
And the uncov-rgn correction service returns a revert result with reverted decisions
When I uncov-rgn invoke correct in revert mode with --yes, format "json", and guidance "Refactor"
Then the uncov-rgn command should exit normally
And the uncov-rgn output should contain "correction_id"
And the uncov-rgn output should contain "reverted_decisions"
Scenario: uncov-rgn correct dry-run in rich format shows impact panel
Given an uncov-rgn CLI runner and mocked lifecycle service
And the uncov-rgn correction service returns an impact analysis
When I uncov-rgn invoke correct in dry-run mode with rich format and guidance "Preview changes"
Then the uncov-rgn command should exit normally
And the uncov-rgn output should contain "Correction Impact"
And the uncov-rgn output should contain "Dry Run"
Scenario: uncov-rgn correct dry-run in json format shows impact data
Given an uncov-rgn CLI runner and mocked lifecycle service
And the uncov-rgn correction service returns an impact analysis
When I uncov-rgn invoke correct in dry-run mode with format "json" and guidance "Check impact"
Then the uncov-rgn command should exit normally
And the uncov-rgn output should contain "correction_id"
And the uncov-rgn output should contain "risk_level"
Scenario: uncov-rgn correct raises ResourceNotFoundError
Given an uncov-rgn CLI runner and mocked lifecycle service
And the uncov-rgn correction service request raises ResourceNotFoundError
When I uncov-rgn invoke correct in revert mode with --yes and guidance "Fix something"
Then the uncov-rgn command should abort
And the uncov-rgn output should contain "Not found"
Scenario: uncov-rgn correct raises ValidationError
Given an uncov-rgn CLI runner and mocked lifecycle service
And the uncov-rgn correction service request raises ValidationError
When I uncov-rgn invoke correct in revert mode with --yes and guidance "Validate me"
Then the uncov-rgn command should abort
And the uncov-rgn output should contain "Validation Error"
Scenario: uncov-rgn correct raises CleverAgentsError
Given an uncov-rgn CLI runner and mocked lifecycle service
And the uncov-rgn correction service request raises CleverAgentsError
When I uncov-rgn invoke correct in revert mode with --yes and guidance "General error"
Then the uncov-rgn command should abort
And the uncov-rgn output should contain "Error"
Scenario: uncov-rgn correct with invalid mode aborts
Given an uncov-rgn CLI runner and mocked lifecycle service
When I uncov-rgn invoke correct with invalid mode "rollback" and guidance "test"
Then the uncov-rgn command should abort
And the uncov-rgn output should contain "Invalid mode"
Scenario: uncov-rgn correct with empty guidance aborts
Given an uncov-rgn CLI runner and mocked lifecycle service
When I uncov-rgn invoke correct with valid mode "revert" and empty guidance
Then the uncov-rgn command should abort
And the uncov-rgn output should contain "guidance"