Skip to content

fix(net): a minted source enforces its own request validity - #6748

Merged
kixelated merged 2 commits into
mainfrom
quest/m1/api-audit/answer
Oct 25, 2026
Merged

kixelated merged 2 commits into
mainfrom
quest/m1/api-audit/answer

Conversation

@kixelated

@kixelated kixelated commented Oct 25, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

A source minted for a dynamic request only stopped serving a stale instance if its session remembered to compute a RequestValidity and check it on each operation. Until a track request reached such a check, a stale source stayed open and cached, so later requesters were handed a broadcast whose every new track failed.

Approach

  • origin::Producer::create_source(path, validity) stores the validity on the source's producer side (broadcast::Alive).
  • broadcast::Dynamic::poll_requested_track checks it. Once the route is replaced or the selection period retires, the source closes. Queued and later track requests get Unroutable, the request stream ends, and tracks already accepted keep running to their own end. The poll registers on the validity, so the source closes promptly even when nothing is requested. Its front then reselects instead of keeping a dead source.
  • Lite and IETF sessions no longer thread their own copy. MintedSource/SourceServe lose their validity field, and per-operation checks (TRACK info, SUBSCRIBE, FETCH, TRACKS) read dynamic.validity() from the source. Those checks stay because a request handed out before the lapse can still go upstream after it.
  • JS: deleted wire.ts OriginConsumer.broadcasts, which was registered but never read. Its tests now use advertised (the table a session announces from) or were dropped.
  • Deleted group::Producer::poll_unused, which had no callers. group::Producer::abort_unused is called only by tests, so its allow reason now says so and the dead-code audit quest (quest/m2/audit-dead-code.md) owns it.

Choices made unattended:

  • The source stores the unstarted selection, so per-operation checks keep their exact current semantics (each captures the period it starts in). Admission closes the source the first time a check fails, so a source never outlives the first retirement it observes.
  • None of the dropped public additions from moq-dev/moq#6411 were brought over (answer_source, the unused-race family, empty, withdrawn, JS fallback/requested).

Impact

  • Public API: none. Every change is pub(crate) or behind the internal wire registry in @moq/net.
  • Wire: none.
  • Behavior: a stale epoch-less source now closes instead of lingering, so a requester re-resolves the path instead of hitting Unroutable on every new track.

Validation

  • New model::broadcast::test::a_lapsed_source_refuses_new_tracks. It fails without the check in poll_requested_track and passes with it.
  • Updated a_listing_of_a_retired_instance_never_reaches_the_wire: the serve task now ends with the source.
  • just rs test -p moq-net: 3201 passed.
  • bun test src/origin.test.ts: 94 passed.
  • just check: passed (8869 tests). One SLOW test, moq-cli report::export_echo_reports_where_the_import_solicits, is unrelated to this change.
  • quest check --base origin/main: ok.
  • Not run: just test interop (no wire change).

Finishes and deletes quest/m1/api-audit/answer.md.

(Written by Claude Opus 5.5)

🤖 Generated with Claude Code

kixelated and others added 2 commits October 24, 2026 23:53
The session that mints a source for a dynamic request now hands its
RequestValidity to the source itself. Once the route is replaced or the
selection period retires, the source's request stream ends: queued and
later track requests answer Unroutable, and tracks it already accepted run
to their own end. Sessions read per-operation validity from the source
instead of threading their own copy.

Also drops the unread `OriginConsumer.broadcasts` wire getter in @moq/net
and the uncalled group::Producer::poll_unused, and finishes the quest.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kixelated kixelated changed the title A request's source enforces its validity fix(net): a minted source enforces its own request validity Oct 25, 2026
@kixelated
kixelated marked this pull request as ready for review October 25, 2026 09:10
@coderabbitai

coderabbitai Bot commented Oct 25, 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 42 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: bf9230c0-b7eb-48d4-b6cb-167e60d2016e
Commits

Reviewing files that changed from the base of the PR and between 67bf4e5 and 76a5fdd.

Files selected for processing: 11
  • js/net/src/origin.test.ts
  • js/net/src/origin.ts
  • js/net/src/wire.ts
  • quest/m1/api-audit/README.md
  • quest/m1/api-audit/answer.md
  • quest/m2/audit-dead-code.md
  • rs/moq-net/src/ietf/subscriber.rs
  • rs/moq-net/src/lite/subscriber.rs
  • rs/moq-net/src/model/broadcast.rs
  • rs/moq-net/src/model/group.rs
  • rs/moq-net/src/model/origin.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 25, 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-25T09:12:12.249652Z 76a5fdd Draft marked ready
ℹ️ 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 kixelated left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review by review (OpenAI)

Reviewed commit: 76a5fdd

No actionable bugs found. Enforcing source validity at track-request admission is the right direction: stale sources close and reject queued/new requests while accepted tracks can drain. Checking validity outside the broadcast lock avoids reversing the origin/broadcast lock order, and retaining per-operation checks protects requests already handed to a session. The internal JS registry cleanup does not change the advertised routing table.

Verification: static review of the changes and surrounding selection-period, wakeup, source-close and session-draining code. I did not run tests or interoperability checks. The new regression directly covers route-token expiry; broader selection-period behavior was inspected rather than executed.

@kixelated
kixelated added this pull request to the merge queue Oct 25, 2026
Merged via the queue into main with commit 1308011 Oct 25, 2026
11 checks passed
@kixelated
kixelated deleted the quest/m1/api-audit/answer branch October 25, 2026 16:56
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