Skip to content

fix(net): the session driver's Send and Sync proofs fit the default recursion limit - #9143

Merged
kixelated merged 3 commits into
mainfrom
quest/m1/driver-sync-depth
Nov 19, 2026
Merged

kixelated merged 3 commits into
mainfrom
quest/m1/driver-sync-depth

Conversation

@kixelated

@kixelated kixelated commented Nov 19, 2026 •

Copy link
Copy Markdown
Collaborator

Finishes quest/m1/driver-sync-depth.md.

Summary

On the flake's pinned nightly, under -D recursion_depth_exceeding_limit, two things overflowed: asking whether moq_net::Driver is Sync (the moq-ffi exporter asks this through rustc's is_sync query), and moq-tokio's spawn of panic::isolate(time::run(driver)) proving Send. Both now settle within the default limit:

  • lite::publisher::Publisher::children is a SendCell<kio::Tasks<Control>>, as #8657 did for the subscriber. SendCell gains DerefMut, which is sound because a &mut can only put in another value of the same T, whose bounds the constructor already checked.
  • Driver is explicitly !Sync (a PhantomData<Cell<()>> field). It was never Sync: moq-transport's TaskSet holds Box<dyn FnMut + Send> children. The publisher cell alone still overflowed, and so did the marker alone. Together they settle.
  • Driver proves Send once: an unsafe impl Send backed by a compile-time assertion that destructures every field, so adding a field without checking it fails to build. This cuts moq-tokio's chain (isolate, kio::clock::drive, time::run<Driver>).
  • just rs send-depth also checks moq-tokio's lib, and the send test asserts Driver: Send and that the Sync check answers no (an autoref-specialization probe, with a Session control that answers yes). sh/rs/select.sh runs send-depth on moq-tokio changes too.

Public API: Driver stays Send and !Sync, as before; it is now !Sync on purpose. Wire: none.

Decisions

Made without the maintainer (away); a review can undo each:

  • Plan change: Driver is !Sync, not Send + Sync. The quest asked to prove Driver: Send + Sync, but Driver has never been Sync (the ietf TaskSet, see above), and the exporter only needs the question to settle, not a yes. A driver is polled only through &mut, so Sync gains nothing. Alternative: make the ietf task set Sync as well (a SyncWrapper-style cell for BoxTask), which adds unsafe code for no consumer.
  • unsafe impl Send for Driver instead of another cell, because State is not Sync and SendCell requires both. The exhaustive destructuring keeps it checked.
  • Probe test rather than assert Sync, since the answer is no.

Validation

All on the flake's pinned nightly with -D recursion_depth_exceeding_limit (the send-depth environment):

  • Reproduced first at a245f604: the new Driver probe overflowed through driver::State, Protocol, lite::session::Driver, lite::publisher::Publisher, and kio::Tasks<Control>, and cargo check -p moq-tokio --lib overflowed at rs/moq-tokio/src/client.rs:703, matching the quest's measurement.
  • Isolated each part: without the publisher cell, State: Sync overflows; without the !Sync marker, the Driver probe overflows; without the unsafe impl Send, moq-tokio overflows. With all three, just rs send-depth passes.
  • On stable: cargo test -p moq-net --features async --test send passes (5 tests), python3 sh/rs/select.test.py passes, and just check passes.
  • Gate cost: the added moq-tokio check takes about 3s incrementally when only moq-tokio changed. A cold run also checks moq-tokio's extra dependencies on nightly, which mbx caches.
  • Not run: rust2's just ffi moq-cpp against this branch. Its remaining 19 export errors are fixed by rust2's own pin bump.

Caused by

