Files
cleveragents-core/features
HAL9000 cbc26c8e50 feat(plans): implement ThreeWayMergeEngine for subplan result integration (#9608)
Implement a three-way merge engine that safely integrates subplan execution
results back into parent plan state. The engine handles merging of ancestor
(base), parent (current), and subplan (incoming) states with automatic
application of non-conflicting changes and validation before committing.

Merge logic for plan-specific fields:
- Subplan statuses merged by ID without losing intermediate states
- Cost metadata accumulated across all participating subplans
- Skeleton metadata preserved from parent plan unchanged
- Error state propagated upward when any subplan fails with ERRORED
- Timestamps advanced to most-recent events across merged output

Includes comprehensive BDD tests covering:
- Basic merge scenarios (identical, single update, new IDs)
- Conflict detection and resolution
- Error propagation with configurable priority
- Cost accumulation including budget tracking
- Skeleton metadata preservation
- Timestamp advancement
- Sequential merging
- Edge cases (empty lists, None values, priority resolution)

Closes #9557

ISSUES CLOSED: #9557
2026-06-03 14:15:14 -04:00
..