Skip to content

feat: add CRDT sync status to health/ready endpoint (#30)#39

Merged
mgazza merged 4 commits intomainfrom
feat/crdt-health
Feb 12, 2026
Merged

feat: add CRDT sync status to health/ready endpoint (#30)#39
mgazza merged 4 commits intomainfrom
feat/crdt-health

Conversation

@mgazza
Copy link
Contributor

@mgazza mgazza commented Feb 12, 2026

Summary

  • Track CRDT sync lag per peer in state manager (last sync time per peer, max lag calculation)
  • Add crdt_sync status to /ready endpoint response with peers_connected, sync_lag_ms, last_sync
  • Sync lag threshold for readiness determination (default 30s, configurable via SyncLagThreshold)
  • Prometheus metrics: nexus_crdt_sync_lag_seconds and nexus_crdt_peers_connected gauges

Ready endpoint response format

{
  "ready": true,
  "crdt_sync": {
    "peers_connected": 2,
    "sync_lag_ms": 150,
    "last_sync": "2024-01-01T00:00:00Z"
  }
}

Test plan

  • Unit tests for CRDTSyncStatus() with no peers and with active peers
  • Unit tests for IsCRDTSyncHealthy() within and exceeding threshold
  • API tests for /ready endpoint: standalone mode, ready with checker, not-ready (discovery), not-ready (sync lag)
  • All existing tests pass (go test ./...)

Closes #30

mgazza and others added 4 commits February 12, 2026 06:17
Add per-peer sync time tracking to the State struct. The
handleMembershipUpdate callback now records the last successful
sync time for each peer. New methods CRDTSyncStatus() and
IsCRDTSyncHealthy() expose sync lag data and threshold checks.

Configurable SyncLagThreshold (default 30s) determines when sync
lag makes a node report as not ready.

Part of #30

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Register nexus_crdt_sync_lag_seconds and nexus_crdt_peers_connected
gauges via promauto. These are updated on every membership update
callback from the CRDT layer.

Part of #30

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Extend the ReadinessChecker interface with CRDTSyncStatus() and
IsCRDTSyncHealthy() methods. The /ready endpoint now returns JSON
with crdt_sync details (peers_connected, sync_lag_ms, last_sync).

A node reports not-ready if either peer discovery or CRDT sync
lag threshold is exceeded.

Part of #30

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add state tests for CRDTSyncStatus, IsCRDTSyncHealthy with
various peer/threshold scenarios. Add API tests for the ready
endpoint with mock readiness checker covering ready, not-ready
(discovery), and not-ready (sync lag) cases.

Part of #30

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@mgazza mgazza merged commit 6d452ad into main Feb 12, 2026
2 checks passed
@mgazza mgazza deleted the feat/crdt-health branch February 12, 2026 06:18
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.

Feature: Add CRDT sync status to health/ready endpoint

1 participant