Skip to content

fix(net): lite-07 cost ceiling, zero link cost, and pipelined announce edits match the draft - #9379

Merged
kixelated merged 5 commits into
mainfrom
quest/m1/lite07-routing/conformance
Nov 22, 2026
Merged

kixelated merged 5 commits into
mainfrom
quest/m1/lite07-routing/conformance

Conversation

@kixelated

@kixelated kixelated commented Nov 22, 2026 •

Copy link
Copy Markdown
Collaborator

Finishes quest/m1/lite07-routing/conformance.md: Rust and JS lite-07 now match the draft on four points the main → release routing audit found.

Changes

  • Cost ceiling (Rust). A claim's cost saturates at 2^62-1, as the draft says, instead of u64::MAX. route::MAX_COST reuses origin::Cost::MAX. Both router sums (Claim::joined, Claim::adopted) cap there, and decode_claim reads anything above it as the ceiling, so a value over the ceiling from a peer is never forwarded raw. JS already clamped on decode.
  • Zero link cost (JS). Setup decode reads PARAM_COST (0x4) and refuses a lite-07 cost of 0 with ProtocolViolation, as Rust does. The value is otherwise unused. routed.ts still charges a local cost of 1, and its comment now gives the draft's reason (a receiver MAY charge a local value of at least 1) instead of claiming to match Rust's default.
  • Pipelined announce edits (JS). Answer kept #request set only until the edit started, not until its ANNOUNCE_OK went out. So a peer that sent its next edit while the pre-OK #sync() was still in flight got past the "before the last was answered" guard and was checked against stale prefixes (a/x nested under a pending a). The request is now cleared just before the OK is written, as Rust does.
  • decode_forwarded (Rust). It returns (Instance, u64) and fails on an empty or non-UTF-8 instance instead of returning None. Its one caller already turned None into a PROTOCOL_VIOLATION. The doc no longer says a bad instance "withdraws only the claim", and the test asserts the error.

Choices for review

  • A Rust relay clamps a received claim cost above 2^62-1 rather than refusing it. The draft says costs saturate, JS clamps, and relays from the previous release may still send u64::MAX; refusing would break the mixed-version rollout.
  • Route (ROUTE message) costs stay unchanged. The draft gives them no ceiling, and the router already drops a route whose sum passes u64.
  • JS only refuses a zero cost; it doesn't keep the value (a browser forwards nothing), and it never sends the parameter.

Public API / wire

Public API: none. Wire: Rust no longer sends a claim cost above 2^62-1; JS refuses a lite-07 SETUP cost of 0; a JS publisher refuses an ANNOUNCE_REQUEST sent before the previous one's ANNOUNCE_OK. All three are what the draft already requires, so no draft change.

Validation

  • New JS test an edit sent before the last was answered is refused: it fails on the old answer.ts ("Received function did not throw") and passes with the fix.
  • New JS test: a lite-07 SETUP with cost 0 is refused, cost 5 is accepted, and lite-06 ignores the parameter.
  • New Rust test a_claim_cost_saturates_at_the_ceiling: costs of 2^62-1, 2^62, and u64::MAX written raw in lite-07's varint all decode as 2^62-1. Router tests a_route_past_the_metric_is_never_used now expect the ceiling. The decode_forwarded test expects an error.
  • just check: passed (11128 Rust tests, JS tests, lint, dead code).
  • just test interop --all: the first run failed only js -> rust with audio gap after 1608 samples on a host at load 31. That is the known intermittent gap tracked in quest/m0/interop-green. The rerun passed all 203 cells.

Caused by

  • moq-dev/moq#8901 - the sans-IO router saturated claim costs at u64::MAX, not the draft's 2^62-1 (found by the routing audit)
  • moq-dev/moq#8987 - moved the JS answer's #request clear ahead of the pre-OK sync, and left decode_forwarded returning an Option that every caller now refuses (found by the routing audit)
  • JS never reading PARAM_COST goes back to when the JS lite-07 SETUP was first written; no single PR introduced it.

Follow-ups

None. moq-dev/moq#9349 touches the same announce files (unknown announce types) but different hunks.

Models

Size: S
Implementer: Claude, claude-opus-5-5, unknown effort (arm A)

🤖 Generated with Claude Code

Review

