Skip to content

fix(net): route floors never cover a live session and stay bounded - #9370

Merged
kixelated merged 7 commits into
mainfrom
quest/m1/lite07-routing/route-floors
Nov 22, 2026
Merged

kixelated merged 7 commits into
mainfrom
quest/m1/lite07-routing/route-floors

Conversation

@kixelated

@kixelated kixelated commented Nov 22, 2026 •

Copy link
Copy Markdown
Collaborator

Finishes quest/m1/lite07-routing/route-floors.md.

Problem

Two relays that dial each other (a shared cluster.connect list, mDNS mixed with static peers, a one-sided redial) hold two lite-07 sessions. When the newer one closed first, the relay named it in DEAD. Each receiver then floored the pair at that session, which covers the older, live session too. So every route over the surviving session was refused, and a relay reaching the far side only through them showed the broadcast unavailable until the older session flapped.

The floor table (Router::closed) was also kept for good. A relay crash-looping under a fresh random ID added entries to every survivor without limit. A routing peer could grow it at will: a ROUTE naming made-up relays, then a DEAD for each.

Approach

  • DEAD waits on older sessions. Router::disconnect names its own session only when no live routing session to the same relay is numbered lower. A deferred session's routes are replaced by the usual re-advertisement. So no floor ever covers a live session (FloorsClosed).
  • Floors are bounded by the heard routes. A floor whose pair some heard route joins is always kept. The rest ("loose" floors) are kept, oldest-evicted-first, only while they number no more than the joined pairs. That bounds the table at twice the joined pairs, which is linear in the routes a peer holds, and Router::check asserts it on every input.
  • The draft's rule for sending DEAD, a MAY-forget for floors, the route-algebra README's FloorsClosed argument and its "Two sessions to one neighbour" note, and the module doc are updated.
  • moq_relay::sim::Net::dial_down (test-support) refuses one direction's dials, for the new relay test.

Decisions

The maintainer accepted both on the merge pick (2026-11-22): ✅ DEAD names the closing session (rejected: DEAD names the highest closed session); ✅ the eviction rule below (rejected: evict once no live session or heard route names the relay).

  1. DEAD names the session that just closed, not "the highest closed". A session that closes while an older one to the same relay is still open is never named. The plan said to name the highest closed session. But a DEAD naming a session that no live route crosses fails the receiver's check_dead (Unrouted), which ends the session. Making that check pair-wide would add receiver code just for an accelerator. Under the deferral, the closing session lies below every live one, so its floor still covers only closed sessions. A deferred newer session gets no floor of its own, and its stale copies die by replacement.

  2. Eviction keeps recently loosened floors up to the joined count, instead of "once no live session or heard route names the relay". I measured the alternatives on the_router_gives_the_prototypes_answers:

    • Evicting as soon as no heard route joins the pair regressed partitions and home_dies on 6 shapes. On clique, for example: +1 settle round, stale 8→12, loops 38→55.
    • Relay-level rules ("both relays named", "far relay named") still regressed the tiers shapes.
    • Relay-level rules are also unbounded or quadratic against a hostile peer. With "far named", a peer that keeps one relay named can rotate made-up near relays. With "both named", the floors grow with the square of the named relays.
    • Evicting lazily, only when a new floor is filed, still regressed, because a partition files floors in a burst.

    The chosen rule regresses none of these and is linear.

Impact

  • Public API: none in moq-net. moq_relay::sim::Net::dial_down is added behind the test-support feature.
  • Wire: no encoding change. The draft now says a node sends DEAD for a session only if no lower-numbered session to the same relay is still open, and never names one that closes while one is. It also says a node MAY forget a floor whose pair no route it holds names. lite-07 is still -wip.
  • Behavior: two sessions between a pair of relays no longer black-hole routes when either closes. Floors no longer grow with restarts or a hostile routing peer.

Validation

  • Reproduced first with route::relay::tests::a_second_session_keeps_the_route, a three-router mesh closing whichever A–B session the route crosses. Main fails it; the branch passes.

  • The real surface: cluster_two_sessions::losing_either_of_two_sessions_keeps_the_route runs three moq-relay clusters on kio's simulator with peer grants: A and B dial each other, C dials A, and B publishes. It runs four combinations of which session is cheaper and which one closes. With the deferral reverted it fails: b's session to a closing lost [("live", false)] at C. With the fix it passes, in 0.3–0.4 s.

  • Restart order: a_restart_replaces_the_pairs_floor replaces the sim test the eviction made vacuous. It fails both when the start is dropped from floor_of's order (start 6 is above every floor) and when the start is keyed into the pair (one floor for the pair after start 6, left 2).

  • Bound: a_peer_naming_made_up_relays_leaves_no_floors sends 200 made-up relays with a DEAD each. The router stays at ≤4 floors, and 0 after the peer disconnects; main grows by one floor per relay.

  • Second, independent check, measured with benchmark_relay_floor_growth (nightly), eviction off vs on, floors per lasting relay. Main grows linearly with each replaced identity, while the branch stays flat:

    shape replaced main branch
    clique-32 16 / 32 / 48 / 64 30 / 60 / 90 / 120 27.2 throughout
    chords-32 16 / 32 / 48 / 64 12.9 / 24.2 / 34.7 / 45.4 12.0 / 12.9 / 11.9 / 12.5
    tiers-32 16 / 32 / 48 / 64 9.8 / 18.5 / 23.8 / 31.3 7.1 / 7.1 / 6.9 / 7.2
  • Also ran:

    • the multicast sweeps (--run-ignored only route::tests::multicast(_search|_cost)?): every-order searches, every failure at 32 relays, event work. All pass.
    • the integration mesh_sweep::seeded_meshes_hold_the_route_rules (500 cases, seed 12345), which passes.
    • just check on f0ea574f16, which passes: 11142 tests run, all passed. The local reviewer's sandbox runs no builds or tests by design, so this run stands in for them.
  • /verify-failover was not run: the change stays inside the router and doesn't reach how a front ends a track.

Caused by

  • moq-dev/moq#8901 - brought Router::disconnect naming every closed session, and floors kept for good (found by person, the 2026-11-21 routing audit)

Alternatives

  • One routing session per relay pair by a deterministic tie-break, which the maintainer rejected in the quest plan.
  • The eviction and DEAD variants under Decisions.

Follow-ups

None.

Models

Size: M
Implementer: Claude Code, claude-opus-5-5, unknown effort (arm B)
Implementer: Claude Code, claude-opus-5-5, unknown effort (iterate, M, arm B)

🤖 Generated with Claude Code

(Written by Claude Opus 5.5)

Review

Rewritten by quest review after each round.

  • Head: f0ea574

  • Base: origin/main at 1cdc73b

  • Risk: high, It changes when a relay sends DEAD for a closing session, which is the lite-07-wip wire rule the draft now states, so a peer on a build that expects the old rule could black-hole routes it used to keep, and reverting the draft and relay.rs commits would undo it; RISK.md counts a change to an unpublished -wip wire version as high because the next cut publishes it.

  • Classified: high by Claude Code, claude-haiku-5-5, low effort, session 3bf86b8a-6b22-433d-bab7-7c8cd30deae3

  • Reviewer: Codex, gpt-6.1-sol, high effort

  • Session: 01a2047f-ce12-7253-b94e-b407716300ea, round 1

  • Score: 9/10, No actionable defects were found; the session-floor fix and bounded retention align with callers and regression tests, though builds and tests were not run.

  • Rounds: 2; first round 0; findings 0: fixed 0, refuted 0, open 0

  • Findings: none

kixelated and others added 5 commits November 22, 2026 00:02
A relay names its own closed session only once every older session to the
same relay closed too, so a newer session closing first no longer floors the
older, live one and black-holes every route crossing it. Floors of pairs no
heard route joins are kept only while they number no more than the joined
pairs, oldest evicted first, bounding the table by the heard routes against
restarts and a hostile routing peer.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…he route-floors quest

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…r session closes

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kixelated kixelated changed the title Route floors hold under concurrent sessions and stay bounded against a hostile peer fix(net): route floors never cover a live session and stay bounded Nov 22, 2026
@kixelated
kixelated marked this pull request as ready for review November 22, 2026 11:28
@coderabbitai

