Files
cleveragents-core/robot/checkpoint_real_rollback.robot
freemo ec4c39aecf
CI / benchmark-publish (pull_request) Has been skipped
CI / lint (pull_request) Successful in 17s
CI / build (pull_request) Successful in 28s
CI / quality (pull_request) Successful in 34s
CI / security (pull_request) Successful in 42s
CI / typecheck (pull_request) Successful in 45s
CI / unit_tests (pull_request) Successful in 3m11s
CI / integration_tests (pull_request) Successful in 3m37s
CI / e2e_tests (pull_request) Successful in 4m1s
CI / docker (pull_request) Successful in 56s
CI / coverage (pull_request) Successful in 6m37s
CI / lint (push) Successful in 11s
CI / build (push) Successful in 15s
CI / quality (push) Successful in 32s
CI / typecheck (push) Successful in 44s
CI / benchmark-regression (push) Has been skipped
CI / security (push) Successful in 56s
CI / unit_tests (push) Successful in 2m55s
CI / integration_tests (push) Successful in 3m34s
CI / docker (push) Successful in 59s
CI / e2e_tests (push) Successful in 3m59s
CI / coverage (push) Successful in 6m55s
CI / benchmark-publish (push) Has been cancelled
CI / benchmark-regression (pull_request) Successful in 37m40s
fix(plan): implement real checkpoint rollback via git reset
Replace the simulated rollback in CheckpointService.rollback_to_checkpoint()
with real git operations. The method now executes git reset --hard <sandbox_ref>
followed by git clean -fd inside the sandbox working directory, reverting all
tracked file changes and removing untracked files added after the checkpoint.

Key changes:
- CheckpointService.rollback_to_checkpoint() now calls _git_reset_hard() and
  _git_clean() via subprocess against the sandbox path, enforcing sandbox
  boundary by confining all git operations to cwd=sandbox_path.
- Added _resolve_sandbox_path() to extract sandbox validation into a dedicated
  method, supporting both lifecycle-service and in-memory fallback paths.
- Added _validate_sandbox() to verify the sandbox path is a directory containing
  a .git subdirectory before executing git operations.
- Added _git_changed_paths() to compute the diff between HEAD and the target ref
  before reset, providing accurate restored file counts in the result.
- Domain event emission (CHECKPOINT_RESTORED) added via the optional event_bus,
  following the same EventBus protocol pattern used by other services.
- Updated existing Robot Framework helper (helper_checkpoint_rollback.py) to use
  a real temporary git workspace instead of a fake sandbox path, since
  _validate_sandbox() now enforces that the path is a real git repository.
- Removed @tdd_expected_fail tags from TDD test files since the bug is now fixed.
- Added new Behave scenarios and Robot integration tests for real file reversion,
  file removal after rollback, domain event emission, and sandbox boundary
  enforcement.

ISSUES CLOSED: #822
2026-03-18 16:51:14 +00:00

50 lines
2.7 KiB
Plaintext

*** Settings ***
Documentation Integration tests for real checkpoint rollback via git reset --hard.
... Verifies that CheckpointService.rollback_to_checkpoint() actually
... restores file system state by executing git reset --hard in the
... sandbox working directory. Covers file reversion, file removal,
... domain event emission, and sandbox boundary enforcement.
Resource ${CURDIR}/common.resource
Suite Setup Setup Test Environment
Suite Teardown Cleanup Test Environment
*** Variables ***
${HELPER} ${CURDIR}/helper_checkpoint_real_rollback.py
*** Test Cases ***
Checkpoint Rollback Restores Modified File Content
[Documentation] Create files, checkpoint, modify, rollback, verify original content restored.
[Tags] checkpoint rollback git
${result}= Run Process ${PYTHON} ${HELPER} rollback-restores-content cwd=${WORKSPACE} timeout=30s on_timeout=kill
Log ${result.stdout}
Log ${result.stderr}
Should Be Equal As Integers ${result.rc} 0
Should Contain ${result.stdout} checkpoint-rollback-restores-content-ok
Checkpoint Rollback Removes Files Added After Checkpoint
[Documentation] Create files, checkpoint, add new file, rollback, verify new file removed.
[Tags] checkpoint rollback git
${result}= Run Process ${PYTHON} ${HELPER} rollback-removes-added-files cwd=${WORKSPACE} timeout=30s on_timeout=kill
Log ${result.stdout}
Log ${result.stderr}
Should Be Equal As Integers ${result.rc} 0
Should Contain ${result.stdout} checkpoint-rollback-removes-added-files-ok
Checkpoint Rollback Emits Domain Event
[Documentation] Verify that rollback emits a CHECKPOINT_RESTORED domain event.
[Tags] checkpoint rollback event
${result}= Run Process ${PYTHON} ${HELPER} rollback-emits-event cwd=${WORKSPACE} timeout=30s on_timeout=kill
Log ${result.stdout}
Log ${result.stderr}
Should Be Equal As Integers ${result.rc} 0
Should Contain ${result.stdout} checkpoint-rollback-emits-event-ok
Checkpoint Rollback Rejects Nonexistent Sandbox
[Documentation] Verify that rollback rejects a sandbox path that does not exist.
[Tags] checkpoint rollback boundary
${result}= Run Process ${PYTHON} ${HELPER} rollback-rejects-nonexistent-sandbox cwd=${WORKSPACE} timeout=30s on_timeout=kill
Log ${result.stdout}
Log ${result.stderr}
Should Be Equal As Integers ${result.rc} 0
Should Contain ${result.stdout} checkpoint-rollback-rejects-nonexistent-sandbox-ok