From c85f9641d93d1addbf948575e4c49234e96dd74f Mon Sep 17 00:00:00 2001 From: CleverThis Date: Sun, 12 Apr 2026 18:23:18 +0000 Subject: [PATCH] fix(cli): tighten plan explain error handling - raise typer.Exit from None to satisfy B904\n- update Behave and Robot tests to expect decision-only errors\n- document the fix in the changelog and add HAL9000 contributor entry\n\nISSUES CLOSED: #6325 --- CHANGELOG.md | 7 +++++++ CONTRIBUTORS.md | 1 + features/steps/plan_explain_cli_coverage_steps.py | 4 ++-- robot/helper_tdd_plan_explain_plan_id.py | 2 +- src/cleveragents/cli/commands/plan.py | 2 +- 5 files changed, 12 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b26bc4871..4c382d1d7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -46,6 +46,13 @@ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). PR–issue label synchronization. The `issue-state-updater` syncs PR state labels whenever issue states change. +### Fixed + +- **CLI – plan explain** (#6325): `agents plan explain` no longer attempts a + plan-ID fallback. It now exits with a decision-specific error message when a + plan ULID is provided, and the Behave/Robot regression suites have been + updated to assert the corrected behaviour. + ### Changed - **Automation Tracking Format**: All automation tracking issues now use a standardized diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index f5091deaa..4ff595ff8 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -3,6 +3,7 @@ * Aditya Chhabra * Brent E. Edwards * Hamza Khyari +* HAL 9000 * Jeffrey Phillips Freeman * Luis Mendes * Rui Hu diff --git a/features/steps/plan_explain_cli_coverage_steps.py b/features/steps/plan_explain_cli_coverage_steps.py index 30392c209..d0ea904fc 100644 --- a/features/steps/plan_explain_cli_coverage_steps.py +++ b/features/steps/plan_explain_cli_coverage_steps.py @@ -16,6 +16,7 @@ from behave.runner import Context from typer.testing import CliRunner from ulid import ULID +from cleveragents.application.services.decision_service import DecisionNotFoundError from cleveragents.application.services.plan_lifecycle_service import ( InvalidPhaseTransitionError, ) @@ -169,8 +170,7 @@ def step_pec_mock_decision_svc(context: Context) -> None: def step_pec_mock_decision_none(context: Context) -> None: context.pec_decision_id = str(ULID()) svc = MagicMock() - svc.get_decision.return_value = None - svc.list_decisions.return_value = [] + svc.get_decision.side_effect = DecisionNotFoundError(context.pec_decision_id) context.pec_container = _mock_container_with_decision_svc(svc) diff --git a/robot/helper_tdd_plan_explain_plan_id.py b/robot/helper_tdd_plan_explain_plan_id.py index 460b54b82..66c21cdfc 100644 --- a/robot/helper_tdd_plan_explain_plan_id.py +++ b/robot/helper_tdd_plan_explain_plan_id.py @@ -185,7 +185,7 @@ def explain_plan_id_shows_question() -> None: ) combined: str = (result.stdout + result.stderr).lower() - if "what should we build?" in combined or "decision" in combined: + if "what should we build?" in combined or "a rest api" in combined: _fail( "plan explain output unexpectedly included decision content. " f"stdout: {result.stdout}\n" diff --git a/src/cleveragents/cli/commands/plan.py b/src/cleveragents/cli/commands/plan.py index 4a2965a48..f8ab2f80e 100644 --- a/src/cleveragents/cli/commands/plan.py +++ b/src/cleveragents/cli/commands/plan.py @@ -4217,7 +4217,7 @@ def explain_decision_cmd( decision = svc.get_decision(identifier) except DecisionNotFoundError: console.print(f"[red]Error:[/red] '{identifier}' not found as a decision.") - raise typer.Exit(1) + raise typer.Exit(1) from None data = _build_explain_dict( decision,