From a60104c91d44eca7125e8357b4460483acca9591 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Wed, 25 Nov 2026 13:35:53 -0800 Subject: [PATCH 1/5] chore(quest): claim quest/m1/relayed-refused-fill-gap.md Quest-Claim: ffcf5e4fecd04cd7 From 5d08de03caf75f46541c3f8d9e2a978ae88ada2e Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Wed, 25 Nov 2026 15:28:16 -0800 Subject: [PATCH 2/5] fix(net): an ordered read waits on a time start's history lookup A time start before every group held is looked up through the track's history handler. The ordered read held a later group only for a time start waiting on the groups held, so it handed out the later group first and never returned the one the lookup found. It now holds for a pending lookup too, and the window reports no floor until the lookup answers. Rewrites quest/m1/relayed-refused-fill-gap.md to the decision that remains. Co-Authored-By: Claude Opus 5.5 --- js/net/src/ordered.test.ts | 19 +++++++++ js/net/src/track.ts | 4 +- js/net/src/window.ts | 17 +++++--- quest/m1/relayed-refused-fill-gap.md | 37 ++++++++++++++--- rs/moq-net/src/model/subscription/window.rs | 29 ++++++++----- rs/moq-net/src/model/track.rs | 13 +++--- .../tests/integration/waiting_time_start.rs | 41 +++++++++++++++++++ 7 files changed, 130 insertions(+), 30 deletions(-) diff --git a/js/net/src/ordered.test.ts b/js/net/src/ordered.test.ts index b6336a5cbcd..103e181e662 100644 --- a/js/net/src/ordered.test.ts +++ b/js/net/src/ordered.test.ts @@ -799,3 +799,22 @@ test("an ordered read whose window ends past a group it passed as stale reports expect(ordered.tryNextItem()).toBeUndefined(); expect(ordered.tryNextGroup()).toBeUndefined(); })); + +// A time start before every group held waits on its history lookup, and the group the lookup finds +// comes before the later one held. Ports the Rust +// `waiting_time_start::a_looked_up_time_start_reads_before_a_held_later_group`. +test("a looked-up time start reads before a held later group", async () => { + const producer = new TrackProducer("test").accept({ maxAge: null }); + const requests = producer.requests(); + put(producer, 66n, false); + const ordered = producer + .subscribe(withMax({ delay: { max: null }, ranges: [{ start: 10n, end: 20n }, { start: 66n }] })) + .ordered(); + expect(items(ordered)).toEqual([]); + const fill = await requests.requestedFill(); + const group = fill?.accept(10n); + group?.writeFrame(textFrame("x", Timestamp.unscaled(10n))); + group?.finish(); + expect(items(ordered)).toEqual(["group 10"]); + requests.close(); +}); diff --git a/js/net/src/track.ts b/js/net/src/track.ts index c0443218a36..94b948b43b5 100644 --- a/js/net/src/track.ts +++ b/js/net/src/track.ts @@ -6492,7 +6492,7 @@ export class Subscriber { return runs; } - // In order, the group a waiting time start resolves to comes first: it starts at or before that + // In order, the group an unresolved time start resolves to comes first: it starts at or before that // time, below `key`, and may still land at or past the read's floor `start`, until the budget // gives up on it as on an owed group. Its landing, the answer placing the start, or that verdict // wakes the read; a closed track places the start. @@ -6501,7 +6501,7 @@ export class Subscriber { const producer = this.#state.producer; let waits = false; const coverage = this.#coverage(); - for (const time of this.#window.waitingIn(start, key)) { + for (const time of this.#window.unresolvedIn(start, key)) { if (producer && wireFed(producer)) { // With every key from the floor through the time accounted for, a group still to come // containing it lies below the floor, which the read never hands out. diff --git a/js/net/src/window.ts b/js/net/src/window.ts index e123cad9de9..43b54da8541 100644 --- a/js/net/src/window.ts +++ b/js/net/src/window.ts @@ -954,13 +954,15 @@ export class Window { } /** - * The times in `[start, end)` of the time starts still waiting on the groups held. The group - * containing each starts at or before its time, so one at or past a read's floor and below a - * group may still land between them. Mirrors the Rust `Window::waiting_in`. + * The times in `[start, end)` of the time starts not yet resolved: waiting on the groups held, or + * on a lookup of the track's history. The group containing each starts at or before its time, so + * one at or past a read's floor and below a group may still land between them. Mirrors the Rust + * `Window::unresolved_in`. */ - waitingIn(start: bigint, end: bigint): bigint[] { + unresolvedIn(start: bigint, end: bigint): bigint[] { const times: bigint[] = []; for (const entry of this.#waiting.in(start, end)) times.push(entry.time); + for (const entry of this.#looking.in(start, end)) times.push(entry.time); return times; } @@ -988,9 +990,12 @@ export class Window { return this.#groups.prev(before); } - /** The lowest group in range, undefined while a start waits. Nothing in range floors at group 0. */ + /** + * The lowest group in range, undefined while a start waits, a time start's lookup included: it may + * resolve to a group below every one in range. Nothing in range floors at group 0. + */ floor(): bigint | undefined { - if (this.pending || this.#unplaced()) return undefined; + if (this.pending || this.#unplaced() || this.#looking.size > 0) return undefined; return this.#groups.lowest() ?? 0n; } diff --git a/quest/m1/relayed-refused-fill-gap.md b/quest/m1/relayed-refused-fill-gap.md index 64f2e6e9204..2df0665f765 100644 --- a/quest/m1/relayed-refused-fill-gap.md +++ b/quest/m1/relayed-refused-fill-gap.md @@ -17,8 +17,35 @@ plans applied: `waiting_time_start::a_range_before_every_group_reads_past_it` in `rs/moq-net/tests/integration/` fails there, the relayed reader reporting a NotFound gap over `10..21` where the direct one reports none. -The copy asks upstream to fill the range before the only group; upstream refuses it, since no -group exists there, and the copy records the refusal as a gap. A range that resolves empty at the -publisher is no loss: the copy must answer it the same way, per the cache rule in `AGENTS.md`. -Start by checking how the refusal reaches `find_gap` on the copy, and whether lite-07's -SUBSCRIBE_DROP or the fill's refusal carries it. Check JS's twin of the test too. +[moq-dev/moq#9639](https://github.com/moq-dev/moq/pull/9639) traced it. The relayed reader is not +wrong: the gap is the publisher's own answer. The two readers differ in what they ask the +publisher's history handler (`track::Requests`): + +- A copy whose window covers `Time(10)..20` asks upstream for keys `10..21` with a range fill. The + test's handler drops it unanswered, which records a `NotFound` miss on the publisher's own track + (`fill::Inner::drop`), so the copy reports `Err(10..21)`. A direct reader opened at the publisher + after that miss, asking only `Time(10)..20`, reports the same gap. +- A direct Rust reader at the publisher looks up only the group containing time 10, and never asks + the handler for the rest of the range: a local track owes no key between groups + (`TrackState::owed`). With a handler holding groups 10 and 15, it reads `[10, 66]`, while the + relayed reader reads `[10, 15, Err(16..21), 66]`. +- A direct JS reader does ask the handler for the rest (a fill over `11..21`), and reads + `[10, Err(11..15), 15, Err(16..21), 66]`. + +[moq-dev/moq#9639](https://github.com/moq-dev/moq/pull/9639) fixed the separate bug that hid this: +a direct ordered reader handed out group 66 before its time start's lookup answered, then never +returned the group the lookup found. + +Before the front-drop fix lands, `a_range_before_every_group_reads_past_it` must assert what +the decision below settles, for both readers and 2 items. + +## Waiting + +- Maintainer: Which answer is right for a local ordered reader whose time start resolves through the track's history handler, with keys in range that no group held covers? + - Ask the handler (Recommended) - a local reader asks the handler for the unheld keys of a range resolved through a lookup, as a relay copy and JS already do, so direct, relayed, and JS read the same; costs one more fill per history range on a publisher with a handler. + - Ask nothing - copies stop asking upstream for keys a lookup resolved past, matching today's Rust local reader; a relayed reader then loses history groups like 15 that the handler holds. + - Unanswered is empty - a fill the handler drops unanswered counts as no group there, not a NotFound miss; removes the gap in this test but still lets readers differ on groups like 15, and hides real history loss. + +## Related + +- [Previous Delta](/quest/m2/lite07-subscribe/previous-delta.md) - in [moq-dev/moq#9626](https://github.com/moq-dev/moq/pull/9626), changes how a copy learns a range is empty; this gap is the publisher's own NotFound, so it does not settle it. diff --git a/rs/moq-net/src/model/subscription/window.rs b/rs/moq-net/src/model/subscription/window.rs index 6d715e31c51..6f7de1c167b 100644 --- a/rs/moq-net/src/model/subscription/window.rs +++ b/rs/moq-net/src/model/subscription/window.rs @@ -710,19 +710,25 @@ impl Window { self.waiting.last().is_some_and(|&(time, _)| time > floor) } - /// The times in `times` of the time starts still waiting on the groups held. The group - /// containing each starts at or before its time, so one at or past a read's floor and - /// below a group may still land between them. - pub fn waiting_in + 'static>(&self, times: R) -> impl Iterator + '_ { + /// The times in `times` of the time starts not yet resolved: waiting on the groups held, + /// or on a lookup of the track's history. The group containing each starts at or before + /// its time, so one at or past a read's floor and below a group may still land between + /// them. Unsorted, and a time two spans share comes twice. + pub fn unresolved_in + Clone + 'static>( + &self, + times: R, + ) -> impl Iterator + '_ { let from = match times.start_bound() { ops::Bound::Included(&start) => start, ops::Bound::Excluded(&start) => start.saturating_add(1), ops::Bound::Unbounded => 0, }; - self.waiting - .range((from, 0)..) - .map(|&(time, _)| time) - .take_while(move |time| times.contains(time)) + let looked = times.clone(); + let waiting = + (self.waiting.range((from, 0)..).map(|&(time, _)| time)).take_while(move |time| times.contains(time)); + let looking = + (self.looking.range((from, 0)..).map(|&(time, _)| time)).take_while(move |time| looked.contains(time)); + waiting.chain(looking) } /// Resolve what the groups now held settle: live joins once `latest` exists or an @@ -815,10 +821,11 @@ impl Window { self.groups.contains(key) } - /// The lowest group in range, `None` while an anchor waits. Nothing in range floors - /// nowhere: group 0. + /// The lowest group in range, `None` while an anchor waits, a time start's lookup included: + /// it may resolve to a group below every one in range. Nothing in range floors nowhere: + /// group 0. pub fn floor(&self) -> Option { - match self.is_pending() || self.unplaced() { + match self.is_pending() || self.unplaced() || !self.looking.is_empty() { true => None, false => Some(self.groups.lowest().unwrap_or(0)), } diff --git a/rs/moq-net/src/model/track.rs b/rs/moq-net/src/model/track.rs index 70e4604af7e..56d0850ba70 100644 --- a/rs/moq-net/src/model/track.rs +++ b/rs/moq-net/src/model/track.rs @@ -11082,14 +11082,15 @@ impl Cursor { }) } - /// Pending while a time start in `times` waits to be placed and the group containing it, - /// at or before its time and so below `times.end`, may still land at or past the read's - /// floor `times.start` within the drift budget. Its landing, the answer placing the start, + /// Pending while a time start in `times` waits to be placed, on the groups held or a lookup + /// of the track's history, and the group containing it, at or before its time and so below + /// `times.end`, may still land at or past the read's floor `times.start` within the drift + /// budget. Its landing, the answer placing the start, /// the grace for a gap below it folding, or the budget giving up on it wakes us; a closed /// track places it. `Ready(true)` when a change placed one meanwhile, so the caller looks /// again. fn poll_time_start(&mut self, times: ops::Range, drift: &Drift, waiter: &kio::Waiter) -> Poll { - if self.filter.window.is_settled() || self.filter.window.waiting_in(times.clone()).next().is_none() { + if self.filter.window.is_settled() || self.filter.window.unresolved_in(times.clone()).next().is_none() { return Poll::Ready(false); } let window = &self.filter.window; @@ -11100,7 +11101,7 @@ impl Cursor { // An unjudgeable old gap cannot hold a finite read, as for an owed group. let floor = times.start.max(drift.budget.floor(state.live_floor)); let grace = state.arrival_grace(); - for time in window.waiting_in(floor..times.end) { + for time in window.unresolved_in(floor..times.end) { // With every key from the floor through the time accounted for, a group still // to come containing it lies below the floor, which the read never hands out. let unaccounted = match state.anchors.received() { @@ -11135,7 +11136,7 @@ impl Cursor { let window = &self.filter.window; if waited .iter() - .any(|&time| window.waiting_in(time..=time).next().is_none()) + .any(|&time| window.unresolved_in(time..=time).next().is_none()) { return Poll::Ready(true); } diff --git a/rs/moq-net/tests/integration/waiting_time_start.rs b/rs/moq-net/tests/integration/waiting_time_start.rs index e2c015955b5..e9bd468730a 100644 --- a/rs/moq-net/tests/integration/waiting_time_start.rs +++ b/rs/moq-net/tests/integration/waiting_time_start.rs @@ -229,6 +229,47 @@ async fn a_range_before_every_group_reads_past_it() { fixture.serving.abort(); } +/// An ordered reader at the publisher waits for the history lookup of a time start before +/// every group held, and reads the group the lookup finds before the later one held. +#[kio::test] +async fn a_looked_up_time_start_reads_before_a_held_later_group() { + let publisher = origin(1); + let broadcast = publisher + .route("bcast", moq_net::origin::RouteOptions::hidden()) + .unwrap(); + let track = broadcast + .broadcast() + .create_track("value", moq_net::track::Info::default().with_max_age(None)) + .unwrap(); + let requests = track.requests(); + let serving = kio::clock::sim::spawn(async move { + while let Ok(fill) = requests.requested_fill().await { + if (fill.start().group..fill.end()).contains(&10) + && let Ok(Some(group)) = fill.accept(10, None) + { + write(group); + } + } + }); + write(track.create_group(moq_net::group::Info { start: LIVE }).unwrap()); + let subscription = Subscription::default() + .with_max(None) + .with_order(Order::Ascending) + .with_ranges([ + Range { + start: moq_net::track::Start::Time(10), + end: Some(20), + }, + Range { + start: moq_net::track::Start::Time(LIVE), + end: None, + }, + ]); + let mut reader = track.subscribe(subscription).ordered(); + assert_eq!(read(&mut reader, 1).await, [Ok(10)]); + serving.abort(); +} + /// A copy holding the groups on either side of a time, from fetches, says nothing of a group /// between them: a reader asking from that time starts where the publisher would. #[kio::test] From 7a27917f5162bfa2afe4fc6546d308d4c45cc3b3 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Wed, 25 Nov 2026 16:09:47 -0800 Subject: [PATCH 3/5] chore(quest): record the ask-the-handler decision and what it found on relayed-refused-fill-gap Co-Authored-By: Claude Opus 5.5 --- quest/m1/relayed-refused-fill-gap.md | 35 ++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/quest/m1/relayed-refused-fill-gap.md b/quest/m1/relayed-refused-fill-gap.md index 2df0665f765..e0573dbfab3 100644 --- a/quest/m1/relayed-refused-fill-gap.md +++ b/quest/m1/relayed-refused-fill-gap.md @@ -1,4 +1,4 @@ -# [S] A relayed reader reports a refused fill as a gap a direct reader never sees +# [L] A relayed reader reports a refused fill as a gap a direct reader never sees ## Goal @@ -36,16 +36,37 @@ publisher's history handler (`track::Requests`): a direct ordered reader handed out group 66 before its time start's lookup answered, then never returned the group the lookup found. +Decided by the maintainer on 2026-11-25 ([answer](https://github.com/moq-dev/moq/pull/9639#issuecomment-7177793296)): +a local Rust reader whose time range resolves through the history handler asks it for the keys +with no group held, as copies and JS already do (rejected: ask nothing, unanswered means empty). + +What implementing it found, on top of [moq-dev/moq#9639](https://github.com/moq-dev/moq/pull/9639)'s head: + +- Asking now, rather than after the miss grace, has to be scoped to the spans a lookup resolved + (`Window::found` with `Found::Group` or `Found::Dropped`). Asking every local hole below the + first group the producer created (`TrackState::unfed` treating them as `never`) makes the + history test agree across direct, relayed, and JS (`[10, Err(11..15), 15, Err(16..21), 66]`), but + breaks 23 tests of the deliberate grace for local holes, such as + `a_hole_below_an_undeclared_start_is_asked_after_a_bounded_grace` and + `creating_a_group_past_a_gap_skips_nothing`. The scoped rule threads the lookup-resolved runs + from `Window` through `Misses::judge` into `TrackState::unfed`. +- With asking scoped or not, `a_range_before_every_group_reads_past_it` still disagrees, for the two + reasons the decisions below settle: the publisher keeps the time's own key in range after a + dropped lookup, while a relay re-asks its upstream from the next time once that key is dropped; + and a copy reads an upstream answer of "no group to deliver" as proof the range holds nothing, + handing out the later group before the drops for the range land. + Before the front-drop fix lands, `a_range_before_every_group_reads_past_it` must assert what -the decision below settles, for both readers and 2 items. +these settle, for both readers and through the later group. ## Waiting -- Maintainer: Which answer is right for a local ordered reader whose time start resolves through the track's history handler, with keys in range that no group held covers? - - Ask the handler (Recommended) - a local reader asks the handler for the unheld keys of a range resolved through a lookup, as a relay copy and JS already do, so direct, relayed, and JS read the same; costs one more fill per history range on a publisher with a handler. - - Ask nothing - copies stop asking upstream for keys a lookup resolved past, matching today's Rust local reader; a relayed reader then loses history groups like 15 that the handler holds. - - Unanswered is empty - a fill the handler drops unanswered counts as no group there, not a NotFound miss; removes the gap in this test but still lets readers differ on groups like 15, and hides real history loss. - +- Maintainer: After a time start's lookup from key 0 is dropped (no group starts at or before time T), does the range include key T itself? The publisher keeps T in range, by design (`a_time_start_before_the_cache_asks_nothing_below_it`), so the lookup's own NotFound drop of T is a gap there; a relay copy that learned T was dropped re-asks its upstream from time T+1 and leaves T out, so the two readers report different gaps. + - Exclude T everywhere (Recommended) - the dropped lookup already proved no group starts at T; the window starts the span at T+1 in Rust and JS, changing 2 deliberate tests. + - Include T everywhere - a copy never moves a time start past a key it learned was dropped; keeps the publisher's tests, and its readers report the lookup's drop of T as a gap. +- Maintainer: A copy reads an upstream's "no group to deliver" answer for a time range as proof the range holds nothing (`an_empty_bounded_range_holds_back_no_later_range`), so it hands out a later group before the drops for that range land, while a reader at the publisher, whose handler left those keys unanswered, reports them as a NotFound gap. Which should change? + - Publisher answers with a start (Recommended) - a range whose keys the publisher dropped is answered with its start rather than "no group to deliver", so the copy waits for those drops, as for any range with keys in it. + - Copy waits for drops - the copy keeps reading "no group to deliver" as empty but holds a later group until each key of the range is accounted for; costs a wait on every truly empty range. ## Related - [Previous Delta](/quest/m2/lite07-subscribe/previous-delta.md) - in [moq-dev/moq#9626](https://github.com/moq-dev/moq/pull/9626), changes how a copy learns a range is empty; this gap is the publisher's own NotFound, so it does not settle it. From 5dc138deb382d3cc37ad8920a69956fef7338dca Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Wed, 25 Nov 2026 16:19:04 -0800 Subject: [PATCH 4/5] chore(quest): record the settled relayed-refused-fill-gap decisions Co-Authored-By: Claude Opus 5.5 --- quest/m1/relayed-refused-fill-gap.md | 69 ++++++++++++++++------------ 1 file changed, 40 insertions(+), 29 deletions(-) diff --git a/quest/m1/relayed-refused-fill-gap.md b/quest/m1/relayed-refused-fill-gap.md index e0573dbfab3..f7d4c8a10dc 100644 --- a/quest/m1/relayed-refused-fill-gap.md +++ b/quest/m1/relayed-refused-fill-gap.md @@ -36,37 +36,48 @@ publisher's history handler (`track::Requests`): a direct ordered reader handed out group 66 before its time start's lookup answered, then never returned the group the lookup found. -Decided by the maintainer on 2026-11-25 ([answer](https://github.com/moq-dev/moq/pull/9639#issuecomment-7177793296)): -a local Rust reader whose time range resolves through the history handler asks it for the keys -with no group held, as copies and JS already do (rejected: ask nothing, unanswered means empty). - -What implementing it found, on top of [moq-dev/moq#9639](https://github.com/moq-dev/moq/pull/9639)'s head: - -- Asking now, rather than after the miss grace, has to be scoped to the spans a lookup resolved - (`Window::found` with `Found::Group` or `Found::Dropped`). Asking every local hole below the - first group the producer created (`TrackState::unfed` treating them as `never`) makes the - history test agree across direct, relayed, and JS (`[10, Err(11..15), 15, Err(16..21), 66]`), but - breaks 23 tests of the deliberate grace for local holes, such as - `a_hole_below_an_undeclared_start_is_asked_after_a_bounded_grace` and - `creating_a_group_past_a_gap_skips_nothing`. The scoped rule threads the lookup-resolved runs - from `Window` through `Misses::judge` into `TrackState::unfed`. -- With asking scoped or not, `a_range_before_every_group_reads_past_it` still disagrees, for the two - reasons the decisions below settle: the publisher keeps the time's own key in range after a - dropped lookup, while a relay re-asks its upstream from the next time once that key is dropped; - and a copy reads an upstream answer of "no group to deliver" as proof the range holds nothing, - handing out the later group before the drops for the range land. - -Before the front-drop fix lands, `a_range_before_every_group_reads_past_it` must assert what -these settle, for both readers and through the later group. +Decided 2026-11-25 (maintainer, /quest-run): a local Rust reader whose time range resolves through +the history handler asks it for the keys with no group held, as copies and JS already do, narrowed +to ranges whose start a history lookup placed (`Window::found` with `Found::Group` or +`Found::Dropped`) (rejected: ask nothing, unanswered means empty) +([answer](https://github.com/moq-dev/moq/pull/9639#issuecomment-7177793296)). + +Decided 2026-11-25 (maintainer, /quest-run): once a history lookup comes back empty from key 0, no +group starts at or before the time, so the range starts one past the time, in Rust +(`Window::found`) and JS (`Window.found`): the time's own key is out of range everywhere, and the +lookup's own NotFound drop of it is no gap (rejected: include the key everywhere). This changes the +deliberate `a_time_start_the_groups_cant_place_is_looked_up` and +`a_time_start_before_the_cache_asks_nothing_below_it`. + +Decided 2026-11-25 (maintainer, /quest-run): a publisher answers a range with a start, never "no +group to deliver", whenever it dropped keys in it, so a copy waits for those drops rather than +handing out a later group first (rejected: the copy waits on every key of a range answered empty). +Built on the lite-07 Previous Delta wire, which changes how a copy learns a range is empty. + +What a broad first attempt found, on top of [moq-dev/moq#9639](https://github.com/moq-dev/moq/pull/9639): + +- Making `TrackState::unfed` treat every hole on a local track below the first group the producer + created (`arrivals.first()`) as `never`, so `Misses::judge` asks it now rather than after the miss + grace, makes a history handler holding groups 10 and 15 read the same through direct, relayed, + and JS readers: `[10, Err(11..15), 15, Err(16..21), 66]`. It breaks 23 tests of the deliberate + grace for local holes, such as `a_hole_below_an_undeclared_start_is_asked_after_a_bounded_grace` + and `creating_a_group_past_a_gap_skips_nothing`, which is why the ask is narrowed: thread the runs + of lookup-placed spans from `Window` through `Cursor::probe` and `Misses::judge` into `unfed`. +- With that ask, a relay subscribing after the publisher already recorded the drops hung: the + publisher answered the range "no group to deliver", and the copy placed the time before every + group (`TimeStart::containing` gives `Containing::Before`), reading back to key 0 and waiting on + keys no upstream accounts for. The publisher-side answer above removes that case. +- Gaps split by when their drops land, so the publisher reports `Err(10..11)` then `Err(11..21)` + where a relay gets one drop over `10..21`. Compare readers with adjacent gaps joined, and take + the excluded time key above into account. + +Then `a_range_before_every_group_reads_past_it` asserts the same items for both readers through +the later group, before the front-drop fix lands. ## Waiting -- Maintainer: After a time start's lookup from key 0 is dropped (no group starts at or before time T), does the range include key T itself? The publisher keeps T in range, by design (`a_time_start_before_the_cache_asks_nothing_below_it`), so the lookup's own NotFound drop of T is a gap there; a relay copy that learned T was dropped re-asks its upstream from time T+1 and leaves T out, so the two readers report different gaps. - - Exclude T everywhere (Recommended) - the dropped lookup already proved no group starts at T; the window starts the span at T+1 in Rust and JS, changing 2 deliberate tests. - - Include T everywhere - a copy never moves a time start past a key it learned was dropped; keeps the publisher's tests, and its readers report the lookup's drop of T as a gap. -- Maintainer: A copy reads an upstream's "no group to deliver" answer for a time range as proof the range holds nothing (`an_empty_bounded_range_holds_back_no_later_range`), so it hands out a later group before the drops for that range land, while a reader at the publisher, whose handler left those keys unanswered, reports them as a NotFound gap. Which should change? - - Publisher answers with a start (Recommended) - a range whose keys the publisher dropped is answered with its start rather than "no group to deliver", so the copy waits for those drops, as for any range with keys in it. - - Copy waits for drops - the copy keeps reading "no group to deliver" as empty but holds a later group until each key of the range is accounted for; costs a wait on every truly empty range. +- moq-dev/moq: [moq-dev/moq#9626](https://github.com/moq-dev/moq/pull/9626) (lite-07 Previous Delta) lands, since the publisher's answer for a range with dropped keys is built on its wire; check that the PR is merged. + ## Related -- [Previous Delta](/quest/m2/lite07-subscribe/previous-delta.md) - in [moq-dev/moq#9626](https://github.com/moq-dev/moq/pull/9626), changes how a copy learns a range is empty; this gap is the publisher's own NotFound, so it does not settle it. +- [Previous Delta](/quest/m2/lite07-subscribe/previous-delta.md) - the wire this work builds on, in [moq-dev/moq#9626](https://github.com/moq-dev/moq/pull/9626). From 09482ff5c2e8001412db55c892ba48da7e187781 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Wed, 25 Nov 2026 16:36:42 -0800 Subject: [PATCH 5/5] fix(net): a JS ordered read holds a stale group behind a looked-up time start Co-Authored-By: Claude Opus 5.5 --- js/net/src/ordered.test.ts | 28 ++++++++++++++++++++++++++++ js/net/src/track.ts | 4 +++- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/js/net/src/ordered.test.ts b/js/net/src/ordered.test.ts index 103e181e662..89754897b24 100644 --- a/js/net/src/ordered.test.ts +++ b/js/net/src/ordered.test.ts @@ -818,3 +818,31 @@ test("a looked-up time start reads before a held later group", async () => { expect(items(ordered)).toEqual(["group 10"]); requests.close(); }); + +// A stale live group waits behind a time start still looked up, which keeps its own budget: the read +// never passes the group the lookup finds. +test("a stale group waits behind a looked-up time start", async () => { + using clock = manual(); + const producer = new TrackProducer("test").accept({ timescale: Timescale.MILLI, maxAge: null }); + const requests = producer.requests(); + put(producer, 66n); + clock.jump(Duration.secs(5)); + put(producer, 5000n); + clock.jump(Duration.secs(2)); + const ordered = producer + .subscribe({ + ranges: [ + { start: 10n, end: 20n }, + { start: { live: { min: Duration.millis(4934), max: Duration.secs(1) } } }, + ], + }) + .ordered(); + expect(items(ordered)).toEqual([]); + const fill = await requests.requestedFill(); + expect(fill?.start).toBe(10n); + const group = fill?.accept(10n); + group?.writeFrame(textFrame("x", Timestamp.fromMillis(10))); + group?.finish(); + expect(items(ordered)[0]).toBe("group 10"); + requests.close(); +}); diff --git a/js/net/src/track.ts b/js/net/src/track.ts index 94b948b43b5..a91cbd9bac4 100644 --- a/js/net/src/track.ts +++ b/js/net/src/track.ts @@ -6667,7 +6667,9 @@ export class Subscriber { // scanning: one pass walks a whole backlog off rather than replaying it. if (this.#staleAt(group.start, drift)) { // Passing it passes the owed keys below it too, which the budget gives up with it, but - // for one a wider budget still holds. + // for one a wider budget still holds, and for the group a time start below it resolves + // to, judged by its own budget. + if (this.#waitTimeStart(start, group.start, drift)) return { kind: "idle" }; if (this.#waitWider(start, group.start, drift, drift.budget.at(group.start))) return { kind: "idle" }; this.#passOwed(start, group.start, drift); this.#giveUp({ start: group.start, end: group.start + 1n }, staleHole(drift.budget.at(group.start)));