Commit Graph
123 Commits
Author SHA1 Message Date
efiten f280dec686 android: keep the WebView running with the screen off
Three v1.24.3 field logs of 2026-11-11 (three phones) show the same thing:
about 60 s after "app hidden" every upload, RF sample, region ask and uplink
ping stops until the screen is back on, for 7 to 25 minutes, while receptions
and discover go on. The catch-up of 149e39b keeps monitorTick alive but not
the jobs that wait on a timer, on IndexedDB or on the broker.

What changes:
- AlwaysVisibleWebView reports its window as visible at all times, so
  Chromium never treats the page as hidden. An app copy of
  capacitor_bridge_layout_main.xml puts it in place of CapacitorWebView.
- MainActivity sends appHidden / appVisible on onStop / onStart, because
  visibilitychange no longer fires. app.js logs both, wakelock.js re-acquires
  the screen lock on appVisible and leaves one that is still held alone.
- Service worker cache v64.

Verified: npm test, 485 of 485 pass. assembleDebug builds, and aapt2 shows
eu.on8ar.coredriverx.AlwaysVisibleWebView in the APK's layout.

Not verified: that this stops the freeze. No phone has run this build yet.
Battery use with the screen off is not measured. No version bump and no
release notes: those follow once a screen-off drive confirms it.
The web app (Chrome, Bluefy) is not changed by this and still freezes.
2026-11-11 20:09:21 +01:00
efiten 86de4f69ad android: one-time battery tip before the first Connect
A OnePlus closed the app during a test walk (exit reason o-kill, importance
125, so with the foreground service running). Without an extra permission
the app cannot prevent that, so before the first Connect in the Android app
a popup says to set the battery setting to Unrestricted, linking
dontkillmyapp.com. Shown once (localStorage flag); storage that throws skips
it rather than blocking Connect. Same text in the user guide.

Release v1.24.3, SW cache coredrive-rx-v63.
2026-11-11 14:02:18 +01:00
efiten c761c65709 android: ask for notification permission before capture starts
On Android 13+ the foreground service notification stays hidden until the
user allows notifications, and background-geolocation does not ask.
NativeGps.start now calls LocalNotifications.requestPermissions() before
addWatcher; a refusal or error does not stop capture.

Release v1.24.2, SW cache coredrive-rx-v62.
2026-11-11 12:43:42 +01:00
efiten 149e39bb50 fix(native): keep uploading with the screen off
Field log 2026-11-10: with the screen off the Android WebView stopped
running JavaScript timers while Bluetooth frames and GPS fixes kept
arriving. For eleven minutes receptions were queued but nothing was
published, no RF sample was taken, no discover, region ask or uplink ping
went out, and the broker dropped the link for want of a keepalive. The
116-record backlog went out when the screen came back on; positions and
rx_at in client_rx_observations were correct.

Every frame and GPS fix now calls catchUp, which runs the jobs whose timer
is overdue: the monitor tick, the drain, the pending RF sample and, when
the drain is late and the broker link is down, one reconnect per 15 s.
src/catchup.js holds the decision (test/catchup.test.mjs). The debug log
now records when the app is hidden and visible again. Not yet tested on
the phone.
2026-11-10 22:20:04 +01:00
efiten 3963704592 fix(native): share the debug log through the Android share sheet
In the Android app the Share button did nothing: the WebView has no
navigator.share, and the download-link fallback is ignored there. The
native app now writes the log to its cache (@capacitor/filesystem 8.1.5)
and opens the share sheet with it as a .txt attachment (@capacitor/share
8.0.3). The web paths are unchanged. pickShareMethod picks 'native' first;
test/sharelog.test.mjs covers it.
2026-11-10 22:20:03 +01:00
efiten 26e2b096ba feat(native): scan the deployment URL from a QR code
The Deployment card in Settings gets a "Scan QR code" button. It uses
BarcodeScanner.scan() of @capacitor-mlkit/barcode-scanning 8.2.1 (exact; 8.2.2
was 10 days old), which runs the Google code scanner in Play services: its own
camera screen, no camera permission, the module downloaded once on first use
with progress shown in the card. A scanned code must spell out https:// itself
and then goes through the same config.json check as a typed URL. A cancelled
scan is silent; a QR code that is not a deployment URL says so.

The QR code itself comes from CoreScope's Coverage page (clientRxCoverage.appUrl),
which is a separate change in the CoreScope repository.

android/app/build.gradle leaves libbarhopper_v3.so out of the APK: that is the
bundled ML Kit detector used only by startScan and readBarcodesFromImage, which
the app never calls. Debug APK 29.5 MB with it, 9.2 MB without (4.9 MB before
the plugin).

- src/qrscan.js + test/qrscan.test.mjs: 8 tests (468 total pass)
- web build checked headless: appver filled, Deployment card hidden

Not tested on a device: the scan, the module download and the size cut are
unverified on hardware.
2026-11-10 09:38:25 +01:00
efiten 65de1920f9 feat(native): choose the deployment at runtime instead of baking config.json into the APK
The APK carried the config.json that happened to be in public/ at build time, so
every APK belonged to one deployment, and a real one would have put the broker
login inside the file.

The native app now asks for the URL of a CoreDrive RX web deployment under
Settings and reads that deployment's config.json through CapacitorHttp, outside
the WebView, so the deployment needs no CORS header for it. A new URL is checked
before it replaces the old one. The last good config of the same deployment is
kept in localStorage and used when a start has no network; a different
deployment drops it. android:sync removes config.json from the APK assets.

- src/deployment.js: URL normalization (https only), fetch + validate + cache
- src/config.js: setConfigSource and parseConfigText, fetch path unchanged
- test/deployment.test.mjs: 11 tests (460 total pass)
- web build checked headless: appver filled, Deployment card hidden

