Skip to content

fix(meshd): SocketAddr neighbor map + gate v2 (rebased onto main) - #50

Merged
gHashTag merged 2 commits into
mainfrom
feat/socketaddr-fix-and-gate-v2-onto-main-2026-07-05
Jul 5, 2026
Merged

fix(meshd): SocketAddr neighbor map + gate v2 (rebased onto main)#50
gHashTag merged 2 commits into
mainfrom
feat/socketaddr-fix-and-gate-v2-onto-main-2026-07-05

Conversation

@gHashTag

@gHashTag gHashTag commented Jul 5, 2026

Copy link
Copy Markdown
Owner

Rebased onto main after squash-merge collapse of PR #48+#49 stack.

Context

PR #48 was squash-merged into main as c95afbd. PR #49 was configured with feat/w7-m2-fpga-pivot-2026-07-05 as base and after PR #48 merge its base did NOT auto-rebase to main. Merging PR #49 (as 67edde5) landed the fix into the now-orphaned feat/w7-m2-fpga-pivot-2026-07-05 branch, not into main. This PR re-lands the SocketAddr fix + gate v2 onto main directly.

Content

Cherry-picked two commits onto main:

  • ea34192 fix(meshd): key neighbor map on SocketAddr, not IpAddr — from 43ab3bf
  • d206577 fix(smoke): gate v2 — finite-ETX visibility across N=5 samples — from 293978a

Fix (SocketAddr) was 3× independently verified before merge (sandbox + macOS ×2). Gate v2 was contra-verified 5/5 on macOS.

Verify

git fetch origin
git checkout feat/socketaddr-fix-and-gate-v2-onto-main-2026-07-05
cargo build --bin trios_meshd --release
cargo test --release   # 137 passed
N=5 DURATION=10 ./smoke/m2_loopback_smoke_n_runs.sh   # 5/5 PASS expected

Discipline

  • Feature branch, DRAFT by default
  • No fabricated metrics; loopback numbers are sim-boundary
  • Anchor preserved

phi^2 + phi^-2 = 3

gHashTag added 2 commits July 5, 2026 16:24
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
gHashTag marked this pull request as ready for review July 5, 2026 16:33
@gHashTag
gHashTag merged commit 13e4692 into main Jul 5, 2026
2 checks passed
@gHashTag
gHashTag deleted the feat/socketaddr-fix-and-gate-v2-onto-main-2026-07-05 branch July 5, 2026 16:33
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.

1 participant