Skip to content

feat(net): follow announced instances in moq-net - #5925

Merged
kixelated merged 4 commits into
mainfrom
quest/m1/net-announced-follow
Oct 21, 2026
Merged

kixelated merged 4 commits into
mainfrom
quest/m1/net-announced-follow

Conversation

@kixelated

@kixelated kixelated commented Oct 19, 2026 •

Copy link
Copy Markdown
Collaborator

Implements moq-net follows announced instances: moq-net now owns the follow loop that #5700 hand-rolled in moq-ffi and moq-c (decision 5 there).

Changes

  • moq-net origin::Consumer::announced_broadcast(path, epoch) returns an origin::AnnouncedBroadcast. Its available() (and poll_available()) hands out each publisher instance serving the path: the first once announced, then each one that takes over, or that returns after an end. It is the Rust form of JS request(path, { announced: true }). It settles the three cases the bindings each handled:
    • An End forgets the last instance, so the same instance returning after a gap is handed out again.
    • The last instance is held as a broadcast::WeakConsumer, so it never keeps a front from retiring once the caller lets go.
    • Every change on hand is applied before an answer is read, and a change drops the resolution in flight and resolves afresh. A resolution that runs ahead of its held Restart is skipped when it is the front handed out last.
  • Pinned epoch: announced_broadcast(path, epoch) resolves only that instance. Routing (behind routed_broadcast) gained a private epoch, so a pinned wait parks while another instance serves the path, as a pinned request_broadcast refuses it.
  • moq-ffi MoqAnnouncedBroadcast::available() and moq-c moq_origin_announced_broadcast drop their loops and call it. moq-c's now-unused Consume::holds goes too.
  • Docs: the "Follow restarts" bullet in doc/lib/rs/moq-net.md points at announced_broadcast.
  • Quests: this quest is deleted. Sink restart follow and Rust lazy discovery are unblocked and now name the new API.

As the quest decided, this registers no discovery interest and has no blind fallback. Lazy discovery owns the first.

Public API and wire impact

  • moq-net (additive): origin::Consumer::announced_broadcast, origin::AnnouncedBroadcast with poll_available and available (async feature).
  • moq-ffi, moq-c, the bindings, js/net: no API change. available() keeps its signature; OBS keeps calling it.
  • Wire: none.

Tests

  • Follow epochless restarts in exports and bindings #5700's binding regressions pass unchanged: the 10 announced_broadcast_* tests in rs/moq-ffi/src/test.rs and the consume_announced_* tests in rs/moq-c/src/test.rs.
  • New moq-net tests in rs/moq-net/src/model/follow.rs, on moq_clock simulated time. Each fails when its fix is reverted:
    • announced_hands_out_the_instance_again_after_an_end: fails if an end keeps the last instance.
    • announced_hands_out_a_dropped_takeover_again: fails if the last instance is held strongly. The dropped front never retires.
    • announced_hands_out_a_held_takeover_once: fails without the skip of the front handed out last.
    • announced_hands_out_a_gap_while_resolving_once: an end and a start while resolving hand the newcomer out once.
    • announced_pinned_refuses_another_instance: mirrors the JS an epoch-pinned announced request refuses another instance. Fails if the resolution drops the pin.
  • just check and just test interop --all pass locally on the merge with main (2026-10-20). The first just check run hit export::redundant_importers_switch_through_bufferbloat_on_lite_07, a known main flake tracked by quest/m1/test-flakes-2/redundant-failover-drift.md in moq-cli, which this PR does not touch. A rerun passed all 7763 tests.
  • The earlier WASM failure was a wasm-bindgen schema mismatch (Cargo.lock 0.2.127 vs the nix CLI 0.2.129). Main now derives the CLI from Cargo.lock, and the merge brings that in.

Decisions

The quest left the Rust shape to this PR. The maintainer confirmed all three as implemented (comment).

  1. The Rust shape.
    • ✅ origin::Consumer::announced_broadcast(path, epoch) -> Result<origin::AnnouncedBroadcast, Error>, with available() / poll_available(). It joins the request_broadcast / routed_broadcast family, and its names match moq-ffi's announced_broadcast / MoqAnnouncedBroadcast::available() one to one, so the bindings stay thin.
    • Mirror JS literally: request_broadcast(path, request::Options { announced, epoch }). The return type would then change with the option, or every request would get a long-lived handle with a changing active() broadcast. That breaks today's one-shot Requesting.
    • Keep the shape but use stream names: next() / poll_next() like announce::Consumer and Follow, or a role name such as origin::Following. That is more idiomatic Rust but no longer mirrors the bindings.
  2. What a pinned request does when another instance wins.
    • ✅ It waits. It hands out nothing until its epoch serves the path again, and it hands out that instance again after an end. This matches JS, whose pinned active reads undefined while another epoch wins.
    • Fail with Unroutable once another instance wins. That is louder, but an epoch that returns after a failover gap would then need a new request.
  3. What "the caller still holds it" means. The bindings remembered their own handle (Weak<MoqBroadcastConsumer>, or the moq-c id). moq-net can only see the front, so it remembers a WeakConsumer, which is live while the front is. The difference is narrow. Say a takeover resolves ahead of its held Restart, and the caller drops its handle while another reader keeps that front up, or the front lingers after reads. That caller then waits for the next change instead of getting the same front again.

