fix: filter inconsistent hash sizes by role and add 7-day time window#567
Conversation
…#566) - Filter inconsistentNodes to only include repeaters and room servers, excluding companions which were never affected by the firmware bug - Add 7-day recency window to computeNodeHashSizeInfo() so historical config changes during testing don't create permanent false positives - Update frontend description text to reflect the filtered node types - Add tests for role filtering and time window behavior Fixes #566
…ogical assertions The test packets used header 0x04 (routeType=DIRECT) with pathByte 0x40/0x80 (lower 6 bits = 0), which caused them to be silently skipped by the direct zero-hop filter in computeNodeHashSizeInfo(). Tests passed for wrong reasons (empty results matched vacuous assertions). Fix: use header 0x11 (routeType=FLOOD) with pathByte 0x41/0x81 (non-zero hop count) so packets are actually processed by the hash size computation. Also fix packet ID collisions in TestInconsistentNodesExcludesCompanions (all pubkeys were 64 chars, making len(n.pk) identical for all nodes).
🔍 Charlie Munger Review"All I want to know is where I'm going to die, so I'll never go there." Let me tell you where this PR might die. The Good (briefly)The role filter and time window are sensible, narrowly scoped fixes. The string comparison on ISO 8601 timestamps works because the format is lexicographically sortable — that's fine. The PR description is clear and the perf justification is adequate. Must-Fix
|
TestGetNodeHashSizeInfoLatestWins and TestGetNodeHashSizeInfoIgnoreDirectZeroHop were using identical time.Now() calls for all packets, making them unable to verify ordering semantics as their names claim. Use a base time with per-packet minute offsets so the 'latest wins' logic is actually exercised.
|
✅ Review feedback addressed (commit
|
🐧 Torvalds Final ReviewClean. Small. Does what it says. No over-engineering. What I checked
VerdictZero must-fix items. This is a textbook narrow fix — identifies the problem, solves it with minimal code, tests the fix, doesn't touch anything else. Ship it. APPROVED ✅ |
Summary
Fixes #566 — The "Inconsistent Hash Sizes" list on the Analytics page included all node types and had no time window, causing false positives.
Changes
1. Role filter on inconsistent nodes (
cmd/server/store.go)Added role filter to the
inconsistentNodesloop incomputeHashCollisions()so only repeaters and room servers are included. Companions are excluded since they were never affected by the firmware bug. This matches the existing role filter on collision bucketing from #441.2. 7-day time window on hash size computation (
cmd/server/store.go)Added a 7-day recency cutoff to
computeNodeHashSizeInfo(). Adverts older than 7 days are now skipped, preventing legitimate historical config changes (e.g., testing different byte sizes) from creating permanent false positives.3. Frontend description text (
public/analytics.js)Updated the description to reflect the filtered scope: now says "Repeaters and room servers" instead of "Nodes", mentions the 7-day window, and notes that companions are excluded.
Tests
TestInconsistentNodesExcludesCompanions— verifies companions are excluded while repeaters and room servers are includedTestHashSizeInfoTimeWindow— verifies adverts older than 7 days are excluded from hash size computationcmd/server✅,cmd/ingestor✅Perf justification
The time window filter adds a single string comparison per advert in the scan loop — O(n) with a tiny constant. No impact on hot paths.