Commit Graph
36 Commits
Author SHA1 Message Date
Codex 0a4c79d91d refactor(workers): own runtime contexts and isolate graph generations 2026-11-12 19:18:42 +00:00
Codex 35c0392e4b perf(worker): defer coverage imports and spatial trees in link mode 2026-11-12 09:14:12 +00:00
ben d9f07bc38e chore(infra): fix monitor probe, trust split and stale config
- remove duplicate YAML key left by the deleted Mosquitto alerts
- probe mesh-health-check's real /api/bootstrap endpoint
- app/website nginx trust only their own Anubis edge
- use the default POSTGRES_USER for the tagger DB
- drop the unused Mosquitto 1883 listener and CORS/doc drift
2026-11-12 01:53:29 +00:00
hermes-gadget c807ccfabf p1: qualify link worker packet reads 2026-11-03 13:00:35 +00:00
hermes-gadget 477c2546c1 p1: qualify remaining worker nodes references 2026-11-03 12:44:28 +00:00
hermes-gadget e37dc9abce p1: qualify coverage and link radio tables in RF worker 2026-11-03 00:58:31 +00:00
hermes-gadget 6a7bd84aa0 p1: qualify node links in RF worker 2026-11-03 00:56:50 +00:00
hermes-gadget 7ef35af116 p1: qualify link worker commits for ops schema 2026-11-02 23:55:17 +00:00
hermes-gadget 1c6d95d05c test(path-beta): give the worker-pool replacement budget room for a cold start 2026-10-25 04:19:50 +00:00
hermes-gadgetandhermes-gadget e069f6b102 fix: close Wave 3 medium findings (owner auth, deploy, newuser, alerts, gitleaks, viewshed) (#64)
* fix(owner): Wave 3 mediums — password handling, deploy rollback, newuser races, session revocation

- BUG-017: stop trimming MQTT passwords (frontend + backend). A valid
  broker password may begin/end with whitespace; trimming made it
  permanently unauthenticatable. Username trimming unchanged.
- BUG-013: deploy-website.sh now set -Eeuo pipefail with an EXIT rollback
  trap armed only after the pin mutates; container-down and bundle-mismatch
  paths fail loudly and restore the old pin + verify the restored service.
- BUG-012: newuser.sh installs an EXIT trap (ERR does not fire on explicit
  exit 1 from die()) so every post-mutation failure rolls back; rollback is
  idempotent and a no-op before any mutation flag. Disarm points clear EXIT.
- BUG-011: newuser.sh re-reads + re-validates OWNER_MQTT_USERNAME_MAP under
  the re-acquired lock after the long unlocked discovery window, then merges
  the new grant into the current map — concurrent provisioning runs can no
  longer be overwritten by a stale snapshot.
- BUG-010: owner sessions are now v3 cookies carrying a credential
  generation (Redis-backed). When the broker rejects a previously-valid
  password (revocation detected), the generation bumps and every older
  session is rejected on the next request. TTL shortened 30d -> 7d.

Verified: tsc clean, 310/310 backend tests pass, bash -n on both scripts.

* fix(alert-receiver): durable alert delivery with bounded retry + dead-letter (BUG-014)

Forwarding was fire-and-forget: failures logged asynchronously after HTTP 202,
/healthz stayed green, and alerts could be archived to the local JSONL while
operators never saw them. Now:
- Every receipt is enqueued for delivery with bounded exponential backoff
  (ALERT_FORWARD_MAX_ATTEMPTS=5, base 1s, cap 60s) and dead-lettered to
  receipts.jsonl.dead after exhausting attempts.
- /healthz keeps returning 200 (compose wget healthcheck must not restart
  the container) but the body reports degraded status + detail; new /readyz
  returns 503 when ALERT_FORWARD_URL is unset (archive-only), no successful
  forward since startup, or alerts stuck undelivered >5min.

Verified: tsc clean, 310/310 tests pass.

* fix(ci): classify reviewed public channel keys + fixtures in gitleaks (BUG-009)

The nightly full-history secret scan flagged 42 findings spanning the
documented community channel keys (VALIDATED_CHANNELS — intentionally
public, each verified to decrypt real UK Mesh group text), fake test
fixtures, and a deployed-commit SHA in the website live manifests. That
made a genuine credential easy to dismiss among expected hits.

- Rule-scoped allowlists with exact fingerprints (regexTarget: secret,
  anchored full-value matches) for the Public channel key, test fixtures
  (0123456789... / abcdef0123...), and the manifest commit SHA.
- Structure-exact line allowlist for channelRegistry.ts VALIDATED_CHANNELS.
- Verified locally with gitleaks 8.24.3 full-history scan: 42 -> 0 findings.

* fix(viewshed): side-effect completion markers prevent skipped link jobs (BUG-006)

store_coverage() commits on an autocommit connection, then the worker queues
physical-link jobs and publishes Redis notifications. A Redis failure after
the DB commit NACKed the job; on retry already_calculated() saw the coverage
row and returned early — link work and frontend notifications were skipped
forever.

- Record a Redis completion marker (viewshed:side-effects:<node>) only after
  EVERY side effect succeeds.
- On the already_calculated early return, a missing marker triggers an
  idempotent replay: link jobs are re-enqueued from the stored node position
  (admission is idempotent) and coverage_update/node_upsert notifications are
  re-published from the stored coverage row.
- Redis read failures are treated as incomplete (replay attempt re-raises and
  NACKs rather than silently skipping).
- Added tests/test_side_effect_markers.py (5 tests) with a conftest that stubs
  osgeo/psycopg2 so pure-logic worker tests run without GDAL (CI keeps real
  GDAL via setdefault). Verified: 5/5 new tests pass; full suite 34 passed,
  2 GDAL-required terrain tests fail only in stub env (pass in CI image).

---------

Co-authored-by: hermes-gadget <hermes-gadget@users.noreply.github.com>
2026-08-11 22:50:16 +01:00
gadgethd 6e07077e60 perf: make link worker change driven 2026-08-09 16:16:43 +00:00
gadgethd 133a2eefca fix: reconnect worker DB on InterfaceError; rate-limit error logging 2026-08-03 15:12:05 +01:00
gadgethd 5db382e181 feat: complete codebase reliability upgrade 2026-08-02 03:40:11 +01:00
gadgethd b9b2ecdbfa Harden CI and background worker reliability 2026-07-28 23:17:49 +01:00
gadgethd 1ebc496965 Map UI redesign, live-path visibility, feed latency, and security hardening (#19)
* Fix map node freshness consistency

* Harden output, ingest, caches, and WebSocket limits

* Enforce public visibility across derived data

* Harden proxy and operator deployment boundary

* Make owner grants authoritative and reconcile ACLs safely

* Bound path, spam, and statistics analysis

* Make link and coverage jobs crash-safe

* Implement strategic security remediation

* Fix production cutover configuration

* Fix disabled viewshed worker health signal

* Serve stale stats during background refresh

* Retain stale stats through refresh windows

* Bound analytics work to protect ingestion

* Prioritize summary warmup over chart scans

* Throttle path history rebuilds

* Bound path history result memory

* Stream path history aggregation

* Give bounded path rebuild one CPU

* Serve stale charts during bounded refresh

* Prioritize startup stats before chart scans

* Bound path history segment cardinality

* Pin path rebuild context to privacy generation

* Self-host original frontend fonts

* Allow bounded path rebuild to complete

* Improve live map UI and low-latency group feed

- Dock node details on the right with selection highlight and collapsible layers
- Add node legend, 24h activity sparkline, copy-link, and layout/overlap fixes
- Keep all repeaters visible during Live Path focus
- Send GroupText feed packets immediately over WebSocket (no batch delay)
- Cache expensive stats/observer activity more aggressively to protect ingest
- Remove stale local planning/audit markdown from the tree

* fix(ci): supply OPERATOR_SITE_TOKEN for compose validation

Workers/Compose CI failed because docker-compose requires
OPERATOR_SITE_TOKEN. Add CI placeholders for that and MQTT_PASSWORD.
2026-07-27 02:39:12 +01:00
gadgethd 93cc3e1b38 Expand network intelligence and harden operations (#9)
Consolidates the stacked backend, privacy, network-intelligence, frontend, operations, mobile, and owner-cache changes after resolving main conflicts and passing the full CI suite.
2026-07-23 20:50:47 +01:00
BenandClaude Sonnet 4.6 edc8206a22 Add ML path learner, Anubis bot protection, planned coverage, companion page, and misc improvements
- ml-path-learner: new Python worker that trains a prefix→node ML model from gold paths and writes scores to ml_path_prefix_scores
- lazyResolver: integrate ML scores and edge priors into tiered candidate ranking; bidirectional pass-2 propagation; global cross-group direct anchors
- Anubis: add sidecar bot-protection containers for all public HTTP services; botPolicy.yaml
- Planned coverage: new API route + frontend map layers for placing hypothetical repeaters and computing coverage
- Map: light/dark theme toggle; map-tools button group (LOS, Repeater, theme); plan-repeater mode with click-to-place/remove and polling
- Frontend: remove inferred nodes from map display (backend inference kept for internal use)
- Stats page: observer region summary, channel traffic, companion activity endpoints and UI
- UKCompanionPage: new companion activity page
- Teesside site: extracted into standalone build context (teesside-site/)
- healthcheck overrides: share.html, sw.js, region filter support, SVG score ring updates
- DB: dedicated analytics pool; DATABASE_SKIP_SCHEMA_INIT flag; path hash prefix indexes; lateral join fixes for node_link_radio_reports
- docker-compose: ml-path-learner service; anubis sidecars; DATABASE_SKIP_SCHEMA_INIT on all workers; OBSERVER_RETENTION_SECONDS; REGIONS_FILE
- backend-site: internal operator dashboard routes
- docker/mesh-health-check-entrypoint.sh: extract channel secret from MESHCORE_CHANNEL_SECRETS at startup
- scripts: observer key generation, observer registration, healthcheck tunnel check
- vacuum-compressed-chunks.sh: maintenance script

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-03 01:33:48 +00:00
BenandClaude Opus 4.6 7994e13175 Add SEO, improve path resolution, per-node antenna heights, and UI refinements
Backend: derive observer IATA from packet topic instead of node table,
send messages separately in WS initial state, add tiered prefix/edge
priors to lazy path resolver for more accurate hash disambiguation.

Frontend: add SeoHead, JsonLd, and vite-seo plugin for per-route meta
tags and structured data. Add earth-curvature correction to custom LOS
tool. Owner portal last-hop chart supports hiding/showing individual
series with cookie persistence. Feed page and path map refactored.
Cache-busting build filenames. Track firstSeenTs on aggregated packets.

Infra: serve robots.txt and sitemap.xml via nginx, add manifest.json,
reduce Mosquitto log verbosity. Viewshed worker supports per-node
antenna heights, configurable profile step, and SNR-median calibration.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-27 17:22:31 +00:00
Ben 21224a0525 Refactor backend, map, and worker boundaries
- split backend API into route/service/repository boundaries across stats, owner, and pathing\n- extract shared API bootstrap and helper modules\n- reduce MapLibreMap into smaller frontend map modules with extracted builders, config, popup UI, and types\n- continue worker modularization by extracting RF terrain/tile helpers alongside RF config and loss helpers\n- add repo-local architecture, DB lifecycle, link model, pathing, frontend map, and contributing docs\n\nThis is the verified refactor checkpoint: backend and frontend builds passed, worker syntax checks passed, affected containers were rebuilt, and /healthz is OK.
2026-03-20 17:45:47 +00:00
Ben 812aa95837 Tune RF link model and fix map stale link nodes 2026-03-20 00:41:02 +00:00
Ben 8db9a71e43 Rewrite map stack and tighten path topology 2026-03-19 22:42:35 +00:00
BenandClaude Sonnet 4.6 0c5c97df39 Add Teesside Mesh dashboard and path-beta worker improvements
- New www.teessidemesh.com single-page dashboard (TeessieDashboard.tsx)
  with amber/charcoal theme, connectivity status, repeater cards with
  7-day battery sparklines, MQTT observer grid, and decoded packet feed
- Backend: cross-network connectivity endpoint (hop-count packet matching),
  radio-stats and radio-history proxy endpoints, observer-activity endpoint,
  nodesDay stat field
- docker-compose: website-teesside service on port 3002
- Path-beta: worker pool, resolve cache, and pool refactor for performance
- Connection monitor, WS server and MQTT client improvements
- Mosquitto config, viewshed worker, and frontend UI polish

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-16 02:01:54 +00:00
BenandClaude Opus 4.6 ad4ce0dbb1 Add repeater search page, UK bounds filter, and performance improvements
- New /repeater route with search and detailed repeater cards
- UK geographic bounds filter for viewshed calculations
- Advert packets API endpoint (GET /api/nodes/:id/adverts)
- Battery calculation fix (3.0V-4.2V range)
- NodeMarker optimizations (CircleMarker for repeaters)
- Map z-index adjustments for link lines
- Database performance indexes
- Nginx gzip compression
- Exclude mosquitto/acl and multipath.md from git

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-14 22:31:10 +00:00
Ben 4793fb9a6e Label database clients by service 2026-03-09 02:48:59 +00:00
Ben 7e4d9749ae Improve path resolution and backend connection handling 2026-03-08 03:03:58 +00:00
Ben a7503ef3f2 Refine coverage, owner links, and UK feed 2026-03-08 01:16:58 +00:00
Ben cae0580609 Support multibyte path hashes across live pathing 2026-03-07 15:51:29 +00:00
Ben 05514fdc18 Add owner auth DB, website refresh, and coverage rollback 2026-03-07 03:23:52 +00:00
Ben fe56f39007 Refine beta path rendering, confidence split, and adverts source anchoring 2026-03-06 00:44:07 +00:00
Ben 0e365479a6 Split workers, fix frontend proxy resilience, expand health UX/docs 2026-03-05 00:39:44 +00:00
Ben fb6e1369a7 Harden network filtering and coordinate handling across sites 2026-03-04 22:36:53 +00:00
BenandClaude Sonnet 4.6 17fd8cbb9b Add force_viable links, restore fade margin, improve path routing
- Add force_viable column to node_links to permanently force specific
  RF links regardless of ITM path loss calculation
- Force Hartlepool-RPT <-> YM-NM-RPT link (147.6 dB, confirmed by 4368
  observations but above the 138 dB fade margin threshold)
- Restore FADE_MARGIN_DB=10 in ITM viability check (both code paths)
- Reduce last-resort fallback distance from 500 km to 150 km in the
  backtracking DFS path resolver
- getViableLinkPairs and /api/nodes/:id/links now include force_viable=true
- Add useLinks hook for link state management

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-04 03:14:24 +00:00
BenandClaude Sonnet 4.6 4969ac28b7 Live confirmed-link learning and real-time frontend updates
- Worker loads confirmed links (itm_viable + observed_count >= 5) when
  resolving relay hashes — prefers known neighbours over geographic
  proximity, creating a self-improving feedback loop as traffic accumulates
- Visited-node set added to worker resolver (each node relays once per packet)
- Frontend handles live link_update WebSocket messages: linkPairs and
  viablePairsArr updated in real-time without page refresh
- MIN_LINK_OBSERVATIONS constant defined in both worker and frontend (5)
- link_update added to WSMessageType union

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-04 02:39:30 +00:00
BenandClaude Sonnet 4.6 99daf1e4d2 Add node links, improved path resolution, and confirmed neighbours
- node_links table: stores ITM-viable hop pairs from observed packet paths
  with directional counts (count_a_to_b / count_b_to_a) and path loss dB
- Historical backfill: decodes all stored packets on first run to populate links
- Per-node /api/nodes/:id/links endpoint: fetched on popup open (not preloaded)
- Node popup: shows confirmed neighbours with directional arrows and path loss
- Links layer: amber polylines on map showing all ITM-viable link pairs
- Beta path resolver rewritten as backtracking DFS:
  - Confirmed neighbours tried first (real observed link data)
  - Falls back to closest node within terrain-derived radio range
  - Backtracks when a candidate leads to dead ends at subsequent hops
  - Skips capped at ceil(hops/3) to prevent degenerate all-skip paths
  - Visited set enforces each node appears at most once per path
  - hopCount used to slice path_hashes to actual relay count
- Viable link pairs sent in WebSocket initial_state for path resolution
- LINK_BUDGET_DB raised to 148 dB; fade margin removed from viability check
- Viewshed worker: directional link tracking, UK mainland clipping fixes

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-04 02:27:27 +00:00
BenandClaude Sonnet 4.6 26d96133af Add Paths (Beta), node elevation, and coverage preview
- Paths (Beta): new map layer with confidence-scored packet path resolution.
  Per-hop candidates filtered by 2-char node ID prefix, ranked by proximity
  to the interpolated src-to-rx line. Each hop scored by ambiguity factor
  (1/n_candidates) and distance factor (reachable within elevation-derived
  range). Threshold slider in the filter panel (default 50%). Purple dashed
  polyline, separate from the existing packet paths layer.

- Node elevation: viewshed worker now writes terrain elevation (m ASL) to
  nodes.elevation_m when computing each viewshed, and backfills existing
  nodes from stored radius_m on startup. Elevation shown in node popup.

- Coverage preview: "Preview coverage" button in node popup shows that
  node's viewshed at lower opacity (10%) for 20 seconds then auto-dismisses.

- Beta path range uses stored radius_m from node_coverage directly instead
  of bounding box estimation.

- Fix homepage Live Map button to link directly to app.teessidemesh.com.

- README Phase 3: clarify nodes must be on MQTT to be claimable.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-03 23:10:18 +00:00
Ben cb713d6c1a Initial commit 2026-03-03 19:11:05 +00:00