coderabbitai Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 1 minute.

Check out review usage here.

View limit details

Limit details: You’ve used all 4 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: e781c218-53b4-490c-9fa1-8f74fd59a2cf
Commits

Reviewing files that changed from the base of the PR and between 2f3edd8 and f0ea574.

Files selected for processing: 11

  • drafts/draft-lcurley-moq-lite.md
  • quest/m1/lite07-routing/cluster-doc.md
  • quest/m1/lite07-routing/route-floors.md
  • quest/m2/lite07-finalize.md
  • quest/m2/node-id-drop-start.md
  • rs/moq-net/src/route/relay.rs
  • rs/moq-net/src/route/tests/multicast.rs
  • rs/moq-net/verify/route-algebra/README.md
  • rs/moq-relay/src/sim.rs
  • rs/moq-relay/tests/integration/cluster_two_sessions.rs
  • rs/moq-relay/tests/integration/main.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ No critical issues. Two minor suggestions inline: one test no longer checks anything, and one doc sentence doesn't match the code.

Approach: sound. Deferring DEAD until no lower-numbered live session to the same relay remains is the smallest fix that makes FloorsClosed hold. Capping the number of loose floors at the number of joined pairs keeps the table linear in heard routes and doesn't need a timer.

Reviewed changes

Reviewed all six commits: the router change, the doc and draft text, and the new unit and integration tests.

  • DEAD deferral: Router::disconnect now names its own closed session only when no live routing peer to the same relay has a lower session number. A deferred session is never named, so its stale routes go away when the routes are re-advertised.
  • Bounded floors: Loose tracks floors whose pair no heard route joins anymore. forget() evicts the oldest of them while they outnumber rx_pairs, and check() asserts the bound on every input.
  • Why the bound holds when a floor is filed: a receiver files a floor only after check_dead, which guarantees a live route joins the pair. Own-relay floors are never filed. So a new floor never enters the table already loose.
  • Docs and draft: updated the rule for when DEAD is sent, added a MAY-forget for floors, and rewrote the route-algebra FloorsClosed argument.
  • Tests: added a three-router mesh, a 200-relay hostile-peer bound test, and a kio-simulated cluster_two_sessions integration test using the new Net::dial_down.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using claude-opus-5-5 | 𝕏

Comment thread rs/moq-net/src/route/tests/multicast.rs Resolved
… deferred session is never named

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

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found. Both earlier suggestions are fixed.

Reviewed changes

Reviewed f0ea574, the only commit since the last review. f1ac740 was a merge of main and was already covered.

  • Replaced the vacuous floor test: deleted a_session_floor_keeps_an_entry_per_pair_of_relays, which always sampled 0 floors. Added a_restart_replaces_the_pairs_floor in relay.rs, which sends a ROUTE and a DEAD under start 5 and again under start 6. It checks that the higher start passes the old floor and that the pair keeps one entry. It passes locally, and it would fail if a restart added a second entry.
  • Clarified that a deferred session is never named: the README's FloorsClosed argument, the draft's Closed Sessions rule and changelog, and the module and disconnect comments now say that a session closing while an older one to the same relay is live is never named, and that its routes go by replacement. This matches Router::disconnect.

Pullfrog  | View workflow run | Using claude-opus-5-5 | 𝕏

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found. No commits have landed since the last review, and both earlier findings are settled.

Reviewed changes

No commits since the last review, which approved f0ea574. This run re-checked the two resolved threads against the current head.

  • Replaced the vacuous floor test: the author confirmed that a_restart_replaces_the_pairs_floor fails both ways floor_of's order could break: with the start dropped, and with the start keyed into the pair.
  • Made the docs match disconnect: the module doc, README, and draft now say that a session closing while an older one to the same relay is open is never named. The author confirmed this is the intended behavior (Decision 1).

Pullfrog  | View workflow run | Using claude-opus-5-5 | 𝕏

@kixelated
kixelated added this pull request to the merge queue Nov 22, 2026
Merged via the queue into main with commit 1a67977 Nov 22, 2026
9 checks passed
@kixelated
kixelated deleted the quest/m1/lite07-routing/route-floors branch November 22, 2026 19:28
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