feat(plan-correction): implement correction data model and persistence #10981

Closed
HAL9000 wants to merge 1 commits from pr/8685-correction-data-model-persistence into master

1 Commits

Author SHA1 Message Date
HAL9000 7fba2eaa19 feat(plan-correction): implement correction data model and persistence
CI / benchmark-publish (pull_request) Has been skipped
CI / helm (pull_request) Successful in 40s
CI / push-validation (pull_request) Successful in 35s
CI / lint (pull_request) Successful in 1m3s
CI / build (pull_request) Successful in 1m15s
CI / quality (pull_request) Successful in 1m42s
CI / typecheck (pull_request) Successful in 1m52s
CI / security (pull_request) Successful in 2m6s
CI / benchmark-regression (pull_request) Failing after 1m39s
CI / e2e_tests (pull_request) Successful in 4m34s
CI / integration_tests (pull_request) Successful in 4m55s
CI / unit_tests (pull_request) Successful in 11m2s
CI / docker (pull_request) Successful in 1m36s
CI / coverage (pull_request) Successful in 14m39s
CI / status-check (pull_request) Successful in 3s
The correction data model and persistence feature provides a complete pipeline for
decision tree editing with revert and append correction modes. Implemented components:

- Domain models: CorrectionRequest, CorrectionImpact, CorrectionResult, CorrectionAttempt,
  CorrectionAttemptRecord, CascadeAction, CascadeResult with full Pydantic validation.
- Persistence layer: SQLAlchemy repository with CRUD operations (create, get, list_by_plan,
  update_state, delete), domain model conversion helpers (to_domain/from_domain), and session
  factory pattern consistent with other repositories in the codebase.
- State machine: CorrectionAttemptState enum (pending → executing → complete|failed) with
  validated transitions via validate_correction_state_transition().
- Migration: Alembic migration m8_001_correction_attempts creating correction_attempts table
  with check constraints on mode and state enums, indexed on plan_id.
- Event emission: CORRECTION_APPLIED domain event type added to EventType enum and emitted
  through the EventBus when corrections are successfully applied.
- BDD tests: Comprehensive Behave scenario coverage across correction flows, service coverage,
  subtree isolation, cross-plan cascading, checkpoint rollback wiring, attempt persistence, and
  model validation scenarios.

This feature enables full decision correction workflows including subgraph impact analysis via
BFS traversal, rollback tier depth computation, artifact archival, checkpoint restoration for
revert corrections, and child plan spawning for append corrections.
ISSUES CLOSED: #8685
2026-05-08 21:33:42 +00:00