Rewritten by quest review after each round.

  • Head: f22be33

  • Base: origin/main at 142769f

  • Risk: high, It changes lite-07 wire behavior that deployed peers rely on: JS now refuses a SETUP with a zero link cost, Rust now fails the stream on a bad forwarded instance where it used to withdraw only that claim, and both Rust and JS now clamp claim costs to the draft ceiling, so a peer's over-ceiling costs are forwarded differently. Those peers would see refused streams and different routes, and a revert only undoes it after the next cut ships it. The tier is high rather than medium because whether lite-07 is a frozen or -wip version is not established from the diff, and the risk file makes any wire change high. The test and quest-plan deletion alone would be low.

  • Classified: high by Claude Code, claude-haiku-5-5, low effort, session 2103198b-7cec-44af-8aa6-0458d9c4d798

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

  • Session: 01a202d2-f321-7bf1-9cd0-3b19bd2ad452, round 1

  • Score: 9/10, No actionable regressions were found in the focused fixes with regression coverage, but builds and tests remain unexecuted as instructed.

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

  • Findings: none

kixelated and others added 4 commits November 22, 2026 00:09
…ails decode

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

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kixelated kixelated changed the title Rust and JS lite-07 match the draft on cost ceilings, zero link cost, and pipelined announce requests fix(net): lite-07 cost ceiling, zero link cost, and pipelined announce edits match the draft Nov 22, 2026
@kixelated
kixelated marked this pull request as ready for review November 22, 2026 10:36
@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 2 minutes.

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: 2ce5257c-7d30-4561-9649-4645d74c0b1c
Commits

Reviewing files that changed from the base of the PR and between 0c5b90d and 68763a3.

Files selected for processing: 10

  • js/net/src/lite/answer.test.ts
  • js/net/src/lite/answer.ts
  • js/net/src/lite/routed.ts
  • js/net/src/lite/setup.test.ts
  • js/net/src/lite/setup.ts
  • quest/m1/lite07-routing/conformance.md
  • rs/moq-net/src/lite/announce.rs
  • rs/moq-net/src/lite/instance.rs
  • rs/moq-net/src/route/mod.rs
  • rs/moq-net/src/route/relay.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

@kixelated
kixelated enabled auto-merge November 22, 2026 10:36

@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 — one garbled comment inline.

Approach: sound — clamps claim costs where they enter (decode) and where they grow (joined/adopted), refuses a zero cost at SETUP decode, and moves the JS request clear to the same point Rust uses.

Reviewed changes — the full diff at f22be33: Rust cost ceiling and decode_forwarded, JS SETUP cost and announce pipelining, plus tests.

  • Cost ceiling (Rust) — route::MAX_COST reuses origin::Cost::MAX (a const fn value, 2^62-1). Both router sums and decode_claim cap there, so encode_claim never writes an over-ceiling cost. Clamping rather than refusing keeps relays from the previous release, which may still send u64::MAX, interoperable.
  • decode_forwarded (Rust) — now returns Result<(Instance, u64)>. Its only caller already turned None into InvalidValue, so the wire behavior is unchanged.
  • Zero link cost (JS) — Setup decode refuses a lite-07 PARAM_COST of 0, matching lite/setup.rs.
  • Pipelined announce edits (JS) — #request is now cleared inside #edit, after the pre-OK #sync() and the prefix update, and just before the OK. A pipelined edit now hits the guard at answer.ts:102 instead of being checked against stale prefixes. If #sync() throws, #request stays set, but #run exits anyway, so nothing loops.
  • Tests — the new JS answer test reproduces the stale-prefix nesting. The Rust test covers 2^62-1, 2^62, and u64::MAX. The warm.rs thresholds (Metric::MAX / 4 with a strict <) equal the new ceiling exactly, so saturated costs are still excluded there.

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

Comment thread js/net/src/lite/routed.ts Resolved
@moq-bot
moq-bot Bot disabled auto-merge November 22, 2026 10:38
@moq-bot

moq-bot Bot commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

quest land watch: ended this pull request's pick, disarming its auto-merge, since its head f22be33 is held by finding by pullfrog[bot]: This edit left the comment garbled: "which the draft lets a receiver charge whatever the peer declared" doesn't parse, a (#9379 (comment)). Push a fix, or answer each by a thread reply or a comment linking its review or decision, then land it again.

(written by quest land watch)

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.

Reviewed changes

Reviewed the one new commit since the prior review.

  • Rewrapped the #candidate comment in js/net/src/lite/routed.ts. This fixes the garbled comment from the prior review, and the code is unchanged.

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

@kixelated
kixelated added this pull request to the merge queue Nov 22, 2026
Merged via the queue into main with commit 7849bbd Nov 22, 2026
5 checks passed
@kixelated
kixelated deleted the quest/m1/lite07-routing/conformance branch November 22, 2026 13:34
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