Repository navigation
Skip live packet formatting when the WebSocket hub is empty - #2511
Merged
Merged
Conversation
Adapt the demand check from MeshCore-Beacon/beacon-server commit dd79ca5ca11a329aa734022edd3253d02381b23b to CoreScope's single packet format. Sample listeners after reading each batch, and keep store updates independent of outgoing frames. Fixes Kpa-clawbot#2504.
Contributor
Author
|
Kent Beck Gate: PASS (test quality) at |
n30nex
marked this pull request as ready for review
November 29, 2026 18:09
zfouts
approved these changes
Dec 1, 2026
zfouts
left a comment
Contributor
There was a problem hiding this comment.
Reviewed at 102f57c8. Approving.
- The store still updates when no client is connected: the relay, path-hop and distance indexes,
pickBestObservationand the evidence updates all run. Only the per-observation broadcast maps are skipped. - The new cache-invalidation gate (
len(broadcastTxs)>0 && inv.hasNewObservations) matches the oldlen(result)>0, sinceresulthad one entry per observation of each new transmission. - I checked the race with a client connecting just after the count is sampled. It misses that tick's frames, and nothing is ever partial (the maps are built whole or not at all). Nothing downstream depends on the skipped work:
Hub.Broadcastis the only consumer. A client joining mid-stream already sees this on master. ClientCounttakes onlyhub.mubriefly, and no store lock is held while waiting on the hub.-raceonTestBroadcast*,TestPoller*andBenchmarkPollerLiveFramespasses. The benchmark shows 340 KB / 4,021 allocs per op with no clients against 794 KB / 7,015 with one, matching the PR's claim.
Nits:
cmd/server/store.go:3283: "The relay indexes above also need the path when the feed is idle" sits directly on the branch that skips the stash when idle, so at first it reads backwards. Something like "the path above is computed regardless; this copy is only kept for frames" would be clearer.cmd/server/websocket.go:177: with the early return, a marshal error is no longer logged when nobody is connected. It doesn't matter in practice.
zfouts
added a commit
to zfouts/CoreScope
that referenced
this pull request
Dec 1, 2026
Conflict resolutions: - cmd/server/store.go ingestNewFromDB: keep both. Each transmission is still redacted once (redactLocatedAdvert); master's per-observation observedFrameEvidence (Kpa-clawbot#2497) runs on the observation's own frame before it is dropped, so it reads exact bytes but keeps only the hop width and reception kind. - cmd/server/store.go nodeZeroHopRegionCounts: take master's version, which moved the frame checks into StoreObs.receivedDirectAdvert. Its legacy-singleton fallback read packetpath.AdvertRouteEvidence(tx.RawHex), which is empty for a located advert under privacy, and the evidence needs the payload length, so frameHead cannot supply it. hiddenFrame now keeps routeEvidence (computed from the whole frame at redaction) and receivedDirectAdvert reads tx.frameRouteEvidence(). Test: TestRedactZeroHopLegacySingletonParity. Follow-ups for master's changes: - TestLocationLeakRoutes: classify GET /api/analytics/observer-comparison (Kpa-clawbot#2492). It returns observer IDs, names, reception counts and SNR deltas, no position. - packet_redact_frames_test.go: ingestNewFromDB takes a clientCount (Kpa-clawbot#2511). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2504. Related to #1672.
With no WebSocket listeners, the poller now skips building and encoding live packet frames. SQLite polling, late observations, relay indexes and analytics caches continue to update. A client joining between the transmission and observation reads can receive that tick’s late observations. Connected clients retain the existing wire format.
This independently adapts Beacon’s subscriber demand check to CoreScope’s poller.
Eight alternating runs of 30 SQLite batches each used 32 new transmissions and 32 late observations per batch on one Windows machine with one Go processor.
Idle batches allocated 74% fewer bytes. The connected client received all 64 frames. In a real browser, both sessions received new and late observations across a disconnect and reconnect. The three regressions, related integration tests, race tests and complete server suite passed locally. Tests before the fix