main added a dynamically-discovered regions endpoint (region IATA system).
Port it to a RegionsService.GetRegions RPC: new regions.proto (Region /
RegionGroup messages), a handler reusing getAvailableRegions()/getRegionGroups(),
and useRegions/useRegionGroups switched to connect-query against the generated
types. The REST /api/regions route stays for coexistence.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
is_recent (and is_uplinked/has_packets) come back from ClickHouse as JSON
numbers (1/0); protobuf-es rejected them for the MqttTopic.is_recent bool
field ("expected boolean, got 1"). Add a bool() helper alongside num() and
apply it in the node handler.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Tighten request validation so invalid input is rejected at the edge with a
clear invalid_argument instead of silently producing empty results or opaque
ClickHouse 500s. Grounded against live data (pubkeys are exactly 64 hex,
channel_hash is one byte, before/after are DateTime64 cursors, etc.).
- Add reusable predefined string rules in rules.proto (proto2, required to
extend protovalidate's rule messages): hex64, datetime64, region. The
validator registers these via a registry in createValidator().
- public_key / origin_pubkey: exact 64-hex (hex64) instead of min_len 10.
- chat before/after: DateTime64 format (datetime64); channel_id: hex, max_len 2.
- private_keys: bounded list + base64/hex charset per element.
- node_types: bounded list + per-item length; SearchNodes requires >=1 query.
- region: length+charset bound (hex64/datetime64/region rules), now also on the
four StatsService requests which had no validation.
- map/neighbors: message-level CEL enforcing bbox ordering (min_lat<=max_lat,
min_lng<=max_lng).
Verified end-to-end against the Docker stack: all unary + server-streaming
validation rules reject bad input and accept valid input.
Remove the snake_case mirror interfaces and mapper functions that translated
generated protobuf-es messages for the components, and have the UI consume the
generated types directly (single source of truth = the proto schema).
- Hooks (useStats/useNeighbors/useNodeData/useMeshcoreSearch/useChatMessages)
return generated message types; delete toNodeData/toChatMessage/toSearchResult
and the snake_case select/.map adapters. Delete the dead useAllNeighbors hook
and src/types/map.ts; components import NodePosition/Neighbor/NeighborEdge/
Advert/SearchResult/ChatMessage from src/gen.
- Components read camelCase fields (node page, AdvertDetails, MapView, MapIcons,
stats page, search results, chat). useNodeData surfaces ConnectError with a
nodeErrorCode() helper for the error UI. Drop the always-empty Alt row in the
map popup (generated NodePosition has no altitude).
- buf lint (Option A): give each StatsService RPC its own request message, and
wrap the server-streaming responses (StreamChatResponse / StreamPacketsResponse).
Server stream handlers + the chat stream consumer updated accordingly.
- Add a buf CI workflow (lint/format/breaking on proto changes).
tsc, next build, and buf lint are clean; verified end-to-end in Docker.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- adv_timestamp is a uint32 epoch in ClickHouse; type it uint32 (was string,
which failed JSON encoding with "expected string, got <number>").
- ClickHouse serializes UInt64/aggregate columns (count(), message_count,
packet_count, advert_count) as JSON strings. Coerce every integer field with
a num() helper before building int32 proto messages, fixing intermittent
"expected number (int32), got \"97\"" errors on GetChat/GetNode/etc.
- Stop committing generated code: gitignore src/gen and regenerate it via a
`prebuild` (buf generate) step so `npm run build` always produces it.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Put a schema-first ConnectRPC contract in front of the API, served alongside
the existing REST routes (kept live for a gradual cutover).
- Proto: meshexplorer.v1 services (Map, Node, Neighbors, Stats, Chat, Packets)
in proto/, generated to src/gen via buf + protoc-gen-es. Request messages
carry buf.validate rules.
- Server: per-service handlers in src/server/connect/ reuse the existing
ClickHouse actions/streamers; mounted via @connectrpc/connect-next at
src/pages/api/[[...connect]].ts. A protovalidate interceptor enforces the
buf.validate rules on every request before handlers run.
- Client: connect-web transport + connect-query TransportProvider. Simple
hooks (stats, neighbors, all-neighbors) use connect-query; node/search/chat
and the map's imperative fetch use generated promise clients. Hooks map the
generated camelCase messages back to the existing snake_case shapes so
components are unchanged.
- Chat: live updates now come from the StreamChat server-streaming RPC
(history still paged via GetChat), replacing the 5s polling query.
- Two SSE endpoints become Connect server-streaming (StreamChat, StreamPackets).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Replace the hand-curated region groups with data-driven ones and make the
region_groups ClickHouse table the single source of truth.
- scripts/generate-region-groups.ts: offline generator — clusters regions by
cross-region packet co-occurrence (min-share single-linkage) at two levels
(broad "region" + tight "metro"), names clusters via `claude -p`, reconciles
codes by member overlap so permalinks stay stable, and emits the region_groups
seed. Migration 004 reseeded with the resulting 39 groups.
- Groups are DB-sourced: getRegionGroups() (cached) feeds /api/regions and the
dropdown/labels; filtering resolves a selector in SQL to a region
(region = 'X') or a group (region IN / hasAny ... SELECT region_code FROM
region_groups WHERE group_code = ...). No hardcoded membership in TS;
resolveSelector removed.
- Drop the TS<->SQL parity script (no membership left to sync); regionSql and
the migration ALIAS are kept in sync by hand.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Replace hardcoded (broker, topic) region slugs with uppercase IATA codes
derived from the meshcore/{IATA} base topic, discovered dynamically from
data (adding a region needs no code change). Adds region groups, Grafana
region/group filtering, and fixes the neighbor graph.
- regions.ts: single source of truth — regionFromTopic / normalizeRegion /
regionSql / resolveSelector / selectorLabel. Legacy slugs (seattle->SEA)
and bare meshcore + meshcore/salish -> SEA still resolve.
- regionGroups.ts + seeded region_groups table: PNW/CAL/DEU/POL.
- migration 004: region ALIAS column on meshcore_packets; 001 views expose
region / regions[]; reworked neighbor MV (region-scoped, no cross-region
edges, drops implausible >150km and (0,0) edges); scheduled meshcore_regions MV.
- API/streaming/actions resolve selectors; stream routes drop the hardcoded
region allow-lists; map node query excludes (0,0) sentinel nodes.
- Dynamic region/group dropdowns (useRegions/RegionSelect); /api/regions.
- Grafana: cascading $region / $region_group template vars + panel filters.
- region-parity.ts (npm run check:regions) guards TS<->SQL drift.
- nix dev shell (flake.nix, Node 24).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The letsmesh broker was migrated behind Cloudflare and changed its topic
layout on 2026-06-02, which left prod's MQTT client in a zombie state:
connected per paho's IsConnected() (so the 30s monitor never rebuilt it) but
receiving zero messages, because the subscription was established only once
after the initial connect and never re-applied on paho auto-reconnects. Result:
12 days of silently missing letsmesh ingestion while davekeogh masked the loss.
Make reconnection robust instead of relying on broker-side session persistence:
- Subscribe inside the OnConnect handler so every (re)connect — including paho
auto-reconnects — restores delivery. Use CleanSession(true)+ResumeSubs(false)
so we never depend on the broker remembering our session.
- Add a per-broker data-staleness watchdog: a broker that reports connected but
delivers no messages for MQTT_STALE_AFTER_SECONDS (default 300) is treated as a
zombie and force-rebuilt (disconnect + fresh connect/subscribe). This catches
exactly the failure IsConnected() misses.
- Reduce the external monitor to that watchdog role; transient drops are left to
paho auto-reconnect rather than racing it with a brand-new client.
- Stable per-broker client IDs (by index) and pre-sized MQTTClients slice so
indices stay aligned when an earlier broker fails; guard BrokerStatus/lastActivity
with a mutex; promote connect/subscribe logs to Info for visibility.
Adds unit tests for the watchdog and env parsing; documents the new env var.
Co-authored-by: Alex Vanderpot <alex@Alexs-MacBook-Pro-2.local>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Fixes a 25.x global memory-tracker drift where the tracker pinned at the
max-memory cap (RSS far below it), causing the OvercommitTracker to kill every
query (map/stats/neighbors all 500ing). Deployed in-place on prod over the
existing data dir after a cold backup.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The /api/chat endpoint queried the meshcore_public_channel_messages
VIEW, which does GROUP BY payload over all payload_type=5 packets.
Filtering its output on ingest_timestamp/channel_hash can't push below
the GROUP BY (they're max(...)/derived-from-grouped-payload), so every
call re-aggregated the entire history (~8M rows / 1.2 GiB / ~700ms),
ignoring the ingest_timestamp primary key.
Replace the view reference with an inline subquery
(publicChannelMessagesSubquery) that pushes the time/channel filters
into the inner meshcore_packets scan, so partition + primary-key
pruning applies. Region filtering stays on the outer query since
origin_path_info only exists post-aggregation. Same change to the chat
streaming poller.
Verified on prod: identical output, 8.06M->114K rows read, ~700ms->28ms.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- Point the seattle region at the letsmesh broker (wss://mqtt-us-v1.letsmesh.net:443,
topic meshcore/SEA) where Seattle traffic now lives.
- Fix a pre-existing bug in the path-edge extraction: `path` is a hex string of
1-byte hop prefixes, so use substring(path, 2*i-1, 2) instead of
hex(substring(path, i, 1)) (which re-hexed a single hex char and never matched
the 2-char repeater prefixes -> path edges were always empty). Seattle now yields
path edges again.
Verified on a full prod snapshot: the MV-backed "show all neighbors" query drops
from ~1.6s / 145M rows / 11.8 GiB to ~1ms / 108 rows / 3.8 KiB.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The two slow neighbor queries are converted to read precomputed tables that an
hourly REFRESH EVERY 1 HOUR materialized view maintains, instead of re-aggregating
meshcore_packets per request:
- meshcore_all_neighbor_edges: the global per-region edge graph (direct path_len=0
adverts + repeater-prefix path edges) with endpoint details. getAllNodeNeighbors
now filters it by region + bbox + lastSeen + has_location.
- meshcore_node_direct_neighbors: per-node direct adjacency (both directions) with
neighbor details. getMeshcoreNodeNeighbors now filters it by node_public_key.
Also add the meshcore/SEA topic to the seattle region. Validated on a clean local
stack: migration 001->003 applies, both refreshable MVs create + refresh + populate.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The readonly profile's max_rows_to_read / max_bytes_to_read (500MB) is exceeded by
the map/stats views, which scan the full (growing) meshcore_packets table -> the web
app failed with TOO_MANY_BYTES. Remove the read-size caps; readonly=1, allow_ddl=0,
max_memory_usage and max_execution_time remain the guardrails.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
ClickHouse's internal diagnostics grew unbounded (text_log at Trace level and the
1s query profiler -> trace_log accumulated ~160G over months). Add short TTLs to
all system *_log tables, cap text_log at warning level, and disable the query
profiler in both profiles so trace_log stays empty.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Pin the bundled service images to known versions for reproducible releases and
safe in-place reuse of an existing data dir (matching the production deployment).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Add the MeshCore dashboard (exported from prod) as a provisioned file
dashboard, with a file provider config. Pin the ClickHouse datasource
uid to "clickhouse" so the dashboard's panel datasource references
resolve at provision time.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Bundle Grafana (127.0.0.1:3000) with the grafana-clickhouse-datasource plugin
and an auto-provisioned ClickHouse datasource using the read-only user. Adds
GRAFANA_ADMIN_PASSWORD to .env.example. Verified: datasource health returns OK.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Module is now github.com/ajvpot/meshexplorer/ingest (the code lives under
ingest/ in the meshexplorer repo), updated from the old standalone
clickhouse-meshingest path. build/vet/test pass.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- Add a deploy-focused root README; update the web app README (meshcore-only,
point Docker usage at the unified root compose).
- Fix the migration runner: set the goose clickhouse dialect (it defaulted to
postgres and failed to create its version table). Migrations now apply cleanly.
- Remove the unused meshcore decrypt UDF (meshcore_try_decrypt was never called
by any view/query/code) and simplify the ClickHouse image to a single stage.
Verified end-to-end: `docker compose up` brings up clickhouse -> migrate ->
meshcoreingest + meshexplorer; live ingestion from the real MQTT brokers lands
packets in ClickHouse and the web API serves decoded meshcore nodes via the
readonly user.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Single root compose brings up the whole stack on one internal network:
clickhouse (healthchecked) -> migrate (one-shot) -> meshcoreingest + meshexplorer,
with the discord-bot behind a "bot" profile. Web app/bot connect as the readonly
ClickHouse user; ingest/migrate use the default user. Named volume replaces the
host /tank path. .env.example documents every variable with placeholders; root
.gitignore keeps real .env out of git. Drops the per-project compose files.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Meshtastic was UI-filtering only (no meshtastic data backend). Drop it as a
node type/option, and simplify the map marker/cluster/popup rendering now that
every node is meshcore. Update product copy to MeshCore-only. The nodeTypes
query plumbing stays (the unified view's type is always 'meshcore').
Production build passes.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Vendor the ingest service under ingest/ and move the web app under meshexplorer/.
The ingest builds the meshcoreingest daemon and the goose migration runner,
applies the meshcore ClickHouse schema (packets, adverts, unified node view),
and loads its MQTT broker list and ClickHouse settings entirely from environment
variables (MQTT_BROKERS as a JSON array, CLICKHOUSE_*). No credentials are baked
into the source.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>