fix(meshd): key neighbor map on SocketAddr (loopback smoke regression gate) - #49
Merged
gHashTag merged 2 commits intoJul 5, 2026
Conversation
Loopback smoke on 127.0.0.1:5011/5012/5013 exposed a HashMap collision: all three simulated nodes shared 127.0.0.1, so the last insert won and node-11 lost identity. On real hardware every P203 Mini has a unique IP, so the defect is sandbox-only, but it makes CI smoke unreliable. Change: - HashMap<IpAddr, NodeId> -> HashMap<SocketAddr, NodeId> (rename ip_to_id -> addr_to_id) - Central RX dispatches on full src: SocketAddr from recv_from - drop unused IpAddr import Regression gate: - smoke/m2_loopback_smoke.sh now ends with a strict "triangle convergence gate" that fails with exit 2 if any node does not see both peers at steady ETX 1.0x. - smoke/M2_LOOPBACK_FIX_RESULTS.md documents defect, fix, and reproduction with actual sandbox output. Verification (all -sim, this sandbox, 2026-07-05): - cargo build --bin trios_meshd --release: clean - cargo test --workspace --release: 137 passed, 0 failed - DURATION=10 ./smoke/m2_loopback_smoke.sh: all 3 nodes PASS, exit 0 Behaviour on real hardware unchanged (unique IPs collapse to unique SocketAddrs); this is a strict superset. Ref PR #48 (parent, introduces smoke). phi^2 + phi^-2 = 3
The v1 gate ("last neighbors line == 1.0x for both peers") was
non-deterministic under WMEWMA. Reviewer ran the smoke twice
back-to-back on same host, same binary (SHA 43ab3bf), only pkill
between runs:
run #1: node-11 { 13=2.03 } -> gate FAIL (coin-flip red)
run #2: node-11 { 12=1.00, 13=1.00 } -> gate PASS (coin-flip green)
Both are correct measurements. The gate itself was the problem:
WMEWMA with alpha=0.5, HELLO_MS=300, ETX_WINDOW=3 bounces ETX for
3-4 ticks after any single dropped HELLO on any real channel. The
v1 gate tested the algorithm's asymptote (steady 1.0x) instead of
the SocketAddr fix's actual invariant (both peers visible, ETX
finite). Category error.
v2 gate design:
- Grep last N=5 neighbors lines per node.
- Require both peers with a finite decimal ETX in every sample.
- Reject missing peers (pre-fix regression signal).
- Reject inf/nan (persistent link death).
- Accept transient spikes like 2.03 (correct WMEWMA response).
Sandbox verification:
- Positive: 5/5 runs PASS with new gate.
- Negative: synthetic pre-fix log (node-11 with empty neighbors)
correctly triggers FAIL for node-11.
Also added smoke/m2_loopback_smoke_n_runs.sh: convenience wrapper
that runs the smoke N times (default 5) and requires every run to
exit 0. Encodes the "results-without-repro-check" discipline: a
regression tripwire must be verified deterministic before trusted.
Reference: WMEWMA rationale (Woo, Tong & Culler, SenSys 2003;
Rosati et al., arXiv:1307.6350).
Ref PR #48 (parent), PR #49 (this branch).
phi^2 + phi^-2 = 3
gHashTag
marked this pull request as ready for review
July 5, 2026 16:22
gHashTag
added a commit
that referenced
this pull request
Jul 5, 2026
* fix(meshd): key neighbor map on SocketAddr, not IpAddr Loopback smoke on 127.0.0.1:5011/5012/5013 exposed a HashMap collision: all three simulated nodes shared 127.0.0.1, so the last insert won and node-11 lost identity. On real hardware every P203 Mini has a unique IP, so the defect is sandbox-only, but it makes CI smoke unreliable. Change: - HashMap<IpAddr, NodeId> -> HashMap<SocketAddr, NodeId> (rename ip_to_id -> addr_to_id) - Central RX dispatches on full src: SocketAddr from recv_from - drop unused IpAddr import Regression gate: - smoke/m2_loopback_smoke.sh now ends with a strict "triangle convergence gate" that fails with exit 2 if any node does not see both peers at steady ETX 1.0x. - smoke/M2_LOOPBACK_FIX_RESULTS.md documents defect, fix, and reproduction with actual sandbox output. Verification (all -sim, this sandbox, 2026-07-05): - cargo build --bin trios_meshd --release: clean - cargo test --workspace --release: 137 passed, 0 failed - DURATION=10 ./smoke/m2_loopback_smoke.sh: all 3 nodes PASS, exit 0 Behaviour on real hardware unchanged (unique IPs collapse to unique SocketAddrs); this is a strict superset. Ref PR #48 (parent, introduces smoke). phi^2 + phi^-2 = 3 * fix(smoke): gate v2 — finite-ETX visibility across N=5 samples The v1 gate ("last neighbors line == 1.0x for both peers") was non-deterministic under WMEWMA. Reviewer ran the smoke twice back-to-back on same host, same binary (SHA 43ab3bf), only pkill between runs: run #1: node-11 { 13=2.03 } -> gate FAIL (coin-flip red) run #2: node-11 { 12=1.00, 13=1.00 } -> gate PASS (coin-flip green) Both are correct measurements. The gate itself was the problem: WMEWMA with alpha=0.5, HELLO_MS=300, ETX_WINDOW=3 bounces ETX for 3-4 ticks after any single dropped HELLO on any real channel. The v1 gate tested the algorithm's asymptote (steady 1.0x) instead of the SocketAddr fix's actual invariant (both peers visible, ETX finite). Category error. v2 gate design: - Grep last N=5 neighbors lines per node. - Require both peers with a finite decimal ETX in every sample. - Reject missing peers (pre-fix regression signal). - Reject inf/nan (persistent link death). - Accept transient spikes like 2.03 (correct WMEWMA response). Sandbox verification: - Positive: 5/5 runs PASS with new gate. - Negative: synthetic pre-fix log (node-11 with empty neighbors) correctly triggers FAIL for node-11. Also added smoke/m2_loopback_smoke_n_runs.sh: convenience wrapper that runs the smoke N times (default 5) and requires every run to exit 0. Encodes the "results-without-repro-check" discipline: a regression tripwire must be verified deterministic before trusted. Reference: WMEWMA rationale (Woo, Tong & Culler, SenSys 2003; Rosati et al., arXiv:1307.6350). Ref PR #48 (parent), PR #49 (this branch). phi^2 + phi^-2 = 3 --------- Co-authored-by: gHashTag <auaavroo0312@hotmail.com>
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.
Summary
Fix the sandbox-testability defect discovered while running the M2 loopback
smoke introduced in #48: the neighbor identity map in
trios_meshdwas keyedon
IpAddr, so three simulated nodes on127.0.0.1collided into a singleentry and node-11 lost identity.
Not a hardware M2 blocker. Real P203 Mini boards have unique IPs, so the
bug never surfaces there. This is purely a fix for the CI smoke rig.
Base
This PR is stacked on #48 (
feat/w7-m2-fpga-pivot-2026-07-05). Merge #48first, then this. If you rebase #48 onto main, please rebase this branch too.
Change
src/bin/trios_meshd.rs:HashMap<IpAddr, NodeId>→HashMap<SocketAddr, NodeId>(ip_to_idrenamed toaddr_to_id)SocketAddrreturned byrecv_fromuse std::net::IpAddrdroppedBehaviour on real hardware is a strict superset of the previous code (unique
IPs collapse trivially to unique
SocketAddrs), so no regression there.Regression gate
smoke/m2_loopback_smoke.shnow ends with a "triangle convergence gate":each node's last
neighborslog line must list both peers at steadyETX in the range
1.00–1.09. Any missing peer or non-steady ETX fails thescript with exit code 2. This is the tripwire for anyone who accidentally
regresses the fix.
Verification (sandbox,
-sim, 2026-07-05)Full context:
smoke/M2_LOOPBACK_FIX_RESULTS.md.Reproduction
Discipline hooks
this sandbox at 2026-07-05 22:2x +07 and is labelled
-sim.cites. Advancing the branch requires a fresh
Re-reviewed at <new_sha>: delta <bullet-list>.surface is the committed diff.
phi^2 + phi^-2 = 3