fix(cli): replace non-existent Container.resolve() with named provider calls #1157

Merged
hurui200320 merged 1 commits from bugfix/m3-container-resolve into master 2026-03-30 05:45:10 +00:00
4 changed files with 14 additions and 8 deletions
+5
View File
@@ -152,6 +152,11 @@
Framework integration tests cover override acceptance, fallback acceptance,
and full persistence round-trip. Tests use `@tdd_expected_fail` until the
fix is merged. (#1100)
- Fixed Robot Framework test mocks for ``plan correct`` dry-run and correction
subplan helpers to use ``container.decision_service()`` instead of the
non-existent ``container.resolve()``, matching corrected production code.
Activated regression-guard BDD scenarios for ``plan tree``, ``plan explain``,
and ``plan correct``. (#647)
- Added TDD bug-capture tests for bug #1076 — `use_action()` does not
propagate `automation_profile` to Plan. Three Behave BDD scenarios
(`@tdd_bug @tdd_bug_1076 @tdd_expected_fail`) verify the full precedence
+1 -2
View File
@@ -7,8 +7,7 @@ Feature: Container.resolve() crash in plan tree/explain/correct commands
this class of bug because they mock get_container() with MagicMock, which
auto-creates any attribute.
NOTE: Bug #647 appears fixed; these scenarios now run as normal
regression checks for correct command behavior.
NOTE: Bug #647 is fixed; these scenarios serve as permanent regression guards.
`plan correct` is intentionally exercised with `--dry-run` in this
real-container path so no live LLM execution is triggered.
+4 -3
View File
@@ -21,6 +21,7 @@ if _SRC not in sys.path:
from helpers_common import reset_global_state # noqa: E402
from typer.testing import CliRunner # noqa: E402
from cleveragents.application.container import Container # noqa: E402
from cleveragents.cli.commands.invariant import app as invariant_app # noqa: E402
from cleveragents.cli.commands.plan import app as plan_app # noqa: E402
from cleveragents.cli.commands.validation import app as validation_app # noqa: E402
@@ -275,12 +276,12 @@ def plan_correct_dry_run() -> None:
mock_correction_svc.request_correction.return_value = mock_request
mock_correction_svc.analyze_impact.return_value = mock_impact
# Mock DecisionService resolved via DI container (issue #606 fix)
# Mock DecisionService provider on DI container (issue #606 / #647 fix)
mock_decision_svc = MagicMock()
mock_decision_svc.list_decisions.return_value = []
mock_decision_svc.get_influence_edges.return_value = {}
mock_container = MagicMock()
mock_container.resolve.return_value = mock_decision_svc
mock_container = MagicMock(spec=Container)
mock_container.decision_service.return_value = mock_decision_svc
with (
patch(
+4 -3
View File
@@ -21,6 +21,7 @@ from helpers_common import reset_global_state # noqa: E402
from typer.testing import CliRunner # noqa: E402
from ulid import ULID # noqa: E402
from cleveragents.application.container import Container # noqa: E402
from cleveragents.cli.commands.plan import app as plan_app # noqa: E402
from cleveragents.domain.models.core.correction import ( # noqa: E402
CorrectionImpact,
@@ -115,12 +116,12 @@ def _mock_correction_service() -> MagicMock:
def _mock_container() -> MagicMock:
"""Create a mock DI container that resolves a stub DecisionService."""
"""Create a mock DI container with a stub DecisionService provider."""
mock_decision_svc = MagicMock()
mock_decision_svc.list_decisions.return_value = []
mock_decision_svc.get_influence_edges.return_value = {}
container = MagicMock()
container.resolve.return_value = mock_decision_svc
container = MagicMock(spec=Container)
container.decision_service.return_value = mock_decision_svc
return container