Repository navigation
feat(net): metadata subscriptions in Rust, JS, and the bindings - #9793
Merged
Merged
Conversation
Quest-Claim: 09947984951c4386
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>
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>
A slab entry per header let a slow C consumer grow native memory without bound. `moq_header_callback` now passes each `moq_header` by pointer for the call, which drops `moq_consume_meta_header` and its free. The interop plan also registers the metadata cells, so an early stop reports them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Since main's pacing changes, a publisher records a group's traffic a step after its reader gets the bytes, so the check settles in simulated time first, as the file's other traffic checks do. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
kixelated
marked this pull request as ready for review
November 27, 2026 23:29
This was referenced Nov 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Finishes quest/m2/subscribe-meta.md (deleted here), on top of the relay half in moq-dev/moq#9758.
Problem
moq-dev/moq#9758 made every lite-07 publisher and relay serve metadata subscriptions, but nothing outside
moq-netcould open one: the lookup (track_meta,trackMetaOf) was crate-private or@internal, and reading it meant knowing a metadata copy stores an empty payload with the size beside it.moq-hlslive and archive indexing and the route-health standby need it before the lite-07 cut.Approach
A metadata subscription is a subscription of its own, with types of its own, so a payload read of a header-only frame cannot be written.
moq-net: newmetamodule.broadcast::Consumer::meta(name)returnsmeta::Consumer, whosesubscriberesolves tometa::Subscriber(recv_group,finished,update,control,info). Itsmeta::Groupreadsnext_header() -> Option<frame::Info>: the timestamp and the declared plain size, read from stored slices so a compressed frame is never inflated or waited on, and without holding the payload in flight.@moq/net:Metanamespace mirroring it.broadcast.meta(name)givesMeta.Consumer,Meta.Subscriber(recvGroup,finished,update,info,close), andMeta.Group(nextHeader,index,start,close).skip_to/readFrameIndex({ from })). Nothing switches mode in place.moq-ffi:MoqBroadcastConsumer::subscribe_metareturnsMoqMetaConsumer(recv_group,info,update,cancel), whoseMoqMetaGroupreadsnext_header() -> MoqFrameHeader { size, timestamp }. Python, Go, Kotlin, Swift, and Dart wrap it as each wrapssubscribe_track, and C++ is generated.libmoq:moq_consume_meta,moq_consume_meta_update, andmoq_consume_meta_cancel. Itsmoq_header_callbackreceives eachmoq_header(group, frame index, size, and timestamp) borrowed for the call, so libmoq holds nothing per header however slowly the caller drains its copies. This adds to the ABI and leavesmoq_subscriptionunchanged.metatail lane crosses the relay on lite-07, Rust to Rust and both ways with each native JS runtime.session_delivery_metasweeps relay depth, viewers, and tracks per viewer, comparing metadata against payload.doc/concept/moq-lite.md,doc/lib/c, and the libmoq README.failover.md,hls-server-lifecycle.md, andhls-archive-vod.mdlose theRequiredentry it was.Decisions
Choices made without asking, for review. The user was away, so the last three were taken on the recommendation, each with the option it rejected:
largest,subscription, a group'send, and JSclosed. Fallow flags unread JS members, and the Rust side mirrors the same set.ordered(),with_range, orfetch_groupyet. The C API delivers headers group by group in arrival order, each naming its group and frame.next_headeris named after Rust'snext_frame(the header-first read), notread_frame(the whole-frame read). The binding pass suggestedread_header. I keptnext_header, since nothing behind it is "read whole".broadcast.meta(name)) and types (meta::Consumer/Subscriber/Group, JSMeta.*,MoqMetaConsumer/MoqMetaGroup, Cmoq_consume_meta). A payload read of a header-only frame cannot be written, so the bindings need noUnsupportederror. The quest recommended this "to confirm when this starts".metaflag onSubscription. That gives one subscribe path, but groups need a runtime "is header-only" check and the C struct changes its ABI.moq-net. The quest recommended this "to confirm when this starts".Unsupportedon an older session. That makes the cost visible, but every caller then needs a version branch.poll_frame_header(quest/m3/route-health/metaatc00addff48). In JS, though, a compressedcreateFrameholds nothing in the group untilfinish(). It would need a new frame-entry state carried through mirrors, takeovers, cut-frame handling, and compression binding, and the parked JS never did this either. I first recommended this option, then changed my recommendation once the JS cost was clear.Impact
!):moq-net:broadcast::Consumer::meta, and themetamodule withConsumer,Subscribing,Subscriber, andGroup.@moq/net:Broadcast.Consumer.metaand theMetanamespace.moq-ffi:MoqBroadcastConsumer::subscribe_meta,MoqMetaConsumer,MoqMetaGroup, andMoqFrameHeader, plus the matching names in every wrapper.moq_header,moq_header_callback, and the threemoq_consume_meta*functions.Alternatives
metaflag onSubscriptionwith promotion in place, as moq-dev/moq#8882 built. It was rejected on 2026-11-16 (see Waiting).fetch_group. A one-shot header read has no consumer yet.Follow-ups
quest/m0/test-flakes-5/finish-go-row-under-load.md(new): under the full interop matrix, one reader of the Go publisher's finished tail sometimes gets nothing, which fails the wholefinish go ->row. Seen here (a python reader got 0 of 10 frames) and on moq-dev/moq#9758. It has no open decisions.quest/m3/meta-reuse.md(existing) still owns serving lite-07 metadata readers from the payload copy.Validation
Merged
mainatce45c1f3b8. Since main's pacing changes, a publisher records traffic a step after the reader gets the bytes, so one test settles in simulated time before reading traffic, as the file's other traffic checks already do.rs/moq-net: full suite with--features async, 4649 passed.lite::meta_tests, through the publicmetaAPI on simulated time, billed per hop:broadcast::Consumer::metaat the payload lookup fails the four lite-07 tests.js/net: 3999 passed, 1 skipped.lite/meta.test.tshas 18 tests: the same cases through a session and through a front, plusinfo,update, andfinished.moq-ffisubscribe_meta_reads_headersand libmoqmeta_reads_headerscheck the mapping, an empty frame read as size 0, and a clean end (libmoq's on a NULL header).Wrappers:
just go check,just py testandjust py check,just kt check, andjust dart checkeach pass with a new local test. Swift was only format-checked, because this Linux host has no toolchain.just cipasses oncb0c30d699. The later commits add only the quest file and trim unread members, with JS meta tests andjust fixrerun on them.The interop plan registers the five
metacells, so a run that stops early reports them as not run.just test interop --all: every row passes, including the five newmetalanes, except all ninefinish go ->cells.--finish --publishers go --subscribers python,rustpassed. See Follow-ups.session_delivery_meta(--quick, 16 KiB frames, 4 frames per group, time per round, payload then metadata):Models
Size: M
Implementer: Claude Code, claude-opus-5-5, unknown (arm A)
🤖 Generated with Claude Code
(Written by Claude Opus 5.5)
Review
Rewritten by
quest reviewafter each round.Head: 0ae8076
Base: origin/main at ce45c1f
Risk: medium,
Medium: it adds new public API (Rust `broadcast::Consumer::meta`, JS `meta()`, C `moq_consume_meta*`, and the Go, Python, Kotlin, Swift, and Dart bindings) and new internals, all additive, with no wire or existing-API change, so it is a patch for the next cut and a revert fully undoes it. What could break: a bug in the new header-read path or the new C ABI functions could reach downstream consumers of the next release, which the repo's own tests and the interop lane meet first, and a revert would undo it. The quest plan and test/interop files are low, and nothing touches auth, release scripts, RISK.md, or the merge-gate selection, so none of the High paths apply.Classified: medium by Claude Code, claude-haiku-5-5, low effort, session
d0ff7fa7-0b5b-4822-9356-0c56996b688eRisk file: bb7b1c0de60b
Accepted by the maintainer:
Taken under afk as the agent's recommendation, open to maintainer override (PR body, Decisions): a compressed frame's header appears when the frame is published, with its payload. Exposing it at open needs a new JS frame-entry state through mirrors, takeovers, and compression binding, the parked JS never did it, and no producer streams compressed frames.Reviewer: Codex, gpt-6.2-sol, high effort
Session:
01a21f13-f050-79d1-8e8e-aa82abb61fdd, round 4Score: 8/10,
The branch is ready to land once metadata readers can see a streamed DEFLATE frame’s declared header while its payload is still being written.Rounds: 4; first round 2 (medium 2); findings 2 (medium 2): fixed 1, refuted 0, open 1
Findings, accepted by the maintainer:
rs/moq-net/src/model/meta.rs:157:Expose streamed DEFLATE headers when frames openThe last round's findings, at 1f4ad1a:
rs/moq-net/src/model/meta.rs:157:Expose streamed DEFLATE headers when frames open;The parked Rust implementation at `c00addff48:rs/moq-net/src/model/group.rs:1170` explicitly returned the declared header from an unfinished DEFLATE frame, and the current Rust metadata path still waits for the frame to finish.