Commit Graph

894 Commits

Author SHA1 Message Date
Kpa-clawbot
6ec00a5aab test(go): fix failing test + add 18 tests, coverage 91.5% → 92.3%
Fix TestStoreGetAnalyticsChannelsNumericHash: corrected observation
transmission_id references (3,4,5 → 4,5,6) and changed assertion to
only check numeric-hash channels (seed data CHAN lacks channelHash).

New tests covering gaps:
- resolvePayloadTypeName unknown type fallback
- Cache hit paths for Topology, HashSizes, Channels
- GetChannelMessages edge cases (empty, offset, default limit)
- filterPackets: empty region, since/until, hash-only fast path,
  observer+type combo, node filter
- GetNodeHashSizeInfo: short hex, bad hex, bad JSON, missing pubKey,
  public_key field, flip-flop inconsistency detection
- handleResolveHops: empty param, empty hop skip, nonexistent prefix
- handleObservers error path (closed DB)
- handleAnalyticsChannels DB fallback (no store)
- GetChannelMessages dedup/repeats
- transmissionsForObserver from-slice filter path
- GetPerfStoreStats advertByObserver count
- handleAudioLabBuckets query error path

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-27 13:13:31 -07:00
github-actions
00453c843e ci: update test badges [skip ci] 2026-03-27 20:07:54 +00:00
Kpa-clawbot
d16ac82f6d fix: subscribe MQTT with explicit QoS 0 to prevent puback flag errors (fixes #161)
Upstream brokers publishing QoS 1 cause our mqtt client to send PUBACKs
with invalid flag bits, triggering Mosquitto disconnect storms. Explicitly
requesting QoS 0 avoids PUBACKs entirely.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-27 13:06:47 -07:00
Kpa-clawbot
25ab880fd4 docs: Scribe session finalization log — 28 issues closed, Go rewrite staged, DB merge complete
- Merged decision inbox (empty, no new decisions to file)
- Orchestration log entry summarizing session deliverables
- Agent work: Hicks (6 fixes + Go MQTT ingestor + Go web server), Newt (4 frontend fixes), Bishop (gap coverage + E2E expansion), Kobayashi (root cause + DB plan), Hudson (merge execution + Docker setup), Coordinator (issue triage), Ripley (support onboarding)
- Session impact: 28 issues closed, 7,308→400 nodes, 2.7GB→860MB RSS, 185MB staged DB merged to prod, Go ingestor (25 tests) + server (42 tests) ready, E2E coverage 16→42 tests
- Infrastructure: Staging environment operational (Docker Compose, old problematic DB), CI pipeline self-healing

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-27 12:58:40 -07:00
Kpa-clawbot
8f712774ae fix: WS broadcast missing decoded fields + cache analytics endpoints
#156: The Go WebSocket broadcast from IngestNewFromDB was missing the
'decoded' field (with header.payloadTypeName) that live.js needs to
display packet types. Added decoded object with payloadTypeName
resolution, plus observer_id, observer_name, snr, rssi, path_json,
and observation_count fields to match the Node.js broadcast shape.

#157-160: Analytics endpoints (hash-sizes, topology, channels) were
recomputing everything on every request. Added:
- TTL caching (15s) for topology, hash-sizes, and channels endpoints
  (matching the existing RF cache pattern)
- Cached node list + prefix map shared across analytics (30s TTL)
- Lazy-cached parsed path JSON on StoreTx (parse once, read many)
- Cache invalidation on new data ingestion
- Global payloadTypeNames map (avoids per-call allocation)

Fixes #156, fixes #157, fixes #158, fixes #159, fixes #160

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-27 12:17:26 -07:00
github-actions
59e616668b ci: update test badges [skip ci] 2026-03-27 19:16:27 +00:00
Kpa-clawbot
1457795e3e fix: analytics channels + uniqueNodes mismatch
fixes #154: Go analytics channels showed single 'ch?' because
channelHash is a JSON number (from decoder.js) but the Go struct
declared it as string. json.Unmarshal failed on every packet.
Changed to interface{} with proper type conversion. Also fixed
chKey to use hash (not name) for grouping, matching Node.js.

fixes #155: uniqueNodes in topology analytics used hop resolution
count (phantom hops inflated it). Both Node.js and Go now use
db.getStats().totalNodes (7-day active window), matching /api/stats.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-27 12:07:50 -07:00
Kpa-clawbot
2f5404edc3 fix: close last parity gaps in /api/perf and /api/nodes/:pubkey
- db.go: Add freelistMB (PRAGMA freelist_count * page_size) and walPages
  (PRAGMA wal_checkpoint(PASSIVE)) to GetDBSizeStats
- store.go: Add advertByObserver count to GetPerfStoreStats indexes
  (count distinct pubkeys with ADVERT observations)
- db.go: Add getObservationsForTransmissions helper; enrich
  GetRecentTransmissionsForNode results with observations array,
  _parsedPath, and _parsedDecoded
- db_test.go: Add second ADVERT with different hash_size to seed data
  so hash_sizes_seen is populated; enrich decoded_json with full
  ADVERT fields; update count assertions for new seed row

fixes #151, fixes #152

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-27 11:57:35 -07:00
Kpa-clawbot
744702ccf6 feat(perf): show Go Runtime stats instead of Event Loop on Go backend
When engine=go, the perf page now renders Go-specific runtime stats
(goroutines, GC collections, GC pause times, heap breakdown, CPUs)
instead of the misleading Node.js Event Loop metrics. Falls back to
the existing Node UI when engine is not 'go' or goRuntime data is
missing. Includes color-coded GC pause thresholds.

fixes #153

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-27 11:49:10 -07:00
Kpa-clawbot
979b649028 fix(go): add missing packetStore fields to /api/perf (inMemory, maxPackets, etc.)
Frontend reads ps.inMemory.toLocaleString() which crashed because
the Go response was missing inMemory, sqliteOnly, maxPackets, maxMB,
evicted, inserts, queries fields. Added all + atomic counters.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-27 11:39:16 -07:00
Kpa-clawbot
47531e5487 Add golden fixture parity test suite — Go must match Node shapes
- Capture Node.js API response shapes from prod server as golden fixtures
- Store normalized shape schema in cmd/server/testdata/golden/shapes.json
  covering 16 endpoints: stats, nodes, packets (raw + grouped), observers,
  channels, channel_messages, analytics (rf, topology, hash-sizes, distance,
  subpaths), bulk-health, health, perf, and node detail
- Add parity_test.go with recursive shape validator:
  - TestParityShapes: validates Go response keys/types match Node golden
  - TestParityNodeDetail: validates node detail response shape
  - TestParityArraysNotNull: catches nil slices marshaled as null
  - TestParityHealthEngine: verifies Go identifies itself as engine=go
  - TestValidateShapeFunction: unit tests for the validator itself
- Add tools/check-parity.sh for live Node vs Go comparison on VM
- Shape spec handles dynamic-key objects (perObserverReach, perf.endpoints)
- Nullable fields properly marked (observer lat/lon, snr/rssi, hop names)

Current mismatches found (genuine Go bugs):
- /api/perf: packetStore missing 8 fields, sqlite missing 2 fields
- /api/nodes/{pubkey}: missing hash_sizes_seen, observations, _parsedPath,
  _parsedDecoded in node detail response

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-27 11:37:56 -07:00
Kpa-clawbot
f97b4c78ad fix: add missing status, uptimeHuman, websocket fields to Go /api/perf
The frontend perf dashboard crashes with toLocaleString error because
the Go /api/perf endpoint was missing fields that Node returns:
- status: "ok"
- uptimeHuman: formatted "Xh Ym" string
- websocket: { clients: N } via hub.ClientCount()

The Go /api/health endpoint already had all three fields.

fixes #150

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-27 11:33:55 -07:00
Kpa-clawbot
4101dc1715 test(go): push Go server test coverage from 77.9% to 91.4% (#145)
Add comprehensive coverage_test.go targeting all major coverage gaps:
- buildPacketWhere: all 8 filter types (0% -> covered)
- QueryMultiNodePackets: DB + store paths (0% -> covered)
- IngestNewFromDB: v3/v2 schema, dedup, defaults (0% -> covered)
- MaxTransmissionID: loaded + empty store (0% -> covered)
- handleBulkHealth DB fallback (24.4% -> covered)
- handleAnalyticsRF DB fallback (11.8% -> covered)
- handlePackets multi-node path (63.5% -> covered)
- handlePacketDetail no-store fallback (71.1% -> covered)
- handleAnalyticsChannels DB fallback (57.1% -> covered)
- detectSchema v2 path (30.8% -> covered)
- Store channel queries, analytics, helpers
- Prefix map resolve with GPS preference
- wsOrStatic, Poller, perfMiddleware slow queries
- Helper functions: pathLen, floatPtrOrNil, nilIfEmpty, etc.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-27 11:23:27 -07:00
Kpa-clawbot
5bb5bea444 fix(go): channels null arrays + hash size enrichment on nodes
- Fix #148: channels endpoint returned null for msgLengths when no
  decrypted messages exist. Initialize msgLengths as make([]int, 0)
  in store path and guard channels slice in DB fallback path.

- Fix #149: nodes endpoint always returned hash_size=null and
  hash_size_inconsistent=false. Add GetNodeHashSizeInfo() to
  PacketStore that scans advert packets to compute per-node hash
  size, flip-flop detection, and sizes_seen. Enrich nodes in both
  handleNodes and handleNodeDetail with computed hash data.

fixes #148, fixes #149

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-27 11:21:41 -07:00
Kpa-clawbot
407c49e017 fix(go): add eventLoop to /api/health with GC pause percentiles, fixes #147
Go's /api/health was missing the eventLoop object that Node.js provides.
The perf.js frontend reads health.eventLoop.p95Ms which crashed with
'Cannot read properties of undefined' when served by the Go server.

Adds eventLoop field using GC pause data from runtime.MemStats.PauseNs
(last 256 pauses) to compute p50Ms, p95Ms, p99Ms, currentLagMs, maxLagMs
— matching the Node.js response shape exactly.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-27 11:04:43 -07:00
Kpa-clawbot
8a0f731452 fix: topology uniqueNodes counts only real nodes, not hop prefixes
The Go analytics topology endpoint was counting every unique hop string
from packet paths (including unresolved 1-byte hex prefixes) as a unique
node, inflating the count from ~540 to 6502. Now resolves each hop via
the prefix map and deduplicates by public key, matching the Node.js
behavior.

fixes #146

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-27 10:50:32 -07:00
Kpa-clawbot
1e39b2439c Scribe: Record Hicks perf (#143), Bishop E2E expansion (+25 tests #144), issue triage (#134-#142 closed, #146 filed)
- Hicks: Go /api/perf endpoint with runtime.MemStats, GC pauses, cache metrics
- Hicks: Fixed /api/health to include schema compat detection
- Bishop: 25 new Playwright E2E tests (42 total) covering perf, audio, channels, observers, traces
- Issues #134-#142 manually closed (dupes/Polish already fixed by Newt)
- Issue #146 filed: unique node count bug (6502 phantom nodes)
- CI run #565 all tests passing

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-27 10:47:32 -07:00
Kpa-clawbot
93dbe0e909 fix(go): add runtime stats to /api/perf and /api/health, fixes #143
- /api/perf: add goRuntime (heap, GC, goroutines, CPU), packetStore
  stats (totalLoaded, observations, index sizes, estimatedMB),
  sqlite stats (dbSizeMB, walSizeMB, row counts), real RF cache
  hit/miss tracking, and endpoint sorting by total time spent
- /api/health: add memory.heapMB, goRuntime (goroutines, gcPauses,
  numCPU), real packetStore packet count and estimatedMB, real
  cache stats from RF cache; remove hardcoded-zero eventLoop
- store.go: add cacheHits/cacheMisses tracking in GetAnalyticsRF,
  GetPerfStoreStats() and GetCacheStats() methods
- db.go: add path field to DB struct, GetDBSizeStats() for file
  sizes and row counts
- Tests: verify new fields in health/perf endpoints, add
  TestGetDBSizeStats, wire up PacketStore in test server setup

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-27 10:45:00 -07:00
Kpa-clawbot
4ca850fdd0 test(e2e): add Playwright tests for all uncovered pages #144
Add 25 new E2E tests covering pages that previously had no Playwright coverage:

Packets page (4 tests):
- Detail pane hidden on fresh load
- groupByHash toggle
- Clicking row shows detail pane
- Detail pane close button

Analytics sub-tabs (7 tests):
- RF, Topology, Channels, Hash Stats, Hash Issues, Route Patterns, Distance

Compare page (2 tests):
- Observer dropdowns populate
- Running comparison produces results

Live page (2 tests):
- Page loads with map and stats
- WebSocket connection indicators

Channels page (2 tests):
- Channel list loads with items
- Clicking channel shows messages

Traces page (2 tests):
- Search input and button present
- Search returns results for valid hash

Observers page (2 tests):
- Table loads with rows
- Health indicators present

Perf page (2 tests):
- Metrics load
- Refresh button works

Audio Lab page (3 tests):
- Controls load (play, voice, BPM, volume)
- Sidebar lists packets by type
- Clicking packet shows detail and hex dump

Total: 42 tests (was 17). All new tests validated against analyzer.00id.net.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-27 10:42:35 -07:00
Kpa-clawbot
a6f713a09c chore: bump cache busters to trigger CI deploy 2026-03-27 10:40:18 -07:00
Kpa-clawbot
d007ed03f7 ci: trigger deploy with all fixes included 2026-03-27 10:38:45 -07:00
Kpa-clawbot
57bb5aaac9 ci: trigger fresh run with all fixes 2026-03-27 10:37:05 -07:00
Kpa-clawbot
3f10ca6065 Session close: merge decisions inbox, finalize logs
- Merged copilot-directive-scribe-always.md into decisions.md
- Added 2026-03-27T17:13 directive: Scribe auto-run after agent batches
- Verified all 6 orchestration logs (Hicks, Newt, Hudson, Bishop, Kobayashi, Ripley)
- Appended scribe consolidation summary to 2026-03-27T16-session.md
- Deleted inbox file after merge

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-27 10:27:12 -07:00
Kpa-clawbot
d7172961f4 fix(go): analytics endpoints parity — fixes #134, #135, #136, #137, #138, #140, #142
Implement all analytics endpoints from in-memory PacketStore instead of
returning stubs/empty data. Each handler now matches the Node.js response
shape field-by-field.

Endpoints fixed:
- /api/analytics/topology (#135): full hop distribution, top repeaters,
  top pairs, hops-vs-SNR, per-observer reachability, cross-observer
  comparison, best path analysis
- /api/analytics/distance (#137): haversine distance computation,
  category stats (R↔R, C↔R, C↔C), distance histogram, top hops/paths,
  distance over time
- /api/analytics/hash-sizes (#136): hash size distribution from raw_hex
  path byte parsing, hourly breakdown, top hops, multi-byte node tracking
- /api/analytics/hash-issues (#138): hash-sizes data now populated so
  frontend collision tab can compute inconsistent sizes and collision risk
- /api/analytics/route-patterns (#134): subpaths and subpath-detail now
  compute from in-memory store with hop resolution
- /api/nodes/bulk-health (#140): switched from N per-node SQL queries to
  in-memory PacketStore lookups with observer stats
- /api/channels (#142): response shape already correct via GetChannels;
  analytics/channels now returns topSenders, channelTimeline, msgLengths
- /api/analytics/channels: full channel analytics with sender tracking,
  timeline, and message length distribution

All handlers fall back to DB/stubs when store is nil (test compat).
All 42+ existing Go tests pass. go vet clean.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-27 10:23:11 -07:00
Kpa-clawbot
7bd14dce6a fix: run go tool cover from module directory, not repo root
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-27 10:21:59 -07:00
Kpa-clawbot
9ca7777851 fix: version-badge link contrast in nav stats bar
Style .version-badge anchor elements to use --nav-text-muted color
instead of browser-default blue. Adds hover state using --nav-text.
Works with both light and dark themes via existing CSS variables.

fixes #139

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-27 10:14:50 -07:00
Kpa-clawbot
7807063967 ci: add Go test coverage reporting to CI pipeline
- Go server and ingestor tests now run with -coverprofile
- Coverage percentages parsed and printed in CI output
- Badge JSON files generated (.badges/go-server-coverage.json,
  .badges/go-ingestor-coverage.json) matching existing format
- Badges uploaded as artifacts from go-build job, downloaded
  in test job, and published alongside existing Node.js badges
- Coverage summary table added to GitHub Step Summary

fixes #141

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-27 10:14:14 -07:00
Kpa-clawbot
a026a75fc8 .squad/agents/hudson: Summarize history, keep 2026-03-27 session details
- Archived pre-2026-03-27 detailed entries into summary section
- Retained current session context (DB merge, Docker Compose, staging setup)
- File reduced from 33.5KB to 4.4KB while preserving important learnings

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-27 09:57:42 -07:00
Kpa-clawbot
b6c567903f .squad: Merge session inbox to decisions, update agent histories
- Merged all 27 inbox decision files into decisions.md (comprehensive dedup)
- Cleaned inbox/ directory (only .gitkeep remains)
- Updated agent histories with 2026-03-27 session context:
  - Kobayashi: DB merge plan, #133 triage, team coordination
  - Hicks: 6 fixes + Go rewrite completion, API parity, phantom node cleanup
  - Newt: 4 frontend fixes, live page improvements, observer comparison
  - Bishop: PR reviews, test gap fixes, E2E validation
  - Hudson: DB merge execution, Docker Compose migration, staging setup
  - Ripley: Support engineer onboarded, staleness thresholds documented
- decisions.md now comprehensive reference (20+ technical decisions)
- Removed 51 lines of duplicate inbox entries

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-27 09:56:44 -07:00
Kpa-clawbot
b92e71fa0e refine version badge: clickable links, version only on prod
- Commit hash is now an <a> linking to GitHub commit (full hash in URL, 7-char display)
- Version tag only shown on prod (port 80/443 or no port), linked to GitHub release
- Staging (non-standard port) shows commit + engine only, no version noise
- Detect prod vs staging via location.port
- Updated tests: 16 cases covering prod/staging/links/edge cases
- Bumped cache busters

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-27 09:54:53 -07:00
Kpa-clawbot
a7a280801a feat: display version and commit hash in stats bar
Add formatVersionBadge() that renders version, short commit hash, and
engine as a single badge in the nav stats area. Format: v2.6.0 · abc1234 [go].
Skips commit when 'unknown' or missing. Truncates commit to 7 chars.
Replaces the standalone engine badge call in updateNavStats().

8 unit tests cover all edge cases (missing fields, v-prefix dedup,
unknown commit, truncation).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-27 09:52:13 -07:00
Kpa-clawbot
6cdbf7e3f6 perf(go): remove debug logging, update history
Remove temporary rf-cache debug logs. Update hicks history with
endpoint optimization learnings.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-27 09:49:46 -07:00
Kpa-clawbot
b42d7e3f14 debug: add RF cache logging
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-27 09:43:40 -07:00
Kpa-clawbot
6158734536 fix(go): fix RF cache - use separate mutex, TTL-only expiry
Previous approach invalidated cache on every ingest (every 1s with live
mesh data). Now uses TTL-only expiry (15s). Separate cache mutex avoids
data race with main store RWMutex.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-27 09:40:43 -07:00
Kpa-clawbot
0d9b535451 feat: add version and git commit to /api/stats and /api/health
Node.js: reads version from package.json, commit from .git-commit file
or git rev-parse --short HEAD at runtime, with unknown fallback.

Go: uses -ldflags build-time variables (Version, Commit) with fallback
to .git-commit file and git command at runtime.

Dockerfile: copies .git-commit if present (CI bakes it before build).
Dockerfile.go: passes APP_VERSION and GIT_COMMIT as build args to ldflags.
deploy.yml: writes GITHUB_SHA to .git-commit before docker build steps.
docker-compose.yml: passes build args to Go staging build.

Tests updated to verify version and commit fields in both endpoints.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-27 09:39:49 -07:00
Kpa-clawbot
ab879b78fe fix: remove continue-on-error from Go staging deploy — broken deploys should fail CI
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-27 09:37:14 -07:00
Kpa-clawbot
10c672f8d7 perf(go): add TTL cache for RF analytics response
Cache the computed RF analytics result for 15 seconds.
1.2M observation scan takes ~140ms; cached response <1ms.
Cache invalidated when new packets are ingested.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-27 09:35:51 -07:00
Kpa-clawbot
013a67481f ci: add Go staging auto-deploy to CI pipeline
Build and deploy the Go staging container (port 82) after Node staging
is healthy. Uses continue-on-error so Go staging failures don't block
the Node.js deploy. Health-checks the Go container for up to 60s and
verifies /api/stats returns the engine field.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-27 09:34:16 -07:00
Kpa-clawbot
73c1f6636e perf(go): optimize RF analytics inner loop
Move per-transmission work (hash indexing, type resolution, packet sizes)
outside the per-observation loop. Cache SNR dereference, pre-resolve type
name once per transmission. Reduces redundant map lookups from 1.2M to 52K.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-27 09:32:45 -07:00
Kpa-clawbot
a1e17ef171 feat: add engine identifier to /api/stats and /api/health
Both backends now return an 'engine' field ('node' or 'go') in
/api/stats and /api/health responses so the frontend can display
which backend is running.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-27 09:31:59 -07:00
Kpa-clawbot
e47b5f85ed feat: display backend engine badge in stats bar
Show [go] or [node] badge in the nav stats bar when /api/stats
returns an engine field. Gracefully hidden when field is absent.

- Add formatEngineBadge() to app.js (top-level, testable)
- Add .engine-badge CSS class using CSS variables
- Add 5 unit tests in test-frontend-helpers.js
- Bump cache busters

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-27 09:31:32 -07:00
Kpa-clawbot
876faa6e03 perf(go): optimize channels + RF with payload index and pre-allocation
- Add byPayloadType index to PacketStore for O(1) type-5 lookups
- Channels scan reduced from 52K to ~17K packets (3x fewer iterations)
- Use struct-based JSON decoding (avoids map[string]interface{} allocations)
- Pre-allocate snrVals/rssiVals/scatterAll with capacity hints for 1.2M obs
- Remove second-pass time.Parse loop (1.2M calls) in RF analytics
  Track min/max timestamps as strings during first pass instead
- Index also populated during IngestNewFromDB for new packets

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-27 09:27:38 -07:00
Kpa-clawbot
42afbb1398 perf(go): switch channels + RF analytics to in-memory store
Replace SQLite-backed handlers for /api/channels, /api/channels/:hash/messages,
/api/analytics/rf, and /api/analytics/channels with in-memory PacketStore queries.

Before (SQLite via packets_v VIEW on 1.2M rows):
  /api/channels              7.2s
  /api/channels/:hash/msgs   8.2s
  /api/analytics/rf           4.2s

After (in-memory scan of ~50K transmissions):
  Target: all under 100ms

Three new PacketStore methods:
- GetChannels(region) — filters payload_type 5 + decoded type CHAN
- GetChannelMessages(hash, limit, offset) — deduplicates by sender+hash
- GetAnalyticsRF(region) — full RF stats with histograms, scatter, per-type SNR

All handlers fall back to DB queries when store is nil (test compat).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-27 09:17:24 -07:00
Kpa-clawbot
bad023ccad fix: hide packet detail pane on fresh page load
Add detail-collapsed class to split-layout initial HTML so the empty
right panel is hidden before any packet is selected. The class is
already removed when a packet row is clicked and re-added when the
close button is pressed.

Add 3 tests verifying the detail pane starts collapsed and that
open/close toggling is wired correctly.

Bump cache busters.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-27 09:10:51 -07:00
Kpa-clawbot
afe16db960 feat(go-server): in-memory packet store — port of packet-store.js
Streams transmissions + observations from SQLite at startup into
5 indexed in-memory structures. QueryPackets and QueryGroupedPackets
now serve from RAM (<10ms) instead of hitting SQLite (2.3s).

- store.go: PacketStore with byHash, byTxID, byObsID, byObserver, byNode indexes
- main.go: create + load store at startup
- routes.go: dispatch to store for packet/stats endpoints
- websocket.go: poller ingests new transmissions into store

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-27 08:52:07 -07:00
Kpa-clawbot
1137dd1c08 test: close test gaps for #123 decrypted status and #131 WS handler runtime
Gap 1 (#123): Add 3 decoder tests for GRP_TXT decrypted status path.
Mock ChannelCrypto via require.cache to simulate successful decryption.
Tests cover: sender+message formatting, no-sender fallback, multi-key
iteration with first-match-wins semantics.

Gap 2 (#131): Rewrite 5 src.includes() string-match tests as runtime
vm.createContext tests. New makeNodesWsSandbox() helper with controllable
setTimeout, mock DOM, tracked API/cache calls, and real debouncedOnWS.
Tests verify: ADVERT triggers refresh, non-ADVERT ignored, debounce
collapses multiple ADVERTs, cache reset forces re-fetch, scroll/selection
preserved during WS-triggered refresh.

Decoder: 58 -> 61 tests. Frontend helpers: 87 (5 replaced, not added).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-27 08:47:52 -07:00
Kpa-clawbot
3cd6cb98fa ci: add Go build/test job, re-enable frontend coverage, clean up temp files
- Add go-build job to deploy.yml that builds and tests cmd/server and cmd/ingestor
- Go job gates the Node.js test job and deploy job
- Re-enable frontend coverage detection (was hardcoded to false)
- Remove stale temp files from repo root (recover-delta.sh, merge.sh, replacements.txt, reps.txt)
- Add temp scripts and Go build artifacts to .gitignore

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-27 08:47:10 -07:00
Kpa-clawbot
e3cb0421b1 fix(docker): resolve Go staging port conflict and MQTT connectivity
- Change staging-go HTTP port from 81 to 82 (via STAGING_GO_HTTP_PORT)
  to avoid conflict with CI's Node.js staging on port 81
- Change staging-go MQTT port from 1884 to 1885 (via STAGING_GO_MQTT_PORT)
  to avoid conflict with Node.js staging MQTT on port 1884
- Add MQTT_BROKER=mqtt://localhost:1883 env var so Go ingestor connects
  to its own internal mosquitto instead of unreachable prod external IP

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-27 08:42:51 -07:00
github-actions
724b9581fd ci: update test badges [skip ci] 2026-03-27 15:12:06 +00:00
Kpa-clawbot
99c23f8b59 feat: add observer packet comparison page (fixes #129)
Add #/compare page that lets users select two observers and compare
which packets each sees. Fetches last 24h of packets per observer,
computes set diff client-side using O(n) Set lookups. Shows summary
cards (both/only-A/only-B), stacked bar, type breakdown, and tabbed
detail tables. URL is shareable via ?a=ID1&b=ID2 query params.

- New file: public/compare.js (comparePacketSets + page module)
- Added compare button to observers page header
- 11 new tests for comparePacketSets (87 total frontend tests)
- Cache busters bumped

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-27 08:11:30 -07:00