fix(sync): make the reconcileSamePath winner HLC-monotonic (P4-QUAL-02 follow-up)#95
Conversation
…2 follow-up) The same-path/different-remote winner is now the HIGHEST (HLC, deviceID, eventID) coordinate — consistent with same-remote last-writer-wins and snapshot import — instead of the lowest. The lowest-coordinate rule let the installed row's source HLC sit below a dropped rival's, making delete/ different-remote mixes and multi-event-per-remote mixes diverge by delivery order. Both witness tripwires fired as designed and were retired with their generator exclusions; genEventSet now draws the full event space (deletes + multi-event remotes across different-remote paths). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (12)
📝 WalkthroughWalkthroughThis PR fixes reconcileSamePath's same-path/different-remote conflict resolution to select the highest (HLC, deviceID, eventID) coordinate as winner instead of the lowest, retires previously excluded divergence-witness tests, widens the property-test event generator, and updates dependent test expectations and spec/documentation. ChangesHLC-monotonic reconciliation fix
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant Event as Incoming Event
participant Reconcile as reconcileSamePath
participant Payload as ProjectPayload
participant Conflict as Conflict Record
Event->>Reconcile: submit event/remote for same path
Reconcile->>Reconcile: compare via samePathLess(existing, incoming)
Reconcile->>Payload: select highest (HLC, deviceID, eventID) as canonical winner
Reconcile->>Conflict: record WinnerKey/LoserKey and incomingWins flag
Reconcile-->>Event: return canonical payload
Compact metadata Poem 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Summary
reconcileSamePathnow installs the highest(HLC, deviceID, eventID)coordinate as the same-path/different-remote winner (one-line comparison flip ininternal/sync/events.go), matching same-remote LWW (decideUpsert) and snapshot import (importEntryTx). The previous lowest-coordinate winner was the root cause of both known order-dependence divergences (PR test(sync): property/model-check layer over the pure Decide seam (P4-QUAL-02) #94's handoff): the installed row's source HLC could sit below a dropped rival's, so a mid-HLC delete — or a same-remote LWW lift racing the cross-remote reconcile — flipped the terminal state by delivery order.TestDecideDifferentRemote{Delete,MultiEvent}DivergesWitness) fired exactly as designed and were deleted per their own failure-message protocol, together with bothgenEventSetexclusions: the property/model-check layer now runs the full event space (deletes + multi-event remotes mixed freely across different-remote paths, 1-3 remote pool per path).hlc_test.go×3,decide_property_test.go,conflicts_test.go); theapply_test.goconflict.resolvedfingerprint fixtures are literal-match only and needed no change.conflicts resolvenames the interim installed winner), ledger rows P5-ARCH-01/P4-QUAL-02 (residual/follow-up SHIPPED), work-log entry.Validation
gofmtclean;golangci-lint run0 issues;spec-driftpass (20 specs, 12 changed files).go test -race ./...pass — the widened generator drives the rapid convergence, import≡replay, and 3-replica model suites over the previously-excluded classes.go test -fuzz=FuzzDecideConvergence -fuzztime=60s ./internal/sync/: 1.48M execs, no crash.🤖 Generated with Claude Code
Summary by CodeRabbit
Bug Fixes
Documentation