Skip to content

feat: tracker-only device stats with auth-failure tracking#16

Merged
d4rken merged 1 commit into
mainfrom
feat/tracker-only-device-stats
May 1, 2026
Merged

feat: tracker-only device stats with auth-failure tracking#16
d4rken merged 1 commit into
mainfrom
feat/tracker-only-device-stats

Conversation

@d4rken

@d4rken d4rken commented May 1, 2026

Copy link
Copy Markdown
Member

Summary

  • Make DeviceClientIdentityTracker the sole source for the 1h/24h device-activity report. The reporter no longer reads device.lastSeen, device.version, or ConnectionRegistry — it builds windows from tracker seenAt instead. Post-restart the report shows what this server instance has actually observed.
  • Track every authenticated request (octi UAs verbatim, non-octi as an empty marker so they bucket as <unknown>). Record client identity immediately after auth succeeds, before the per-account rate-limit gate, so legitimately over-limit devices stay visible. Persisted device.lastSeen / IP-tracker churn is still gated behind the rate limiter.
  • Add an auth-failure stream: every AuthResult.Failure from verifyCaller and WsRoute lands in a capped (10k), 24h-windowed deque, tagged with stable reasons (missing-device-id, missing-credentials, unknown-device, bad-credentials). Reporter logs a per-window reason × top-5 UA matrix.

Test plan

  • Tracker unit tests: octi/non-octi/non-octi-update record semantics, retain prune, failure record + out-of-order 24h prune, cap eviction, concurrent insert.
  • Rewritten DeviceActivityReporterTest for the tracker-driven signature, including auth-failure section formatting.
  • AuthenticateDeviceTest tag assertions plus parse-collapse cases (blank/malformed device-id, non-Basic auth, invalid base64, payload without colon, non-UUID account).
  • HTTP/WS integration tests for auth-failure tracking and "rate-limited successful auth still records identity".
  • ./gradlew check green.

Drop reads of device.lastSeen, device.version, and ConnectionRegistry from the stats path; build 1h/24h windows from DeviceClientIdentityTracker seenAt timestamps. Non-octi clients are bucketed as <unknown>.

Add auth-failure stream with stable reason tags (missing-device-id, missing-credentials, unknown-device, bad-credentials). Storage is a synchronized ArrayDeque capped at 10k events; snapshots prune anything older than 24h. Reporter logs a per-window reason x top-5 UA matrix.

Record client identity immediately after auth succeeds, before the per-account rate-limit gate, so legitimately over-limit devices stay visible in the report. Persisted device.lastSeen still updates only after the gate accepts.
@d4rken d4rken merged commit 3691da6 into main May 1, 2026
5 checks passed
@d4rken d4rken deleted the feat/tracker-only-device-stats branch May 1, 2026 04:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant