Skip to content

fix(backups): order snapshots by their time, not their name - #107

Merged
TusanHomichi merged 2 commits into
mainfrom
claude/105-snapshot-order
Oct 14, 2026
Merged

TusanHomichi merged 2 commits into
mainfrom
claude/105-snapshot-order

Conversation

@TusanHomichi

Copy link
Copy Markdown
Member

Primary Issue

Closes #105

Problem And Outcome

backup::snapshots_in sorted by file name. restore sets the old database aside as consolebook-prerestore-<stamp>.db, which sorts after every consolebook-<stamp>.db (p > 2). So after any restore, the set-aside database was "newest" for good:

Snapshots now sort by the UTC stamp at the end of their name, then by name. Every consumer of "newest" or "oldest" follows from that one function: listing, retention, copy status, catch-up, and doctor.

Changes

  • backup.rs: snapshots_in sorts by snapshot_order(), which takes the stamp after the last -, then the full name.
  • tests/snapshot_order.rs: fixture files written out of order: an early backup, a pre-restore set-aside, and a later backup.
    • Listing order is by time.
    • Retention removes the chronologically oldest.
    • A share holding only the set-aside database is behind, and catch_up copies the latest backup, not the set-aside one.
  • CHANGELOG.md: Unreleased → Fixed.

Correction rung: 1. One ordering function owns "oldest first" for every caller.

Verification

  • Negative control: with the old found.sort(), all three new tests fail.
  • cargo fmt --check and cargo clippy --workspace --all-targets -- -D warnings are clean. snapshot_order, backup_copy, and backup_restore pass.
  • Full local proof: to be added below.

Review And Merge Notes

🤖 Generated with Claude Code

https://claude.ai/code/session_01TsvZjbz8dTRM8A1NqAP5ts


Generated by Claude Code

consolebook-prerestore-<stamp>.db sorted after every consolebook-<stamp>.db,
so after any restore the set-aside database stayed "newest" for good:
catch-up copied it off the server, copy status read current while later
copies failed, and retention pruned real backups ahead of it.

Closes #105

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01TsvZjbz8dTRM8A1NqAP5ts
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-14T22:26:09.072619Z 1e6e632 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Copy link
Copy Markdown
Member Author

Full local proof on 1e6e632 (scripts/proof.py, euid 0 with DAC capabilities dropped): passed, all 7 gates. Browser suite 59 expected, 0 unexpected, 0 flaky. Receipt .proof/20261014T222358Z-1e6e632ab91c/receipt.json, sha256 6a60ae228b0db9473cdb43abd4ba30fc0a1694bd6f487d1262cf6120b14fb68b. CI is green and Codex had no findings.


Generated by Claude Code

@TusanHomichi
TusanHomichi merged commit b74c520 into main Oct 14, 2026
4 checks passed
@TusanHomichi
TusanHomichi deleted the claude/105-snapshot-order branch October 14, 2026 22:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

backups: a pre-restore snapshot sorts as "newest" forever, masking copy failures

2 participants