Repository navigation
fix+test(instance-sync): symmetric newest-writer-wins (converge) + conflict/round-trip/offline tests + docs - #272
Merged
Merged
Conversation
…NVERGE + conflict/round-trip/offline coverage The pull side already resolved by LastModified (newest-writer-wins), but the PUSH side upserted UNCONDITIONALLY — an older local push clobbered a newer remote node, and since the pull only applies a strictly-newer remote, the two instances then lost the newer edit (LWW violated). PushNode now skips when the remote is strictly newer (the pull brings it local), making resolution symmetric so both sides converge on the newest write. Adds InstanceSyncConflictTest (5, all green; full InstanceSync suite 23/23): - Round-trip: local→remote and remote→local edits both converge. - Concurrent same-node edit: the newer side wins on BOTH sides (remote-newer and local-newer) — the push no longer clobbers a newer remote. - Offline "long flight": edits accumulate in the durable manifest while unreachable, then drain and converge on reconnect. - Different-field concurrent edit: whole-node newest-wins (documents the trade-off vs a field-level RFC 7396 merge). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes an instance-sync convergence bug by making newest-writer-wins (by MeshNode.LastModified) symmetric: the push path now skips overwriting a strictly newer remote node, matching the existing pull-side conflict rule. It also adds an integration test suite covering round-trip convergence, concurrent edits, and offline accumulation/drain behavior.
Changes:
- Add a push-side “remote strictly newer → skip” guard to prevent older local pushes from clobbering newer remote content and breaking LWW convergence.
- Add conflict/round-trip/offline integration tests validating bidirectional convergence behavior under multiple scenarios.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| test/MeshWeaver.InstanceSync.Test/InstanceSyncConflictTest.cs | Adds new integration tests for symmetric LWW conflict resolution, round-trip convergence, and offline drain scenarios. |
| src/MeshWeaver.InstanceSync/InstanceSyncWorker.cs | Updates push upsert logic to skip overwriting strictly newer remote nodes to achieve symmetric newest-writer-wins convergence with pull. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…eview) PushNode's skip-if-remote-newer guard is now applied only for a Bidirectional source. A PushOnly source runs NO pull sweep and is authoritative-local by definition, so skipping there would strand the newer remote AND permanently block the local edit from ever propagating — it must always push. Adds a PushOnly test pinning this, and scopes the doc's conflict-resolution note accordingly. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
Contributor
Contributor
Contributor
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The fix — a real convergence bug
Instance sync resolved conflicts by
LastModified(newest-writer-wins) on the pull side, but the push side upserted unconditionally — so an older local push clobbered a newer remote node, and since the pull only applies a strictly-newer remote, the newer edit was lost (LWW violated, no self-heal).PushNodenow skips when the remote is strictly newer (the pull brings it local), making resolution symmetric so the two instances converge on the newest write.Tests (
InstanceSyncConflictTest, 5 — full suite 23/23 green)Docs
InstanceSync.mdupdated: conflict resolution/convergence, offline model, the permission note (sync is an Editor-level capability, gated onUpdate), and the new coverage.Builds clean under
Release -warnaserror.🤖 Generated with Claude Code