e1f3b00322
- Added DecisionCorrectionResult model to decomposition_models.py to track which nodes were recomputed vs preserved during selective subtree recomputation. - Implemented recompute_subtree(node_id, existing_result, config) in DecompositionService, which identifies the subtree rooted at the given node using DecompositionNode.children_ids, recomputes only that subtree while preserving sibling branches and ancestor nodes, and returns a DecisionCorrectionResult with recomputed_nodes, preserved_nodes, and metrics. - Added BDD feature file features/decomposition_decision_correction.feature containing 9 scenarios covering: selective subtree recomputation for leaf, middle, and root nodes; sibling branch preservation; ancestor node preservation; DecisionCorrectionResult model validation; custom config support; error handling for unknown nodes; metrics tracking. - Added step definitions in features/steps/decomposition_decision_correction_steps.py ISSUES CLOSED: #10012
58 lines
2.7 KiB
Gherkin
58 lines
2.7 KiB
Gherkin
Feature: Decision correction with selective subtree recomputation
|
|
As a plan orchestrator
|
|
I want to recompute only the affected subtree when a decision is incorrect
|
|
So that sibling branches and ancestors are preserved unchanged
|
|
|
|
Background:
|
|
Given a decomposition service for correction
|
|
And a decomposition result with a multi-level hierarchy
|
|
|
|
Scenario: Recompute subtree for a leaf node - only leaf is recomputed
|
|
When I recompute the subtree for a leaf node
|
|
Then the correction result should have recomputed nodes
|
|
And the correction result should have preserved nodes
|
|
And the target node should be in the recomputed set
|
|
And sibling nodes should be in the preserved set
|
|
|
|
Scenario: Recompute subtree for a middle node - subtree is recomputed
|
|
When I recompute the subtree for a middle node
|
|
Then the correction result should have recomputed nodes
|
|
And the correction result should have preserved nodes
|
|
And the target node should be in the recomputed set
|
|
And ancestor nodes should be in the preserved set
|
|
|
|
Scenario: Recompute subtree for root - all nodes are recomputed
|
|
When I recompute the subtree for the root node
|
|
Then the correction result should have recomputed nodes
|
|
And the correction result should have no preserved nodes
|
|
|
|
Scenario: DecisionCorrectionResult tracks recomputed vs preserved nodes
|
|
When I recompute the subtree for a middle node
|
|
Then the DecisionCorrectionResult should have a target_node_id
|
|
And the DecisionCorrectionResult should have recomputed_node_ids
|
|
And the DecisionCorrectionResult should have preserved_node_ids
|
|
And the DecisionCorrectionResult should have metrics
|
|
|
|
Scenario: Sibling branches are unaffected during selective recomputation
|
|
When I recompute the subtree for a middle node
|
|
Then sibling branches should not be in the recomputed set
|
|
And sibling branches should be in the preserved set
|
|
|
|
Scenario: Recompute subtree with custom config
|
|
When I recompute the subtree for a leaf node with custom config
|
|
Then the correction result config should match the custom config
|
|
|
|
Scenario: Recompute subtree raises ValueError for unknown node
|
|
When I recompute the subtree for an unknown node
|
|
Then a decomp correction ValueError should be raised
|
|
|
|
Scenario: Recompute subtree preserves ancestor nodes
|
|
When I recompute the subtree for a leaf node
|
|
Then ancestor nodes should be in the preserved set
|
|
|
|
Scenario: Correction result metrics track recomputed and preserved counts
|
|
When I recompute the subtree for a middle node
|
|
Then the metrics should contain recomputed_count
|
|
And the metrics should contain preserved_count
|
|
And the metrics should contain subtree_size
|