Skip to content

Show recent direct SNR distribution on node Analytics - #2513

Merged
efiten merged 2 commits into
Kpa-clawbot:masterfrom
n30nex:codex/node-snr-distribution-20261129
Dec 1, 2026
Merged

efiten merged 2 commits into
Kpa-clawbot:masterfrom
n30nex:codex/node-snr-distribution-20261129

Conversation

@n30nex

@n30nex n30nex commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

Closes #2506. Implements F2 in #1155.

Node Analytics shows how often fixed observers received the node at each SNR level. Fourteen intervals cover readings below −30 dB, five-dB steps through 30 dB, and readings at or above 30 dB. Each bar has a visible count and a labeled table row. The selected time window is bookmarkable.

The chart counts up to 500 of the newest retained SNR readings from the existing node analytics response. One pass fills fourteen counters. Missing readings contribute no samples, and zero counts as a measurement.

The interval and count presentation takes its design from Beacon’s bounded reception analytics and Beacon’s Signal view. CoreScope renders its own HTML and CSS.

Browser checks used a local #/nodes/<pubkey>/analytics?days=1 fixture at 320 px and 1400 px. All fourteen counts matched the server: 16 readings from 17 direct receptions in 24 hours, 18 from 19 in seven days. Both included two 0 dB readings. Keyboard navigation reached the interval table, and returning to the saved window reused the cached analytics response.

Regression coverage includes tests/e2e/test-node-analytics-heard-by-e2e.js:87. Test-only RED d8fc58e0f and GREEN 9dcf2241d.

Tests before the fix

@n30nex

n30nex commented Nov 29, 2026

Copy link
Copy Markdown
Contributor Author

Kent Beck Gate: PASS (test quality) at 9dcf2241d. The browser checks each of the 14 bins against the actual analytics response. The populated fixture yielded 16 readings in one day and 18 in seven days, including two zeros in each window. The empty view, boundary values, keyboard access, Back navigation and one request per time window are covered.

@n30nex
n30nex marked this pull request as ready for review November 29, 2026 18:20

@zfouts zfouts left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed at 9dcf2241. Approving.

  • This is frontend-only and reads the existing snrTrend, which comes from heardSnrTrend (cmd/server/heard_by.go) over the same direct-heard snapshot that feeds Heard By. So it uses the shared #2453 rule rather than a second definition of "direct".
  • The data stays bounded: 500 per observer and 500 overall. Taking the newest 500 from rings of 500 per observer is exact.
  • I checked the bins by hand: −31 goes to "Below −30", −30 to bin 1, 29.75 to bin 12 and 30 to "30 and above".
  • The data comes through api(), the colour is var(--accent), there's an empty state, and days goes into the URL hash and is read back, accepting only the four button values.
  • The unit tests pass locally (16/16).

Nits:

  1. public/node-analytics.js:166: the branch that parses an SNR given as a string can't be reached, because the server always sends a number (float64(r.smp.SNR)/4). It could go, along with the '0' test case.
  2. With 30 days or All on a busy node, the newest 500 readings may all fall in the last day, so the chart can match the 24 h view. The caption says so, which seems fine.
  3. A screenshot of the chart in the PR would help; the e2e test only saves one when SCREENSHOT_DIR is set.

@efiten
efiten merged commit 6ef8d65 into Kpa-clawbot:master Dec 1, 2026
17 checks passed
zfouts added a commit to zfouts/CoreScope that referenced this pull request Dec 2, 2026
… and the advert reception changes to Postgres

Brings in 10 master commits: Kpa-clawbot#2366 (catalogue key tier), Kpa-clawbot#2497 (regions
count only received adverts), Kpa-clawbot#2498 (archived foreign-advert flags), Kpa-clawbot#2492
(observer comparison), Kpa-clawbot#2511, Kpa-clawbot#2513, Kpa-clawbot#2514, Kpa-clawbot#2517, Kpa-clawbot#2518, Kpa-clawbot#2519.

Conflicts:
- cmd/ingestor/approved_channels.go: both sides added a mutex to
  channelKeySet. One mu now serialises refresh, master's setCatalog and the
  branch's Close, and guards the users.db/Postgres accounts readers as well
  as master's approvedNames and catalogue tier.
- cmd/ingestor/db.go, nodes upsert: master's foreign_advert carry-over on
  top of the branch's qualified columns and lastSeenClampSQL. Master looked
  up the archived flag with ?1, which dbx.Rebind turns into $11 on Postgres;
  it is now a plain ? bound to the public key again, and the EXISTS is
  wrapped in CASE so Postgres stores 0/1 in the BIGINT column.
- cmd/ingestor/db.go, MoveStaleNodes: master's UPDATE that restores an
  archived foreign flag runs before the branch's portable moveStaleNodesSQL
  (not master's INSERT OR REPLACE ... SELECT *), with IS DISTINCT FROM 1
  instead of the SQLite-only IS NOT 1.

Ported to Postgres:
- catalog_keys (Kpa-clawbot#2366): pgschema migration 0004_catalog_keys.sql (same
  columns, CHECKs, defaults and key; LatestVersion 4), the table in
  sqlite_endstate.sql, and the worker's upsert sets updated_at from
  excluded.updated_at instead of strftime('%s','now').
- corescope-migrate copies catalog_keys and verify never prints
  catalog_keys.key_hex (channel secrets), for any store.
- GetNodes region filter (Kpa-clawbot#2497) and the observer comparison (Kpa-clawbot#2492) used
  IS NOT 'tx'; both use IS DISTINCT FROM 'tx'. The comparison's
  ORDER BY label COLLATE NOCASE is lower(<label expression>) on Postgres,
  which folds ASCII only under COLLATE "C", as NOCASE does.
- docs/catalogue-keys.md: the revert SQL on PostgreSQL.

Tests on both backends:
- The catalogue key tests that use a store and the Kpa-clawbot#2498 foreign-advert
  tests run on SQLite and Postgres (onBothStores; insertTx uses RETURNING).
- New dual tests for the observer comparison and the GetNodes region filter.
- pgschema: an upgrade from version 3 with data; the control migration tests
  no longer assume 3 is the latest version.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

Show the distribution of recent direct SNR readings on node Analytics

3 participants