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

2 Commits

Author SHA1 Message Date
freemo 6522364503 test(robot): mock get_container in Robot helpers for plan correct tree wiring
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
The production fix in plan.py now resolves DecisionService via the DI
container to build the structural tree and influence edges.  The Behave
step definitions were updated but three Robot Framework helper scripts
were missed, causing 7 test failures (exit code 1) because get_container
was called without a mock.

- helper_m4_correction_subplan_smoke: add get_container mock to
  correction_revert, correction_append, correction_dry_run, full_flow
- helper_m3_decision_validation_smoke: add get_container mock to
  plan_correct_dry_run
- helper_m3_e2e_verification: add get_container mock and update
  analyze_impact/execute_correction assertions to include the new
  decision_tree and influence_edges keyword arguments
2026-03-08 23:22:53 +00:00
freemo e584f57f41 fix(cli): pass decision tree and influence edges to CorrectionService in plan correct handler
Resolve DecisionService via the DI container in correct_decision() to
build the structural tree (parent → children adjacency list) and fetch
influence DAG edges, then forward both to CorrectionService.analyze_impact()
and CorrectionService.execute_correction().  Previously these methods
received None for both arguments, causing _compute_affected_subtree() BFS
to return only the single target decision instead of the full affected
subtree.

Changes:
- src/cleveragents/cli/commands/plan.py: Added DI container resolution of
  DecisionService, structural tree construction from list_decisions(), and
  influence edge retrieval via get_influence_edges().  Both are passed as
  keyword arguments to analyze_impact() and execute_correction().
- features/plan_correct_tree_wiring.feature: 3 BDD scenarios verifying
  tree/edge forwarding for dry-run, execution, and leaf-node cases.
- features/steps/plan_correct_tree_wiring_steps.py: Step definitions with
  mock container and argument-capturing CorrectionService.
- robot/plan_correct_tree_wiring.robot: Integration smoke tests.
- robot/helper_plan_correct_tree_wiring.py: Robot helper exercising CLI
  via CliRunner with mock patches.
- benchmarks/plan_correct_tree_wiring_bench.py: ASV benchmarks for tree
  building and analyze_impact overhead.
- Updated existing test steps (m3, m4, pec, uncov-rgn) to mock the DI
  container so existing correction scenarios continue to pass.

ISSUES CLOSED: #606
2026-03-08 23:22:53 +00:00