Skip to content

fix(net): publish the send estimate before the connect - #6652

Merged
kixelated merged 3 commits into
mainfrom
quest/m1/test-flakes-2/go-reservation-grant
Oct 25, 2026
Merged

kixelated merged 3 commits into
mainfrom
quest/m1/test-flakes-2/go-reservation-grant

Conversation

@kixelated

@kixelated kixelated commented Oct 24, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

TestReservationUpdateReleasesSubscribedTrack (go/wrapper/bandwidth_test.go) failed with "grant unavailable" because a client could observe a connect before the session's send estimate reached the persistent allocator. Two hops raced the connects counter:

  1. moq_net::Session created its send-estimate producer empty and only filled it once the driver noticed a consumer and sampled.
  2. moq-tokio's reconnect loop published Connected (bumping connects) before run_session forwarded that estimate into the connection's persistent send_bandwidth.

Fixed at the source, so no wait is needed in the test at all:

  • moq-net: the send-estimate producer is seeded with the session's first sample (already taken at construction), so Session::send_bandwidth() reads an estimate from the start whenever the backend has one.
  • moq-tokio: Shared::connected seeds the persistent estimate before publishing the state, so a watcher that sees the connect already reads the estimate and the reservation grants that divide it.
  • moq-ffi (wasm dial): same ordering, the estimate is seeded before the session is published.

The Go test is unchanged: after waitConnects, Reservation.Grant() is now deterministically non-nil.

Quest quest/m1/test-flakes-2/go-reservation-grant.md is deleted along with its link in the epic README.

Reproduction

Go test, -race, 32 extra CPU burners on a 24-core host already at load ~30:

Build Runs "grant unavailable"
main (unloaded) 200 1
main (loaded) 1000 272
this PR (unloaded) 2000 0
this PR (loaded) 3000 0

Decisions made

  • Fixed the ordering at the source instead of making the test wait. The quest suggested waiting on the grant's own signal, but the Go Reservation exposes no change signal (only the Grant() snapshot), so a wait would have meant either a polling retry or a new public GrantChanged across every binding. Making "connected implies the estimate is readable" true removes the race for every consumer, not just this test.
  • Extended send_bandwidth_samples_while_the_driver_runs in moq-net to assert the estimate is readable before the driver first runs, rather than adding a new test. No new moq-tokio test: the Go test now exercises the ordering end to end deterministically.

Public API and wire impact

Public API: none (no signatures change). Behavior: moq_net::Session::send_bandwidth() and moq_tokio::Connection::send_bandwidth() now hold an estimate as soon as a connect is observable, instead of None until the first sample was forwarded. Docs on both say so.

Wire: none.

Checks

  • just go check (vet, build, go test -race ./...)
  • Repro loop above
  • nix develop --command just check: every selected module passed, including Rust nextest (8775 passed) and the wasm32 clippy of moq-ffi
  • nix develop --command just test interop --all: 172/172 passed with the host at load ~33. Two earlier runs at load ~87 failed the browser js publisher's tone checks, rust-swapped -> js-native-node (timestamp gap), and the rust-denied grant/Unauthorized check. main passed 172/172 at load ~41 between them, and this branch then passed at ~33, so I read those as load flakes rather than this change. They were never compared at equal high load.

Follow-ups

  • The tone and timestamp-gap failures are already covered by the sibling quests tone grace and interop timestamp gap.
  • Possible new flake: under heavy load the rust-denied publisher over the WebSocket fallback logged auth token ended err=no stream credit and did not exit with Unauthorized, and one subscriber reported grant nothing. Worth a quest if it shows up again.
  • A Reservation.GrantChanged in moq-ffi and the bindings would let non-Rust senders follow their grant without polling, if a consumer needs it.

🤖 Generated with Claude Code

(Written by Claude Opus 5.5)

kixelated and others added 2 commits October 24, 2026 09:28
A client could observe a connect before the session's send estimate reached
the persistent allocator, so reservation grants read None right after
connecting. Seed the session's estimate producer with its first sample, and
seed the connection's persistent estimate before publishing the connect.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kixelated kixelated changed the title The Go reservation test waits for a grant fix(net): publish the send estimate before the connect Oct 24, 2026
@kixelated
kixelated marked this pull request as ready for review October 24, 2026 17:58
@coderabbitai

coderabbitai Bot commented Oct 24, 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 13 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: f7fc44b7-df15-4b52-8f67-0e23380f0b4f
Commits

Reviewing files that changed from the base of the PR and between 1092357 and f057783.

Files selected for processing: 6
  • quest/m1/test-flakes-2/README.md
  • quest/m1/test-flakes-2/go-reservation-grant.md
  • rs/moq-ffi/src/session/dial.rs
  • rs/moq-net/src/client.rs
  • rs/moq-net/src/session.rs
  • rs/moq-tokio/src/connection.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

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-25T00:19:24.040781Z f057783 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@kixelated

Copy link
Copy Markdown
Collaborator Author

Landing this at 5edc80c1ae.

  • Fixes the Go reservation flake at its source: a session's send estimate is set before its connect becomes visible (moq-net Session::new, moq-tokio Shared::connected, the moq-ffi wasm dial).
  • Review checked that the first estimate is the backend's own snapshot and not a placeholder, and that no other path publishes a connect first (moq-uring and moq-wasm have no such path).
  • Codex reviewed this head with no findings. CI passed, and the base-relative quest check passed.
  • Follow-up, not in this PR: js/net/src/connection/reload.ts also marks a connection connected before its send estimate is filled.

(Written by Claude Opus 5.5)

@kixelated
kixelated added this pull request to the merge queue Oct 24, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Oct 24, 2026
# Conflicts:
#	quest/m1/test-flakes-2/README.md
@kixelated

Copy link
Copy Markdown
Collaborator Author

Merged origin/main (1092357) to clear the queue's merge conflict. The only conflict was the Required list in quest/m1/test-flakes-2/README.md: this PR dropped the Go reservation grant link and main dropped the interop timestamp gap link (moq-dev/moq#6658), so both are gone. The PR's own code diff is unchanged. just check and the pre-land quest check pass on f057783.

(Written by Claude Opus 5.5)

@kixelated
kixelated added this pull request to the merge queue Oct 25, 2026
Merged via the queue into main with commit 2832aeb Oct 25, 2026
10 checks passed
@kixelated
kixelated deleted the quest/m1/test-flakes-2/go-reservation-grant branch October 25, 2026 01:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant