Skip to content

feat(net): relays forward metadata subscriptions upstream as metadata - #9758

Merged
kixelated merged 10 commits into
mainfrom
quest/m2/subscribe-meta-wire
Nov 27, 2026
Merged

kixelated merged 10 commits into
mainfrom
quest/m2/subscribe-meta-wire

Conversation

@kixelated

@kixelated kixelated commented Nov 27, 2026 •

Copy link
Copy Markdown
Collaborator

Closes the quest quest/m2/subscribe-meta-wire.md (deleted here), whose first half landed in moq-dev/moq#9733.

Problem

moq-dev/moq#9733 put metadata subscriptions on the lite-07 wire and taught both publishers to serve them, but a relay still answered a metadata subscription by pulling the full payload upstream and stripping it on egress. Payload crossed every hop above the reader even though no reader on that path needed it, which defeats the point of the mode for route-health standbys and moq-hls indexing.

Approach

A relay keeps a separate metadata copy of a track beside its payload copy, filled by its own metadata SUBSCRIBE upstream. The two copies never splice or switch mode in place.

  • rs/moq-net:
    • A broadcast keys its tracks by track::Key { name, meta } (crate-private). It never uses a reserved name.
    • A broadcast's meta flag is set only where its handler can fill a metadata copy: lite-07 session sources and origin fronts. Anywhere else, a metadata lookup resolves to the payload copy, and the publisher strips its payloads as before.
    • A metadata group stores each frame as an empty payload with its declared size and its object fields (the IETF object ID and properties), so a relay forwards sparse object records from it. It refuses payload writes, and a payload group refuses header writes.
    • The lite subscriber sends meta on SUBSCRIBE and on fills, and ingests the payload-less FRAME as a header.
    • The publisher's SUBSCRIBE and one-shot paths look up the copy matching msg.meta.
    • Billing: a header delivers no frame or bytes, at ingress and at egress.
  • js/net mirrors this:
    • Metadata copies are kept in a separate request map.
    • A lite-07 ConsumeBroadcast and every front expose a metadata view.
    • The subscriber sends meta and decodes the metadata FRAME.
    • The publisher picks the copy by msg.meta.
    • JS has no ietf extension on lite, so it has no object records to keep.
  • Over an upstream hop of lite-06 or earlier, which cannot carry the mode, a source broadcast keeps no metadata copy. Metadata readers resolve to the track's one payload copy and its one payload subscription, and the publisher strips the payload for them. The relay never opens a second payload subscription for them.
  • Draft: a relay asks upstream for metadata with a metadata subscription, and MAY serve any part from a payload copy that proves upstream would answer it the same way. Where its upstream cannot carry the mode, it serves metadata readers from the Track's payload subscription and copy, and MUST NOT open a second payload subscription for them.
  • Quests:
    • The finished quest and its links are removed.
    • subscribe-meta.md records the decision below.
    • New quest/m3/meta-reuse.md plans reusing the payload copy on lite-07 too.

Decisions

  • 2026-11-27 (maintainer, relayed by the coordinator): ✅ separate copies on lite-07; over an older hop, metadata readers are served from the payload copy and the relay never opens a second payload subscription upstream, since that downloads the same data twice (rejected: the 2026-10-13 rule of serving metadata from the payload copy on lite-07 and switching when the last payload reader leaves, which needs a cross-copy splice; reuse on lite-07 is planned in quest/m3/meta-reuse.md).
    • The coordinator's brief said a pre-lite-07 hop opened its own payload SUBSCRIBE and dropped the payload. Rust and JS already behaved as the rule asks: an older session's source keeps no metadata copy, so both readers resolve to one payload copy.
    • The new tests pin it: on a lite-06 hop with a payload reader and a metadata reader, exactly one subscription and one copy of the payload cross that hop.
    • Both tests fail when a metadata copy is forced on older hops.
  • 2026-11-27 (maintainer): ✅ add quest/m3/meta-reuse.md for reusing the payload copy on lite-07 hops, with its cost, rationale, and the moq-dev/moq#8882 splice concern (rejected: building the splice here).
  • 2026-11-27 (maintainer): ✅ fix the review finding as recommended: the metadata ingest passes the full decoded header, with object ID and properties, into write_header; and Track.Request.meta is marked @internal (rejected: accepting the finding; dropping the PR).

Impact

  • Public API: none. track::Key, track_meta, Track.Request.meta, and the JS metaWireOf/trackMetaOf are crate-private or @internal.
  • Wire: none. This uses the existing lite-07 Meta byte and metadata FRAME.
  • Behavior:
    • A relay now forwards a metadata subscription upstream as a metadata subscription over lite-07, so payload no longer crosses a hop for a metadata reader.
    • When a track has both payload and metadata readers behind a lite-07 hop, the relay holds two upstream subscriptions for it, one per mode. Over an older hop it holds one.

