Skip to content

Allow a TRACE route to revisit a node in both hop resolvers (#2520) - #2521

Merged
efiten merged 3 commits into
Kpa-clawbot:masterfrom
zfouts:fix/trace-revisit-2520
Dec 2, 2026
Merged

efiten merged 3 commits into
Kpa-clawbot:masterfrom
zfouts:fix/trace-revisit-2520

Conversation

@zfouts

@zfouts zfouts commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

A TRACE route can come back through a node (A -> B -> A). Both hop resolvers assumed a node appears once on a path, so the earlier visit was left unresolved and flagged as geographically inconsistent, even when A is the only node with its prefix. This lets a TRACE revisit a node in both resolvers. Every other packet type keeps one visit per node.

Why a TRACE may revisit

The firmware allows it on purpose: Packet::calculatePacketHash mixes path_len into a TRACE hash ("TRACE packets can revisit same node on return path"), while every other packet's hash ignores the path, so wasSeen keeps a node from forwarding it twice.

Changes

  • Ingestor (cmd/ingestor/path_resolver.go, cmd/ingestor/db.go): resolvePathWithContext takes allowRevisit. When set, only the previous hop is excluded (a radio does not hear its own transmission, so a node is never its own next hop), and anchoring on the previous hop through the neighbour graph is unchanged. The second A of a TRACE was stored as null in observations.resolved_path; now it is resolved.
  • Shared rule (internal/packetpath/route.go): PathMayRevisit(payloadType) is true for TRACE only.
  • Frontend (public/hop-resolver.js): inferPath takes opts.allowRevisit. It skips the one-position bans and the cross-hop confidence bans, and the step cost forbids the same node only at the next hop. Geography and neighbour links still choose among nodes sharing a prefix, and a revisit costs nothing extra.
  • Frontend callers (public/packet-helpers.js, public/packets.js, public/map.js): inferObservationPath takes the packet's payload_type and sets the flag for a TRACE. The packet detail pane and the map deep link pass it. It uses a local TRACE_PAYLOAD_TYPE constant, because PayloadLabels is not loaded by every unit test that loads packet-helpers.js.

Without the flag the behaviour is unchanged.

Tests

  • Go: cmd/ingestor/trace_revisit_test.go, internal/packetpath/route_test.go, and an updated cmd/ingestor/resolved_path_test.go.
  • JS: tests/unit/test-hop-path-inference.js (Test 10b) and tests/unit/test-hop-path-detail.js (revisit through inferObservationPath, plus the detail pane and map deep link passing the payload type).
  • sh test-all.sh passes and ESLint on public/*.js reports 0 errors.

Browser validation

Checked in Chromium (Playwright, 1280px) against a copy of the E2E fixture with one synthetic TRACE b3 -> 7d -> b3, on the merge base and on this branch. Before, the first b3 is an unlisted hop with the inconsistency warning and the map route says "1 unresolved". After, both b3 hops are EW-HomeBase and the route reads 3 hops, 10 km. Light and dark screenshots of the packet detail and the map route panel are in this comment. Not checked on a real mesh capture.

Closes #2520

🤖 Generated with Claude Code

zfouts and others added 2 commits December 1, 2026 15:42
…ode (Kpa-clawbot#2520)

resolvePathWithContext excluded every node already on the path, so the
second A of a TRACE route A -> B -> A was stored as null in
observations.resolved_path. The firmware allows the revisit on purpose:
Packet::calculatePacketHash mixes path_len into a TRACE hash ("TRACE
packets can revisit same node on return path"), while every other
packet's hash ignores the path, so wasSeen keeps a node from forwarding
it twice.

packetpath.PathMayRevisit(payloadType) is the shared rule (TRACE only).
With it, resolvePathWithContext excludes only the previous hop (a radio
does not hear its own transmission) and still anchors on it through the
neighbour graph. Non-TRACE packets keep the one-visit exclusion.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…pa-clawbot#2520)

inferPath kept every node to one position, so on a TRACE route A -> B -> A
the earlier A was left unassigned and flagged unreliable even when A is
the only node with its prefix and 14 km from B.

inferPath takes opts.allowRevisit: it skips the one-position bans and
the cross-hop confidence bans, and the step cost forbids the same node
only at the next hop. Geography and neighbour links still choose among
nodes sharing a prefix; a revisit costs nothing extra.
inferObservationPath takes the packet's payload_type and sets it for a
TRACE (9); the packet detail pane and the map deep link pass it.
Without the flag the behaviour is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@zfouts
zfouts marked this pull request as ready for review December 1, 2026 22:15
…tionPath

Replace the bare 9 with TRACE_PAYLOAD_TYPE. PayloadLabels is not loaded by
every unit test that loads this file, so the constant is local, with a
comment pointing at PayloadLabels.enums.TRACE.enumId.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@zfouts

zfouts commented Dec 2, 2026

Copy link
Copy Markdown
Contributor Author

Before/after screenshots for a TRACE that goes back through a node, taken in Chromium (Playwright, 1280px wide) against the E2E fixture.

Setup: a copy of test-fixtures/e2e-fixture.db with one synthetic TRACE added, b3 -> 7d -> b3: b3 is EW-HomeBase (the only node starting with b3) and 7d is XMD Repeater 4, about 5 km away. Before is the PR's merge base (6ef8d65a), with resolved_path stored as master's ingestor writes it (second b3 is null). After is the PR head, with resolved_path as the new ingestor writes it (both visits resolved). Both servers were built in golang:1.27 with CGO_ENABLED=1.

What to look at:

  • Before: the first b3 is shown as an unlisted hop with the geographically-inconsistent warning, the route header says "1 unresolved", and the map route panel lists b3 as "unlisted".
  • After: both b3 hops are EW-HomeBase, the warning is gone, and the route reads 3 hops, 10 km (before, 5 km).

Light theme

Before (master) After (this PR)
Packet detail, Path row Before: Packet detail, Path row, light theme, b3 to 7d to b3 TRACE After: Packet detail, Path row, light theme, b3 to 7d to b3 TRACE
Packet detail, Path (3 hops) breakdown Before: Packet detail, Path (3 hops) breakdown, light theme, b3 to 7d to b3 TRACE After: Packet detail, Path (3 hops) breakdown, light theme, b3 to 7d to b3 TRACE
Map route panel (View route on map) Before: Map route panel (View route on map), light theme, b3 to 7d to b3 TRACE After: Map route panel (View route on map), light theme, b3 to 7d to b3 TRACE

Dark theme

Before (master) After (this PR)
Packet detail, Path row Before: Packet detail, Path row, dark theme, b3 to 7d to b3 TRACE After: Packet detail, Path row, dark theme, b3 to 7d to b3 TRACE
Packet detail, Path (3 hops) breakdown Before: Packet detail, Path (3 hops) breakdown, dark theme, b3 to 7d to b3 TRACE After: Packet detail, Path (3 hops) breakdown, dark theme, b3 to 7d to b3 TRACE
Map route panel (View route on map) Before: Map route panel (View route on map), dark theme, b3 to 7d to b3 TRACE After: Map route panel (View route on map), dark theme, b3 to 7d to b3 TRACE

Click an image for the full-size version.

Also pushed since the earlier review state: 976b1e02 replaces the bare 9 in inferObservationPath with a named TRACE_PAYLOAD_TYPE constant (a local one, because PayloadLabels is not loaded by every unit test that loads packet-helpers.js). No behavior change.

@efiten
efiten merged commit 016aaba into Kpa-clawbot:master Dec 2, 2026
17 checks passed
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 paths that revisit a node lose one occurrence — server leaves it unresolved

2 participants