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

Merged
freemo merged 1 commit 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 force-pushed feature/m6-cross-plan-correction from 3c69798443
Some checks failed
CI / benchmark-publish (pull_request) Has been skipped
CI / lint (pull_request) Successful in 13s
CI / build (pull_request) Successful in 17s
CI / quality (pull_request) Successful in 17s
CI / security (pull_request) Successful in 31s
CI / typecheck (pull_request) Successful in 35s
CI / unit_tests (pull_request) Successful in 3m18s
CI / docker (pull_request) Successful in 41s
CI / integration_tests (pull_request) Successful in 4m7s
CI / coverage (pull_request) Failing after 4m9s
CI / benchmark-regression (pull_request) Successful in 25m39s
to a85b7c5812
All checks were successful
CI / lint (pull_request) Successful in 14s
CI / typecheck (pull_request) Successful in 32s
CI / security (pull_request) Successful in 29s
CI / quality (pull_request) Successful in 22s
CI / benchmark-publish (pull_request) Has been skipped
CI / build (pull_request) Successful in 24s
CI / unit_tests (pull_request) Successful in 3m14s
CI / integration_tests (pull_request) Successful in 4m11s
CI / coverage (pull_request) Successful in 4m38s
CI / docker (pull_request) Successful in 1m29s
CI / benchmark-regression (pull_request) Successful in 26m44s
2026-03-04 17:01:06 +00:00
Compare
freemo force-pushed feature/m6-cross-plan-correction from a85b7c5812
All checks were successful
CI / lint (pull_request) Successful in 14s
CI / typecheck (pull_request) Successful in 32s
CI / security (pull_request) Successful in 29s
CI / quality (pull_request) Successful in 22s
CI / benchmark-publish (pull_request) Has been skipped
CI / build (pull_request) Successful in 24s
CI / unit_tests (pull_request) Successful in 3m14s
CI / integration_tests (pull_request) Successful in 4m11s
CI / coverage (pull_request) Successful in 4m38s
CI / docker (pull_request) Successful in 1m29s
CI / benchmark-regression (pull_request) Successful in 26m44s
to 012ed7408e
All checks were successful
CI / lint (pull_request) Successful in 15s
CI / typecheck (pull_request) Successful in 35s
CI / security (pull_request) Successful in 39s
CI / quality (pull_request) Successful in 25s
CI / benchmark-publish (pull_request) Has been skipped
CI / build (pull_request) Successful in 14s
CI / unit_tests (pull_request) Successful in 3m27s
CI / integration_tests (pull_request) Successful in 5m9s
CI / docker (pull_request) Successful in 39s
CI / coverage (pull_request) Successful in 4m30s
CI / benchmark-regression (pull_request) Successful in 28m40s
2026-03-04 19:56:29 +00:00
Compare
freemo force-pushed feature/m6-cross-plan-correction from 012ed7408e
All checks were successful
CI / lint (pull_request) Successful in 15s
CI / typecheck (pull_request) Successful in 35s
CI / security (pull_request) Successful in 39s
CI / quality (pull_request) Successful in 25s
CI / benchmark-publish (pull_request) Has been skipped
CI / build (pull_request) Successful in 14s
CI / unit_tests (pull_request) Successful in 3m27s
CI / integration_tests (pull_request) Successful in 5m9s
CI / docker (pull_request) Successful in 39s
CI / coverage (pull_request) Successful in 4m30s
CI / benchmark-regression (pull_request) Successful in 28m40s
to 4ca4874c4d
All checks were successful
CI / lint (pull_request) Successful in 14s
CI / typecheck (pull_request) Successful in 34s
CI / quality (pull_request) Successful in 15s
CI / security (pull_request) Successful in 35s
CI / benchmark-publish (pull_request) Has been skipped
CI / build (pull_request) Successful in 16s
CI / integration_tests (pull_request) Successful in 2m54s
CI / unit_tests (pull_request) Successful in 4m9s
CI / coverage (pull_request) Successful in 4m48s
CI / docker (pull_request) Successful in 1m46s
CI / lint (push) Successful in 13s
CI / typecheck (push) Successful in 35s
CI / quality (push) Successful in 16s
CI / security (push) Successful in 31s
CI / build (push) Successful in 14s
CI / unit_tests (push) Successful in 2m11s
CI / integration_tests (push) Successful in 3m9s
CI / benchmark-regression (pull_request) Successful in 30m12s
CI / benchmark-regression (push) Has been skipped
CI / docker (push) Successful in 40s
CI / coverage (push) Successful in 4m25s
CI / benchmark-publish (push) Successful in 17m34s
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 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!562
No description provided.