Repository navigation
Bind the route proof to the router - #9113
Conversation
Quest-Claim: dbeaae4f90ba62d4
The router ranked claims of equal rank by the relays that took them and their claimant, ignoring the mark, so an upstream scoped neighbour could be told nothing while an unmarked claim of the same rank was at hand. Claims now rank the mark after the rank, as routes and restate do. Extracts the functions the route proof's binding calls: Offer::own, Offer::onward, Here::arrive, order, Claim::over, Claim::exported, Claim::adopted, and claim_order. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The proof's Rust binding ran the prototype. It now runs the router's own functions for a node's own route, sending a route on, taking one in, and ordering candidates, and binds the claim instance too: within a domain, across a grant, and the order claims are picked in. The algebra gains a leading key (a claim's precedence), a tag that reads the route, and an instance-supplied order among equal lengths, so each instance orders as the router does: routes by the neighbour's Node ID, marked identities included; claims by precedence, rank, mark, length, claimant, and giver. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Random pairs rarely tied on rank with a different mark or path length, so a router that ignored either still matched every vector. A third of the pairs now differ only there. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
sticky.rs runs on RelaySim, so the rule-as-it-runs sweep checks the router that ships. The proof README says what the binding covers and what it does not; the prototype helpers only the old binding used go. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Warning Review limit reachedYou'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 6 minutes. View limit details
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. |
There was a problem hiding this comment.
✅ No new issues found.
Approach: Sound. It pulls the router's own route and claim functions out of Router and points the Agda binding at them, so the proof now samples what ships rather than the multi.rs prototype. The one behavior change is the claim_order mark fix, which is narrow and has a regression test.
Reviewed changes
This review covers all 19 files: the relay.rs refactor and claim-order fix, the rewritten algebra.rs/sticky.rs binding, and the Agda instances and docs.
relay.rsroute functions:Offer::own,Offer::onward,Here::arrive, andorderreplace inline code inown_offer/usable/reselect/sent. I traced each one and the filters and keys match the code they replace.relay.rsclaim functions:Claim::over,Claim::exported, andClaim::adopted, plus freetakes/stamp, replace the inline join inways/stands/closestand the stamp/limit inadopt/stands.standsmoves the marked-export refusal intoexported(.., upstream). I checked that this is equivalent on every branch:- own claim:
claim.marked; - another node's claim:
claim.over(best).marked, which equals the oldcrossed_markthrough themarks/best.offer.markedinvariant; - unavailable claim:
crossed_mark; - gone claim:
gone.claim.marked.
- own claim:
- Closest-claim fix:
ClaimOrdernow ranks the mark after the rank, soclosestprefers an unmarked claim at equal rank, asrestateand routes already did. Before, a marked scoped neighbour could be told nothing.an_unmarked_claim_is_closest_among_equal_rankscovers it. restatekey: it now goes throughclaim_order(claim, None, owner).ownerfollowsmarked, so the order is unchanged.- Binding tests:
algebra.rsgenerates 336 route vectors and 320 claim vectors from the router functions.sticky.rsruns onRelaySim.- The prototype-only helpers and the
tiestest are removed.
- Agda changes:
Increasinggains a leading key (rise) and an edge-awaretag.Routeadds the metric and other-start filters and orders by the full Node ID.NamedreplacesSim.Claimmodels precedence, adoption versus the domain step, and the chain limit.Orderreplacesshortlexwithnewest/runs.
claude-opus-5-5 | 𝕏
reselect keeps #9114's Ways record and orders by the bound order function; the multicast README drops both finished quests' links. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ollowers #9114 logs a route change only when a way's next hop, rank, or mark moves. claim_order reads only the route's rank and mark, so a same-rank, same-session route that turns marked and moves the closest claim is still logged. The test pins that, and fails with the mark left out of Ways. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
This run covers the two commits since 207acbe: the merge of main, which brings in #9114, and one new router test.
- Merged
reselect: it now builds #9114'sWaysfromself.usable(origin)and picks with the boundorder. The record holds each usable route's next hop, rank, and mark, plus the next hop in use.claim_orderandwaysread only a route's rank and mark, and both are in that record, so any route change that moves the closest claim gets logged. claim_orderdoc: it now says the function reads only whatWaysrecords, and linksRouter::relog.- New test
a_route_flipping_which_claim_is_unmarked_reaches_its_followers:- Node 5's route turns marked at the same rank. That alone logs a route change and moves the closest claim to node 4.
- Node 4 then gains an unmarked route through node 3. That also logs, and the closest way moves to
Next::Via(3). - I ran it locally, together with the 45 other tests in
route::relay::tests. All pass.
claude-opus-5-5 | 𝕏
|
Maintainer decision (2026-11-19, in the coordinating session): merge on the coordinator's recommendation while the maintainer travels. Under that pick, the coordinator's choice: ✅ merge, with the marked-claim fix in (Written by Claude Fable 5.2 with high effort) |
|
Answered: the decision above is recorded in #9113 (comment) and nothing else waits on the maintainer here. (Written by Claude Fable 5.2 with high effort) |
|
quest land watch: the merge queue removed this pull request at d80788a because it conflicts with The land fixer works on it in the background, and the watcher re-enqueues it at the back of the queue once it is fixed or judged flaky, or hands it back here with what it needs. (written by quest land watch) |
|
quest land watch: armed auto-merge on this pull request at 9d66263, so it joins the back of the merge queue once its required checks pass, with the land fixer's fix ( (written by quest land watch) |
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
This run covers the merge of main since d80788a. The only change it makes to this PR is how the conflict in relay.rs was resolved.
- Resolved the neighbour-claims conflict: a claim whose chain the node refuses still counts toward
main'sChanges::looped, whichnode.rsreads intoRouteRefusal::Looped. The check now calls the PR's freetakes(&claim.chain, self.me.relay, self.forwards)instead of the oldself.takesmethod. No callers of the old method remain, and the branch still yieldsChange::Lost, somain's refusal counting and the bound predicate both carry over unchanged.
claude-opus-5-5 | 𝕏

Finishes
quest/m3/route-proof-binding.md.Problem
The lite-07 route rule has an Agda proof (
rs/moq-net/verify/route-algebra/) that routes and claims settle. Its Rust binding still ran the prototype the proof was written against (route/tests/multi.rs), notroute::relay::Router. Sojust test route-proofproved a rule nobody runs.Approach
relay.rsand called by the router itself:Offer::own,Offer::onward,Here::arrive,order,Router::usable;Claim::over(joined with the route to the announcer),Claim::exportedandClaim::adopted(the two sides of a grant), andclaim_order, whichclosestandrestatenow share.Increasing.agda): it gains a leading key, a tag that reads the route, and an instance-supplied order among equal path lengths. Each instance now orders exactly as the router does.Route.agda,Named.agdareplacingSim.agda): nodes are Node IDs, marked identities included.[marked identity, node], and that marked hop counts toward the 32.Claim.agda):closestdoes.algebra.rswrites 336 route results toVectors.agdaand 320 claim results to the newClaimVectors.agda. Agda must reproduce each one byrefl. A third of the choices tie up to the neighbour, claimant, or giver, and a third also differ only in the mark or path length, so each tie-break decides some.sticky.rsruns onRelaySim, so the "rule as it runs" sweep checks the shipping router.a_marked_route_does_not_tie_with_an_unmarked_oneis gone:relay::Routerhas noties, becausewaysoffers every usable route.Counterexample: an upstream told nothing at an equal rank
Binding the claim order showed the router wrong.
closestranked claims of equal rank by the relays that took them and then the claimant, ignoring the mark. Routes andrestateboth put the unmarked one first.Smallest case (
an_unmarked_claim_is_closest_among_equal_ranks): relay 1 hears node 4's claim over a link it marked upstream, and node 5's claim over an unmarked one, at the same rank. Node 4 names the lower Node ID, soclosestpicked it.standsthen tells a marked (upstream) scoped neighbour nothing, even though an unmarked claim of the same rank was at hand. The upstream loses the broadcast.Fixed here, since it changes no wire and no public API:
claim_orderranks the mark after the rank, asrestatealready did. Before the fix the test fails (pickreturned node 4 and the upstream was told nothing); after it, it passes. The mutation sweep (below) plants the old order back, and the Agda vectors reject it.Merged with #9114
moq-dev/moq#9114 made
reselectlog a route as changed only when itsWays(each usable route's next hop, rank, and mark, and the next hop in use) move. The merge keeps that record and hasreselectorder by the boundorder.Ways,relog, and the invariant check.Offer::own,Offer::onward,Here::arrive,order,usable,Claim::over,exported,adopted, andclaim_orderare the same code.ROUTE_VECTORS=writeregeneratesVectors.agdaandClaimVectors.agdabyte for byte.closestfix.claim_orderreads only the route's rank and mark, never its path, andwaysdoes the same throughClaim::over.Waysrecords both, so no route change that moves the closest claim goes unlogged. The router's own retelling (dirty) follows a remark or a rank move of the route in use, as before.a_route_flipping_which_claim_is_unmarked_reaches_its_followerspins the case: a same-rank route through the same session turns marked, which moves the closest claim to the other announcer, and then that announcer gains an unmarked route. Each step is logged and the closest way follows. With the mark left out ofWays, the test fails at the first step.reselectand a note onclaim_order.What the bound proof covers
Accelerate).sticky.rson the router: 29 of 2,282 routes differ in next hop between two delivery orders, none in rank, mark, or reachability).What it still does not cover
The proof README's "What this does not give" lists each. In short:
routeandadoptrefuse as malformed. That a node feeds the bound functions the latest offer per neighbour is argued on paper.Decisions
closestdecides it over unreachable claims too. The label is history-dependent likeclaimed, and is documented as such rather than modelled.closestin line with the route order andrestate.Waysas is. It records exactly whatclaim_orderandwaysread from a route (rank and mark per next hop, and the one in use), so it hides no change to the closest claim.Validation
just test route-proof(pinned nix build): every module checks, including both vector files.just check: passes (10,660 tests).relay.rs, the vectors regenerated, and Agda run on them. Caught: an unmarked marked route; a marked route sent upstream; a path naming another start of the receiver's relay; the floor ignored; the hop limit off by one; the named drain ignored; the priority not lowered; the mark, the neighbour Node ID, or the length left out oforder; the mark or claimant left out ofclaim_order; a join keeping the claim cost or dropping the route mark; a claim exported over a marked link; an adopter taking a chain naming it, keeping the priority, ignoring the port mark, or never naming itself; an older run ranked newer. Missed: the exporter's chain limit off by one (equivalent, see above).sticky.rswith the mark moved below the next hop in use: 20 routes differ in the mark, andan_equal_route_in_use_never_leaves_a_neighbour_without_onefails, as the README argues.cargo test --release -p moq-net --lib route::tests::multicast -- --ignored): 6 passed.just checkpasses (10,673 tests).ROUTE_VECTORS=writeleaves both vector files unchanged, sojust test route-proofbuilds the same derivation that already checked, and Nix reuses it (exit 0).Impact
route::relayis crate-private).Caused by
closestranking claims without the mark (found by the proof binding).Follow-ups
None.
Models
Size: L
Implementer: Claude Code, claude-opus-5-5, unknown effort
🤖 Generated with Claude Code
(Written by Claude Opus 5.5)
Review
mechanical fix by codex, gpt-6.1-sol, medium effort:
Merged base; re·solved relay.rs conflict by retaining the extracted takes predicate and base looped counter; passed nix develop --command just check base and nix develop --command just test route-proof.(head 9d66263)Rewritten by
quest reviewafter each round.Head: d80788a
Base: origin/main at a245f60
Risk: high,
it changes .github/workflows/nightly.yml, which is always high: workflows run with the repository's secrets and decide what merges and shipsClassified: high by the always-high paths
Reviewer: Codex, gpt-6.1-sol, xhigh effort
Session:
01a1f13e-2e94-7c90-a9d4-6bcbc23d2550, round 1Score: 9/10,
No actionable defects were found in the scoped source review; builds and tests were not run, as instructed.Rounds: 2; first round 0; findings 0: fixed 0, refuted 0, open 0
Findings: none