feat(correction): wire checkpoint rollback into correction service revert flow #1199

Merged
freemo merged 1 commit from feature/correction-checkpoint-rollback into master 2026-03-30 21:29:28 +00:00
Owner

Summary

Wires checkpoint rollback into the correction service revert flow, enabling automatic workspace snapshots, physical artifact archival, and selective rollback to any checkpoint.

Changes

  • src/cleveragents/application/services/checkpoint_service.py: Added create_workspace_snapshot(), selective_rollback(), archive_artifacts(), _compute_diff_snapshot() for diff-based storage
  • src/cleveragents/application/services/correction_service.py: Added revert_decisions() with checkpoint rollback invocation, _archive_decision_artifacts() for physical archival, atomic semantics in execute_revert()
  • src/cleveragents/application/container.py: Wired checkpoint_service into CorrectionService (also fixes #986)
  • src/cleveragents/cli/commands/plan.py: Added --to-checkpoint option to rollback; correct uses container-provided service
  • src/cleveragents/domain/models/core/checkpoint.py: Added pre_decision to checkpoint_type
  • features/correction_checkpoint_rollback.feature: 12 BDD scenarios
  • features/tdd_correction_checkpoint_wiring.feature: Removed @tdd_expected_fail (bug #986 fixed)

Bonus Fix

This PR also fixes bug #986 (CorrectionService missing checkpoint_service wiring) by properly wiring checkpoint_service in the DI container and removing the @tdd_expected_fail tag from its TDD test.

Closes #943

## Summary Wires checkpoint rollback into the correction service revert flow, enabling automatic workspace snapshots, physical artifact archival, and selective rollback to any checkpoint. ## Changes - `src/cleveragents/application/services/checkpoint_service.py`: Added `create_workspace_snapshot()`, `selective_rollback()`, `archive_artifacts()`, `_compute_diff_snapshot()` for diff-based storage - `src/cleveragents/application/services/correction_service.py`: Added `revert_decisions()` with checkpoint rollback invocation, `_archive_decision_artifacts()` for physical archival, atomic semantics in `execute_revert()` - `src/cleveragents/application/container.py`: Wired `checkpoint_service` into `CorrectionService` (also fixes #986) - `src/cleveragents/cli/commands/plan.py`: Added `--to-checkpoint` option to `rollback`; `correct` uses container-provided service - `src/cleveragents/domain/models/core/checkpoint.py`: Added `pre_decision` to checkpoint_type - `features/correction_checkpoint_rollback.feature`: 12 BDD scenarios - `features/tdd_correction_checkpoint_wiring.feature`: Removed `@tdd_expected_fail` (bug #986 fixed) ## Bonus Fix This PR also fixes bug #986 (CorrectionService missing checkpoint_service wiring) by properly wiring `checkpoint_service` in the DI container and removing the `@tdd_expected_fail` tag from its TDD test. Closes #943
freemo added this to the v3.5.0 milestone 2026-03-29 08:38:55 +00:00
freemo force-pushed feature/correction-checkpoint-rollback from 7467fa304c
Some checks failed
CI / benchmark-publish (pull_request) Has been skipped
CI / lint (pull_request) Successful in 3m28s
CI / typecheck (pull_request) Successful in 3m54s
CI / security (pull_request) Successful in 4m23s
CI / quality (pull_request) Successful in 3m42s
CI / build (pull_request) Successful in 17s
CI / helm (pull_request) Successful in 34s
CI / unit_tests (pull_request) Failing after 4m4s
CI / docker (pull_request) Has been skipped
CI / integration_tests (pull_request) Failing after 3m58s
CI / coverage (pull_request) Successful in 8m37s
CI / e2e_tests (pull_request) Successful in 12m19s
CI / status-check (pull_request) Failing after 2s
CI / benchmark-regression (pull_request) Successful in 57m29s
to 643760004c
Some checks failed
CI / benchmark-publish (pull_request) Has been skipped
CI / lint (pull_request) Failing after 34s
CI / security (pull_request) Successful in 58s
CI / build (pull_request) Successful in 22s
CI / helm (pull_request) Successful in 22s
CI / quality (pull_request) Successful in 3m53s
CI / typecheck (pull_request) Successful in 4m1s
CI / coverage (pull_request) Has been skipped
CI / benchmark-regression (pull_request) Has been skipped
CI / integration_tests (pull_request) Successful in 5m56s
CI / unit_tests (pull_request) Failing after 6m13s
CI / docker (pull_request) Has been skipped
CI / e2e_tests (pull_request) Successful in 8m46s
CI / status-check (pull_request) Failing after 2s
2026-03-30 00:10:39 +00:00
Compare
freemo left a comment

Review: Looks Good (self-authored — posted as comment)

Clean DI fix wiring checkpoint rollback into the correction service.

Notes

  1. Private method access: self._checkpoint_service._resolve_sandbox_path(plan_id) accesses a private method across service boundaries. Consider making _resolve_sandbox_path() public on CheckpointService.
  2. Good: CLI plan correct now properly resolves CorrectionService from the container — significant DI hygiene improvement.
  3. Good: Proper migration of test assertions from rollback_to_checkpoint to selective_rollback.
  4. Good: Vulture whitelist updated.
## Review: Looks Good (self-authored — posted as comment) Clean DI fix wiring checkpoint rollback into the correction service. ### Notes 1. **Private method access**: `self._checkpoint_service._resolve_sandbox_path(plan_id)` accesses a private method across service boundaries. Consider making `_resolve_sandbox_path()` public on `CheckpointService`. 2. **Good**: CLI `plan correct` now properly resolves `CorrectionService` from the container — significant DI hygiene improvement. 3. **Good**: Proper migration of test assertions from `rollback_to_checkpoint` to `selective_rollback`. 4. **Good**: Vulture whitelist updated.
freemo left a comment

Updated Review (Deep Pass): Changes Required

My initial review flagged only the private method access. The deep review reveals more issues.

New Finding: Missing Robot Framework Integration Test

No robot/correction_checkpoint_rollback.robot exists. The PR has BDD tests but no Robot integration test. Per CONTRIBUTING.md §Multi-Level Testing Mandate, integration tests are required.

New Finding: Missing argument validation on new public methods

  • create_workspace_snapshot(): plan_id, sandbox_ref, decision_id not validated for empty/null
  • selective_rollback(): plan_id, checkpoint_id not validated
  • revert_decisions(): plan_id, target_decision_id not validated
    Per CONTRIBUTING.md §Argument Validation: "All public methods must validate arguments."

New Finding: Multiple silent exception catches

  • selective_rollback() line ~407: HEAD capture catches Exception with no logging — sets current_head = None
  • _compute_diff_snapshot() line ~518: catches Exception, returns empty list silently
  • _archive_decision_artifacts() line ~804: catches Exception, logs at debug level, returns empty list

Previous finding confirmed: _checkpoint_service._resolve_sandbox_path() accesses private method across class boundary.

## Updated Review (Deep Pass): Changes Required My initial review flagged only the private method access. The deep review reveals more issues. ### New Finding: Missing Robot Framework Integration Test No `robot/correction_checkpoint_rollback.robot` exists. The PR has BDD tests but no Robot integration test. Per CONTRIBUTING.md §Multi-Level Testing Mandate, integration tests are required. ### New Finding: Missing argument validation on new public methods - `create_workspace_snapshot()`: `plan_id`, `sandbox_ref`, `decision_id` not validated for empty/null - `selective_rollback()`: `plan_id`, `checkpoint_id` not validated - `revert_decisions()`: `plan_id`, `target_decision_id` not validated Per CONTRIBUTING.md §Argument Validation: "All public methods must validate arguments." ### New Finding: Multiple silent exception catches - `selective_rollback()` line ~407: HEAD capture catches `Exception` with no logging — sets `current_head = None` - `_compute_diff_snapshot()` line ~518: catches `Exception`, returns empty list silently - `_archive_decision_artifacts()` line ~804: catches `Exception`, logs at debug level, returns empty list ### Previous finding confirmed: `_checkpoint_service._resolve_sandbox_path()` accesses private method across class boundary.
freemo force-pushed feature/correction-checkpoint-rollback from b0a62ed37c
Some checks failed
CI / benchmark-publish (pull_request) Has been skipped
CI / build (pull_request) Successful in 17s
CI / helm (pull_request) Successful in 23s
CI / quality (pull_request) Successful in 43s
CI / typecheck (pull_request) Successful in 1m2s
CI / lint (pull_request) Successful in 3m18s
CI / integration_tests (pull_request) Successful in 3m57s
CI / unit_tests (pull_request) Successful in 4m2s
CI / security (pull_request) Successful in 4m3s
CI / docker (pull_request) Successful in 1m18s
CI / e2e_tests (pull_request) Successful in 9m32s
CI / coverage (pull_request) Successful in 8m12s
CI / status-check (pull_request) Successful in 1s
CI / benchmark-regression (pull_request) Has been cancelled
to 38e05ac45a
All checks were successful
CI / benchmark-publish (pull_request) Has been skipped
CI / lint (pull_request) Successful in 18s
CI / build (pull_request) Successful in 20s
CI / helm (pull_request) Successful in 22s
CI / typecheck (pull_request) Successful in 1m0s
CI / quality (pull_request) Successful in 3m41s
CI / integration_tests (pull_request) Successful in 3m51s
CI / security (pull_request) Successful in 4m3s
CI / unit_tests (pull_request) Successful in 4m11s
CI / docker (pull_request) Successful in 1m31s
CI / coverage (pull_request) Successful in 11m48s
CI / e2e_tests (pull_request) Successful in 21m45s
CI / status-check (pull_request) Successful in 1s
CI / build (push) Successful in 17s
CI / helm (push) Successful in 21s
CI / quality (push) Successful in 3m48s
CI / integration_tests (push) Successful in 3m58s
CI / typecheck (push) Successful in 3m58s
CI / security (push) Successful in 4m6s
CI / unit_tests (push) Successful in 7m16s
CI / lint (push) Successful in 8m14s
CI / benchmark-regression (push) Has been skipped
CI / docker (push) Successful in 1m36s
CI / e2e_tests (push) Successful in 18m9s
CI / coverage (push) Successful in 12m13s
CI / status-check (push) Successful in 1s
CI / benchmark-publish (push) Successful in 28m11s
CI / benchmark-regression (pull_request) Successful in 54m54s
2026-03-30 21:07:40 +00:00
Compare
freemo scheduled this pull request to auto merge when all checks succeed 2026-03-30 21:08:09 +00:00
freemo merged commit 38e05ac45a into master 2026-03-30 21:29:28 +00:00
freemo deleted branch feature/correction-checkpoint-rollback 2026-03-30 21:29:28 +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!1199
No description provided.