Repository navigation
Backlog
Description
Idea
With the DAGI filter (#740: kommune, landsdel, region, postnummer), the Nodes page can narrow the list to an area and report how many nodes without a position it hid. Users also want numbers about the selected area and a way to compare areas.
This is separate from #740 M3c, which only makes the existing Analytics tabs honour the DAGI selection. This issue is a new overview.
Wanted (owner, 2026-11-27)
An overview of one selected area:
- the number of nodes by role;
- active vs quiet/stale nodes;
- new nodes;
- observers;
- packets per hour;
- the busiest repeaters;
- the average number of hops.
A comparison across all kommuner, landsdele or regioner:
- for example repeaters per kommune and repeaters per 100 km²;
- where coverage or observers are missing;
- possibly a choropleth map: kommuner coloured by a chosen metric.
Placement: a new Analytics tab, "Areas (DAGI)", sharing the analytics cache and the DAGI selection.
Research first (M0, no code)
- Metrics: for each wanted number, define it exactly, and say where it comes from: the in-memory store, the existing analytics snapshots, or the DAGI membership cache (
code → set(pubkey)). Note the existing helpers it can reuse. Which numbers are cheap, and which are expensive? - Semantics:
- by node position (membership) vs by observer position vs by traffic;
- how to count nodes without a position;
- postnummer areas that reach into the sea (feat(dagi): DAGI asset pipeline and node lookup (#740 M1) #983);
- Christiansø (outside the kommune division);
- the Copenhagen street postcodes (grouped).
- Area-normalised metrics: per 100 km² from the DAGI
areaM2. Is a per-inhabitant metric possible without new data (population is not in DAGI)? If not, leave it out. - Performance (AGENTS.md rule 0):
- the cost of computing per-area aggregates for all 99 kommuner, 11 landsdele, 5 regioner and ~600 postnumre;
- one pass over nodes and traffic, cached and refreshed with the analytics cycle;
- no per-area queries per request;
- memory bounds.
- API shape: named structs (no
map[string]interface{}); one endpoint for the overview of one area and one for the comparison table; how it fits the existing analytics cache keys and the DAGI selection (nodeScopeKey). - UI:
- the tab layout on desktop and a phone;
- the comparison as a sortable table plus an optional choropleth (polygons from
GET /api/config/dagi/polygons, the cost on a phone); - deep links (
#/analytics?tab=areas&kommune=…); - the credit line.
- Privacy: hidden or blacklisted nodes must not leak through counts in small areas. Mirror how the existing analytics handle hidden identities.
- Plan: milestones (for example M1 the overview API and tab, M2 the comparison table, M3 the choropleth), each with tests, perf proof and customizer implications (rule 8).
Depends on #740 M1/M2 (merged) and M3a (merged).
🤖 Generated with Claude Code
Metadata
Metadata
Assignees
Labels
No labels
Activity
dborup commentedon Nov 27, 2026
Research (M0) — #1002
Scope: #1002, an Analytics tab "Areas (DAGI)" with an overview of one area and a comparison across areas. Research and plan only: no repo change, no commit, no PR.
Base:
origin/masterat71372e99(#740 M1 #983, M2 #988 and M3a #991 merged; M3b #1003 open; M3c not started). I exported it withgit archiveto a scratch folder. The measurements ran there as throw-away Go tests (not committed) against the real embedded DAGI asset, the realdagiMembershipand a realPacketStore.Evidence labels: [T] tested on 2026-11-27 (a command was run and its output read); [K] read in code on
origin/master; [A] assumption or judgement.1. Conclusion and recommendation
analyticsRecomputer("dagi-areas") on the existing analytics cycle (default 5 min).computeAnalyticsTopologyper area) [T].GET /api/analytics/dagi-areas?layer=kommune: the comparison table for one layer.GET /api/analytics/dagi-area?kommune=0751: the overview of one area./api/nodesand M2'sunpositionedHiddendo. An area's node count therefore equals the Nodes page total for the same DAGI filter. No small-count suppression is needed, because every remaining node is already public with its position.areas. That key is the existing configured-areas tab (public/analytics.js:250). Recommended:tab=dagi-areas, label "Areas (DAGI)"./api/analytics/areascounts blacklisted and hidden nodes (tested);computeNewNodesfilters the blacklist but not hidden name prefixes.2. Research point 1: metrics (definition, source, reuse, cost)
All metrics use one window, the last 24 h (§9, Q3).
oldestLoaded,store.go:579) andpartialWindow: true. Per-hour rates then divide by the covered hours.identityHidden(identity_visibility.go:15) does not hide.getCachedNodesAndPMOK(store.go:7965; role, lat/lon, last_seen and first_seen are already in it,store.go:7800) + membership snapshot (dagi_membership.go:43)normalizeRole(role_analytics.go),snap.nodes[pk].at, the postnummer-needs-kommune rule (dagi_membership.go:156)classifyNodeHealthon last_seen with the configured thresholds (defaults: infra 24 h / 72 h, others 1 h / 24 h,config.go:1476), including observer creditLoadObserverReportsonce per cycleclassifyNodeHealth(observer_credit.go:111),GetHealthMs(config.go:1515): the Areas tab's and network status's rulefirst_seenwithin 7 days, excluding returning keys (aninactive_nodesrow)FirstSeen+ one bulkinactive_nodesquery per cycleinactiveNodeLastSeenSQL(new_nodes.go), so the tab agrees with Tools › New NodesPacketPathObserverdocuments atdb.go:2303)tx.Observations) + membershipidentity_visibility.gocomment)s.packets(sorted by first_seen,store.go:247)resolvedPubkeyReversetxID → pubkey hashes (store.go:535)distinctRelayCount(relay_airtime_share.go:120); hash → node viaresolvedPubkeyHash(resolved_index.go:266)txGetParsedPath(longest observation)avgHopsOfrule (store.go:10841), but unroundedareaM2/ 10⁸). Kommune, landsdel and region onlyareaM2(dagi.go:136)What already exists for one area, and why it is not reused for the comparison:
computeAnalyticsTopology(store.go:8428) already yieldsavgHops(store.go:8612) andtopRepeaters(store.go:8751) for one node scope. That is how Backlog: place names, DAGI region filter and km² coverage from Klimadatastyrelsen data #740 M3c will make Topology honour a DAGI selection.Cheap vs expensive: every node metric is cheap (< 1 ms for all areas). The traffic metrics are the expensive part. Of the measured 23 ms [T]:
time.Parseon 70K timestamps takes 2.4 ms. A string compare takes 0.44 ms, and a binary search on the sorteds.packetswould replace it.3. Research point 2: semantics
Node position, observer position or traffic:
store.go:4409, as M2 documents), so "packets from Aarhus" would only count adverts.Nodes without a position (no GPS, 0/0, NaN or out of range;
dagi_membership.go:142):unpositionedVisible(dagi_api.go:175). That is the same number and wording family as the M3a notice.Positioned but outside every kommune (abroad, at sea):
outsideDenmark.dagi_membership.go:156), so a node at sea with "6960" is not counted under 6960.Postnummer areas that reach into the sea (#983):
areaM2values total 147,662 km², against 43,058 km² for kommune, landsdel and region [T].Christiansø (
0411,outsideKommune: true, 0.35 km²,dagi.go:156):Copenhagen street postcodes:
dagiGroupStreetPostcodes(dagi.go:317). Labels come from M3a's group label: "1050–1473 København K".Overlapping layers: a node counts once per layer (kommune ⊂ landsdel ⊂ region; postnummer is independent). Layer totals are therefore comparable across layers, but they are never summed across layers.
4. Research point 3: area-normalised metrics
areaM2from the asset. It is the source area, exterior minus holes, which M1 also uses for precedence.code,name,region,outsideKommune,street,areaM2andrings(dagi.go:126–142). There is no population.5. Research point 4: performance (AGENTS.md rule 0)
5.1 Data used
The data is synthetic, built from the CI fixture's shape and scaled to about 2,500 nodes [T]:
5.2 Results
All on local arm64 with Go 1.26.0; best of 5–7 runs [T].
Rejected alternatives, on the same 2,500-node / 70K-transmission day [T]:
computeAnalyticsTopologyper area5.3 Design consequences
StartAnalyticsRecomputers(analytics_recomputer.go:480, default 5 min at line 482, configurable as for the others).StartupLoadDonewarm-up gate like RF, Topology and Channels, and honourpauseWhenIdle.dagi.enabledand the asset loads.atomic.Pointer. A request costs one slot lookup plus JSON encoding.s.mu.s.mu.RLock, fors.packets,tx.ObservationsandresolvedPubkeyReverse: about 20 ms at 70K. That is shorter than the 77.6 ms the unfiltered topology recompute already holds on the same data [T].sort.Searchfor the window start, not at the oldest packet.analyticsCacheMaxEntries(analytics_cache_bounds.go:28) is unaffected, because no cache keyed by request params is added.BlacklistGeneration()andHiddenNamePrefixesGeneration()(config.go:1682, 1820).RecomputeNowand waits for it (~23 ms) before serving, so a newly hidden node is never served from a stale snapshot.5.4 Response sizes
Measured with
encoding/jsonon the synthetic rows [T]:6. Research point 5: API shape
Named structs only, with no
map[string]interface{}. The existingAreaDensity.RoleCounts map[string]int(types.go:292) is not copied: roles become fixed fields.Validation reuses
parseDagiRequest(dagi_api.go:82) and mirrors analytics today:unknown kommune(etc.), asanalyticsScopedoes (dagi_api.go:306).one DAGI area param is required. The client already sends exactly one (M3a's most-specific-wins rule).layeris 400.Fit with the existing cache keys and
nodeScopeKey:nodeScopeKey(dagi_api.go:125) and no new cache key is involved. The selected area is just an index into the snapshot, and the snapshot is the analytics cache entry.area(configured polygons) andregion(observer IATA) are ignored by these endpoints, and the tab hides those controls (§9, Q10). Supporting them would mean one snapshot per region × area, which is the cardinalityStartAnalyticsRecomputersexplicitly avoids (its doc comment atanalytics_recomputer.go:470).setAnalyticsSnapshotHeaders(analytics_pause_when_idle.go:39) applies unchanged.TestOpenAPICompletenesspasses.7. Research point 7: privacy
7.1 What the code does today [K/T]
Lists exclude hidden identities:
/api/nodesdrops blacklisted keys and hidden name prefixes (routes.go:1863–1873).dagi_api.go:175).identityHidden(identity_visibility.go:15), which also covers the observer blacklist.Several aggregate analytics count every node row:
GetNodesForAreaAnalytics(db.go:4560) readsSELECT … FROM nodeswith no filter. Tested: three nodes in one area, one blacklisted and one with a hidden prefix:/api/nodesreturnstotal: 1;/api/analytics/areasreturnsdensity[0].total: 3.computeAnalyticsRoles(role_analytics.go:153) counts the whole node snapshot, but only nationally.computeNewNodesfiltersIsBlacklistedbut notIsNameHidden(new_nodes.go:103).7.2 Rules for the new tab (recommended)
identityHidden(cfg, pubkey, name)in the node pass. A hidden node is not counted: not in roles, health, new nodes, observers, density or totals.row.nodesequals/api/nodes?<param>=<code>total.7.3 Out of scope, worth separate issues
/api/analytics/areasdensity, position gaps and probably bridge nodes include hidden identities (tested for density, §7.1).computeNewNodesignores hidden name prefixes.8. Research point 6: UI
8.1 Placement and deep links
The tab:
data-tab="dagi-areas", "Areas (DAGI)", placed after "Areas" (analytics.js:250), with acase 'dagi-areas'in the render switch (analytics.js:627)./api/config/dagienabledtrue, read through M3a's memoised config. Otherwise the button is hidden.The code lives in its own file,
public/analytics-dagi-areas.js(an IIFE with pure helpers, testable invm), soanalytics.js(8,033 lines) only gains the button and the case.The selection is M3a's
DagiFilter:getSelected(),onChangeandready()(dagi-filter.js:766).?kommune=/?landsdel=/?dkregion=/?postnr=are already synced by the router.Tab-only params:
layer=(comparison layer) andsort=(metric), registered inTAB_URL_PARAMS(analytics.js:438) so other tabs drop them.#/analytics?tab=dagi-areas&kommune=0751#/analytics?tab=dagi-areas&layer=postnummer&sort=heard#/analytics?tab=dagi-areas&dkregion=1082&layer=kommune&sort=repeatersPer100Km2Defaults:
Filters:
AREA_FILTER_TABS(analytics.js:260).8.2 Desktop (1440×900)
The numbers in both mock-ups are illustrative, not measured; the areas are real (Aarhus is 471 km² in the asset).
8.3 Phone (375×560)
Table behaviour:
<tr>/<li>nodes (appendChild in the new order), and a refresh patches their cells. There is never a full innerHTML rebuild (rule 0).textContentonly, so the XSS gate needs no opt-out.8.4 Choropleth (M3) and its phone cost
GET /api/config/dagi/polygons?layer=<layer>(dagi_api.go:415;Cache-Control: public, max-age=86400and an ETag, line 468), decoded with M3b'sdecodeRings(feat(dagi): DAGI filter on Packets and the area outline on the Map (#740 M3b) #1003).L.polygonplus first paint), median of 5 [T]:compression.gzipdefaults tofalse(config.example.json:627). Without a gzipping proxy, a phone downloads the raw 180–323 KB once per layer per day, and the browser caches it.map=1).setStyle) and never re-fetches.--dagi-choro-1 … 5(theming rule), with "no data" as--border.8.5 Credit line
/api/config/dagi, with Licence and Terms links built by M3a's footer builder (dagi-filter.js:445), exported for reuse rather than copied (DRY).credit, so an API consumer gets it too (CC BY 4.0 attribution).9. Research point 8: plan
Each milestone is one PR and needs owner sign-off (rule 5).
M1: the aggregate, the overview API and the tab (overview only)
Changes:
cmd/server/dagi_area_stats.go:computeDagiAreaStats(nodes, snap, txWindow, cfg, now): a pure function over plain inputs;dagi-areasrecomputer;GET /api/analytics/dagi-area;public/analytics-dagi-areas.js: the overview card, the sparkline, the busiest list, the notices and the credit.analytics.js: the button, the case andTAB_URL_PARAMS.docs/user-guide/area-filter.mdon what the numbers mean.Tests:
row.nodes == /api/nodes?kommune=… totalfor every area of a seeded DB.map[string]interface{}count does not grow.vmunit test of the real file (rendering, XSS as text, no request beforeready()).scripts/e2e-shards.json):kommune=0751, then the card renders;Perf proof:
BenchmarkDagiAreaStats(2.5K/70K, 2.5K/140K, 20K/560K).TestDagiAreaStatsWithinBudget, best of 5. Proposed budgets (×12 under-race), set from the measured 23 ms and 233 ms:Browser validation (rule 2): screenshots at 375×560 and 1440×900, light and dark.
Customizer (rule 8): none yet. M4 tracks the hardcoded values: the 24 h window, 7 days for "new", top 5, and the default comparison metric.
M2: the comparison table
Changes:
GET /api/analytics/dagi-areas?layer=.layer=/sort=deep links.Tests:
layer/sortround-trip through the URL.Perf: first render of the 605 postnummer rows and one re-sort at 4× CPU throttling.
Customizer: note the default layer and metric for M4.
M3: the choropleth
Changes:
setStyleon metric change, the quantile legend and the attribution.--dagi-choro-1…5instyle.css, mapped inTHEME_CSS_MAP(customize.js).decodeRings.Tests:
Perf: decode + draw at 4× throttling.
compression.gzip.Customizer: the colour ramp variables (theming rule).
M4: the customizer
A
dagi-areassection following the masts/heritage pattern:An enum-keyed window needs no extra cache cap (#430 exemption, since
windowis whitelisted).Tests: a sandbox test plus an e2e twin, as in 723/724.
10. Open questions for the owner (each with my recommended default)
avgHops, which M3c will show for the same selection. The two can differ, so the tab's label says "heard".scripts/build-dagi.py. That changes the asset and its pinned SHA-256.tab=dagi-areas?tab=areasis taken.classifyNodeHealth(active / degraded / silent, with observer credit, the configured thresholds)?11. What was not verified
🤖 Generated with Claude Code
dborup commentedon Nov 28, 2026
Owner decisions on the M0 research (2026-11-28)
These answer the 12 open questions in §10. Where an answer differs from the research's default, the line says "changed".
avgHops, side by side and labelled "heard" and "relayed".areaM2as is (no land clipping). The UI notes that coastal postnumre include sea, so their density reads low.tab=dagi-areas. The existing Areas tab is unchanged.dagi-filter.jsso the two do not fork.classifyNodeHealth. On a phone, "Quiet" covers degraded and silent.Next: #1005 and #1006, then M1 (the overview API and the tab).
🤖 Generated with Claude Code
chore(lint): declare the AnalyticsDagiAreas global (#1002 M1)
test(analytics): pin the perf world's clock in the dagi-areas budget …
fix(analytics): Areas (DAGI) review round 1 (#1002 M1)
Merge pull request #1029 from dborup/feat/1002-m1-dagi-area-overview
dborup commentedon Nov 29, 2026
M1 merged in #1029: the Analytics "Areas (DAGI)" overview of one area. The comparison across areas (M2) is still open.
test(dagi): expect the /terms credit link; pin the generator header i…
dborup commentedon Nov 30, 2026
Owner request (2026-11-30) for M2 (comparison across areas): show repeater density precisely enough to compare areas.
Today the overview shows "Repeaters / 100 km²" with one decimal, e.g. Sydjylland (landsdel 218542): 83 repeaters on 8,649 km² of land = 0.96 per 100 km², shown as "1.0". Rounded like that, close areas look identical.
For M2:
cmd/server/dagi_area_stats.go:615);test(analytics): take the choropleth's 4x phone throttle relative to …
fix(analytics): DAGI comparison review round 1 — reveal, labels, fram…
test(analytics): take the DAGI comparison's 4x phone throttle relativ…
fix(analytics): pin the phone gap-chip line so the row estimate holds…
fix(analytics): DAGI choropleth review round 1 — theme restyle, one f…
test(analytics): DAGI comparison review round 2 — pin reveal threshol…
fix(analytics): a map tap on a phone keeps the map in place (#1002 M3, …
test(analytics): raise DAGI comparison perf budgets at 4x throttle to…
test(analytics): assert the DAGI comparison perf budgets at a plain 4…
Merge pull request #1069 from dborup/feat/1002-m2-dagi-comparison
Merge pull request #1071 from dborup/feat/1002-m3-dagi-choropleth
dborup commentedon Dec 2, 2026
M2 (comparison table, #1069,
91eef300) and M3 (choropleth, #1071) are merged. Owner decision on the perf budgets: 250 ms render / 100 ms re-sort at a plain 4× CPU throttle (CI measured ~180 / ~86 ms, so the re-sort has ~14 % headroom). Open review nits:tests/e2e-phone-cpu.jshas no user left, and the M2 shard note still states 150 / 50 ms.Merge pull request #1090 from dborup/chore/1002-perf-helper-cleanup
fix(analytics): keep the choropleth shapes in the Tab order, cover th…
dborup commentedon Dec 2, 2026
Owner decision (2026-12-02) on the density columns of the Areas (DAGI) comparison:
repeatersPer100Km2(not degraded or silent). The total repeater count stays, with the inactive ones shown separately.observersPer100Km2for postnumre.Follow-up PR to come (server field semantics + OpenAPI text, table/choropleth/overview UI, tests).
Merge pull request #1098 from dborup/fix/1002-density-active-only
Merge pull request #1091 from dborup/fix/1002-m3-choropleth-perf
dborup commentedon Dec 2, 2026
Merged: #1098 (density counts active repeaters only, none for postnumre — owner decision) and #1091 (choropleth decode + draw in about half the time, same paths; keyboard focus kept).