Skip to content

fix(db): paginate complete trace tag groups - #124

Open
n30nex wants to merge 1 commit into
MeshCore-Beacon:devfrom
n30nex:codex/beacon-trace-pagination
Open

fix(db): paginate complete trace tag groups#124
n30nex wants to merge 1 commit into
MeshCore-Beacon:devfrom
n30nex:codex/beacon-trace-pagination

Conversation

@n30nex

@n30nex n30nex commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

What this PR does

Closes #123. The trace-list cursor filters individual packets before grouping them by trace tag. A tag returned on an earlier page can therefore appear again with an older timestamp and a smaller packet count.

Apply the cursor to each filtered group's maximum last_heard_at in HAVING. Existing region, scope, type and time-window filters still define the group; its complete count, timestamps and best-payload selection are preserved. No schema or API contract changes.

Type of change

  • Bug fix
  • Tests

Checklist

  • go build ./... passes
  • gofmt -l . is empty
  • go vet ./... passes
  • go test ./... passes
  • sqlc regenerated with v1.31.1
  • No schema, API handler/type or dependency changes
  • I have read CONTRIBUTING.md

Testing notes

The PostgreSQL regression uses temporary tables in a rolled-back transaction and calls the real Store/SQL path. Interleaved packet timestamps make four trace tags produce seven summaries across two-row pages on the original query, including three repeats with altered summaries. The candidate returns exactly four complete summaries. Both outcomes were reproduced in five native Pi 5 runs.

Twelve cases check initial/cursor/end pages, region and duplicate-region filters, unknown regions, scopes, types and inclusive time windows. Cases where scope/type/time filtering changes a group's maximum verify that the cursor uses that filtered maximum. Returned times, counts, IATA counts, type, longest path and SNR values are reconciled.

Full Go checks pass locally and natively on the Pi, including the combined preview source. Live seven-row pages reconcile 45 global traces and 36 regional traces without repeats or changed summaries; TRACE and PING lists also pass. Ordinary API/burst smoke, fresh MQTT ingestion, public source hashes and the populated Traces view pass at the preview. Exact combined source: 031fd5659ca038dacd0dc8ceba681fd66fd8564b, linked from Source & changes.

The existing timestamp-only cursor still has no tie breaker and is represented in milliseconds. Traversal across equal timestamps or concurrent data changes is not made snapshot-complete by this fix; extending that contract is separate work.

AI tools assisted implementation and validation under the contributor's standing approval for this effort.

@n30nex
n30nex requested a review from 446564 as a code owner September 6, 2026 19:08
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.

Trace pagination repeats tags and truncates their summaries

1 participant