feat(wireless): reconstruct per-client roaming history from AP logs (v0.23.11-beta)

Closes #105.

RouterOS narrates the whole life of an association in its log — association, every
band or AP change, and the disconnect — each line carrying the signal at that
moment. Nothing else in the platform can see any of it: roaming happens between
polls, so a poll only ever observes where a client ended up, never that it moved.

Sessions are now rebuilt from those lines and shown on the client detail page: the
path across radios, signal at each step, duration, and RouterOS's own disconnect
reason. Sessions averaging six or more roams an hour are flagged, since a client
bouncing between radios is usually a roaming-threshold problem rather than a faulty
client.

No new collection and no new storage. It reads the events already gathered, so it
works retroactively over whatever log history exists.

Two things came out of testing against real logs rather than the samples in the
issue, and both were wrong in ways the samples could not have shown:

  Ordering. RouterOS log timestamps are second-granular, so a reassociation emits
  its disconnect and reconnect inside the same logged second, and collection
  assigns sub-second values in whichever order they were read — observed on a live
  AP as both `.849/.849` and `.096/.097` for the same kind of pair. Sorting on the
  raw timestamp attached the disconnect to the session the connect had just opened,
  so every reassociation reconstructed as a 0-second session while the real one
  disappeared. On one IoT client that was 255 phantom sessions out of 422. Events
  are now ordered by whole second and ties broken by meaning: a disconnect closes
  what came before, a connect opens what comes after. The same client now shows its
  real behaviour — 900s, 840s and 930s sessions, reassociating every 15 minutes.

  Signal sanity. Real logs contain `signal strength 91`. dBm is negative, so a
  positive reading is not a measurement; recording it would draw a client with an
  impossibly perfect signal. Treated as unknown.

21 tests, including the full ping-pong trace quoted in the issue — which the
reconstruction correctly identifies as flapping — plus both timestamp-collision
shapes seen in production.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2GT-Rich
2026-08-22 21:27:14 -07:00
co-authored by Claude Opus 5
parent 37887d38c2
commit 57d650c159
11 changed files with 820 additions and 4 deletions
+18
View File
@@ -82,3 +82,21 @@ prediction-and-revert protection that per-device changes do.
Legacy `/caps-man` — the pre-RouterOS 7 controller — is a separate API tree and is not
covered. The RouterOS 7 `wifi` stack is supported.
## Roaming history
A client's association history is reconstructed from access point logs at
`GET /api/clients/:mac/roaming?range=24h`, and shown on the client detail page.
Roaming happens between polls, so a poll-based view can never see it — the log is
the only record that a client moved, when, and at what signal. Sessions are rebuilt
from RouterOS's own lines, including every band or AP change and the disconnect
reason.
Sessions with six or more roams per hour are flagged. A client bouncing between
radios usually indicates roaming thresholds rather than a faulty client: overlapping
cells at similar signal give it no reason to prefer one.
Nothing new is collected — this reads the events already gathered, so it works
retroactively over whatever log history exists. It does require association logging
to be enabled on the access points.