fix(storage): restore the last saved snapshot when timestamps tie 🤖🤖🤖 - #276
fix(storage): restore the last saved snapshot when timestamps tie 🤖🤖🤖#276Sampoornnagpal wants to merge 2 commits into
Conversation
Signed-off-by: Sampoorn Nagpal <nagpalsampoorn@gmail.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Included review availability: Your plan provides up to 12 included reviews per hour; 10 remain after this review. 📝 WalkthroughWalkthroughSQLite snapshot retrieval now uses ChangesSnapshot latest selection
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to Snapshot restoration now consistently returns the most recently saved snapshot when timestamps match, including after reopening the database. The covered behavior is ready to merge. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Signed-off-by: Sampoorn Nagpal <nagpalsampoorn@gmail.com>
What does this PR do?
Two snapshots can receive identical
created_attimestamps.restore_latest_snapshot()then selects the earlier save, restoring stale agent state. Break timestamp ties by descending SQLite row insertion order while retaining timestamp ordering for distinct saves; no schema migration is required.Add a fixed-clock regression that saves values 1 and 99 and checks that 99 is restored, including after reopening the database. It fails before the fix.
Related issues
No matching open issue found. This does not change the context serialization or durable operation work in #235/#174.
Validation
uv run pytest -q tests/test_sqlite_storage_latest.py tests/storage— 102 passed.Windows/Python 3.12; external import-only helpers bypass the existing
fcntl/SIGUSR2blockers (#84/#85). This verifies snapshot ordering and persistence, not POSIX locking or signal behavior. Helpers are not included.Checklist
Summary by CodeRabbit
Bug Fixes
Tests