fix(packets): preserve captured endpoint names in history - #128
Open
n30nex wants to merge 2 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this PR does
Closes #127. Packet endpoint names are shown live but disappear from list rows after reload or reconnect. In a dev-feed comparison, all ten matched observations had named live endpoints and none had names on their REST list row.
Store the already-computed endpoint resolution in the existing observation INSERT, then return it through list, reconnect-backfill and detail reads. The snapshot belongs to the observation, preserves names/node references/confidence, and survives later registry changes. Duplicate delivery keeps the original snapshot. Existing filtering, pagination, latest-observer selection and endpoint-matching rules remain unchanged; intermediate hop resolution is unchanged too.
Migration 026 adds a nullable JSONB column without a default or backfill. Older rows keep their current list behavior and detail-time lookup fallback. New empty snapshots retain an absent/unresolved result instead of inventing a later historical name. The detail mapper also handles the packet-before-observation window and a nullable legacy broker field safely.
Type of change
Checklist
go build ./...passesgofmt -l .is emptygo vet ./...passesgo test ./...passesCONTRIBUTING.mdTesting notes
Five native Pi PostgreSQL runs pass. Temporary fixtures cover global/regional lists, reconnect rows, each observation's snapshot, Unicode names, ambiguous/unknown endpoints, renamed/deleted nodes, legacy/empty data and duplicate delivery. A 50-row history page still makes one database call; captured detail without intermediate hops uses only the packet and observation queries. Capture uses one existing INSERT, with no follow-up UPDATE. Optional enrichment encoding failure does not discard the observation.
The original read regression fails before the change. Full Go checks pass locally and natively, and Windows race checks pass for ingest and DB packages. A separate test database validates migrations without changing the live feed during candidate testing.
The combined preview runs
7f6616eecf3968ff8bb7f5b879b46b5b7f70f8c7, with its exact source offer verified. Startup applied migration 026 without changing the observation table's relation file or populating any pre-migration snapshot. All ten matched named WebSocket observations now have identical endpoints in REST history (10 mismatches before, zero after). One sample whose latest observer changed was excluded from the comparison. Browser scrollback shows the saved names. Ordinary API/burst smoke and fresh dev MQTT ingestion pass.The initial live sample recorded 237 snapshots, averaging 301.8 bytes per JSONB value with a 1,489-byte maximum. This is a small-feed storage sample, not a bound or production-wide performance claim. The existing frontend already consumes the endpoint fields and was not rebuilt.
This records existing resolver output. The separate use of a repeater-only path resolver for short endpoint hashes needs a focused companion-matching follow-up. Prefix confidence is a candidate match, not authenticated proof of sender identity. Existing rows are not retroactively reconstructed.
AI tools assisted implementation and validation under the contributor's standing approval for this effort.
The endpoint test fixture also exposes the dedicated-resolver entry point used by the companion-matching follow-up, so the two changes remain compatible when combined. This is a test-only addition.