mirror of
https://github.com/ruvnet/RuView
synced 2026-07-20 17:03:24 +00:00
feat(adr-110): NodeSyncSnapshot.staleness_ms — sync age in milliseconds
Iter 34 — adds an optional `staleness_ms` field to the iter-23
NodeSyncSnapshot that exposes (Instant::now() - latest_sync_at).
Dashboards / Prometheus exporters / UI badges can now decay sync
freshness without re-deriving it from latest_sync_at on the host.
Wire compatibility: new field is `#[serde(skip_serializing_if =
"Option::is_none")]` so pre-iter-34 clients that strict-parse via
serde + deny_unknown_fields are unaffected (default serde_json
strategy is to ignore unknown fields anyway).
Sensing-server changes:
+ NodeSyncSnapshot.staleness_ms: Option<u64>
+ sync_snapshot() populates it via latest_sync_at.elapsed().as_millis()
+ iter-24 serialization tests now check 8 contract fields, not 7
+ new test `snapshot_staleness_ms_tracks_apply_time` pins
latest_sync_at to a past Instant and asserts the snapshot reports
~750 ms staleness with ±500 ms tolerance for scheduler delay
User-guide updates:
+ REST/WebSocket field table grows a `staleness_ms` row with the
UI-rendering thresholds (fade at 5 s, drop at 9 s to match the
firmware's VALID_WINDOW_MS-derived gate).
Tests passing:
sync_snapshot_helper_tests: 7/7
node_sync_snapshot_serialization_tests: 3/3 (8-field assertion green)
Co-Authored-By: claude-flow <ruv@ruv.net>
This commit is contained in:
@@ -669,6 +669,7 @@ Field meanings:
|
||||
| `sequence` | u32 | High-water CSI sequence number stamped when this sync packet was emitted. Pair with the per-frame `sequence` field on incoming CSI to interpolate a mesh-aligned timestamp for any frame. |
|
||||
| `csi_fps_ema` | f64 | Per-node EMA of the observed CSI frame rate. Bench typical ≈ 10 Hz. |
|
||||
| `csi_fps_samples` | u32 | How many inter-frame deltas the EMA has seen. Treat values < 5 as "not yet trustworthy" and fall back to 20 Hz. |
|
||||
| `staleness_ms` | u64 (optional) | Milliseconds since the host last received a sync packet from this node ([iter 34](adr/ADR-110-esp32-c6-firmware-extension.md)). Fade UI badges after 5 000 ms; treat ≥ 9 000 ms as the same condition that the firmware's `c6_sync_espnow_is_valid()` reports as `false`. |
|
||||
|
||||
**When `sync` is omitted entirely**: the node isn't on the mesh (or
|
||||
hasn't heard a peer yet). Non-ESP32 paths — multi-BSSID router scan,
|
||||
|
||||
Reference in New Issue
Block a user