Skip to content

fix+test(instance-sync): symmetric newest-writer-wins (converge) + conflict/round-trip/offline tests + docs - #272

Merged
rbuergi merged 2 commits into
mainfrom
test/instance-sync-conflicts
Jul 5, 2026
Merged

rbuergi merged 2 commits into
mainfrom
test/instance-sync-conflicts

Conversation

@rbuergi

@rbuergi rbuergi commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

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). PushNode now 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)

  • Round-trip: local→remote and remote→local edits both converge.
  • Concurrent same-node edit: newer 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 the remote is unreachable → drain and converge on reconnect.
  • Different-field concurrent edit: whole-node newest-wins (documents the trade-off vs a field-level RFC 7396 merge).

Docs

InstanceSync.md updated: conflict resolution/convergence, offline model, the permission note (sync is an Editor-level capability, gated on Update), and the new coverage.

Builds clean under Release -warnaserror.

🤖 Generated with Claude Code

…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>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
@github-actions

github-actions Bot commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Test Results (shard 1)

936 tests  ±0   758 ✅ ±0   4m 15s ⏱️ -16s
 13 suites ±0   178 💤 ±0 
 13 files   ±0     0 ❌ ±0 

Results for commit 7626ab4. ± Comparison against base commit c6bf060.

@github-actions

github-actions Bot commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Test Results (shard 2)

1 112 tests  ±0   1 111 ✅ ±0   6m 48s ⏱️ +19s
   14 suites ±0       1 💤 ±0 
   14 files   ±0       0 ❌ ±0 

Results for commit 7626ab4. ± Comparison against base commit c6bf060.

@github-actions

github-actions Bot commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Test Results (shard 3)

1 739 tests  ±0   1 738 ✅ ±0   6m 58s ⏱️ -5s
   14 suites ±0       1 💤 ±0 
   14 files   ±0       0 ❌ ±0 

Results for commit 7626ab4. ± Comparison against base commit c6bf060.

@github-actions

github-actions Bot commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Test Results (shard 0)

   15 files  ±  0     15 suites  ±0   4m 12s ⏱️ +55s
1 535 tests +220  1 534 ✅ +220  1 💤 ±0  0 ❌ ±0 
1 574 runs  +250  1 573 ✅ +250  1 💤 ±0  0 ❌ ±0 

Results for commit 7626ab4. ± Comparison against base commit c6bf060.

@github-actions

github-actions Bot commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Test Results

   56 files  ±  0     56 suites  ±0   22m 15s ⏱️ +54s
5 322 tests +220  5 141 ✅ +220  181 💤 ±0  0 ❌ ±0 
5 361 runs  +250  5 180 ✅ +250  181 💤 ±0  0 ❌ ±0 

Results for commit 7626ab4. ± Comparison against base commit c6bf060.

@rbuergi
rbuergi merged commit b82606c into main Jul 5, 2026
11 checks passed
@rbuergi
rbuergi deleted the test/instance-sync-conflicts branch August 5, 2026 10:46
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