Alternatives

  • Serve metadata from the payload copy while one is held on lite-07 too, and switch to a metadata subscription when the last payload reader leaves. It needs a splice across copies of different modes, per range, which moq-dev/moq#8882 showed to be the costly part. Planned as quest/m3/meta-reuse.md.
  • Store metadata in the payload copy behind a flag per frame. Rejected: a cache could then answer a payload reader from a header.

Follow-ups

  • quest/m3/meta-reuse.md (new): serve metadata readers from the payload copy on lite-07 hops too, removing duplicate header bytes under mixed demand. It has no open decisions; measure the cost first.
  • quest/m2/subscribe-meta.md: the public metadata subscription API in Rust, JS, and the bindings. It builds on this PR.
  • Interop flake: in one just test interop --all run, every finish go -> * row failed with "error: no health group". The js-native-bun finish reader's subscription to the .health live track ended with no group. It passed 3 of 3 targeted reruns. It looks tied to health publishing returning in moq-dev/moq#9752, not to this change, but it is unproven and worth a quest.

Validation

  • rs/moq-net:
    • The full suite passes with --features async, clippy included.
    • New lite::meta_tests run publisher to relay to reader on simulated time, measuring each hop by its publisher session's billing:
      • Over 07/07 hops, both hops carry zero payload bytes and frames.
      • Over a 06 hop then a 07 hop, the payload crosses only the older hop.
      • Over a 06 hop with a payload reader and a metadata reader, that hop carries one subscription and the payload once.
      • With a payload reader and a metadata reader over 07, once the payload reader leaves no payload crosses any hop.
    • Each test fails under a mutation of what it pins.
    • metadata_headers_keep_their_object_fields: a metadata copy keeps a sparse object ID and marks its wire state sparse, and the egress read returns them.
    • metadata_ingest_waits_for_its_reader: metadata headers pass the receive pacing gate, charged at what they store, so 400,000 headers into a group with an idle reader pause the stream instead of shedding the reader's next header. It fails without the gate.
    • a_paused_metadata_frame_drains_to_its_group_end: a metadata group dropped while a header waits to be admitted still finds its buffered GROUP_END, since no payload follows the header. It fails without the fix.
  • js/net:
    • 3987 tests: 3986 pass, 1 skipped. The new lite/meta.test.ts now has 11 tests.
    • The tests cover the same chains, through both a session broadcast and a front.
    • Each fails when the publisher lookup, the front's metadata view, or the older-hop sharing is broken on purpose.
  • Interop: lite07_meta_interop reads the JS-served metadata stream through the Rust ingest, and test/interop/meta.ts read reads it through the JS ingest. Both plain and deflate tracks agree.
  • just check passes on the head. This includes the drill sensitivity check: the relay-withdraws-lost-publisher mutation was retargeted at the moved context.
  • just test interop --all ran on the previous head, 979dbfca78. Every row passed except the flake under Follow-ups, and those rows passed on 3 of 3 targeted reruns. The commit since changes no wire bytes.
  • /verify-subscribe was not run. None of the functions its model covers changed. The only subscription-accounting code touched is FrameIngest::try_drain_end, which the skill lists as not covered.

Models

Size: L
Implementer: Claude Code, claude-opus-5-5, unknown (arm A)
Implementer: Claude Code, claude-opus-5-5, unknown (iterate, L, arm A)

🤖 Generated with Claude Code

(Written by Claude Opus 5.5)

Review

