Skip to content

fix(rust_brain): preserve HLC on snapshot restore and gossip receive#33

Draft
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/critical-bug-investigation-0ce8
Draft

fix(rust_brain): preserve HLC on snapshot restore and gossip receive#33
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/critical-bug-investigation-0ce8

Conversation

@cursor

@cursor cursor Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Bug and impact

After snapshot restore or cross-node gossip, Hybrid Logical Clock (HLC) timestamps were not preserved. Restored nodes received fresh HLC values, causing legitimate causal writes to raise TimestampRegression — silent data loss after disaster recovery. Gossip without HLC could overwrite fresher local data.

Root cause

restore_from_file() reconstructed MemoryNode without the hlc field (defaulting to a new clock). bulk_write() and gossip.receive() also ignored incoming HLC metadata.

Fix

  • Add _parse_hlc() to normalise HLC from snapshot/wire format
  • Restore HLC on snapshot load and advance the process clock via _hlc.update()
  • Pass HLC through bulk_write() and gossip.receive() with stale-update rejection

Validation

  • Reproduced pre-fix: restore assigned fresh HLC; causal successor write raised TimestampRegression
  • pytest tests/test_enterprise_backup.py tests/test_gossip.py tests/test_rust_brain.py — 28 passed
Open in Web View Automation 

restore_from_file() dropped hlc fields from snapshots, assigning fresh
timestamps that rejected legitimate causal writes (TimestampRegression)
after disaster recovery. gossip.receive() also ignored incoming HLC,
allowing stale overwrites or silent update skips.

- Add _parse_hlc() for snapshot/wire normalisation
- Restore HLC and update process clock on snapshot restore
- Pass hlc through bulk_write and gossip receive with stale rejection

Co-authored-by: Daniel <DJLougen@users.noreply.github.com>
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.

1 participant