Not tested on a device yet.
2026-11-10 09:04:56 +01:00
efitenandClaude Opus 5.5 b6f90aed40 feat(native): Capacitor Bluetooth transport and background GPS behind src/platform.js
Step 1 of a native Android app (issue #13). The Android WebView has no Web
Bluetooth, so CapacitorBleTransport (src/transport-native.js) implements
the WebBluetoothTransport API on @capacitor-community/bluetooth-le: NUS
service, notify to every onFrame listener, serialised writes, reconnect
with backoff. The plugin requests a 512-byte MTU on connect (Device.kt).

NativeGps (src/gps-native.js) uses @capacitor-community/background-
geolocation with a backgroundMessage, which runs a foreground service, so
fixes should keep coming with the screen off. That is the point of the
native app; it is not verified on a device yet.

src/platform.js picks one or the other via Capacitor.isNativePlatform().
In the browser nothing changes in behaviour; the web bundle grows by
about 21 kB (512 kB, was 490 kB) because the plugin JS is now imported.
The service worker is not registered in the native app, and the Web
Bluetooth notice is not shown there.

Tests: 9 new in test/native.test.mjs with injected plugin fakes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 23:46:21 +01:00
efitenandClaude Opus 5.5 f5c231f58e feat(msgwait): count direct messages only, filter every companion channel
The first version filtered only #coredrive. Reading every channel slot of
the companion (CMD_GET_CHANNEL, once per connection, only with the notice
on) lets the app recognise any channel message the way the firmware does:
channel hash, then MAC (Mesh.cpp:225-236), for GRP_TXT and GRP_DATA. What
still triggers a count is a direct message or a room-server post.

The slots cannot change during the connection: the MeshCore app cannot
reach the companion while CoreDrive RX holds the BLE link. A slot the
uplink ping writes is added to the list as well.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 22:13:43 +01:00
efitenandClaude Opus 5.5 79c49e6ab1 feat: optional notice when a message waits on the companion
While CoreDrive RX holds the BLE link the MeshCore app cannot, so a user
asked whether they would miss messages. The companion already pushes a
one-byte PUSH_CODE_MSG_WAITING (0x83) per queued message; the app now
counts those on Home, behind a Settings toggle that is off by default,
with an optional two-tone sound. Nothing is fetched: CMD_SYNC_NEXT_MESSAGE
would remove the message from the companion's queue.

The push carries no type, so #coredrive traffic of other clients would be
counted too. src/msgwait.js matches each push against the 0x88 that came
just before it (logged before processing, Dispatcher.cpp:199): the first
copy of another client's ping-channel GRP_TXT expects one push, which is
swallowed; re-broadcasts expect none (wasSeen, Mesh.cpp:233); echoes of
our own ping expect none (markSeen on send, Mesh.cpp:651). A promise
chain keeps the async decrypt of the 0x88 ahead of the 0x83.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 22:07:35 +01:00
efitenandClaude Opus 5.5 a7a72d7eb7 fix(drain): keep another companion's backlog until it is connected
drainOnce published a row stamped with an earlier companion under that
companion's pubkey while the MQTT clientId was the companion connected
now. The documented ACL binds the topic to ${clientid}, so the broker
denies that publish, and with EMQX's default deny_action=ignore it still
sends a PUBACK. The row was removed from the queue and never stored.

Such rows now stay in the queue (counted as `waiting`) and go out once
their own companion is connected. The hold is asked for the connected
companion only. The debug log says once how many rows are waiting.

Tests: 430 pass (sandboxed run of the full suite). Not tested against a
live broker.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NEgJ9U9V5WmHyRjL96MaDz
2026-10-23 09:19:50 +02:00
efitenandClaude Opus 5.5 2c1905f077 fix(config): keep verifyAdverts through normalizeConfig
normalizeConfig (src/config.js) copied every feature flag except
verifyAdverts. processFrame reads the flag from the normalized config
(src/app.js:1333), so verifyAdverts:true in config.json never reached
heardKeyAfterVerify and 0-hop adverts with an invalid signature were
still accepted under their claimed pubkey.

The existing test only called featureEnabled on hand-built objects.
The new test goes through normalizeConfig: true when set, false when
absent or false.

Tests: node --test, 429/429 pass (run in the WSL sandbox with the
installed node_modules of 4a91f20; the worktree has no node_modules).
Not done: version bump and docs/releases entry.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NEgJ9U9V5WmHyRjL96MaDz
2026-10-23 00:26:21 +02:00
efitenandClaude Opus 5.5 52c95526a5 feat: choose the uplink ping scope from the repeaters around the companion (v1.22.0)
A fixed uplinkScope ("be") reaches almost nobody just over the border: of
the Limburg border repeaters in CoreScope's node_declared_regions, many in NL
declare only *, nl or nl-li. uplinkScope is now a preference list
("de,nl,be"). Per ping, src/autoscope.js counts how many of the repeaters
heard directly in the last 5 minutes forward each candidate (the companion's
default scope first, then the list) and takes the most forwarded. With none
forwarded but *, the ping goes out un-scoped (fw v12+); with nothing known,
in the companion's default scope (CMD_GET_DEFAULT_FLOOD_SCOPE, fw v10+).

Declared regions come from CoreScope GET /api/nodes/declared-regions
(uplinkRegionsUrl, default corescopeUrl + that path, every 30 min) merged
with this session's own region answers. The MQTT payload is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 21:28:16 +02:00
efitenandClaude Opus 5.5 9b1ff057ed feat: "Uplink ping now" button to test a spot
Sends one uplink ping immediately from Settings → Diagnostics, shown once
the ping channel is set up. It skips the interval, distance, parked and
skip-cell rules (the skip cells live on the phone, so a spot already
pinged could not be retested for 7 days); the hourly cap and a GPS fix are
still required.

Field test on rx.on8ar.eu/beta, 2026-10-16: ping cdrx 78277c0e was echoed by
1403 and c0cd directly and via 1403→e470 and 1403→…→0606. The echo hash
b76c6a2777f9b0e9 matches the transmission CoreScope received from 15
observers (TRANSPORT_FLOOD, scope be, first hop 1403). Release notes updated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 16:14:23 +02:00
efitenandClaude Opus 5.5 70a59c6197 feat: uplink ping, test whether the mesh hears the companion
CoreDrive only measured what the companion hears. With uplinkPing on (off by
default), it sends a short message on a dedicated hashtag channel
(#coredrive) carrying only a random tag, listens 10 s for a repeater
re-broadcasting it, and publishes the result on the new topic
meshcore/client/{pk}/uplink (UPLINK_PING): tag, packet hash of the echo,
every echo with its first and last hop, and the GPS fix. The position never
goes over the mesh.

- src/grptxt.js: hashtag channel key, channel hash, GRP_TXT MAC check and
  AES-128-ECB decrypt, and the packet hash, per the firmware
  (Mesh.cpp:540-557, Utils.cpp:127-145, Packet.cpp:41-50). Checked against a
  real #wardriving packet from CoreScope live: same text and same hash
  (12c82f82df4cc29c). AES-ECB comes from @noble/ciphers 2.0.1, as WebCrypto
  has no ECB.
- src/uplinkping.js: channel message, get/set channel and flood-scope frames
  (companion_radio/MyMesh.cpp), slot choice that never overwrites another
  channel, echo matching on the tag.
- src/uplinksched.js: a ping only with a fix of 100 m or better, after
  uplinkIntervalSec (60) and uplinkMinMoveM (250), under uplinkMaxPerHour (50),
  and not in a ~180 m cell pinged in the last uplinkSkipDays (7).
- uplinkScope (e.g. "be") sends the ping as a region-scoped flood via
  CMD_SET_FLOOD_SCOPE (fw v8+) and resets the override right after.
- app.js holds the radio (acquireRadio) for the whole exchange, as OK/ERR
  replies carry no correlator; it skips while parked, signing or asking.
- DEVICE_INFO now yields the channel slot count; log header gets a ping row.

Tests: 417 pass (+20): crypto against the real packet, frames, slot choice,
echo matching, scheduler, config defaults, payload shape, header row. Not
tested on air: no ping has been sent from a real companion yet.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 15:52:02 +02:00
efitenandClaude Opus 5.5 5da69305b8 feat: ask a repeater without a CoreScope name for its own name
Field case 2026-10-16: c0cdee59e0db981b answered every discover sweep,
but CoreScope has never seen its advert, so it stayed a bare prefix and
got no regions ask either.

- nodeNames flag (on when config.json exists and omits it, off without
  a config, like regionDiscovery). With it on, discover requests drop
  DISCOVER_PREFIX_ONLY, so replies carry the full 32-byte pubkey
  (+24 bytes each, simple_repeater/MyMesh.cpp:824).
- A repeater heard in range is looked up once per session. Only when
  CoreScope answers without a name is it asked ANON_REQ_TYPE_OWNER
  (MyMesh.cpp:165). The reply is "name\nowner_info"; owner_info is
  dropped.
- Name and regions asks share one queue and one per-encounter budget
  (src/asknext.js): the companion keeps one pending anon request
  (companion_radio/MyMesh.cpp:1570) and the repeater limiter is shared
  across request types. The name is asked first.
- The name replaces the prefix in the recent list and regions card, and
  is published on meshcore/client/{pk}/names as NODE_NAME with the
  companion's fix. New topic; /packets is unchanged.
- Debug header: a names row and nodeNames in the config row.

Not done: CoreScope does not ingest /names yet.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 09:25:48 +02:00
efitenandClaude Opus 5.5 11ca093dd9 feat(names): resolve an ambiguous path hash to its one forwarder
A 2-byte path hash that CoreScope calls ambiguous stayed a bare prefix,
even when the only other match cannot forward. Field case 2026-10-16:
e470 matched BE-HSS-HVZZWL-DIS (repeater) and Aegis (companion), so the
repeater got no name and no regions ask.

Companions and sensors do not forward by default
(companion_radio/MyMesh.cpp:486), so for keys of 4 bytes or fewer the
candidates are fetched from the new optional searchUrl
(/api/nodes/search) and narrowed to repeater/room. Exactly one left:
that is the node. A full search page (10 rows) decides nothing, because
it may have cut off a second forwarder.

Not covered: a companion with client-repeat turned on is ignored here.
Resolve and pubkey lookups now share one session cache.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 09:25:34 +02:00
efitenandClaude Opus 5.5 5a4319736e fix(account): a linked companion no longer goes to My nodes
CoreScope stopped adding linked companions to My nodes (a companion is
not a node to monitor), and its link answer has no myNodes field any
more. The card and the log no longer mention My nodes, and an answer
from an earlier server build that still carries the field is ignored.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-09 15:39:53 +02:00
efitenandClaude Opus 5.5 ea69769d5f fix(account): show the login only when CoreScope announces companion linking
A CoreScope with accounts but without companion linking (v3.14) sends
userManagement.enabled and answers POST /api/auth/device-token with its
SPA page, so the card appeared and every login failed with 'HTTP 200'.
Discovery now also needs userManagement.companionLinking; without it
the card stays hidden and uploading is as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-09 11:41:28 +02:00
efitenandClaude Opus 5.5 b1d43baf2d fix(account): retry a missing discovery and a waiting link with backoff
A CoreScope that was briefly unreachable at start, a slow mobile
request or a 429 left the link waiting, and only an 'online' event or a
reconnect asked again; navigator.onLine rarely changes, so a held queue
could stay held for the whole session. Both are now asked again after
30 s, 60 s, 2, 5 and then every 10 minutes, and stop on an answer.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-09 11:11:47 +02:00
efitenandClaude Opus 5.5 0883f43b22 fix(account): a link attempt belongs to one companion; a BLE drop mid-sign is transient
An attempt for the previous companion could run into the next
connection and have the new companion sign its challenge (a 400 that
marked it failed), while the new companion got no attempt of its own.
Attempts are now per companion: one for another companion waits and
then runs, and signing checks that the target is still connected.

A BLE drop during signing followed by the transport's fast reconnect
let the 4 s step timeout read as 'firmware cannot sign' or a definite
failure, which blocked the link for the connection. A sign error after
the link changed, or with it down, is now transient and retried.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-09 11:10:45 +02:00
efitenandClaude Opus 5.5 0c942e483e fix(drain): publish every queued row under the companion that captured it
With the hold, a queue can keep one companion's rows for a long time.
Connecting another, linked companion then published that backlog under
the new pubkey: someone else's receptions counted as its coverage, and
data from an unlinked companion got past requireLinkedCompanion. Rows
now carry the capturing companion (rx, rx_name; not part of any MQTT
payload), drain publishes each under its own pubkey, and the hold is
decided per row. Rows queued before this version behave as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-09 11:09:40 +02:00
efitenandClaude Opus 5.5 62621c591c feat: CoreScope account card, auto-link on connect, hold while unlinked
Settings gets a 'CoreScope account' card, shown only when CoreScope has
user management on (or this companion's uploads are held). A connected
companion is linked automatically; the sign exchange holds the radio so
region discovery, the discover sweep and the RF sampler cannot answer
for it. Drain holds only when CoreScope requires linked companions.
The service worker no longer caches CoreScope's account/config answers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-09 11:03:04 +02:00
efitenandClaude Opus 5.5 40c294dba4 feat(drain): hold the queue while CoreScope requires a linked companion
One optional precondition next to publisher.connected(): when held, the
pass publishes nothing and does not touch the queue. Push pending now
names the hold instead of blaming the broker.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-09 11:00:02 +02:00
efitenandClaude Opus 5.5 46f27bc618 feat: account card view model (pure)
Linked / linking / waiting / firmware cannot sign / failed + Retry, the
● on the connected companion, and the 'N waiting' line while held. The
card also shows while held after a failed discovery, so a held queue is
never unexplained.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-09 10:59:41 +02:00
efitenandClaude Opus 5.5 9f9ed11e63 feat(account): hold a freshly linked companion until the ingestor can see it
With requireLinkedCompanion, CoreScope's ingestor re-reads its linked
list on a miss at most once per 5 s and drops what arrives in between,
after the broker acked it. A fresh link now keeps the queue held for
6 s and then signals a change, so the first upload is not lost.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-09 10:59:29 +02:00
efitenandClaude Opus 5.5 9c22d19453 feat(account): auto-link a connected companion to the account
Cached → done; refreshed list → done; else challenge, sign
'corescope-link:<host>:<challenge>' on the companion, post, cache.
410 retried once, 400 and unsupported firmware not retried until the
next connect or Retry, network, 429 and BLE drops wait for the next
attempt. myNodes full/failed is a note, not a failure. One attempt at
a time.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-09 10:58:04 +02:00
efitenandClaude Opus 5.5 039a6747e6 feat(account): device-token login, logout, companions cache, 401
The password is sent once and never stored; the token is stored with its
origin and never logged. Logout revokes without waiting. Any 401 clears
the token. 429 says how long to wait when Retry-After is readable. No
request carries cookies: CoreScope judges a request with its session
cookie on that cookie alone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-09 10:57:36 +02:00
efitenandClaude Opus 5.5 9ee9984b01 feat(account): discovery gate, origin-bound session, hold flag
Only userManagement.enabled === true turns the feature on; every other
outcome is off with one log line naming the reason (including the CORS
hint). clientRxRequireLinkedCompanion is remembered per origin; a
deployment that never answered means not required.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-09 10:57:02 +02:00
efitenandClaude Opus 5.5 304553f98b feat: companion signs bytes over CMD_SIGN_START/DATA/FINISH
Same onFrame/send path as selfinfo.js. 128-byte chunks stay under the
176-byte frame and the ESP32's 173-byte ATT payload. ERR or silence on
START means the firmware cannot sign; OK/ERR ahead of the START reply
belong to earlier commands and are ignored.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-09 10:53:24 +02:00
efitenandClaude Opus 5.5 cea751fa7c feat(config): optional corescopeUrl, normalized to an origin
Falls back to the origin of resolveUrl; both empty turns the account
feature off. Runtime config only, nothing hardcoded.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-09 10:52:35 +02:00
efitenandClaude Opus 5 0e72292253 fix: "Push pending now" during a slow connect left orphaned MQTT sockets (v1.18.4)
Publisher.reconnect() called mqtt.js client.reconnect() unconditionally.
mqtt.js connect() replaces this.stream without closing the previous one
(client.js:257), so a press while a CONNECT was still unanswered left the
earlier socket open. When an orphan closed, its 'close' set
client.connected = false over a live session and armed a reconnect that
orphaned that session in turn.

Field log 2026-09-19: connack timeouts on a weak mobile link, then five
presses in four seconds (12:05:54 to 12:05:57), then "connected" followed
by "offline" and "connection closed" in the same second at 12:05:58,
12:06:00, 12:06:02 and 12:06:04.

reconnect() now returns false and does nothing while an attempt is in
flight (no session, no reconnect timer armed); the Push button logs that.
Once the socket has closed it still skips the 4 s wait. Two tests run the
real mqtt.js client over a fake stream; without the guard the first fails.

Not verified: the EMQX log has no lines for this client id, so the
broker-side session takeover between the sockets was not observed.

Version, release notes and the service-worker cache bump ride along, as
AGENTS.md requires.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-19 19:54:05 +02:00
efitenandClaude Opus 5 1a98a6df8d fix: the region hold's default timers threw in the browser (v1.18.3)
holdUntilReply's default was `timers = { setTimeout, clearTimeout }`, so the
native timers were called with that object literal as `this`. Chromium rejects
that with "TypeError: Illegal invocation"; Node does not check, which is why
279 tests passed over it.

The throw lands inside askRepeater's try, after the ask has gone out, so the
20 s hold and the restore of the repeater's original contact path were both
skipped; the restore record waited in localStorage for the next connect. It
fires once per repeater per session, on the ask that applies the override.
Field log 2026-09-18: three of them, 14036f, e3d3f4 and cf7903, each on
"attempt 1 of 4".

Version, release notes and the service-worker cache bump ride along, as
AGENTS.md requires.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-18 10:57:17 +02:00
efitenandClaude Opus 5 ac9f5126be fix: end the contact-override hold when the repeater answers
A repeater saved as a contact has its stored path forced to zero-hop for the ask and put
back afterwards, and the queue waits for that round. It waited a flat 20s. In the
2026-09-14 commute log 49a98584fce5 and 72d171e63056 both answered 2s after the ask and
the queue then sat blocked 18s more each; cafe314d00e2, heard at 17:47:01, was not asked
until 17:47:14 because of it. Every answer visible across the field logs so far — 11 of
them — arrived 1–2s after its ask.

holdUntilReply resolves on whichever comes first: the matched reply for that target, or
OVERRIDE_HOLD_MS. onRegionsFrame releases the hold right after it files an answer, and a
reply that lands before the hold starts skips it. The no-reply fallback keeps its 20s:
how early a restore is safe while no answer has arrived is a firmware question, and this
only removes time after the answer is in hand.

The restore line now says which way the hold ended, "(reply in, hold ended early)" or
"(no reply in 20s)", so the next field log can confirm it.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012GJuEuyG3JMrSeAGCmJ1GP
2026-09-14 18:09:15 +02:00
Erwin FitenandClaude Opus 5 ec55d31bfe fix: the debug log announced a healthy BLE link once a second
noteLinkState's guard was inverted. `state.linkQuiet` holds the INVERSE of
the link being up, so the steady state is `linkQuiet !== linkUp` and an edge
is `linkQuiet === linkUp`. The guard returned on the edge and fell through in
the steady state — the exact opposite of both.

Per-second monitorTick therefore wrote "companion link back" on every tick of
a perfectly healthy link, and swallowed the real transition: linkQuiet never
flipped off its `false` initial value, so "companion link down" could never be
reached at all. A field log from this morning shows 157 of 200 buffered lines
spent on the spam, the whole 200-line ring buffer covering 2m36s, and not one
"link down" line — defeating cc710a3, which added the pair so that a dropped
link would stop reading like an app that had crashed.

The edge decision moves to monitor.js as the pure `linkTransition`, next to
the other per-tick monitor helpers, since app.js cannot be imported under
node --test. Five regression tests cover both steady states, both edges, and a
full drop/return cycle driven tick by tick.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-14 09:48:06 +02:00
efitenandClaude Opus 5 cc710a3a11 fix: stop transmitting into a BLE link that is down
The 2026-09-13 log ends with two and a half minutes of "discover send failed: GATT
Server is disconnected" — one sweep every 30 seconds, each a write into a characteristic
that no longer exists — an "rf sample incomplete — discarded" for every sampler round,
and region asks failing the same way. None of it could reach a radio.

discoverDecision takes linkUp and reports 'link-down' ahead of every other state; the
monitor tick returns right after rendering it, the RF sampler reschedules without
sampling, and region asks stop with them. The discover clock is not advanced while down,
so the first tick after the link returns sweeps immediately instead of waiting out an
interval.

The link state is read from the browser's own device object through a new
transport.connected(), not mirrored into a flag of ours. A flag would be stale exactly
when it matters, which is the same failure shape as the duplicated default fixed in
v1.17.1 — one source per fact.

Said once in each direction rather than per tick. A log that just goes quiet is
indistinguishable from a crash, an area with nothing to hear, or a feature switched off.

Capture, queueing and uploading are untouched: receptions already in hand are still
queued and published, and the MQTT link keeps its own reconnect.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HSoyBhrLLtSqLgBMEKMiJV
2026-09-13 13:42:56 +02:00
efitenandClaude Opus 5 9a8614396b fix: the per-encounter allowance was 3, not the 4 v1.16.0 announced
Two files held a default for the same limit. src/regionsched.js set DEFAULT_MAX_ASKS = 4
and only the tests read it; src/config.js carried its own 3, and the app reads the
config. So the raise from 3 to 4 shipped in the release notes and not in the app. Nothing
failed and no test could see it — the only evidence was a field log line reading
"attempt 3 of 3 this encounter".

Fixed at the cause rather than by correcting the number: config.js now imports all five
pacing defaults from the scheduler, so there is one number per limit. A test asserts the
config's defaults ARE the scheduler's, which is the assertion that was missing.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HSoyBhrLLtSqLgBMEKMiJV
2026-09-13 02:05:03 +02:00
efitenandClaude Opus 5 7ad2f132b0 fix: leave the repeater's rate limiter to the repeater
v1.16.0 mirrored simple_repeater's anon_limiter as a rolling client-side ceiling of four
asks per 180s per target. Reading the firmware instead of this repo's notes about it
shows the copy can only do harm.

anon_limiter(4, 180) is real (examples/simple_repeater/MyMesh.cpp:880) and is shared
across every anon request type and every requester, as the notes said. What they did not
say is that RateLimiter::allow uses a FIXED window:

    if (now < _start_timestamp + _secs) { _count++; if (_count > _maximum) return false; }
    else { _start_timestamp = now; _count = 1; }

The window is anchored to the repeater's clock and starts at the first request it accepts
after an expiry, which a client cannot observe. A rolling copy is therefore wrong in both
directions, and expensively in one: it refuses asks the repeater would have answered
because its window had just reset. The request it refused most reliably was the bonus ask
v1.16.0 was built to send — the one aimed at a strong reception, which by nature does not
wait. The same source shows a denial costs nothing: _count keeps counting but
_start_timestamp does not move, so extra requests neither extend the block nor penalise
the sender.

One repeater's load is bounded by the encounter, unchanged from v1.16.0: four unanswered
asks plus at most one bonus, each at least 30s apart, no new encounter until five minutes
of silence. Five asks over at least two minutes, and on the road far fewer — 180 seconds
is about 3 km, by which time the repeater is out of range and the question does not arise.
That last point is the user's, and the field log agrees with it: every reception the
client-side window would have held off came from a node heard for minutes at a time.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HSoyBhrLLtSqLgBMEKMiJV
2026-09-12 23:59:36 +02:00
efitenandClaude Opus 5 ebbca34fcb feat: a much stronger reception buys one more ask; no signal floor
The 2026-09-12 commute answered the question v1.15's instrumentation was built to ask.

No floor. The ranges came back overlapping — answered snr -5.25 … +12 dB, silent -11 …
-0.75 dB — and two of the three answers came from asks at snr -5.25 / rssi -117 and snr
-1.75 / rssi -113. Any floor worth setting would have blocked them. The earlier reading
that looked like a clean split was drawn from the old scheduler, where silent asks were
timer asks whose signal I took from a reception minutes earlier: the number was standing
in for freshness, not for link quality, and once every ask fired on a live reception the
correlation vanished.

What the same log did show: efef79435050 spent its three asks between 21:06:50 and
21:08:08, all around -115 dBm and all unanswered, and was then heard from 21:09:37 at
-76 to -69 dBm — up to 46 dB stronger, the best receptions of the drive — with nothing
left to spend, because the encounter only ends after five minutes of silence and it kept
coming in loud. So a reception at least 6 dB better in snr than the best one this
encounter already asked on now earns exactly one extra ask, once per encounter.

The per-encounter allowance also goes 3 -> 4, as asked.

Both of those need the firmware's limiter to stop being an approximation: at most 4 asks
to one repeater in any 180s, which is what simple_repeater accepts across every
requester and type. Enforced directly now, ageing on its own clock so an encounter reset
does not clear it, and deliberately not configurable. Note it mostly does not come up on
the road — 180 seconds is about 3 km, by which time the repeater is out of range — and
the field log bears that out: the receptions it would have held off all came from nodes
heard for minutes at a time.

One interaction worth knowing: four asks 30s apart fills the 180s window, so a target
that spends the full allowance cannot take its bonus until the oldest ask ages out,
roughly half a minute. regionMaxAsks: 3 in config.json leaves that slot free instead.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HSoyBhrLLtSqLgBMEKMiJV
2026-09-12 23:52:02 +02:00
efitenandClaude Opus 5 0917e1c893 fix: connect threw maybeReplayPendingRestore is not defined
The v1.15.1 cleanup deleted a contiguous block of the dead ask path, and that block had
one function in the middle of it that belongs to neither path and is called on every
connect: the replay of a contact-path restore left behind by a session that died between
forcing a contact to zero-hop and putting it back. Restored unchanged.

v1.15.1's check — load the built page in a browser — proved the module initialised,
which was v1.15.0's fault, but it never reached the connect path: that sits behind a Web
Bluetooth pairing a desktop browser with no companion cannot complete. The check that
does catch this compares every top-level definition against the last known-good release
and looks for surviving references to each removed name. Run against v1.14.0 it now
reports none for all eleven definitions dropped since.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HSoyBhrLLtSqLgBMEKMiJV
2026-09-12 20:41:05 +02:00
efitenandClaude Opus 5 12db3a8f35 fix: v1.15.0 threw before any of its wiring ran
The app painted its shell, opened on Home instead of Settings, and no button or
navigation tab responded.

Removing the old scheduler left one line behind that read a constant no longer
imported: `const OVERRIDE_ROUND_TIMEOUT_MS = PENDING_TIMEOUT_MS` (app.js:359). Being
module-level, evaluating app.js raised a ReferenceError before the view switch and
before a single event listener was attached — the HTML rendered and nothing worked.

Deleted with it, for the same reason it was found: the rest of the old ask path, left in
place and no longer reachable. prepareAndAskRegions, askRegions, finishOverrideRound and
restoreContact all referenced removed imports or the removed pending slot; askRepeater
already does that work inline. disconnectAll also still nulled state.regions.pending; it
now clears the outstanding-tag map and the queue, which is what actually has to happen —
no reply can arrive over a transport that is gone, and a tag from one session must never
match a request from the next.

Why the checks passed: rollup reports a missing export as a warning, not an error; the
suite covers the pure modules and never evaluates app.js; and I did not load the
production bundle in a browser before releasing, though I had loaded every beta build.
This release was verified by serving dist/ and opening it: the version line is painted
by app.js, so seeing it at all is the proof the module initialised.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HSoyBhrLLtSqLgBMEKMiJV
2026-09-12 15:55:21 +02:00
efitenandClaude Opus 5 8bfadeaac8 feat: pace region discovery by what the radio hears, not by a clock
The scheduler had three limits and four drives showed each one costing answers rather
than protecting anything. All three are gone; what replaces them is bounded by the
repeater firmware's own limiter instead of by a clock of our own invention.

The shared one-ask-per-60s airtime budget. One ask, from wherever, blocked every
repeater heard in the following minute. The 2026-09-11 80 km log has a2cf63b9fd89 asked
at 18:24:55 on rssi -120 and silent, then heard at 18:25:26 on -102 — 18 dB stronger —
and skipped, because the budget had gone on the weaker reception 31 seconds earlier and
that same ask had put it into backoff.

The 5/15/30-minute per-target backoff, counted per session. A repeater asked once from a
bad spot was locked out for the rest of the drive. It is replaced by an encounter: three
unanswered asks at least 30s apart, then left alone until it has been out of earshot for
five minutes, after which the next reception is a new encounter with a fresh run. Three
asks 30s apart is 3 in any 180s window, inside simple_repeater's 4 anon requests per
180s shared across all requesters — the cap is what keeps us there, not the spacing.

The single in-flight slot. It capped the feature at three asks a minute, and at one per
session whenever a request went unanswered. Several requests can now be outstanding, so
replies are attributed on the 4-byte tag the companion echoes back and an unmatched
reply is dropped rather than guessed at: "something is pending" would file one
repeater's declared regions under another and store it as fact.

Measured, not assumed. A build without the three limits sent 15 asks and got 6 answers;
v1.14.0 on a comparable run sent 5 and got 1. That build is the one merged here (the
beta/regions-sprint commits below), with the pacing tightened from 15s/6 asks to
30s/3 asks so one repeater sees strictly less than the firmware allows one client.

Also here: every ask now carries the snr and rssi of the reception that triggered it,
into the reply or into the timeout. Four drives point at a split — every ask at snr
+1.75 dB or better was answered, every one at -1.25 dB or worse was not — that until now
had to be assembled by hand from pairs of log lines the ring buffer rolls out mid-drive.
No signal floor is applied; this is the measurement that would justify one.

Deleted rather than left behind: selectNextTarget's successors (heardAskDecision,
commitAsk, undoAsk, isTargetDue, dueDelayMs, retryBackoffFor, recordCandidate,
applyRegionsReply, pendingExpired) and monitor's regionDiscoverDue/REGION_INTERVAL_MS.
regionreq.js is framing only now; regionsched.js owns the scheduling.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HSoyBhrLLtSqLgBMEKMiJV
2026-09-12 12:59:06 +02:00
efitenandClaude Opus 5 09bd120183 beta: file every ask under the signal it went out on
Three drives have now pointed at the same split — every region reply came from a
reception at roughly -109 dBm or better, every ask at -111 or worse stayed silent — and
every time it had to be assembled by hand from pairs of log lines, on a sample of ten,
from a ring buffer that rolls those lines out mid-drive. That is not a measurement yet.

An ask now carries the snr and rssi of the reception that triggered it, through the
outstanding map and into whatever comes back. A reply files them under answered; a tag
that times out files them under silent, which is the half that was never recorded at
all. pruneOutstanding returns the dropped records instead of a count for that reason.

The header states both ranges:

  beta sig   answered asks 7: rssi -109 … -78dBm, snr 1.75 … 12.25dB | silent asks 12: …

They argue for a signal floor only if they do not overlap. If they do overlap, the idea
is dead and one drive says so, which is the same amount of evidence either way.

Per-ask and per-reply lines carry the same two numbers, so a spot check in the visible
part of the buffer does not depend on the header.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HSoyBhrLLtSqLgBMEKMiJV
2026-09-12 12:46:10 +02:00
efitenandClaude Opus 5 630409830c beta: count distinct repeaters in the header, not queue entries
The first field run read "6 of 15 repeaters answered, 15 asks sent". Both 15s are the
same counter — successful enqueues — so the row invited exactly the wrong reading, that
15 distinct repeaters were seen and each was asked once. Neither half was measurable
from it.

Three denominators now stated separately: repeaters SEEN (distinct nodes, from the
per-target map), asks SENT (transmissions), and receptions (how often those nodes were
heard at all). The ratio that decides this experiment is answered over seen; asks over
answered is what it costs.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HSoyBhrLLtSqLgBMEKMiJV
2026-09-12 12:38:58 +02:00
efitenandClaude Opus 5 efcdc2a780 beta: give the asking an end, and make both throttles tunable on the server
Two gaps in the first cut, both raised from the field side.

"Until it answers" never ends. A repeater held in range that does not reply was asked
again on every reception for the rest of the session, which is a poll, not a
measurement. An encounter now gets betaMaxAsks unanswered asks (6) and then stops. What
reopens it is silence: after betaForgetMin (5) without hearing that node, the next
reception is a NEW encounter and the count starts clean, because the same repeater met
40 km later is a different distance and a different antenna aspect, and the failures of
the last meeting say nothing about this one. An answer still ends it permanently, and no
encounter reopens that.

The encounter is ended by silence rather than by elapsed time, so a node heard steadily
for ten minutes stays one meeting instead of being handed a fresh run halfway through.

Second, the 2s queue interval was the wrong knob to state as the rate, and it was
hardcoded. There are two distinct limits and they now live in config.json, editable on
the server between drives with no rebuild:

  betaAskGapSec     2   between ANY two transmitted asks; stops rounds overlapping
  betaTargetGapSec 15   between two asks to the SAME repeater; this is the rate that
                        matters for a node parked in range, heard many times a minute
  betaMaxAsks       6   unanswered asks per encounter
  betaForgetMin     5   silence that starts a new encounter

A value that is missing or unusable (string, negative, NaN) takes the default rather
than disabling the limit it configures: on a transmitting path a typo must not read as
"no limit".

enqueue now returns WHY it said no ('answered' / 'queued' / 'capped' / 'too-soon')
instead of a bare false, the per-ask log line carries "attempt N of M this encounter",
and the header gained a row counting receptions ignored because the repeater had used
its asks. Without that count a capped node and a node that stopped transmitting look
identical in the log.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HSoyBhrLLtSqLgBMEKMiJV
2026-09-12 10:37:33 +02:00
efitenandClaude Opus 5 cf6597cbdb beta: ask on every reception, no budget, no backoff, no single slot
An experiment, not a proposed default. Built for rx.on8ar.eu/beta and compiled in only
by `REGION_BETA=1 vite build`; a normal build folds the flag to false and drops every
branch, which the prod bundle confirms (none of the beta strings survive it).

The premise under test, in the requester's words: a moving receiver goes from node to
node, so a repeater is never asked often enough to block its own TX window. So this
path removes all three throttles at once — the shared one-ask-per-60s airtime budget,
the 5/15/30-minute per-target backoff, and the single in-flight slot.

Procedure it implements: a reception of a repeater resolves to a full pubkey (advert
carries one; discover and path-hash prefixes go through the CoreScope resolve endpoint
the app already uses for names), the target is queued, and the queue drains one ask per
2s. A repeater is taken out of rotation only by answering. A target already queued is
not queued twice, so the ask rate is the RECEPTION rate rather than a 2s clock; 2s is a
floor between transmissions, not a generator.

Dropping the single in-flight slot breaks the reply matcher: applyRegionsReply resolves
one pending request, and with several outstanding, "something is pending" would file one
repeater's regions under another. matchOutstanding keys on the 4-byte tag the companion
echoes in its RESP_CODE_SENT ack, an unmatched reply is dropped rather than guessed at,
and tags older than 120s are pruned so the map cannot grow without bound.

Kept deliberately: the contact-path override (a saved contact with a stale out_path is
FLOODed and repeaters ignore flooded requests), and its 20s restore hold. Whether
restoring earlier costs the reply is a firmware question, and this experiment is not
the place to answer it, so a round that needs an override blocks the queue for 20s.
Overrides were needed twice in three field logs.

What the field log will have to show, since the per-ask lines roll out of the 200-line
buffer: two new header rows carry repeaters answered over repeaters seen, asks sent
over replies, and the queue/outstanding/timed-out/unmatched/FLOOD counters.

Not addressed here: simple_repeater rate-limits anon requests to 4 per 180s shared
across all requesters and all types, so a repeater held in range for minutes will start
dropping these. That is part of what the measurement is for.

No service worker in this build: it is served from a subdirectory of the production
origin, and registering '/sw.js' from there would claim the root scope and serve the
experiment to the production URL.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HSoyBhrLLtSqLgBMEKMiJV
2026-09-12 10:26:33 +02:00
efitenandClaude Opus 5 14df2e0438 feat: ask a repeater only while it is being heard, and refund an ask that never left
Twelve minutes of the 2026-09-11 v1.13.0 log: six region requests, one answer. The one
that was answered fired on a live reception and came back in two seconds. The other five
each charged their target an attempt and dropped it into the 5/15/30-minute backoff, so
e3d3f4d7edd0 (heard directly at 12:04:54 and 12:09:32) and 6b8c65b77cf3 (12:03:53,
12:08:02, 12:10:05) could not be asked while they were demonstrably in range.

Two separate causes, both in the ask bookkeeping rather than in the framing or the reply
matcher, and each fixed at its own site.

The 60s timer fallback is removed. selectNextTarget picked from the whole session pool
with no notion of range, which at road speed is a repeater already passed: 12:04:37 to
e470a7fd67fa, last heard 5m45s earlier, and 12:05:38 to 01fa326b4758 are the two clean
examples in the log, neither answered. Since 52b7ff5 those asks also stamp the shared
one-ask-per-60s airtime budget, so a blind ask blocked the heard path for the following
minute as well as backing its target off. maybeAskHeardTarget is now the whole
scheduler, and selectNextTarget, demoted and cursor go with the fallback they served.

A BLE write that throws now costs nothing. commitAndAsk charged attempts, lastAskedAt
and the airtime budget before the write, and askRegions only logged the rejection, so a
request that never reached the radio held the pending slot for its full 20s and then
printed "no reply ... within 20s" — indistinguishable from a repeater that heard us and
stayed silent. Two of the six asks were this: 12:00:00 and 12:02:36, both immediately
after "BLE: reconnecting". commitAsk now returns a receipt and undoAsk restores it,
refusing once the send-ack has captured a tag (that request IS on the air) or once
another target holds the slot. prepareAndAskRegions gained a try/catch for the same
reason: state.transport is nulled on disconnect and askRegions dereferences it, which
rejected unobserved and wedged the slot until it timed out.

Removing the timer removes the only line that narrated the scheduler once a minute, so
heardAskDecision reports why it said no (in flight, budget, answered, backoff, with the
remaining wait) and the heard path logs that at most once a minute. Those four states
were previously indistinguishable from each other and from silence.

Known trade-off, stated in the release notes: the stationary pause stops the discover
sweep, so a parked app now depends on organic traffic to raise a candidate. A repeater
in range that transmits nothing while you are parked next to it is no longer asked.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HSoyBhrLLtSqLgBMEKMiJV
2026-09-11 12:47:02 +02:00
Erwin FitenandClaude Opus 5 506efab11c feat: ask forwarders for their regions, not just nodes that answer discover
A 'rxlog' attribution only happens on a FLOOD route, where path[last] IS the
node that transmitted to us — one radio hop away, which is exactly the direct
neighbour relation a regions request needs. Those receptions were never
candidates. The stated reason was that the packet carries no pubkey to address,
but that is not the obstacle: the discover path has the same gap and closes it
with a CoreScope lookup, and the app already sends these same prefixes to that
endpoint to resolve names. So forwarders now resolve to a full pubkey and become
candidates like any other repeater.

This fills a real hole rather than adding volume. isOrganicHeard backs the
discover sweep off for 15s after any organic reception, so in busy areas — where
forwarder traffic is densest — the sweep is suppressed and yields the FEWEST
discover-sourced candidates exactly where there is the most to hear.

Node type is unknown for a path hash, which is accepted rather than ignored: a
node appears in a path only because it RETRANSMITTED the packet, and companions
and sensors do not forward, so this population is repeaters and possibly room
servers. A non-answerer costs one ask and is then held off by the existing
5/15/30-minute backoff, the same as a repeater that stays silent. No airtime is
added either way — both paths share the one-ask-per-60s budget.

Whether a 2-byte prefix resolves uniquely often enough to be worth it is a
measurement, not a guess, and the app puts the companion in 2-byte path-hash
mode itself, so this is the least favourable case. The log header now carries
"path keys: N of M path-hash prefixes resolved to a pubkey (K ambiguous or
unknown)". It lives in the header because the 200-line ring buffer rolls
per-prefix lines out long before a drive ends, and it counts DISTINCT prefixes:
resolvePubkey is called on every reception from a forwarder and answers from its
session cache, so counting calls would report the busiest node many times over
and say nothing about how many forwarders could be identified.

Adding a third writer to the candidate map exposed a pre-existing bug worth
naming. The map value is the answered-key isTargetDue compares against, and
advert-sourced candidates carry a real advertTs while discover- and
forwarder-sourced ones carry null. A plain set(pk, null) overwrote a known
timestamp, so answered.get(t) !== advertTs for a repeater that HAD answered: it
read as due and was asked again for nothing. That already applied to the
discover path; a third writer would have tripled it. recordCandidate never
downgrades a known timestamp, and returns the EFFECTIVE key so the call site
cannot hand a stale null to the ask decision — which was the same bug by a
second route. A changed timestamp still overwrites; a re-advert is the
documented signal to ask again.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-11 09:30:47 +02:00
Erwin FitenandClaude Opus 5 52b7ff534f fix: one silent repeater killed every later region ask for the session
state.regions.pending is the single in-flight slot, and it was released in only
three places: a FLOOD send-ack, an accepted reply, and disconnect. None of those
is the ordinary outcome for a moving receiver — a request sent DIRECT to a
repeater we have already driven past is simply never answered, and that left the
slot occupied for the rest of the session.

heardAskEligible gates on that slot, so the first unanswered ask disabled the
event-driven path entirely. What remained was the 60s timer picking a candidate
from the whole session pool — exactly the clock-chosen, minute-late ask the
module header says cannot work at speed. A 23-minute commute log shows ~19
repeaters heard, every ask landing on the timer cadence, not one
"heard ... directly" line, and a single reply.

A pending request now carries sentAt and expires after PENDING_TIMEOUT_MS,
swept by the one-second tick rather than a setTimeout — this app is routinely
backgrounded mid-drive, where a timer fires late or not at all. A pending
without a sentAt counts as expired: a wedged slot costs a whole session, an
early expiry costs one ask that the airtime budget already bounds.

Two invariants the timer path documented but never enforced, unnoticed only
because the wedged slot meant the heard path never ran:

- The shared 60s airtime budget is now stamped in commitAndAsk, the one site
  that transmits, so it counts asks from both paths. It was stamped only in
  maybeAskHeardTarget, so timer asks spent airtime for free.
- The timer no longer asks over a live request. Doing so overwrote pending.tag
  and applyRegionsReply then rejected the real reply as a tag mismatch, so the
  fallback path was destroying the answers this feature exists to collect.

OVERRIDE_ROUND_TIMEOUT_MS now derives from the same constant: once the contact
path override is torn down no reply can arrive, so pending must not outlive it.

Also fixes the log line that hid this. "every repeater heard so far has already
answered" was printed whenever the pool came up empty, including when every
candidate was merely waiting out its retry backoff — it read as a finished job
while one repeater of nineteen had answered.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-11 09:30:13 +02:00
efitenandClaude Opus 5 d2e2573375 feat: verify advert signatures before an identity reaches CoreScope (closes #11)
An Advert's Ed25519 signature is the only cryptographic proof of identity MeshCore
offers. Everything else is plaintext and attacker-chosen: pubkey, name and self-reported
position are whatever the sender wrote, and hop counts, paths and prefixes carry no MAC.
The capture rule in this repo covers provenance, not authenticity, so a 0-hop advert can
be genuinely heard direct and still name a node that does not exist. Adverts captured
here are published to CoreScope, the registry the name resolvers read from, so one
forgery heard by one driver becomes a named node on someone else's screen.

parsePacket now returns advertSig: the pubkey, the signature and the exact message the
firmware signs, which is pubkey(32) || timestamp(4, LE) || app_data with app_data
truncated to MAX_ADVERT_DATA_SIZE (meshcore-firmware src/Mesh.cpp:271-280 verifies what
:404-437 signed, cap at src/MeshCore.h:12). The timestamp goes in as the raw wire bytes,
not the parsed advertTs, so no re-encoding can disagree with what was received. Getting
the 32-byte cap wrong would make every long advert look forged, so the fixture test
covers it, and the real captured advert already in the fixtures verifies against its own
signature, which is what proves the construction rather than asserting it.

src/advertsig.js does the crypto and nothing else. Verification is async: @noble/ed25519
needs a hash and only the async path has one without extra wiring. The capture handler
was already async. A forged advert can carry a pubkey or signature that is not a valid
curve point, which noble rejects by throwing, so that is caught and read as a failed
verification rather than taking the capture path down.

A failed check drops the identity and keeps the reception. The SNR and RSSI measured at
that position are real whoever wrote the advert; only the name attached to them is
worthless, and discarding the row would lose genuine coverage. This is deliberately
narrower than core-hunter, which refuses the whole reception (efiten/core-hunter#356),
because that repo is about identity and this one is about coverage. As a side effect the
node stops being a region-discovery candidate, so the app never sends an anonymous
request to an address somebody invented.

verifyAdverts is off unless config.json says otherwise, and is listed false in
FEATURE_DEFAULTS as well as NO_CONFIG_DEFAULTS. It is the only flag that makes the app
record less than it heard, and inheriting that silently would look like adverts going
missing. The exported log header reports it next to the other three, because "no advert
in the capture" and "advert rejected" are otherwise the same silence.

Not done: no Settings UI for the flag, config.json only, matching the other three. The
gate is not exercised against a forged advert on real hardware, only against fixtures
and a signed synthetic advert.

New dependency: @noble/ed25519 3.2.0. Bundle 435.17 kB -> 442.78 kB (gzip 136.22 ->
139.71).

Tests: 255 pass (+16). SW cache v39 -> v40.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Manrn3qdrTJFz3C4o9PPFL
2026-09-09 17:55:29 +02:00