Rewritten by quest review after each round.

  • Head: 05e5ece

  • Base: origin/main at eca170c

  • Risk: high, A mistake in the lite-07 wire changes (the SUBSCRIBE Meta byte, payload-less FRAME ingest, and the relay's per-mode upstream subscriptions in rs/moq-net and js/net) would reach relays and peers that speak moq-lite-07-wip, and since that is an unpublished -wip version the next cut publishes it, so it breaks deployed peers and published Rust and JS consumers who rely on the wire, and it is hard to undo once a cut ships it.

  • Classified: high by Claude Code, claude-haiku-5-5, low effort, session d132b366-f26b-4ad9-93b6-44f63782f16e

  • Risk file: bb7b1c0de60b

  • Reviewer: Codex, gpt-6.2-sol, xhigh effort

  • Session: 01a21db7-38c3-7181-b010-5477de6aebc2, round 4

  • Score: 10/10, The rebase preserves the earlier fixes, and the incremental review found no new issues attributable to the branch.

  • Rounds: 10; first round 2 (medium 2); findings 7 (medium 7): fixed 6, refuted 1, open 0

  • Findings: none

  • Reviewer: Claude Code, claude-opus-5-5, high effort, second

  • Session: 68b61d59-d888-4544-92a1-2a87b1e62b05, round 4

  • Score: 9/10, Every change since the last round comes from rebasing onto the new main (WebTransport reset wording in the draft, join-budget retention, route-lost recovery, the m2 plan entry, CI and tooling), with no metadata-subscription code touched, so the branch's own change stands as already reviewed and has no open blocking findings.

  • Rounds: 10; first round 1 (medium 1); findings 2 (medium 2): fixed 2, refuted 0, open 0

  • Findings: none

kixelated and others added 6 commits November 27, 2026 02:32
…e quest

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A lite-07 session broadcast and an origin front keep a header-only metadata
copy per track apart from the payload copy, filled by a metadata SUBSCRIBE,
mirroring Rust. The interop read mode goes through the JS ingest.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ll mutation

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kixelated kixelated changed the title Metadata mode on the lite-07 wire, served feat(net): relays forward metadata subscriptions upstream as metadata Nov 27, 2026
…ayload copy

A metadata copy now stores each header's object ID and properties, so a
relay forwards sparse IETF object records from it. Tests pin that over a
hop that cannot carry the mode, payload and metadata readers share one
payload subscription. The draft states it as a MUST, the quest records the
decision, and quest/m3/meta-reuse.md plans reuse on lite-07.

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

Copy link
Copy Markdown
Collaborator Author

Design change: the maintainer settled this PR's open decisions on 2026-11-27. They are recorded under ## Decisions in the description.

  • lite-07: keep separate metadata and payload copies.
  • Older hops: serve metadata readers from the track's one payload subscription and copy, and never open a second payload subscription upstream. Rust and JS already did this. New tests pin it, and the draft states it as a MUST.
  • New quest: quest/m3/meta-reuse.md plans reusing the payload copy on lite-07 too.
  • Review finding, fixed as recommended:
    • The metadata ingest now passes the full decoded header, with object ID and properties, into write_header.
    • Track.Request.meta is marked @internal.

The earlier review rounds counted against this branch include those for moq-dev/moq#9733. This head is reviewed in new sessions.

(Written by Claude Opus 5.5)

kixelated and others added 2 commits November 27, 2026 08:21
Metadata headers pass the receive pacing gate before they commit, charged
at what they store, so a stalled reader pauses the stream instead of losing
headers to shedding. The Rust front records a track's properties per name,
as JS does, and the JS front asks a metadata copy's source too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A metadata group dropped while its ingest waits to admit a header skipped
the header's declared size, which no payload backs, and could swallow the
buffered GROUP_END. Also returns front property records to per copy, which
cross-mode checks across mixed versions would refuse.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kixelated
kixelated marked this pull request as ready for review November 27, 2026 16:39
@coderabbitai

coderabbitai Bot commented Nov 27, 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 5 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: b9fd7f5e-b87a-43ac-9b65-ee9f36dde6e8
Commits

Reviewing files that changed from the base of the PR and between fc2af06 and fff8db1.

Files selected for processing: 32

  • drafts/draft-lcurley-moq-lite.md
  • js/net/src/broadcast.ts
  • js/net/src/group.ts
  • js/net/src/internal.ts
  • js/net/src/lite/group.ts
  • js/net/src/lite/meta.test.ts
  • js/net/src/lite/publisher.ts
  • js/net/src/lite/subscriber.ts
  • js/net/src/resume.ts
  • js/net/src/track.ts
  • js/net/src/wire.ts
  • quest/m2/README.md
  • quest/m2/lite07-finalize.md
  • quest/m2/subscribe-meta-wire.md
  • quest/m2/subscribe-meta.md
  • quest/m3/meta-reuse.md
  • quest/m3/route-health/README.md
  • quest/m3/route-health/ietf.md
  • rs/moq-net/src/coding/reader.rs
  • rs/moq-net/src/lite/meta_tests.rs
  • rs/moq-net/src/lite/mod.rs
  • rs/moq-net/src/lite/publisher.rs
  • rs/moq-net/src/lite/subscriber.rs
  • rs/moq-net/src/model/broadcast.rs
  • rs/moq-net/src/model/front.rs
  • rs/moq-net/src/model/group.rs
  • rs/moq-net/src/model/listing.rs
  • rs/moq-net/src/model/origin.rs
  • rs/moq-net/src/model/track.rs
  • rs/moq-net/src/recv.rs
  • test/drill/mutations/relay-withdraws-lost-publisher.patch
  • test/interop/meta.ts
  • 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

…ta-wire

# Conflicts:
#	drafts/draft-lcurley-moq-lite.md
@kixelated
kixelated added this pull request to the merge queue Nov 27, 2026
Merged via the queue into main with commit aad1e17 Nov 27, 2026
5 of 6 checks passed
@kixelated
kixelated deleted the quest/m2/subscribe-meta-wire branch November 27, 2026 16:57
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