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
Member

Summary

Closes #647

Fixes the Container.resolve() crash in plan tree, plan explain, and plan correct CLI commands by aligning Robot Framework test mocks with the corrected production code.

Changes

Robot Framework Mock Alignment

  • robot/helper_m3_decision_validation_smoke.py: Updated mock from mock_container.resolve.return_value to mock_container.decision_service.return_value to match the production code path (container.decision_service()). Added spec=Container to prevent silent attribute auto-creation.
  • robot/helper_m4_correction_subplan_smoke.py: Same fix in _mock_container() helper function, also with spec=Container.

BDD Feature File Comment Update

  • features/container_resolve_crash.feature: Updated comment wording to clarify that bug #647 is fixed and the scenarios serve as permanent regression guards. The @tdd_expected_fail tag was already removed by the TDD branch prior to this fix branch being created; the permanent @tdd_issue and @tdd_issue_647 tags remain per TDD tag lifecycle rules in CONTRIBUTING.md.

CHANGELOG

  • CHANGELOG.md: Added entry under ## Unreleased describing the fix.

Context

The three container.resolve(_DS) call sites in plan.py were already replaced with container.decision_service() in master. However, two Robot test helpers still used the old mock pattern (container.resolve.return_value), which passed silently because MagicMock auto-creates any attribute. This commit completes the fix by ensuring mocks match the actual production code, and adds spec=Container to both mock containers so that any future attribute mismatches will raise AttributeError instead of passing silently.

Quality Gates

Gate Status
lint Pass
typecheck Pass (0 errors)
unit_tests 12,822 scenarios passed
integration_tests Pass
e2e_tests 56 passed, 1 skipped
coverage_report 97% (≥97%)
## Summary Closes #647 Fixes the `Container.resolve()` crash in `plan tree`, `plan explain`, and `plan correct` CLI commands by aligning Robot Framework test mocks with the corrected production code. ## Changes ### Robot Framework Mock Alignment - **`robot/helper_m3_decision_validation_smoke.py`**: Updated mock from `mock_container.resolve.return_value` to `mock_container.decision_service.return_value` to match the production code path (`container.decision_service()`). Added `spec=Container` to prevent silent attribute auto-creation. - **`robot/helper_m4_correction_subplan_smoke.py`**: Same fix in `_mock_container()` helper function, also with `spec=Container`. ### BDD Feature File Comment Update - **`features/container_resolve_crash.feature`**: Updated comment wording to clarify that bug #647 is fixed and the scenarios serve as permanent regression guards. The `@tdd_expected_fail` tag was already removed by the TDD branch prior to this fix branch being created; the permanent `@tdd_issue` and `@tdd_issue_647` tags remain per TDD tag lifecycle rules in CONTRIBUTING.md. ### CHANGELOG - **`CHANGELOG.md`**: Added entry under `## Unreleased` describing the fix. ## Context The three `container.resolve(_DS)` call sites in `plan.py` were already replaced with `container.decision_service()` in master. However, two Robot test helpers still used the old mock pattern (`container.resolve.return_value`), which passed silently because MagicMock auto-creates any attribute. This commit completes the fix by ensuring mocks match the actual production code, and adds `spec=Container` to both mock containers so that any future attribute mismatches will raise `AttributeError` instead of passing silently. ## Quality Gates | Gate | Status | |------|--------| | lint | ✅ Pass | | typecheck | ✅ Pass (0 errors) | | unit_tests | ✅ 12,822 scenarios passed | | integration_tests | ✅ Pass | | e2e_tests | ✅ 56 passed, 1 skipped | | coverage_report | ✅ 97% (≥97%) |
hurui200320 added this to the v3.2.0 milestone 2026-03-25 11:22:43 +00:00
hurui200320 added the
Type
Bug
label 2026-03-25 11:22:43 +00:00
hurui200320 force-pushed bugfix/m3-container-resolve from 9e39c5a683 to 021fb9985e 2026-03-25 12:14:58 +00:00 Compare
hurui200320 force-pushed bugfix/m3-container-resolve from 021fb9985e to 946aaf0620 2026-03-25 12:34:22 +00:00 Compare
hurui200320 force-pushed bugfix/m3-container-resolve from 946aaf0620 to 3589a495ad 2026-03-27 10:01:05 +00:00 Compare
Owner

Code Review Note

Unable to review — the branch for this PR (expected bugfix/m3-container-resolve or similar) was not found on the remote. A TDD branch tdd/container-resolve-crash exists with regression tests but not the actual fix. Please verify the fix branch has been pushed.

## Code Review Note **Unable to review** — the branch for this PR (expected `bugfix/m3-container-resolve` or similar) was not found on the remote. A TDD branch `tdd/container-resolve-crash` exists with regression tests but not the actual fix. Please verify the fix branch has been pushed.
freemo requested review from freemo 2026-03-28 21:28:05 +00:00
freemo requested review from brent.edwards 2026-03-28 21:28:05 +00:00
freemo requested changes 2026-03-28 21:32:01 +00:00
Dismissed
freemo left a comment
Owner

Day 48 Planning Review — Bug Fix PR for #647

