Skip to content

Add CRDT clock and convergence coverage - #93

Merged
hahn-kev merged 1 commit into
mainfrom
tests/crdt-clock-and-convergence
Aug 7, 2026
Merged

Add CRDT clock and convergence coverage#93
hahn-kev merged 1 commit into
mainfrom
tests/crdt-clock-and-convergence

Conversation

@hahn-kev-bot

Copy link
Copy Markdown
Collaborator

AI-generated summary

Adds direct coverage for the CRDT correctness guarantees that previously had none — the second batch from the test-suite review.

Hybrid clock (HybridDateTimeProviderTests, new file). Every other test injects a MockTimeProvider that stubs out the real clock logic, so HybridDateTimeProvider had zero coverage. New tests use a settable TimeProvider to exercise:

  • a forward wall clock resets the counter;
  • a backward/equal wall clock reuses the newer timestamp and increments the counter (staying monotonic across repeated calls);
  • TakeLatestTime advances local time past the newest received commit and ignores older ones.

HybridDateTime ordering (HybridDateTimeTests). Added the comparison operators (<, >, <=, >=) and the counter tie-break on equal instants, which drive the clock's counter-increment decision and were untested.

Sync convergence (SyncTests). Existing multi-client tests only edited different entities or the same entity with strictly-increasing timestamps, so the tie-break path never ran. Added:

  • concurrent edits to the same entity at the same instant converge to one deterministic winner on both replicas;
  • later-timestamp-wins for concurrent same-entity edits;
  • SyncWith idempotency (a second sync transfers nothing);
  • the ShouldSync/IsSynced short-circuit via NullSyncable (IsSynced was never asserted anywhere before).

Test-only; no production code changed.

Test plan

  • dotnet test on the affected tests passes (23/23 locally, including pre-existing HybridDateTimeTests).

Covers the library's central correctness claims that had no direct tests:
- HybridDateTimeProvider clock logic (backward/equal wall clock -> reuse
  timestamp and bump counter; TakeLatestTime advancing past synced commits).
  The rest of the suite injects a MockTimeProvider that stubs this out.
- HybridDateTime comparison operators and counter tie-break on equal instants.
- Concurrent edits to the same entity converge to a single deterministic
  winner across both replicas (same-instant tie-break and later-timestamp-wins).
- SyncWith idempotency (a second sync transfers nothing) and the
  ShouldSync/IsSynced short-circuit via NullSyncable.

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

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@hahn-kev, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 56 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 9eebee24-9422-4b79-8885-44ab4f505c2d

📥 Commits

Reviewing files that changed from the base of the PR and between 03f609f and e698f73.

📒 Files selected for processing (3)
  • src/SIL.Harmony.Tests/Core/HybridDateTimeProviderTests.cs
  • src/SIL.Harmony.Tests/Core/HybridDateTimeTests.cs
  • src/SIL.Harmony.Tests/SyncTests.cs

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.

@hahn-kev

hahn-kev commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor
⚠️ Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@hahn-kev

hahn-kev commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor
⚠️ Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@hahn-kev
hahn-kev merged commit 37ff910 into main Aug 7, 2026
7 checks passed
@hahn-kev
hahn-kev deleted the tests/crdt-clock-and-convergence branch August 7, 2026 06:37
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.

2 participants