Skip to content

[claude] Resume snapshot replays from checkpoints - #107

Open
myieye wants to merge 3 commits into
mainfrom
claude/harmony-105-late-commit-tests
Open

[claude] Resume snapshot replays from checkpoints#107
myieye wants to merge 3 commits into
mainfrom
claude/harmony-105-late-commit-tests

Conversation

@myieye

@myieye myieye commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

[Claude, autonomous]

Fixes #105. Commits now carry a local IsSnapshotCheckpoint flag marking positions a replay may resume from, and the pruner keeps whatever snapshots that choice needs, replacing the CommitIndex % 2 rule. Design and the dead ends behind it: docs/snapshot-checkpoints.md.

  • Consumers need a migration for the new Commits column, hence +semver: minor on the commit.
  • Legacy databases have no flags, so the first late commit finds no checkpoint, drops everything and regenerates. That is the repair and the bootstrap in one, at the cost of one slow sync.
  • Reading state at an old commit resumes from a checkpoint too, which fixes a change reading a neighbour's state as of the commit asked about rather than the replay position. On a database with no checkpoints that read replays all of history until the first late commit establishes them.
  • Not done from the design doc: restructuring the playback to decide and flush at each checkpoint. Same outcome from the same function, and the batch holds a snapshot per touched entity either way.

Adding several commits at once only keeps a snapshot for every other one.
A commit dated between a commit with no snapshot and the next one that has
one makes the replay start after its own parent, while the entity resumes
from the older snapshot it still has, so the commits in between are applied
by nobody.

Both tests fail: one loses an edit, the other revives a cascade-deleted
definition whose word is still deleted and breaks the foreign key.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Team

Run ID: f8a782bf-4755-4a8f-ad4c-2e62a44c409b

📥 Commits

Reviewing files that changed from the base of the PR and between 50f4502 and 4c9ebcd.

📒 Files selected for processing (1)
  • src/SIL.Harmony.Tests/LateCommitTests.cs

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The pull request adds two regression tests for late commits after snapshot pruning. The tests cover word edits and cascade-deleted definition edits, including state restoration and preservation of DeletedAt.

Changes

Late commit regression tests

Layer / File(s) Summary
Snapshot pruning test setup
src/SIL.Harmony.Tests/LateCommitTests.cs
Adds LateCommitTests and a helper that verifies that snapshots for a commit and entity were pruned.
Late commit replay scenarios
src/SIL.Harmony.Tests/LateCommitTests.cs
Tests late word edits after snapshot pruning. Tests late edits to cascade-deleted definitions and verifies that DeletedAt remains non-null without re-cascading the delete.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: 🟡 Moderate · up to 4c9eb

This change adds regression coverage for late commits after snapshot pruning, but the new tests currently fail because the underlying replay behavior is not yet fixed. Merge after the accompanying fix makes these scenarios pass.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 1 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is related to snapshot replay behavior and checkpoints, which are central to the tests. It does not state that the pull request adds regression tests for late commits, but it remains suffici…
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/harmony-105-late-commit-tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Notes from the investigation into #105: the completeness invariant, why a
hole is an interval rather than a commit, the rules that make checkpoints
safe, and the dead ends so nobody repeats them. Records the measurements
too, since most of the arguments here turn on numbers.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@myieye myieye changed the title Add failing tests for snapshot loss after a late commit [Claude] Roll snapshots back to a checkpoint when a commit arrives out of order Sep 4, 2026
Fixes #105. A commit dated before commits already in the database made the
replay resume each entity from whatever snapshot survived, which can predate
edits whose snapshots were pruned, so nothing re-applied them. One symptom lost
an edit, the other revived a cascade-deleted entity and broke the FK to its
deleted parent.

Commits now carry IsSnapshotCheckpoint: a position where every entity's newest
snapshot at or before it is that entity's state there, so a replay can resume
from it. SnapshotCheckpointPolicy picks every 8th commit of a replayed batch
plus its last, and the pruner keeps whatever snapshots that choice needs, which
replaces the CommitIndex % 2 rule. Reading state at an old commit resumes from a
checkpoint too, so a change no longer reads a neighbour's state as of the commit
being asked about rather than the position being replayed.

Flags are only ever written for commits inside a window being replayed. When
there is no checkpoint before the late commit, nothing safe exists to resume
from, so everything is dropped and regenerated: that is both the repair and the
bootstrap for databases written before this existed.

Consumers need a migration for the new Commits column.

+semver: minor

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@myieye myieye changed the title [Claude] Roll snapshots back to a checkpoint when a commit arrives out of order [claude] Resume snapshot replays from checkpoints Sep 4, 2026
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.

[claude] Snapshot rollback resumes from a stale snapshot and loses intermediate state

1 participant