The code fix itself (replacing Container.resolve() with named provider calls) is sound and well-scoped. However, there are blocking issues that must be resolved before merge:

  1. Merge conflictsmergeable: false. Branch must be rebased onto current master.

  2. @tdd_expected_fail removal not visible in diff — The PR description claims the tag was removed, but the diff only shows a comment rewording in features/container_resolve_crash.feature. If the tag was already absent on master before this branch was created, the description is misleading. Please clarify: was @tdd_expected_fail present on this branch before your changes? If not, remove the claim from the PR description.

  3. Tag naming mismatch — The feature file uses @tdd_issue / @tdd_issue_647 but CONTRIBUTING.md requires @tdd_bug / @tdd_bug_647. The three-tag system specified in CONTRIBUTING.md uses @tdd_bug, @tdd_bug_<N>, and @tdd_expected_fail — not @tdd_issue. Please verify and correct the tag names if needed.

  4. @freemo's comment (Mar 27) about the branch not being found on the remote — @hurui200320, please reply confirming the branch is now available and request re-review.

Requested changes: Rebase onto master, resolve tag naming, clarify @tdd_expected_fail removal, respond to @freemo's comment.

**Day 48 Planning Review — Bug Fix PR for #647** The code fix itself (replacing `Container.resolve()` with named provider calls) is sound and well-scoped. However, there are blocking issues that must be resolved before merge: 1. **Merge conflicts** — `mergeable: false`. Branch must be rebased onto current `master`. 2. **`@tdd_expected_fail` removal not visible in diff** — The PR description claims the tag was removed, but the diff only shows a comment rewording in `features/container_resolve_crash.feature`. If the tag was already absent on master before this branch was created, the description is misleading. Please clarify: was `@tdd_expected_fail` present on this branch before your changes? If not, remove the claim from the PR description. 3. **Tag naming mismatch** — The feature file uses `@tdd_issue` / `@tdd_issue_647` but CONTRIBUTING.md requires `@tdd_bug` / `@tdd_bug_647`. The three-tag system specified in CONTRIBUTING.md uses `@tdd_bug`, `@tdd_bug_<N>`, and `@tdd_expected_fail` — not `@tdd_issue`. Please verify and correct the tag names if needed. 4. **@freemo's comment (Mar 27)** about the branch not being found on the remote — @hurui200320, please reply confirming the branch is now available and request re-review. **Requested changes**: Rebase onto master, resolve tag naming, clarify `@tdd_expected_fail` removal, respond to @freemo's comment.
freemo approved these changes 2026-03-30 04:22:36 +00:00
Dismissed
freemo left a comment
Owner

Review: APPROVED

Small, focused fix. Using MagicMock(spec=Container) correctly prevents auto-creating non-existent attributes. Properly replaces the non-existent container.resolve() with actual DI provider calls.

## Review: APPROVED Small, focused fix. Using `MagicMock(spec=Container)` correctly prevents auto-creating non-existent attributes. Properly replaces the non-existent `container.resolve()` with actual DI provider calls.
hurui200320 force-pushed bugfix/m3-container-resolve from 3589a495ad to 2651e15854 2026-03-30 05:12:51 +00:00 Compare
hurui200320 dismissed freemo's review 2026-03-30 05:12:51 +00:00
Reason:

New commits pushed, approval review dismissed automatically according to repository settings

Author
Member

Thanks for the thorough review, Jeff.

Point 2 (@tdd_expected_fail removal): You're right — the @tdd_expected_fail tag was already absent on master before this branch was created. The PR description was misleading. I've updated it to accurately reflect that only a comment rewording was made in the feature file, not a tag removal. I've also corrected the tag name references from @tdd_bug/@tdd_bug_647 to @tdd_issue/@tdd_issue_647 to match what's actually in the file.

Point 3 (tag naming): The feature file uses @tdd_issue / @tdd_issue_647, which is actually the correct naming per CONTRIBUTING.md (lines 1190-1192). The three-tag system defined there uses @tdd_issue, @tdd_issue_<N>, and @tdd_expected_fail. Some older CHANGELOG entries reference @tdd_bug (a historical convention), but the authoritative specification in CONTRIBUTING.md uses @tdd_issue. No change needed here.

Branch has been rebased onto the latest master and force-pushed. The PR is now mergeable and all quality gates pass.


Note: This reply was generated by opencode.

Thanks for the thorough review, Jeff. **Point 2 (`@tdd_expected_fail` removal):** You're right — the `@tdd_expected_fail` tag was already absent on master before this branch was created. The PR description was misleading. I've updated it to accurately reflect that only a comment rewording was made in the feature file, not a tag removal. I've also corrected the tag name references from `@tdd_bug`/`@tdd_bug_647` to `@tdd_issue`/`@tdd_issue_647` to match what's actually in the file. **Point 3 (tag naming):** The feature file uses `@tdd_issue` / `@tdd_issue_647`, which is actually the correct naming per CONTRIBUTING.md (lines 1190-1192). The three-tag system defined there uses `@tdd_issue`, `@tdd_issue_<N>`, and `@tdd_expected_fail`. Some older CHANGELOG entries reference `@tdd_bug` (a historical convention), but the authoritative specification in CONTRIBUTING.md uses `@tdd_issue`. No change needed here. Branch has been rebased onto the latest master and force-pushed. The PR is now mergeable and all quality gates pass. --- *Note: This reply was generated by [opencode](https://github.com/anthropics/opencode).*
hurui200320 merged commit 2651e15854 into master 2026-03-30 05:45:10 +00:00
hurui200320 deleted branch bugfix/m3-container-resolve 2026-03-30 05:45:10 +00:00
Sign in to join this conversation.
No Reviewers
No Label
Type
Bug
2 Participants
Notifications
Due Date
No due date set.
Reference: cleveragents/cleveragents-core#1157