Integrate time and delivery into model + update protocol layer - #826
Closed
kixelated wants to merge 1 commit into
Closed
Integrate time and delivery into model + update protocol layer#826kixelated wants to merge 1 commit into
kixelated wants to merge 1 commit into
Conversation
This PR combines the model refactoring with protocol layer updates since they're tightly coupled. The model now supports temporal awareness and latency-aware delivery. ## Rust (moq-lite) Model Changes **Frame (`model/frame.rs`)**: - Added `instant: Time` field for presentation timestamp - Frame size changed from `u64` to `usize` - State machine now tracks time alongside data **Group (`model/group.rs`)**: - Integrates with `ExpiresProducer` for expiration tracking - Calls `expires.create_frame()` when appending frames - Tracks `max_instant` for latest timestamp in group **Track (`model/track.rs`)**: - Major refactoring: `TrackProducer` now manages: - `delivery: DeliveryProducer` for delivery preferences - `subscribers: Subscribers` tracking all consumers - `expires: ExpiresProducer` for group/frame expiration - `TrackConsumer` now has: - `subscriber: Subscriber` with its own delivery preferences - `expires: ExpiresConsumer` to check expiration - `delivery: DeliveryConsumer` to react to changes - Filters expired groups transparently before returning - **Breaking change**: Track no longer has `priority` field (moved to per-subscriber `Delivery`) **Broadcast (`model/broadcast.rs`)**: - Simplified from ~450 to ~200 lines - Stores `TrackProducer` instead of `TrackConsumer` - Separates explicit publishes (`producers`) from dynamic requests (`requested`) - Cleaner ownership model **Origin (`model/origin.rs`)**: - API consistency improvements - Uses `.new()` instead of `.default()` - Updated tests for new producer/consumer patterns ## Rust (moq-lite) Protocol Layer Changes **IETF Protocol**: - `subscribe.rs`: Added `delivery_timeout` parameter (maps to `max_latency`) - `publish.rs`: Added `delivery_timeout` parameter - `publisher.rs` & `subscriber.rs`: Handle new delivery fields - `parameters.rs`: Renamed `get_int`/`set_int` to `get_varint`/`set_varint` - `request.rs`: Added `Default` derive for `RequestId` - `setup.rs`: Updated to use new parameter methods **Lite Protocol**: - `version.rs`: Added `DRAFT_03` version - `subscribe.rs`: Added `max_latency` and `ordered` fields to Subscribe/SubscribeOk/SubscribeUpdate - `frame.rs` (new): Frame encoding helper with timestamp deltas - `publisher.rs` & `subscriber.rs`: Encode/decode new fields, version-gated for Draft03 - `session.rs`: Updated for new parameter APIs - `mod.rs`: Export `FrameHeader` **Coding Layer**: - `reader.rs` & `writer.rs`: Updated for varint parameter changes ## TypeScript (lite) Changes **Core Types**: - `frame.ts` (new): `Frame` class with `instant: Time.Milli` and `payload: Uint8Array` - `track.ts`: Tracks now have reactive `priority`, `maxLatency`, and `ordered` properties using Signals - `group.ts`: Updated to work with Frame objects - `broadcast.ts`: Simplified track management matching Rust changes - `stream.ts`: Updated for new Frame type **Protocol Layer**: - `lite/version.ts`: Added `DRAFT_03` - `lite/subscribe.ts`: Added `maxLatency` and `ordered` fields to messages - `lite/frame.ts` (new): Frame encoding with delta timestamps - `lite/publisher.ts` & `lite/subscriber.ts`: Handle new fields with version gating - `lite/session.ts`, `lite/connection.ts`: Updated for new APIs - `ietf/publisher.ts` & `ietf/subscriber.ts`: Updated for new delivery parameters - `connection/connect.ts`: Use DRAFT_03 by default - `connection/reload.ts`: Handle new track properties **Signals**: - `js/signals/src/index.ts`: Added Signal utilities for reactive track properties **Validation**: - `zod.ts`: Added validation for new fields ## Breaking Changes - **Track API**: `priority` removed from Track, now per-subscriber via `Delivery` - **Frame size**: Changed from `u64` to `usize` in Rust - **Frame type**: TypeScript now uses `Frame` objects instead of raw `Uint8Array` - **Subscribe API**: Now requires `Delivery` parameter ## Compatibility - **Version gating**: Draft01/Draft02 clients continue to work - **Draft03**: New version includes `max_latency` and `ordered` fields - **Backward compatible**: Older versions negotiate down gracefully ## Known Issues - hang crate and related examples will fail to compile (fixed in next PR) - moq-relay and moq-clock need updates (fixed in later PR) ## Dependencies - **Depends on**: PR #2 (Delivery & Expiration) - **Depended on by**: PR #5 (Hang Simplification) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
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.
Summary
This PR combines the model refactoring with protocol layer updates (originally planned as separate PRs #3 and #4, but they're too tightly coupled to separate). The model now supports temporal awareness and latency-aware delivery, and the protocol layer is updated to support the new subscribe parameters.
Rust (moq-lite) Model Changes
Frame
instant: Timefield for presentation timestampu64tousizeGroup
ExpiresProducerfor expiration trackingexpires.create_frame()when appending framesmax_instantfor latest timestamp in groupTrack (Major Refactoring)
TrackProducer now internally manages:
delivery: DeliveryProducer- for updating track-level delivery preferencessubscribers: Subscribers- tracks all connected consumers and their demandsexpires: ExpiresProducer- manages group/frame expirationTrackConsumer now has:
subscriber: Subscriber- declares its own delivery preferencesexpires: ExpiresConsumer- can check if groups are expireddelivery: DeliveryConsumer- can react to delivery changesBreaking change: Priority removed from Track, now per-subscriber via
DeliveryBroadcast
TrackProducerinstead ofTrackConsumerproducers) from dynamic requests (requested)Rust (moq-lite) Protocol Layer Changes
IETF Protocol
delivery_timeoutparameter to Subscribe and Publish messagesgroup_orderfield to SubscribeOkget_int/set_int→get_varint/set_varintDefaultderive forRequestIdLite Protocol
max_latencyandorderedfields to Subscribe/SubscribeOk/SubscribeUpdatelite/frame.rsfor frame encoding with timestamp deltasTypeScript (lite) Changes
Core Types
Frameclass withinstant: Time.Milliandpayload: Uint8Arraypriority: Signal<number>maxLatency: Signal<Time.Milli>ordered: Signal<boolean>Protocol Layer
maxLatencyandorderedfieldsSubscribeUpdatemessages are sentSignals
Breaking Changes
priorityremoved from Track, now per-subscriber viaDeliveryu64tousizein RustFrameobjects instead of rawUint8ArrayDeliveryparameterCompatibility
✅ Version gating: Draft01/Draft02 clients continue to work
✅ Draft03: New version includes max_latency and ordered fields
✅ Backward compatible: Older versions negotiate down gracefully
Known Issues
Test Plan
Dependencies
Notes
Originally planned as two separate PRs (Model Refactoring + Protocol Layer), but they're too tightly coupled:
This combined PR ensures the model and protocol stay synchronized.
🤖 Generated with Claude Code