Skip to content

feat: scoped/unscoped transport-route statistics (#899)#915

Open
efiten wants to merge 17 commits intoKpa-clawbot:masterfrom
efiten:feat/scope-stats-899-v2
Open

feat: scoped/unscoped transport-route statistics (#899)#915
efiten wants to merge 17 commits intoKpa-clawbot:masterfrom
efiten:feat/scope-stats-899-v2

Conversation

@efiten
Copy link
Copy Markdown
Contributor

@efiten efiten commented Apr 27, 2026

Summary

  • Adds hashRegions config to the ingestor — region names whose HMAC-SHA256 keys are derived at startup, mirroring the existing hashChannels pattern
  • At ingest, transport-route packets with Code1 ≠ 0000 are HMAC-matched against configured region keys; result stored in new scope_name column
  • DB migration scope_name_v1 adds the column; scope matching runs only on new packets
  • New GET /api/scope-stats?window= endpoint (1h/24h/7d, 30s TTL) returning transport totals, scoped/unscoped counts, per-region breakdown, and time-series
  • New Scopes tab in the Analytics page with summary cards, per-region table, and two-line SVG chart
  • Scope name shown in packet breakdown detail panel

Test plan

  • cd cmd/ingestor && go test ./... — covers scope_name_v1 migration, loadRegionKeys, matchScope, BuildPacketData scope matching
  • cd cmd/server && go test ./... — covers GetScopeStats, handleScopeStats error paths
  • Add "hashRegions": ["#yourregion"] to ingestor config, restart, verify scope_name column gets populated
  • Open Analytics → Scopes tab, verify summary cards and window selector work
  • Open Packets page, confirm scope_name appears in breakdown detail for transport-route packets

Closes #899

🤖 Generated with Claude Code

efiten and others added 17 commits April 27, 2026 10:45
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…edback)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…#899)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…clawbot#899)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Register GET /api/scope-stats route with per-window 30s cache; fix
COALESCE on SUM in GetScopeStats summary query to handle empty result sets.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…clawbot#899)

Add scope_name to transmissionBaseSQL/scanTransmissionRow when the column
exists, and render a Scope row in the detail-meta dl for scoped transport
packets (matched region = "#name", unmatched = "unknown scope").

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…deploy

The backfill processed all historical transport-route rows in a tight loop
at startup with no throttling. scope_name is populated at ingest for new
packets going forward; historical rows remain NULL.

Co-Authored-By: Claude Sonnet 4.6 <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.

Feature: add a new stats page for scopes

1 participant