fix(cli): pass decision tree and influence edges to CorrectionService in plan correct handler #639

Merged
freemo merged 2 commits from fix/plan-correct-tree-wiring into master 2026-03-08 23:28:05 +00:00
Owner

Summary

Fixes the plan correct CLI handler which never passes the decision tree or influence edges to CorrectionService, producing single-node impact analysis regardless of the plan's actual decision structure.

Closes #606

Root Cause

The correct_decision() handler in plan.py created a bare CorrectionService() and called analyze_impact() and execute_correction() without passing decision_tree or influence_edges. Both parameters default to None -> empty dicts, causing _compute_affected_subtree() BFS to return only the single target decision, ignoring all descendants and influence-DAG dependents.

Changes

Production Fix (src/cleveragents/cli/commands/plan.py)

  • Resolve DecisionService via get_container() (following the pattern used by plan explain and plan tree)
  • Build structural tree adjacency list from decision_svc.list_decisions(plan_id) using parent_decision_id relationships
  • Fetch influence edges from decision_svc.get_influence_edges(plan_id)
  • Pass both decision_tree and influence_edges to svc.analyze_impact() and svc.execute_correction()

Existing Test Fixups

  • Updated 4 step definition files that mock CorrectionService to also mock the new DecisionService resolution path

New Tests

  • Behave BDD: 3 scenarios verifying tree/edge forwarding (dry-run subtree, execution subtree, leaf node)
  • Robot Framework: 3 integration smoke tests
  • ASV Benchmark: Tree building and analyze_impact overhead benchmarks

Quality Gates

  • nox -s lint — PASSED
  • nox -s typecheck — 0 errors
  • nox -s unit_tests — 9,109 scenarios, 0 failures
  • nox -s coverage_report — 97%

ISSUES CLOSED: #606

## Summary Fixes the `plan correct` CLI handler which never passes the decision tree or influence edges to `CorrectionService`, producing single-node impact analysis regardless of the plan's actual decision structure. Closes #606 ## Root Cause The `correct_decision()` handler in `plan.py` created a bare `CorrectionService()` and called `analyze_impact()` and `execute_correction()` without passing `decision_tree` or `influence_edges`. Both parameters default to `None` -> empty dicts, causing `_compute_affected_subtree()` BFS to return only the single target decision, ignoring all descendants and influence-DAG dependents. ## Changes ### Production Fix (`src/cleveragents/cli/commands/plan.py`) - Resolve `DecisionService` via `get_container()` (following the pattern used by `plan explain` and `plan tree`) - Build structural tree adjacency list from `decision_svc.list_decisions(plan_id)` using `parent_decision_id` relationships - Fetch influence edges from `decision_svc.get_influence_edges(plan_id)` - Pass both `decision_tree` and `influence_edges` to `svc.analyze_impact()` and `svc.execute_correction()` ### Existing Test Fixups - Updated 4 step definition files that mock `CorrectionService` to also mock the new `DecisionService` resolution path ### New Tests - **Behave BDD**: 3 scenarios verifying tree/edge forwarding (dry-run subtree, execution subtree, leaf node) - **Robot Framework**: 3 integration smoke tests - **ASV Benchmark**: Tree building and analyze_impact overhead benchmarks ## Quality Gates - `nox -s lint` — PASSED - `nox -s typecheck` — 0 errors - `nox -s unit_tests` — 9,109 scenarios, 0 failures - `nox -s coverage_report` — 97% ISSUES CLOSED: #606
freemo added this to the v3.3.0 milestone 2026-03-08 02:13:04 +00:00
freemo scheduled this pull request to auto merge when all checks succeed 2026-03-08 23:22:47 +00:00
freemo force-pushed fix/plan-correct-tree-wiring from e8f26a8807
All checks were successful
CI / benchmark-publish (pull_request) Has been skipped
CI / lint (pull_request) Successful in 16s
CI / build (pull_request) Successful in 16s
CI / quality (pull_request) Successful in 20s
CI / typecheck (pull_request) Successful in 38s
CI / security (pull_request) Successful in 47s
CI / unit_tests (pull_request) Successful in 2m31s
CI / docker (pull_request) Successful in 43s
CI / integration_tests (pull_request) Successful in 4m8s
CI / coverage (pull_request) Successful in 4m34s
CI / benchmark-regression (pull_request) Successful in 29m45s
to 6522364503
All checks were successful
CI / benchmark-publish (pull_request) Has been skipped
CI / lint (pull_request) Successful in 16s
CI / build (pull_request) Successful in 17s
CI / quality (pull_request) Successful in 19s
CI / typecheck (pull_request) Successful in 36s
CI / security (pull_request) Successful in 36s
CI / unit_tests (pull_request) Successful in 2m16s
CI / docker (pull_request) Successful in 39s
CI / integration_tests (pull_request) Successful in 3m7s
CI / coverage (pull_request) Successful in 4m29s
CI / benchmark-regression (pull_request) Successful in 30m23s
2026-03-08 23:22:55 +00:00
Compare
freemo scheduled this pull request to auto merge when all checks succeed 2026-03-08 23:24:00 +00:00
freemo scheduled this pull request to auto merge when all checks succeed 2026-03-08 23:24:14 +00:00
freemo merged commit 61fc70d84b into master 2026-03-08 23:28:05 +00:00
freemo deleted branch fix/plan-correct-tree-wiring 2026-03-08 23:28:06 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
cleveragents/cleveragents-core!639
No description provided.