No single PR: the overflow is a new compiler lint (rust-lang/rust#159228) applied to session state that had grown deep over many PRs.

Follow-ups

None.

Models

Size: S
Implementer: Claude Code, claude-opus-5-5, medium effort (arm B)

(Written by Claude Opus 5.5 with medium)

Review

Rewritten by quest review after each round.

  • Head: 979b919

  • Base: origin/main at b2372ad

  • Risk: medium, the base has no RISK.md to name what is always high or customer-facing, so every change is medium

  • Classified: medium by default

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

  • Session: 01a1f1ba-d6aa-7132-b732-13142930b029, round 2

  • Score: 9/10, No actionable defects were found in the merge integration; the combined check selection preserves both branches' checks, though builds and tests were not run as instructed.

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

  • Findings: none

kixelated and others added 2 commits November 18, 2026 16:59
…ecursion limit

The lite publisher's control children prove Send + Sync once in a SendCell, the
driver proves Send once from its fields and is explicitly !Sync, and send-depth
checks moq-tokio's spawn and the driver's Sync answer under the lint.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kixelated kixelated changed the title Prove the session driver Sync, and moq-tokio's spawn Send, within the default recursion limit fix(net): the session driver's Send and Sync proofs fit the default recursion limit Nov 19, 2026
@kixelated
kixelated marked this pull request as ready for review November 19, 2026 02:55
pullfrog[bot]
pullfrog Bot previously approved these changes Nov 19, 2026

@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.

Approach: sound. It ends the recursion at the narrowest types: the lite publisher's task set proves its bounds once in a SendCell, Driver answers Sync with a definite no, and Driver proves Send once per field. Dropping the quest's "Send + Sync" goal is justified, because Driver was already !Sync: the ietf TaskSet holds BoxTask = Box<dyn FnMut(..) + Send>, with no Sync (rs/moq-net/src/util.rs:17).

Reviewed changes — the full diff at 67f90e4 across all 8 files.

  • Publisher::children in a SendCell: the same approach #8657 used for the subscriber. SendCell::default() still requires kio::Tasks<Control>: Send + Sync when the cell is built.
  • SendCell: DerefMut: sound. A &mut T can only swap in another value of the same T, and auto traits depend only on the type, so the unsafe impl Send/Sync reasoning still holds.
  • Driver is !Sync on purpose: a PhantomData<Cell<()>> field. No public API change, since Driver was never Sync.
  • unsafe impl Send for Driver: backed by a const block that destructures every field and asserts each is Send. Adding a field, or changing one to a non-Send type, fails to build. This matches what the old whole-type assertion caught, and Boxable requires Send + Sync on every target, so nothing changes per platform.
  • send test probes: an autoref-specialization probe checks that Driver answers no to Sync, with Session as a control that answers yes. A fn(Driver) coercion checks Send. Both compile under -D recursion_depth_exceeding_limit through send-depth.sh's --test send.
  • Gate coverage: send-depth.sh now also checks moq-tokio --lib. That covers the spawn in connect_session (rs/moq-tokio/src/client.rs:703), which is built with default features. select.sh now runs the gate on moq-tokio changes too, with a matching case in select.test.py.

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

@coderabbitai

coderabbitai Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Driver now has an explicit non-Sync marker and a field-level Send check followed by an unsafe Send implementation. Publisher.children now stores its task collection in SendCell, which supports mutable dereferencing. Tests check Driver’s Send and non-Sync properties and Session’s Sync property. Lint selection and the send-depth script now include moq-tokio. The prior driver sync-depth document was removed.

Merge Risk: Minimal · up to 979b9

The change makes the session driver's Send and Sync proofs fit the compiler's default recursion limit while keeping Driver Send and not Sync. No merge-blocking risk was identified.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: the session driver's Send and Sync proofs now fit the default recursion limit. The changeset adds SendCell to the publisher children, marks Driver !Sync, and adds an u…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description check Passed The description states the goal (make the Driver Sync and Send proofs settle under the default recursion limit) and names the concrete changes: SendCell in Publisher::children, a PhantomData<Cell<()>>…
Full details: Title check

Explanation

The title names the main change: the session driver's Send and Sync proofs now fit the default recursion limit. The changeset adds SendCell to the publisher children, marks Driver !Sync, and adds an unsafe impl Send with a compile-time field check. The title is specific and matches the objectives. The 'fix(net)' scope is accurate, and the title is long but still one clear sentence.

Full details: Description check

Explanation

The description states the goal (make the Driver Sync and Send proofs settle under the default recursion limit) and names the concrete changes: SendCell in Publisher::children, a PhantomData<Cell<()>> marker making Driver !Sync, an unsafe impl Send with exhaustive destructuring, the send-depth script and select.sh updates, and the send test. These match the changeset, so the description is related and specific.

Finishing Touches

Simplify code

  • Commit to this branch
  • Create a new PR
  • 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

Recent review info

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: 1f9a286d-e9a2-4764-b615-7361f43d1b2e
Commits

Reviewing files that changed from the base of the PR and between 67f90e4 and 979b919.

Files selected for processing: 2

  • sh/rs/select.sh
  • sh/rs/select.test.py

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 0 remain after this review.

@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: the one commit since the last review merges origin/main.

  • Merged origin/main into the branch: the conflict in sh/rs/select.sh keeps both gates. The send-depth line still runs on (moq-net|moq-tokio) changes, next to main's new wants libmoq → just rs c-tests --syntax line. sh/rs/select.test.py also keeps the moq-tokio send-depth assertion and main's test_gate_compiles_c_callers_against_libmoq.

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

@kixelated
kixelated added this pull request to the merge queue Nov 19, 2026
Merged via the queue into main with commit f23debd Nov 19, 2026
8 checks passed
@kixelated
kixelated deleted the quest/m1/driver-sync-depth branch November 19, 2026 03:42
kixelated added a commit to kixel-ai/rust2 that referenced this pull request Nov 19, 2026
moq's main now builds moq-tokio and the facade without tripping
recursion_depth_exceeding_limit (moq-dev/moq#9143). Port every moq
program and bench to its API: groups keyed by a start timestamp,
origin routes in place of publications, inclusive time ranges, and
libmoq in place of moq-c. Drop the stale excludes and exclude the six
new refusals.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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