Files
cleveragents-core/features/plan_lifecycle_commands_coverage.feature
T
CoreRasurae cc24d8c8ac fix(cli): remove legacy plan commands from help output
Completely removed all legacy plan commands from the CLI:
    - Removed tell, build, new, current, cd, continue CLI commands
    - Removed programmatic wrapper functions (tell_command, build_command, etc.)
    - Removed legacy deprecation message
    - Updated help text to indicate V3 Plan Lifecycle exclusively
    - Removed stale references to tell/build in help output and command validation

    Removes the legacy 'tell' and 'build' CLI shortcuts from main.py:
    - Removed echo lines advertising tell/build commands
    - Removed tell/build from valid_cmds list
    - Removed tell/build from _LIGHTWEIGHT_COMMANDS frozenset
    - These dead entries were preventing helpful error messages

    Test infrastructure improvements:
    - Event bus exception test: Patch the module-level logger during emit() so that
      structlog.testing.capture_logs() can capture the logs. Without patching, the
      module-level logger created at import time is not captured by the context manager.
    - Session create/list commands: Suppress cleveragents.mcp logger to CRITICAL level
      during JSON/YAML output formatting to prevent health check warnings with ANSI codes
      from being written to stdout before JSON output, which breaks JSON parsing.
    - Extended plan_cli_coverage_boost with scenarios for estimation_result,
      invariants, execution_environment, validation_summary, and checkpoint
      coverage in _plan_spec_dict

    Documentation:
    - Created docs/Legacy_to_V3_Guide.md with comprehensive migration instructions
    - Updated CONTRIBUTING.md to document removal of legacy workflow
    - Updated CHANGELOG.md to reference issue #4181 instead of PR #10800

ISSUES CLOSED: #4181
2026-05-05 02:01:49 +00:00

196 lines
8.8 KiB
Gherkin