Suggested follow-ups

  • Sink restart follow is now unblocked and can build on announced_broadcast.
  • moqsrc (rs/moq-gst/src/source/imp.rs, follow_path) and moq play (rs/moq-cli/src/play/media.rs) still drive follow() by hand and resolve on each start, without the takeover-once and gap handling. A quest could move both onto announced_broadcast.

(Written by Claude Opus 5.5)

🤖 Generated with Claude Code

kixelated and others added 3 commits October 18, 2026 23:33
Add `origin::Consumer::announced_broadcast(path, epoch)`, the Rust form of
JS `request(path, { announced: true })`. Its `available()` hands out each
publisher instance serving the path, owning the follow loop moq-ffi and
moq-c carried since #5700: an end forgets the last instance, the last
instance is held weakly, and a change while resolving resolves afresh.
A pinned epoch refuses any other instance.

moq-ffi's `MoqAnnouncedBroadcast::available()` and moq-c's
`moq_origin_announced_broadcast` now use it, with no binding API change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kixelated

Copy link
Copy Markdown
Collaborator Author

Quest outcome: implemented and verified locally (just check, just test interop --all). Opened as a draft because the quest left the Rust API shape to this PR. The three open decisions in the description (shape, pinned semantics, and weak-front memory) each ship with the recommended option and are waiting on a maintainer call. Next step: /quest-iterate to settle them.

(Written by Claude Opus 5.5)

@kixelated

Copy link
Copy Markdown
Collaborator Author

Maintainer decisions on the three open decisions (relayed from an interactive session, 2026-10-19): all three as implemented.

  1. Shape: origin::Consumer::announced_broadcast(path, epoch) -> origin::AnnouncedBroadcast with available() / poll_available(), matching moq-ffi one to one. JS keeps its request(path, { announced, epoch }) form.
  2. A pinned request waits while another instance wins, rather than failing Unroutable.
  3. "Still held" means a WeakConsumer of the front. No per-call liveness token.

(Written by Claude Opus 5.5)

@kixelated
kixelated marked this pull request as ready for review October 20, 2026 20:41
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 20, 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-20T20:47:12.661791Z 4da990b Manual request
ℹ️ 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.

@coderabbitai

coderabbitai Bot commented Oct 20, 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
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 161dbc2f-d898-4947-afd6-0b66bc09ce23
📥 Commits

Reviewing files that changed from the base of the PR and between 96d6b5b and 4da990b.

📒 Files selected for processing: 11
  • doc/lib/rs/moq-net.md
  • quest/m1/README.md
  • quest/m1/lazy-discovery/rust.md
  • quest/m1/net-announced-follow.md
  • quest/m1/sink-restart-follow.md
  • rs/moq-c/src/consume.rs
  • rs/moq-c/src/origin.rs
  • rs/moq-ffi/src/origin.rs
  • rs/moq-net/src/model/follow.rs
  • rs/moq-net/src/model/mod.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.

@kixelated

Copy link
Copy Markdown
Collaborator Author

@codex review

(Written by Claude Opus 5.5)

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. More of your lovely PRs please.

Reviewed commit: 4da990ba3d

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@kixelated

Copy link
Copy Markdown
Collaborator Author

Merge summary for 4da990ba3d436bee0b14faeaaee213ce88b776d2:

  • moq-net gains origin::Consumer::announced_broadcast(path, epoch) and origin::AnnouncedBroadcast (available() / poll_available()), the Rust form of JS request(path, { announced: true }). moq-ffi and moq-c drop their own follow loops and call it; their APIs are unchanged. No wire change.
  • Decisions, confirmed by the maintainer (comment): the shape mirrors moq-ffi one to one; a pinned request waits while another instance serves the path; "still held" is a WeakConsumer of the front.
  • Main merged in, which fixes the earlier WASM failure (a wasm-bindgen version mismatch now pinned on main).
  • Local checks on this head: just check (7763/7763; a first run hit the known moq-cli flake tracked by quest/m1/test-flakes-2/redundant-failover-drift.md), just test interop --all, quest check.
  • Review: Codex found no issues on this head (receipt).

Follow-up: move moqsrc and moq play onto announced_broadcast.

(Written by Claude Opus 5.5)

@kixelated
kixelated added this pull request to the merge queue Oct 20, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Oct 20, 2026
@kixelated
kixelated added this pull request to the merge queue Oct 20, 2026
@kixelated
kixelated removed this pull request from the merge queue due to a manual request Oct 21, 2026
@kixelated
kixelated added this pull request to the merge queue Oct 21, 2026
Merged via the queue into main with commit 74499ba Oct 21, 2026
14 checks passed
@kixelated
kixelated deleted the quest/m1/net-announced-follow branch October 21, 2026 03:04
kixelated added a commit that referenced this pull request Oct 21, 2026
The follow and front-reconcile tests from #5925 used dynamic(prefix, route). Unanswered default-route claims become dynamic(prefix); those that accept a peer's broadcast or carry an epoch keep their scenario on the hidden dynamic_route.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
kixelated added a commit that referenced this pull request Oct 21, 2026
…-followups

Point sink-restart-follow at announced_broadcast, which #5925 landed, drop the abandoned native-noq-feature entry, and link the macOS QUIC connect fix #6110.

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