test: add checkpoint save/restore round-trip tests - #112
Conversation
12 tests covering the CheckpointManager save/restore cycle: - Basic round-trip (create + restore reproduces all files) - Metadata preservation (config, metrics, result survive) - Integrity hash verification (passes after creation) - Tamper detection (hash fails when file modified) - Nonexistent restore raises CheckpointError - Multi-checkpoint isolation (each restores its own data) - List/delete operations - Target directory clearing (protected dirs like .git preserved) - Size reporting - System state capture and restoration - Mid-evolution interruption recovery Addresses TODO.md item: 'Add test for checkpoint save/restore'
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughExpands checkpoint save/restore coverage to 13 tests, including tamper detection during restore, filesystem deletion checks, size bounds, protected-directory restoration, system-state assertions, and interruption recovery. Updates TODO tracking counts for the completed test. ChangesCheckpoint coverage
Estimated code review effort: 2 (Simple) | ~10 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@tests/unit/core/test_checkpoint_save_restore.py`:
- Around line 146-150: Update test_delete_checkpoint to capture the path
returned by create_checkpoint, then assert that path no longer exists after
delete_checkpoint("del") succeeds, while retaining the existing registry
assertion.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: cefa8155-72b9-4468-b7b9-1285146049a9
📒 Files selected for processing (2)
TODO.mdtests/unit/core/test_checkpoint_save_restore.py
- Use get_checkpoint_path() instead of hardcoded internal layout in test_integrity_hash_fails_when_file_tampered - Drop brittle error-message substring match in test_restore_nonexistent_raises; just assert CheckpointError is raised - Assert on restore_checkpoint return value in test_restore_clears_target_except_protected - Capture create_checkpoint path in test_delete_checkpoint and assert it no longer exists after deletion (CodeRabbit suggestion)
|
Addressed review feedback — here's what changed and what I verified against the implementation: 1. Hardcoded checkpoint layout in
2. Brittle
3. Missing return-value check in
4. CodeRabbit inline comment: assert disk deletion in
5. Caveat about CheckpointManager implementation — Not actionable
|
- Add test_restore_rejects_tampered_checkpoint: exercises the restore_checkpoint(verify_integrity=True) path against a tampered checkpoint, closing the integration gap flagged in review. - Tighten test_checkpoint_size_reported: assert size covers known content bytes and stays within a sane upper bound, instead of only checking size > 0. - Add docstring caveat to test_integrity_hash_fails_when_file_tampered noting the coupling to plain-file storage layout. - Update TODO.md test count from 12 to 13.
Replace the hardcoded 10_000 byte upper bound with a content-relative multiplier (expected_content_bytes * 100) so the test adapts if metadata format grows rather than flaking on an arbitrary constant. Addresses review feedback on PR #112.
|
Addressed review feedback: Point 1 — "Tests assume behaviors not visible in the diff": Verified against the actual
No change needed — the reviewer couldn't confirm from the diff alone, but the implementation matches. Point 2 — hardcoded |
- Reduce size multiplier from 100x to 30x (actual overhead is ~24x); 100x was too loose to catch metadata bloat regressions. - Shorten tamper-check match from 'Integrity verification failed' to 'Integrity' so the test survives harmless wording changes. - Note observed overhead ratio in the comment for future reference.
|
Addressed review feedback (commit 1.
2.
3. Caveat about CheckpointManager API assumptions — Not actionable
|
What
Adds 12 tests for
CheckpointManagersave/restore round-trip, covering the gap identified in TODO.md: "Add test for checkpoint save/restore".Tests
CheckpointError.git/) preservedcapture_system_state=TrueVerification
ruff format --check .✅ruff check evoseal/ tests/✅pytest tests/unit/core/test_checkpoint_save_restore.py -q→ 12 passed ✅TODO.md
Checks off: "Add test for checkpoint save/restore"
Tracking table updated: P2 20→21, Total 60→61
Summary by CodeRabbit