Skip to content

Enforce HLC drift bounds on backward clock + harden vector clock parsing#28

Merged
dexcompiler merged 1 commit intohlc/drift-check-improvementfrom
copilot/sub-pr-27
Feb 7, 2026
Merged

Enforce HLC drift bounds on backward clock + harden vector clock parsing#28
dexcompiler merged 1 commit intohlc/drift-check-improvementfrom
copilot/sub-pr-27

Conversation

Copy link
Contributor

Copilot AI commented Feb 7, 2026

Tightens HLC drift enforcement to detect backward clock jumps immediately, and hardens VectorClock parsing against malformed input with extra separators.

Changes

  • HLC drift checking: NewGuidWithHlc() and Witness() now validate drift bounds after every state update, catching large backward-clock jumps immediately when ThrowOnExcessiveDrift=true
  • VectorClock parsing: Entry parsing now splits on first : only (Split(':', 2, ...)) to avoid issues with malformed input containing extra separators
  • VectorClock whitespace: Parse methods treat whitespace-only strings as empty input
  • Lock consistency: VectorClockCoordinator uses Lock type consistent with other coordinators
  • Drift test coverage: Added regression tests for backward-clock drift enforcement

Example

// Backward clock now detected immediately
var tp = new SimulatedTimeProvider();
var factory = new HlcGuidFactory(tp, 
    options: new HlcOptions { MaxDriftMs = 0, ThrowOnExcessiveDrift = true });

factory.NewGuidWithHlc();  // logical time = 1000
tp.SetUtcNow(tp.GetUtcNow() - TimeSpan.FromMilliseconds(1));  // clock jump backward

factory.NewGuidWithHlc();  // ❌ throws HlcDriftException immediately

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Enforce HLC drift bounds on backward clock and improve vector clock parsing Enforce HLC drift bounds on backward clock + harden vector clock parsing Feb 7, 2026
Copilot AI requested a review from dexcompiler February 7, 2026 02:20
@dexcompiler dexcompiler marked this pull request as ready for review February 7, 2026 02:20
@dexcompiler dexcompiler merged commit acc539e into hlc/drift-check-improvement Feb 7, 2026
1 check passed
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