Feature: Plan V3 Lifecycle Commands Coverage
As a developer
I want to test V3 lifecycle commands in plan.py
So that previously uncovered lines/branches have test coverage
# ===================================================================
# V3 Lifecycle - use_action command
# ===================================================================
Scenario: Use action creates a plan from an available action with string arguments
When I invoke use_action with string argument "target_coverage=80"
Then the use_action CLI should succeed
And the lifecycle plan panel should be printed
Scenario: Use action parses integer and float argument values correctly
When I invoke use_action with args "count=42" and "ratio=3.14"
Then the use_action CLI should succeed
And the parsed arguments should contain integer 42 and float 3.14
Scenario: Use action parses boolean argument values correctly
When I invoke use_action with args "verbose=true" and "dry_run=false"
Then the use_action CLI should succeed
And the parsed arguments should contain booleans true and false
Scenario: Use action rejects invalid argument format without equals sign
When I invoke use_action with malformed argument "badarg"
Then the use_action CLI should abort
And the output should mention invalid argument format
Scenario: Use action falls back to action name lookup when ID not found
When I invoke use_action where get_action raises NotFoundError
Then the use_action CLI should succeed via name fallback
Scenario: Use action parses custom automation profile
When I invoke use_action with automation profile "full-auto"
Then the use_action CLI should succeed
And the lifecycle service should receive full-auto profile
Scenario: Use action rejects invalid automation profile
When I invoke use_action with automation profile "super_auto"
Then the use_action CLI should abort
And the output should mention invalid automation profile
Scenario: Use action reports error when action is not available
When I invoke use_action and ActionNotAvailableError is raised
Then the use_action CLI should abort
And the output should mention action not available
Scenario: Use action handles validation errors gracefully
When I invoke use_action and ValidationError is raised
Then the use_action CLI should abort with lifecycle validation error
Scenario: Use action handles general CleverAgents errors
When I invoke use_action and CleverAgentsError is raised
Then the use_action CLI should abort with lifecycle general error
# ===================================================================
# V3 Lifecycle - execute_plan command
# ===================================================================
Scenario: Execute plan transitions a strategize-complete plan to execute phase
When I invoke execute_plan with a valid plan ID
Then the execute_plan CLI should succeed
And the execute phase panel should be printed
Scenario: Execute plan auto-selects the only strategize-complete plan when no ID given
When I invoke execute_plan without ID and one strategize-complete plan exists
Then the execute_plan CLI should succeed
Scenario: Execute plan aborts when no plans are ready for execution
When I invoke execute_plan without ID and no strategize plans exist at all
Then the execute_plan CLI should abort
And the output should mention no plans ready for execution
Scenario: Execute plan aborts when multiple plans are ready and no ID given
When I invoke execute_plan without ID and multiple strategize-complete plans exist
Then the execute_plan CLI should abort
And the output should mention multiple plans ready
Scenario: Execute plan reports invalid phase transition error
When I invoke execute_plan and InvalidPhaseTransitionError is raised
Then the execute_plan CLI should abort
And the output should mention invalid transition
Scenario: Execute plan reports plan not ready error
When I invoke execute_plan and PlanNotReadyError is raised
Then the execute_plan CLI should abort
And the output should mention plan not ready
Scenario: Execute plan auto-runs strategize on queued plan
When I invoke execute_plan with a plan in strategize-queued state
Then the execute_plan CLI should succeed
And the PlanExecutor should have run strategize inline
Scenario: Execute plan succeeds when auto-progress already moved plan to execute
When I invoke execute_plan and auto-progress already moved plan to execute
Then the execute_plan CLI should succeed
# ===================================================================
# V3 Lifecycle - apply_plan command
# ===================================================================
Scenario: Lifecycle apply transitions an execute-complete plan to apply phase
When I invoke apply with a valid plan ID
Then the apply CLI should succeed
And the apply phase panel should be printed
Scenario: Lifecycle apply auto-selects the only execute-complete plan
When I invoke apply without ID and one execute-complete plan exists
Then the apply CLI should succeed
Scenario: Lifecycle apply aborts when no plans are ready for apply
When I invoke apply without ID and no execute-complete plans exist
Then the apply CLI should abort
And the output should mention no plans ready for apply
Scenario: Lifecycle apply aborts when multiple plans are ready and no ID given
When I invoke apply without ID and multiple execute-complete plans exist
Then the apply CLI should abort
And the output should mention multiple plans ready for apply
# ===================================================================
# V3 Lifecycle - plan_status command
# ===================================================================
Scenario: Plan status shows details for a specific plan ID
When I invoke plan status with a specific plan ID
Then the plan status CLI should succeed
And the plan status panel should be displayed
Scenario: Plan status lists all active plans when no ID given
When I invoke plan status without ID and active plans exist
Then the plan status CLI should succeed
And the active plans table should be displayed
Scenario: Plan status shows no plans message when empty
When I invoke plan status without ID and no plans exist
Then the plan status CLI should succeed with no plans message
# ===================================================================
# V3 Lifecycle - list_plans command
# ===================================================================
Scenario: Lifecycle list shows all plans without filters
When I invoke list without filters
Then the list CLI should succeed
And the lifecycle plans table should be displayed
Scenario: Lifecycle list filters plans by phase
When I invoke list with phase filter "strategize"
Then the list CLI should succeed
Scenario: Lifecycle list rejects invalid phase filter
When I invoke list with phase filter "bogus_phase"
Then the list CLI should abort
And the output should mention invalid phase
Scenario: Lifecycle list shows no plans message when empty
When I invoke list and no plans match
Then the list CLI should succeed with empty list message
# ===================================================================
# V3 Lifecycle - cancel_plan command
# ===================================================================
Scenario: Cancel plan cancels a plan with a reason
When I invoke cancel with a reason "no longer needed"
Then the cancel CLI should succeed
And the output should show cancellation with reason
Scenario: Cancel plan cancels a plan without a reason
When I invoke cancel without a reason
Then the cancel CLI should succeed
And the output should show cancellation without reason text
Scenario: Cancel plan handles plan errors
When I invoke cancel and PlanError is raised
Then the cancel CLI should abort
And the output should mention cannot cancel
# ===================================================================
# _print_lifecycle_plan
# ===================================================================
Scenario: Print lifecycle plan displays details for a real LifecyclePlan
When I call _print_lifecycle_plan with a LifecyclePlan instance
Then the lifecycle plan panel should be rendered with plan details
Scenario: Print lifecycle plan falls back for a non-LifecyclePlan object
When I call _print_lifecycle_plan with a non-LifecyclePlan object
Then the fallback plan panel should be rendered
Scenario: Print lifecycle plan shows error message when present
When I call _print_lifecycle_plan with a LifecyclePlan that has an error
Then the lifecycle plan panel should include the error message