Files
cleveragents-core/robot/revert_re_execution.robot
brent.edwards b46a0e6102
CI / status-check (push) Blocked by required conditions
CI / build (push) Successful in 18s
CI / helm (push) Successful in 31s
CI / lint (push) Successful in 3m29s
CI / typecheck (push) Successful in 3m56s
CI / benchmark-regression (push) Has been skipped
CI / quality (push) Successful in 3m41s
CI / unit_tests (push) Successful in 4m11s
CI / integration_tests (push) Failing after 4m12s
CI / security (push) Successful in 4m38s
CI / docker (push) Successful in 1m32s
CI / coverage (push) Successful in 11m33s
CI / e2e_tests (push) Failing after 23m17s
CI / benchmark-publish (push) Failing after 38m50s
feat(plan): implement real revert-mode re-execution from decision point (#1153)
## Summary

Implements the full revert-mode re-execution pipeline from the specification (§ Correction Flow, Revert Mode), enabling `agents plan correct --mode=revert` to truly re-execute from the targeted decision point rather than only logically marking decisions as superseded.

### Changes

- **Resource rollback**: `CorrectionService.execute_revert` now delegates to `CheckpointService.rollback_to_checkpoint` when a decision-aligned checkpoint exists, performing real `git reset --hard` in the sandbox. Gracefully degrades when checkpointing is unavailable.
- **Reasoning rollback**: Extracts `actor_state_ref` from the target decision's `ContextSnapshot` for downstream LangGraph actor restoration.
- **Guidance injection**: Generates a `user_intervention` decision ID for callers to record correction guidance in the decision tree.
- **Phase transition**: Signals that the plan should re-enter Strategize via `phase_transition_target="strategize"` on the result.
- **Model extension**: Added `checkpoint_restored`, `actor_state_ref`, `user_intervention_decision_id`, and `phase_transition_target` fields to `CorrectionResult` with backward-compatible defaults.
- **Dispatch update**: `execute_correction` now accepts and forwards a `decisions` parameter.

### Design Approach

Uses a signal-based architecture: rather than having `CorrectionService` directly manipulate plan state or LangGraph actors, the enhanced `execute_revert` returns signal fields on `CorrectionResult` that downstream consumers use for the full pipeline. This preserves separation of concerns.

### Tests

- **Behave**: 16 new BDD scenarios in `features/revert_re_execution.feature`
- **Robot**: 7 integration tests in `robot/revert_re_execution.robot`
- **Coverage**: 98% (above 97% threshold)

### Quality Gates

| Gate | Status |
|------|--------|
| `nox -s lint` | Pass |
| `nox -s typecheck` | Pass (0 errors) |
| `nox -s unit_tests` | Pass (12376 scenarios, 0 failed) |
| `nox -s integration_tests` | Pass (1631 passed, 3 pre-existing failures #647) |
| `nox -s e2e_tests` | Pass (37 passed) |
| `nox -s coverage_report` | Pass (98%) |

Closes #844

Reviewed-on: #1153
Co-authored-by: Brent E. Edwards <brent.edwards@cleverthis.com>
Co-committed-by: Brent E. Edwards <brent.edwards@cleverthis.com>
2026-03-28 00:57:51 +00:00

61 lines
3.2 KiB
Plaintext

*** Settings ***
Documentation Integration tests for revert-mode re-execution from decision point.
... Validates checkpoint restoration, actor state recovery, phase
... transition signalling, and selective subtree recomputation.
Resource ${CURDIR}/common.resource
Suite Setup Setup Test Environment
Suite Teardown Cleanup Test Environment
*** Variables ***
${HELPER} robot/helper_revert_re_execution.py
*** Test Cases ***
Revert With Checkpoint Restores Sandbox
[Documentation] Verify revert delegates to CheckpointService when available
[Tags] phase2 correction revert re-execution
${result}= Run Process ${PYTHON} ${HELPER} revert-with-checkpoint cwd=${WORKSPACE}
Should Be Equal As Integers ${result.rc} 0
Should Contain ${result.stdout} revert-with-checkpoint-ok
Revert Without Checkpoint Skips Restoration
[Documentation] Verify revert works without checkpoint service
[Tags] phase2 correction revert re-execution
${result}= Run Process ${PYTHON} ${HELPER} revert-no-checkpoint cwd=${WORKSPACE}
Should Be Equal As Integers ${result.rc} 0
Should Contain ${result.stdout} revert-no-checkpoint-ok
Revert Extracts Actor State Ref
[Documentation] Verify actor state reference is extracted from decision
[Tags] phase2 correction revert re-execution
${result}= Run Process ${PYTHON} ${HELPER} revert-actor-state cwd=${WORKSPACE}
Should Be Equal As Integers ${result.rc} 0
Should Contain ${result.stdout} revert-actor-state-ok
Revert Signals Phase Transition
[Documentation] Verify revert signals Strategize re-entry
[Tags] phase2 correction revert re-execution
${result}= Run Process ${PYTHON} ${HELPER} revert-phase-transition cwd=${WORKSPACE}
Should Be Equal As Integers ${result.rc} 0
Should Contain ${result.stdout} revert-phase-transition-ok
Revert Creates User Intervention Decision
[Documentation] Verify user_intervention decision ID is generated
[Tags] phase2 correction revert re-execution
${result}= Run Process ${PYTHON} ${HELPER} revert-intervention-id cwd=${WORKSPACE}
Should Be Equal As Integers ${result.rc} 0
Should Contain ${result.stdout} revert-intervention-id-ok
Full Revert Re Execution Flow
[Documentation] End-to-end revert with checkpoint + actor state + phase transition
[Tags] phase2 correction revert re-execution e2e
${result}= Run Process ${PYTHON} ${HELPER} full-revert-flow cwd=${WORKSPACE}
Should Be Equal As Integers ${result.rc} 0
Should Contain ${result.stdout} full-revert-flow-ok
Revert Selective Subtree Only
[Documentation] Verify only downstream decisions are affected
[Tags] phase2 correction revert re-execution subtree
${result}= Run Process ${PYTHON} ${HELPER} revert-selective-subtree cwd=${WORKSPACE}
Should Be Equal As Integers ${result.rc} 0
Should Contain ${result.stdout} revert-selective-subtree-ok