feat(correction): implement cross-plan correction cascading with child plan state handling #562

Merged
freemo merged 1 commits from feature/m6-cross-plan-correction into master 2026-03-04 22:10:15 +00:00
Owner

Summary

Implements the four child-plan-state-dependent behaviours defined in the specification (§ Cross-Plan Correction Cascading) when a correction's affected subtree includes child plans.

Closes #547

Changes

Domain Models (correction.py)

  • ChildPlanState enum: NOT_STARTED, IN_PROGRESS, COMPLETED_UNAPPLIED, APPLIED
  • CorrectionRejection: Result type with reason and affected_applied_child_plan_ids
  • CascadeAction: Per-child-plan action record (cancel, cancel_and_rollback, reject)
  • CascadeResult: Full cascade outcome with all actions, cancelled/rolled-back plan lists
  • CorrectionStatus.REJECTED: New terminal status for rejected corrections

Service (cross_plan_correction_service.py)

  • CrossPlanCorrectionService: Orchestrates cross-plan cascading with:
    • evaluate_cascade() — dry-run evaluation of cascade actions
    • execute_cascade() — atomic cascade execution with rollback on failure
    • execute_correction_with_cascade() — integration point for CorrectionService
  • Protocol-based DI: ChildPlanLookup, ChildPlanCanceller, SandboxRollbacker
  • classify_cascade_action() helper function

Cascade Behaviour Table

Child Plan State Action
Not yet started Cancel the child plan
In progress Cancel + rollback sandbox
Completed but not applied Cancel + rollback sandbox
Already applied Reject — return CorrectionRejection

Mixed states: reject if any child plan is already applied (even if others are cancellable).

Testing

  • 24 Behave BDD scenarios (features/cross_plan_correction.feature)
  • 8 Robot Framework e2e tests (robot/cross_plan_correction.robot)
  • ASV benchmarks (benchmarks/cross_plan_correction_bench.py)

Quality Gates

  • nox -s lint
  • nox -s typecheck (0 errors, no # type: ignore)
  • nox -s unit_tests (8158 scenarios passed)
  • nox -s integration_tests (1145 tests passed)
  • nox -s coverage_report (97% ≥ threshold)
## Summary Implements the four child-plan-state-dependent behaviours defined in the specification (§ Cross-Plan Correction Cascading) when a correction's affected subtree includes child plans. Closes #547 ## Changes ### Domain Models (`correction.py`) - **`ChildPlanState`** enum: `NOT_STARTED`, `IN_PROGRESS`, `COMPLETED_UNAPPLIED`, `APPLIED` - **`CorrectionRejection`**: Result type with `reason` and `affected_applied_child_plan_ids` - **`CascadeAction`**: Per-child-plan action record (`cancel`, `cancel_and_rollback`, `reject`) - **`CascadeResult`**: Full cascade outcome with all actions, cancelled/rolled-back plan lists - **`CorrectionStatus.REJECTED`**: New terminal status for rejected corrections ### Service (`cross_plan_correction_service.py`) - **`CrossPlanCorrectionService`**: Orchestrates cross-plan cascading with: - `evaluate_cascade()` — dry-run evaluation of cascade actions - `execute_cascade()` — atomic cascade execution with rollback on failure - `execute_correction_with_cascade()` — integration point for CorrectionService - Protocol-based DI: `ChildPlanLookup`, `ChildPlanCanceller`, `SandboxRollbacker` - `classify_cascade_action()` helper function ### Cascade Behaviour Table | Child Plan State | Action | |---|---| | Not yet started | Cancel the child plan | | In progress | Cancel + rollback sandbox | | Completed but not applied | Cancel + rollback sandbox | | Already applied | **Reject** — return `CorrectionRejection` | Mixed states: reject if **any** child plan is already applied (even if others are cancellable). ### Testing - **24 Behave BDD scenarios** (`features/cross_plan_correction.feature`) - **8 Robot Framework e2e tests** (`robot/cross_plan_correction.robot`) - **ASV benchmarks** (`benchmarks/cross_plan_correction_bench.py`) ### Quality Gates - `nox -s lint` ✅ - `nox -s typecheck` ✅ (0 errors, no `# type: ignore`) - `nox -s unit_tests` ✅ (8158 scenarios passed) - `nox -s integration_tests` ✅ (1145 tests passed) - `nox -s coverage_report` ✅ (97% ≥ threshold)
freemo added this to the v3.5.0 milestone 2026-03-04 10:50:16 +00:00
freemo added the
Type
Feature
label 2026-03-04 10:50:21 +00:00
freemo force-pushed feature/m6-cross-plan-correction from 3c69798443 to a85b7c5812 2026-03-04 17:01:06 +00:00 Compare
freemo force-pushed feature/m6-cross-plan-correction from a85b7c5812 to 012ed7408e 2026-03-04 19:56:29 +00:00 Compare
freemo force-pushed feature/m6-cross-plan-correction from 012ed7408e to 4ca4874c4d 2026-03-04 21:20:49 +00:00 Compare
freemo scheduled this pull request to auto merge when all checks succeed 2026-03-04 21:21:00 +00:00
freemo merged commit 4ca4874c4d into master 2026-03-04 22:10:15 +00:00
freemo deleted branch feature/m6-cross-plan-correction 2026-03-04 22:10:16 +00:00
Sign in to join this conversation.
No Reviewers
No Label
Type
Feature
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: cleveragents/cleveragents-core#562