Skip to content

[codex] implement JS lite FETCH#2032

Draft
kixelated wants to merge 2 commits into
devfrom
codex/js-lite-fetch
Draft

[codex] implement JS lite FETCH#2032
kixelated wants to merge 2 commits into
devfrom
codex/js-lite-fetch

Conversation

@kixelated

@kixelated kixelated commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Add TrackConsumer.fetchGroup(sequence, options?) and FetchGroupOptions for one-shot group fetches.
  • Implement moq-lite-05 FETCH send and serve paths in JS, including stream type dispatch, bare frame responses, timestamp delta encoding, and cached group serving.
  • Explicitly reject fetchGroup() for moq-transport until the IETF path has a real implementation.
  • Resolve the consume side through a Broadcast subclass, not callbacks (see below).

Consume-side design (no callbacks)

Instead of registering per-operation closures on the shared Broadcast (the old onTrackInfo / onFetchGroup resolvers), a consumed broadcast is now a ConsumeBroadcast that extends Broadcast and holds a direct reference to the Subscriber it was opened from. It overrides resolveTrackInfo / resolveFetchGroup to fetch over the wire. This mirrors the Rust BroadcastConsumer, which owns its session and calls methods on it rather than having the session install callbacks.

  • lite: ConsumeBroadcast overrides both, issuing TRACK_INFO / FETCH (lite-05+).
  • ietf: ConsumeBroadcast overrides only resolveFetchGroup to reject (moq-transport has no one-shot fetch); track info stays on the inherited subscribe path.
  • The base Broadcast keeps the local produce-side implementations (static/requested track info, retained-window group scan) as the default the subclass overrides.

There is no exported @internal interface and no stored function values.

Root Cause

The JS lite FETCH message codec existed, but the runtime never dispatched StreamId.Fetch and the subscriber side had no API to issue FETCH. A Rust lite-05 subscriber could therefore open stream type 3 against JS and get unknown stream type: 3.

Public API Changes

  • New TrackConsumer.fetchGroup(sequence, options?) method.
  • New FetchGroupOptions interface with optional priority.

Breaking changes: none for external consumers. (Internally, the Broadcast.onTrackInfo wire-layer resolver setter is removed in favor of the subclass; it was never part of the intended public surface.)

Validation

  • just js check (@moq/net type-check + lint pass)
  • just js test (all 190 @moq/net tests pass, including the lite cached-group fetch and the ietf unsupported-fetch integration tests)

(Reworked by Claude Opus 4.8; original implementation written by GPT-5)

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Sorry @kixelated, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

…class, not callbacks

The consume side registered per-operation closures on the shared Broadcast
(onTrackInfo / onFetchGroup, stashed as #infoResolver / #fetchResolver). Drop
those callbacks entirely: a consumed broadcast is now a ConsumeBroadcast that
extends Broadcast and holds a direct reference to the Subscriber it was opened
from, overriding resolveTrackInfo / resolveFetchGroup to fetch over the wire.
This mirrors the Rust BroadcastConsumer, which owns its session and calls methods
on it rather than having the session install callbacks.

- lite: ConsumeBroadcast overrides both, issuing TRACK_INFO / FETCH (lite-05+).
- ietf: ConsumeBroadcast overrides only resolveFetchGroup to reject (no one-shot
  fetch in moq-transport); track info stays on the inherited subscribe path.
- The base Broadcast keeps the local produce-side implementations (static/requested
  track info, retained-window group scan) as the default the subclass overrides.

No exported @internal interface, no stored function values. Behavior is unchanged;
the wire->model TrackInfo mapping is factored into one helper.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@kixelated kixelated force-pushed the codex/js-lite-fetch branch from cc2ccaa to acab008 Compare July 3, 2026 19:52
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