feat(traceroutes): add packetId column for cross-source trace correlation (#3623)#3643
Conversation
…tion (#3623) The traceroutes table stored no reference to the originating Meshtastic packet, so the same physical traceroute heard on multiple sources (e.g. a direct TCP listener and an MQTT feed) could not be correlated, and individual traces couldn't be grouped/displayed per-packet (all flood-routing branches of one packet) rather than only as the collapsed resulting path. Adds a nullable `packetId` column to the traceroutes table: - Migration 097 (SQLite/PostgreSQL/MySQL, idempotent). BIGINT on PG/MySQL since Meshtastic packet ids are unsigned 32-bit and overflow signed INTEGER; SQLite INTEGER is already 64-bit. NULL = pre-migration rows. - Schema (all three backends), DbTraceroute types (db/types + database facade), and the repository insert/upsert/update + normalization paths. - Populated from `meshPacket.id` on the TCP path (meshtasticManager) and `packet.id` on the MQTT path (mqttIngestion). For traceroutes we initiated, the pending row's packetId is filled in when the response arrives via updateTracerouteResponse. `routeBack` (the other gap flagged in the issue discussion) was already persisted end-to-end, so no change was needed there. The packetId is now stored and returned by the traceroute queries; the per-packet branch visualization in the issue is a separate frontend feature this unblocks. Tests: 2 new repository round-trip tests (insert + response-fill, across all three backends); migration count/last-name assertions updated. Full Vitest suite green (7127 passed), server tsc clean. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011JEaCGwY9Wz8jeV4e22GW4
|
Claude finished @Yeraze's task —— View job PR Review: feat(traceroutes): add packetId column for cross-source trace correlation (#3623)
Overall this is a clean, well-scoped change. The implementation follows existing project conventions closely and the migration is properly idempotent across all three backends. A few observations below, ranging from a genuine bug to minor style points. Bug: Inconsistent
|
Summary
Closes #3623.
The
traceroutestable stored no reference to the originating Meshtastic packet, so the same physical traceroute heard on multiple sources (e.g. a direct TCP listener and an MQTT feed) couldn't be correlated, and individual traces couldn't be grouped/displayed per-packet (all flood-routing branches of one packet) instead of only the collapsed resulting path.This adds a nullable
packetIdcolumn to the traceroutes table and populates it on every ingestion path.Changes
097_add_packet_id_to_traceroutes.ts) — addspacketIdacross SQLite / PostgreSQL / MySQL, idempotent. BIGINT on PG/MySQL since Meshtastic packet ids are unsigned 32-bit and overflow a signed INTEGER; SQLite INTEGER is already 64-bit.NULL= pre-migration rows.db/schema/traceroutes.ts, all three backends) + types (db/types.tsand thedatabase.tsfacade interface).db/repositories/traceroutes.ts) — threadspacketIdthroughinsertTraceroute,upsertTracerouteSync(insert + pending-update branches),updateTracerouteResponse, and the row-normalization helpers.meshPacket.idon the TCP path (meshtasticManager.ts) andpacket.idon the MQTT path (mqttIngestion.ts). For traceroutes we initiate, the pending row'spacketIdis filled in when the response arrives viaupdateTracerouteResponse.Note on
routeBackThe issue discussion suggested return-path persistence was also missing. It turns out
routeBackis already persisted and returned end-to-end (column, insert/upsert, select, normalization all present), so no change was needed there.Scope
This delivers the storage/correlation foundation. The per-packet branch visualization shown in the issue is a separate frontend feature that this unblocks (the
packetIdis now stored and returned by the traceroute queries).Testing
tsc -p tsconfig.server.json --noEmitclean.🤖 Generated with Claude Code