Skip to content

[fix] Selector and clock correctness fixes #245

Description

@St4NNi

Goal

Three correctness fixes at the foundation that everything later builds on. First, the sync peer
selector hashes the local node id, so every node computes a different holder set for the same
document. Second, placement candidates are not filtered by node kind, which would let laptops
become document holders once user nodes exist. Third, conflict resolution is last writer wins
on wall clock time and nothing guards against clock skew, so a single node with a fast clock
would win every conflict forever. See the federation plan and
the hardening plan item PH-1.

Workplan

  1. Remove the local node id from the selector score so all nodes compute the same selection
  2. Filter user kind nodes out of the sync candidate set. The kind is known locally from the
    realm config
  3. Add an apply time skew guard. Inbound events with a timestamp too far in the future get
    rejected, counted and logged. The threshold is configurable with a default of 300 seconds.
    Document that operators must run NTP

Definition of Done

  • Two nodes compute identical peer sets for the same document
  • Events with future timestamps are rejected and visible in telemetry

Test Concept

  • Unit tests for selector determinism across simulated node identities
  • Boundary tests for the skew guard

Risks / Blockers

  • Removing the bias changes existing placements on dev realms. That is fine, dev state gets
    recreated

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Fields

    No fields configured for Bug.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions