Repository navigation
feat(net)!: a reconnecting client is connected once the peer accepts its credential - #9038
Conversation
Quest-Claim: 16edfb3c8237bf9b
… its credential Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Maintainer decision on how bindings see acceptance: ✅ (a) moq-tokio's (Written by Claude Opus 5.5 with high) |
… session Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… replacement is established Handover.tla models the per-session Established step and checks that a connection reads as connected only once its session is established. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…in tests read an arrival's GOAWAY deterministically Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…WAY moves out of the live slot Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…variant Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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 4 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.
ℹ️ Two rough edges worth a look: a doc regression for moq-lite 03/04 across the bindings, and a stale sync commit in the model skill.
Approach: sound — acceptance is latched on the auth link that already owns the credential verdict, so every layer (policy, driver, bindings, JS) reads one signal instead of re-deriving it, and the model encodes the same rule.
Reviewed changes
- Acceptance per session (
rs/moq-net/src/auth.rs,lite/session.rs):accepted: boolbecomesAcceptance { Accepted, Awaiting, Silent }withLink::poll_accepted/Session::poll_accepted; the peer's SETUP (lite-05/06) and the AUTH_OK to the session's own credential (lite-07) latchAccepted, lite-03/04 areSilent, and lite-01/02 plus moq-transport accept at connect.Link::closekeeps the entry, so an acceptance survives the close it precedes. - Reconnect policy (
rs/moq-net/src/reconnect.rs):Action::Established(Box<Session>)is reported once per live session, checked before the close so an accepted-then-dropped session is an outage;Live::establishedgates the idle-predecessor close, the fallback probe, and theOfflineafter a mid-dial retirement, andconnected()no longer strips that queuedOffline. - moq-tokio (
rs/moq-tokio/src/connection.rs):Status::Connectedandestablished()move toAction::Establishedthrough a heldpendingtransport;stopped()latchesOkonce any session connected. - JS (
js/net):AuthSession.acceptedplus asilentprop;Reloadserves a session only once accepted, draining, or past the bar, and#settlereads the session's acceptance rather than uptime alone. - Model (
Handover.tla, both configs):Establish,OnEstablished,Serving, per-sessionaccepted/served, and theConnectedMeansEstablishedrule. - Tests and docs: binding reconnect tests drop their 1 s waits, relay drain tests read the GOAWAY through a reconnecting connection, the interop refused-WebSocket case asserts the refused session never reads connected, and the
Connecteddocs inmoq-ffi/libmoqname the lite-03/04 bar.
deepseek-v4.1-flash | 𝕏
|
Decision from the maintainer:
(Written by Claude Opus 5.5 with high) |
…tablishes a session A lite-07 session reads as connected only once the peer sends the AUTH_OK to the connection's own credential (or a SETUP on lite-05/06 and moq-transport) or drains it with a GOAWAY. The 1 s healthy bar establishes a session only on moq-lite 03/04, which never answer the credential. Applied to the Rust policy (`Reconnect`), JS `Reload`, and `Handover.tla`, which now picks per session whether its version answers. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
✅ No new issues found. Both earlier findings are fixed, and the uptime rule now applies only to moq-lite 03/04, consistently across Rust, JS, the model and the docs.
Approach: sound. The healthy-bar deadline now exists only when Session::is_silent() is true. Reconnect::established is set only where Action::Established is reported, so the policy flag and the reported state can no longer drift apart.
Reviewed changes
Two commits since the last pullfrog review: 51e8538a8 limits uptime to versions that never answer the credential, and 2bf3599f4 updates the model skill to match.
- Silent-only uptime (
rs/moq-net/src/reconnect.rs,auth.rs,session.rs): AddedLink::is_silentandSession::is_silent. TheLivebranch computes thehealthydeadline only for a silent session. On a version that answers, it waits onpoll_acceptedand the handover timer, however long the session has been up. - One place establishes the policy: Removed the tenure-based
establishedfromend()and the extra sets inprobed()andfollow(). This is safe because a probe starts only on an established live session (live.probe.filter(|_| live.established)). The healthy pacing reset throughretry.settleis unchanged. - JS
Reload(js/net/src/connection/reload.ts,auth_session.ts): Added theAuthSession.silentgetter. The uptime sleep in the serve race, and the uptime branch of#settle, now apply only whenauth.silent. - Model (
Handover.tla): Each session now pickssilentnon-deterministically, andHealthy(s)requires it.FirstWalkFailsFastnow also checksestablished => \E s : served.FollowPred,EndClosedandProbeGetsThroughno longer setestablished. - Tests: Renamed the uptime test to
an_unanswered_session_is_not_established_by_uptime; it now asserts a lite-07 session up 10× the bar is never established and its close ends the policy.an_unanswered_replacement_does_not_servenow waits 10× the bar before the AUTH_OK. A new JS test covers a lite-07 session up 5 s without an AUTH_OK. The lite-06 tests now establish through an accepted session first.a_token_is_presented_on_every_sessionanswers the connection credential too. - Docs: Every binding's Backoff,
onceand connect sentence, anddoc/bin/gstreamer.mdfor both elements, now carry the moq-lite 03/04 uptime caveat. Theverify-reconnectsync commit moved to51e8538a84, with the state counts updated.
claude-opus-5-5 | 𝕏
… fixed the close flake The client's close returned SESSION_NOT_FOUND when the server closed the accepted session first: before #9038 a session closed within 1s of uptime ended the reconnect loop, racing the test's close. #9038 establishes a session once its SETUP is answered, so the client now redials. Drop the comments that still describe the old rule, and the finished quest. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… comments it outdated (moq-dev#9078) Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

Summary
A reconnecting client now counts a session as established once the peer accepts the connection credential (or drains it with a GOAWAY), and only then reports it connected. Uptime stands in for that answer only on moq-lite 03/04, which have none: a lite-07 session the peer never answers stays unconnected however long it is up. A refused session never shows as connected, and
established()returns the refusal. This finishes the credential-established quest. The binding tests that waited out the 1 s healthy bar now drop the session as soon as it reports connected.moq-net): the auth link records anAcceptanceper session (Accepted,Awaiting,Silent). A client's peer accepts with its SETUP on lite-05/06 and moq-transport, or with the AUTH_OK to the connection's own credential on lite-07. lite-01/02 and the legacy moq-transport handshake accept at connect. lite-03/04 have no acceptance message, so they areSilent.ReconnectreportsAction::Established, carrying the session, once per live session: the peer accepted it or drained it with a GOAWAY, or, on a silent version (lite-03/04,Session::is_silent), it stayed up pastBackoff::healthy. A refused session never gets one. Until then, the session does not count as serving. A predecessor that retires meanwhile leaves the connectionOffline, an idle predecessor is not closed for it, and no fallback probe moves off it.Connectionpublishes Connected, andestablished()resolves, onAction::Establishedinstead of at dial time.established()resolvesOkonce any session was established, even if a one-shot loop has since ended, andErronly when the loop stopped before one was.js/net):Reloadserves a session (statusconnected, theestablishedsignal) only onceAuthSession.acceptedsays so or it drains with a GOAWAY, or, whenAuthSession.silent(lite-03/04), it passes the healthy bar.go/wrapper/reconnect_test.go), Python (py/moq-rs/tests/test_server.py), moq-ffi (rs/moq-ffi/src/test.rs, two places), and libmoq (rs/libmoq/src/test.rs).session_state_names_a_failing_first_dialagain asserts what follows the server's close: the client saw the session connected, so it redials (Disconnected).Handover.tlamodels the per-sessionEstablishedstep and checks a newConnectedMeansEstablishedrule. Its first run found thatReconnect::connecteddropped theOfflinea mid-dial retirement queued, which left the handle reporting a retired session. That is fixed here.doc/lib/index.md,MoqConnectionPhase::Connected,MOQ_CONNECTION_PHASE_CONNECTED, GoConnectionPhaseConnected, JSReload.status,Status::Connected,Connection::established, and theReconnectmodule docs.For moq-dev/moq#9016 (OBS reconnect tests): once this lands, the OBS tests can drop their 1 s healthy-bar waits. Wait for the session to report Connected, then drop it, and the client redials instead of giving up.
Decisions
From the maintainer (comment):
established()wait for the peer's acceptance (or the 1 s bar on lite-03/04) (rejected: (b) anacceptedflag in every binding's state snapshot, (c) keep the 1 s waits). Every binding follows, and the binding tests drop their waits.Made by the agent, please check:
Awaiting, the same as lite-07. A lite-07 session up for minutes without an AUTH_OK now never reads as connected, and its close ends the policy as a refusal. Every lite-07 session presents the connection's own credential (empty when anonymous), so an honest relay always answers.Action::Establishedvariant inmoq_net::reconnect::Action: ✅ the policy reports it (rejected: moq-tokio polling acceptance itself, which would duplicate the healthy timer and needSession::poll_acceptedmade public).Actionis exhaustive on purpose, so this is a breaking change for any externalReconnectdriver. The title carries!.established()latches: ✅Okonce any session was established, even after the one-shot loop ended (rejected:Err(Stopped)once the loop has stopped). Without this, a one-shot client whose peer accepts and drains at once (a draining relay) gotOkorStoppeddepending on timing. A refusal still returns its error.shutdown_signal.rs,runtime_uring.rs) now use a reconnecting connection, which keeps the drained session readable as the predecessor. A one-shot loop ends on the GOAWAY, asreconnect::Config::oncepromises, and they only passed before because Connected was published ahead of the GOAWAY. Other moq-tokio and relay tests now hold the server's session open, or wait until the client is established before the server acts.Public API and wire impact
moq_net::reconnect::ActiongainsEstablished(Box<Session>). Migration: an external driver ofReconnecthandlesAction::Established(session)and publishes that session as serving there, not when it reportsReconnect::connected. The action carries the session because a GOAWAY in the same pass may already have moved it out ofReconnect::session().moq_net::SessionimplementsDebug(its version), whichAction's derivedDebugneeds.Status::Connected, every binding'sConnectedphase, JSReload.status) now fires once the peer accepts the session, not when the transport handshake finishes. A refused session never reports it,connectsdoesn't count it, andestablished()returns its error.established()returnsOkafter a one-shot session that was established has ended.Backoff::healthy(and JSBackoff.healthy) establishes a session only on moq-lite 03/04; on a version that answers the credential, a session the peer never answers is not established however long it is up, and its close fails fast instead of retrying.Validation
just test interop --allpasses (all cells; the chromium route-key case skips as before). Its WebSocket refused-session case now asserts the refused session never reads as connected. Against the previous behavior it reportedconnecting, connected, disconnected. One earlier full run missedfinish python -> gst(the gst late reader got 0 of 10 frames, after it was online). It passed in two isolated runs and in a full rerun, so it's load-dependent and outside this change.Handover.tlapasses with 19.2M distinct states (Handover.cfg, 4 min) and 3.4M (RestartHandoff.cfg), with theConnectedMeansEstablishedrule. Each session now picks whether its version answers the credential, and uptime establishes only a silent one. Restoring the old rule (uptime on every version) failsConnectedMeansEstablishedin 6 steps. Before the mid-dial retirement fix, TLC found aStatusTruthfulviolation in 11 steps.go/just check(Go wrapper suite incl.TestReconnectAcrossRelayRestart),py/just test(124 passed),cargo test -p moq-ffi -p libmoqall pass.moq-netreconnect tests includean_early_goaway_establishes_the_session_it_drains(lite-04 GOAWAY before any answer, the round-1 review finding),an_unanswered_replacement_does_not_serve(Retired, then Offline at the handover, still not Established 10 s later, then Established on the AUTH_OK),an_unanswered_session_is_not_established_by_uptime(a lite-07 session up 10 s without an AUTH_OK is not Established, and its close ends the policy), and anEstablishedat the bar on lite-04.moq-tokio(unit and integration) andmoq-relay(lib and integration) pass 3 times each.reconnect_ends_on_a_first_session_rejectionassertsconnects() == 0.bun test src/passes (3349). New: a lite-07Reloadup 5 s without an AUTH_OK never readsconnected, then does on the AUTH_OK; it fails against the previousreload.ts. Two lite-06 tests that relied on uptime establishing an unanswered session now establish the URL with an accepted session first. The refused-session test assertsstatusnever readsconnected, and it fails against the previousreload.ts.just test interop --allpasses again (204 checks; the chromium route-key case skips as before).cargo test -p moq-net --all-features -p moq-tokio -p moq-ffi -p libmoq -p moq-relay -p moq-gstpasses.moq-tokio'sa_token_is_presented_on_every_sessionstopped accepting at the token and could skip the connection credential's AUTH_OK, so it relied on uptime; it now answers both.just checkpasses. The drill mutation patches still apply.audio_abort_unwanted_keeps_a_late_reader(an audio test with no connection) hung once in a plaincargo testrun and passed 3/3 alone. libmoq'sroute_broadcast_survives_id_reusefails under plaincargo testbecause it relies on nextest's process-per-test (its own comment says so), and passes alone.Follow-ups
Models
Size: S
Implementer: Claude Code, claude-opus-5-5, unknown effort (arm A)
Implementer: Claude Code, claude-opus-5-5, unknown effort (iterate, S, arm A)
Implementer: Claude Code, claude-opus-5-5, high effort (iterate, S, arm A)
(Written by Claude Opus 5.5)
🤖 Generated with Claude Code
Review
Rewritten by
quest reviewafter each round.Head: 2bf3599
Base: origin/main at 16880c8
Risk: medium,
the base has no RISK.md to name what is always high or customer-facing, so every change is mediumClassified: medium by default
Reviewer: Codex, gpt-6.1-sol, high effort
Session:
01a1ecbf-6c7b-7cd3-ae19-4e58cae0c797, round 3Score: 10/10,
The incremental changes consistently restrict uptime-based establishment to silent versions in Rust, JS, and the model, with no new findings; builds and tests were not run as instructed.Rounds: 3; first round 1 (medium 1); findings 1 (medium 1): fixed 1, refuted 0, open 0
Findings: none