Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
043a448
chore(quest): claim quest/m1/precut-fixes/resume-js-window.md
kixelated Nov 18, 2026
4111834
fix(net): a JS resumed reader hands out no group outside its window
kixelated Nov 18, 2026
b253f1e
quest: the JS resume sweep's remaining failures are a follow-up
kixelated Nov 18, 2026
53be838
fix(net): a group the window dropped is asked again once the ranges w…
kixelated Nov 18, 2026
9c1f050
fix(net): a copy that dropped a group does not stand for its backfill
kixelated Nov 18, 2026
697dee8
Merge remote-tracking branch 'origin/main' into quest/m1/precut-fixes…
kixelated Nov 19, 2026
ee9adc2
quest: decide resume-js-sweep's drop question by test, fold the dupli…
kixelated Nov 19, 2026
e9c8855
quest: resume-js-sweep owns Copy.dropped's parity with Rust
kixelated Nov 19, 2026
4be2998
Merge origin/main; an owed group under the local floor holds no copy
kixelated Nov 19, 2026
ccb0d5a
fix(net): a group its copy declares skipped is owed nowhere
kixelated Nov 19, 2026
d38714c
Merge remote-tracking branch 'origin/main' into HEAD
kixelated Nov 19, 2026
2bfb04c
chore(quest): drop resume-js-sweep's link to the finished resume-wind…
kixelated Nov 19, 2026
3ad008e
fix(net): a resumed reader judges the group it took, and holds no fai…
kixelated Nov 19, 2026
663eaf7
docs(quest): resume-js-sweep's bar is every swept seed, not Nightly's…
kixelated Nov 19, 2026
b3ad773
Merge branch 'base' into pr-9115
Nov 19, 2026
439b88d
test(moq-net): follow keyed range resolution API
Nov 19, 2026
638ed4f
Merge origin/main into resume-js-window
kixelated Nov 19, 2026
2590801
Merge remote-tracking branch 'origin/main' into pr9115
kixelated Nov 19, 2026
5a74b64
test(net): unwrap createTrack in the owed-wake resume test
kixelated Nov 19, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions js/net/src/internal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -514,8 +514,8 @@ export interface ResumeSource {
skippedBelow(key: bigint): bigint;
/** Where each range starts on the serving copy once delivery starts at `from`, undefined without one. */
starts(from: bigint): (bigint | undefined)[] | undefined;
/** Each range as the serving copy resolved it, undefined without one. */
resolved(): (Resolved | undefined)[] | undefined;
/** Each range as the reader's window resolved it, whichever copy serves. */
resolved(): (Resolved | undefined)[];
/** The runs of `[start, end)` the serving copy reads, undefined without one. */
runs(start: bigint, end: bigint): Run[] | undefined;
/** Whether a route's copy serves the reader now. */
Expand Down
81 changes: 81 additions & 0 deletions js/net/src/resume.model.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1109,6 +1109,87 @@ test("regressions", async () => {
],
finish: false,
},
// A copy places a time start against the groups it holds, which may put it below where the
// reader's window did: the window decides, so the read hands out no group under it.
{
ops: [
{ kind: "join", reader: 0, spec: spec(false, "hour", [1, 3], false) },
{ kind: "up", instance: 0, slot: 1 },
{ kind: "write", instance: 0, slot: 0, group: 1, frames: 2 },
{ kind: "write", instance: 0, slot: 0, group: 0, frames: 1 },
{ kind: "write", instance: 0, slot: 0, group: undefined, frames: 1 },
],
finish: false,
},
// After a failover, ranges replaced resolve from the newest copy to answer them, not from a
// replaced one whose cache lacks the group they start at.
{
ops: [
{ kind: "join", reader: 2, spec: spec(false, "hour", undefined, false) },
{ kind: "write", instance: 0, slot: 0, group: undefined, frames: 1 },
{ kind: "up", instance: 0, slot: 2 },
{ kind: "write", instance: 0, slot: 2, group: 2, frames: 1 },
{ kind: "ranges", reader: 2, range: [2, 3] },
{ kind: "write", instance: 0, slot: 0, group: undefined, frames: 1 },
],
finish: false,
},
// Ranges replaced once the only route went down resolve on the closed copy, which places them
// against the groups it holds, so the read hands out no buffered group they leave out.
{
ops: [
{ kind: "up", instance: 1, slot: 1 },
{ kind: "write", instance: 1, slot: 1, group: 3, frames: 1 },
{ kind: "join", reader: 1, spec: spec(false, "hour", [1, 3], false) },
{ kind: "write", instance: 1, slot: 1, group: 2, frames: 1 },
{ kind: "down", instance: 1, slot: 1 },
{ kind: "ranges", reader: 1, range: [1, 2] },
],
finish: false,
},
// After a failover, a range moved back resolves from the first copy to answer it, even a
// replaced one under a failover cap, so the groups below that cap stay owed. Mirrors the
// Rust case.
{
ops: [
{ kind: "up", instance: 0, slot: 1 },
{ kind: "join", reader: 2, spec: spec(false, "hour", undefined, false) },
{ kind: "write", instance: 0, slot: 1, group: 7, frames: 2 },
{ kind: "up", instance: 0, slot: 0 },
{ kind: "down", instance: 0, slot: 1 },
{ kind: "ranges", reader: 2, range: [1, 8] },
],
finish: false,
},
// A group the window dropped from a copy with no resume point is asked of its route again
// once the ranges widen to name it.
{
ops: [
{ kind: "up", instance: 1, slot: 0 },
{ kind: "join", reader: 0, spec: spec(false, "hour", [3, 4], false) },
{ kind: "up", instance: 1, slot: 2 },
{ kind: "write", instance: 1, slot: 0, group: 3, frames: 1 },
{ kind: "write", instance: 1, slot: 2, group: undefined, frames: 1 },
{ kind: "down", instance: 1, slot: 0 },
{ kind: "ranges", reader: 0, range: undefined },
],
finish: false,
},
// Ranges widened below the serving copy's resume point ask its route for the groups they
// newly cover, as a route change does.
{
ops: [
{ kind: "up", instance: 0, slot: 1 },
{ kind: "join", reader: 3, spec: spec(false, "hour", [1, 3], false) },
{ kind: "write", instance: 0, slot: 1, group: 1, frames: 1 },
{ kind: "write", instance: 0, slot: 1, group: undefined, frames: 1 },
{ kind: "write", instance: 0, slot: 1, group: undefined, frames: 1 },
{ kind: "down", instance: 0, slot: 1 },
{ kind: "ranges", reader: 3, range: undefined },
{ kind: "write", instance: 0, slot: 0, group: undefined, frames: 1 },
],
finish: false,
},
];
const failures: string[] = [];
for (const [i, c] of regressions.entries()) {
Expand Down
251 changes: 251 additions & 0 deletions js/net/src/resume.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,49 @@ test("a resumed reader's replaced ranges reach its serving copy", async () => {
}
});

test("a group the window dropped above the serving copy's resume point is backfilled once ranges widen to it", async () => {
const clock = new Manual();
const installed = clock.install();
const front = new Front();
const sources = [new BroadcastProducer(), new BroadcastProducer()];
const handles = sources.map((source) => source.consume());
const [ta, tb] = sources.map(copy);
const delay = { max: Duration.millis(3_600_000) };
ta.write(10n);
ta.write(50n);
front.serve(handles[0]);
const sub = front.consumer.track("seq").subscribe({
delay,
ranges: [
{ start: { time: 10n }, end: { time: 10n } },
{ start: { time: 50n }, end: { time: 50n } },
],
});
try {
await clock.advance(Duration.ZERO);
const first = sub.tryRecvGroup();
expect(first?.start).toBe(10n);
first?.close();
// The new copy resumes at group 10 and places time 50 at group 40, the newest it holds at
// or before it, which the reader's window leaves out: dropped above that resume point.
front.serve(handles[1]);
await clock.advance(Duration.ZERO);
tb.write(40n);
await clock.advance(Duration.ZERO);
expect(drain(sub)).toEqual([50n]);
sub.update({ delay, ranges: [{ start: { time: 40n }, end: { time: 60n } }] });
await clock.advance(Duration.ZERO);
await clock.advance(Duration.ZERO);
expect(drain(sub)).toEqual([40n]);
} finally {
sub.close();
front.consumer.close();
for (const handle of handles) handle.close();
for (const source of sources) source.close();
installed.close();
}
});

/**
* A group below the replacement's resume point that the reader never got is asked of the new
* route, as one cursor on the logical track would still get it late.
Expand Down Expand Up @@ -2089,6 +2132,214 @@ test("an ordered reader takes a replaced copy's buffered group before the new co
b.close();
});

// A group the window names under the local floor never lands on a copy, so it is no reason to hold
// an ordered copy's cursor on a group the window leaves out.
test("an ordered resumed reader owes no window group under its local floor", async () => {
const front = new Front();
const a = new BroadcastProducer();
const b = new BroadcastProducer();
const ta = copy(a);
const tb = copy(b);
ta.write(10n);
ta.write(100n, 1, false);
front.serve(a.consume());
const sub = front.consumer
.track("seq")
.subscribe({
delay: { max: null },
ranges: [
{ start: { time: 10n }, end: { time: 10n } },
{ start: { time: 100n }, end: { time: 200n } },
],
})
.withRange({ start: { included: 60n } });
const ordered = sub.ordered();
try {
await settle();
// The window resolves before any group is read.
expect(hooks.servingResolved(sub).map((range) => range?.start)).toEqual([10n, 100n]);
// The replacement places time 100 at group 80, the newest it holds at or before it, which the
// window leaves out. Group 10 is still owed, but under the local floor.
ta.producer.abort(new StreamError(StreamCode.SessionClosed));
tb.write(80n);
tb.write(120n);
front.serve(b.consume());
await settle();
expect(ordered.tryNextGroup()?.start).toBe(120n);
} finally {
ordered.close();
front.consumer.close();
a.close();
b.close();
}
});

// A window group the replacement declares skipped never lands on it, so it is no reason to hold
// its ordered cursor on a group the window leaves out.
test("an ordered resumed reader owes no window group its copy declares skipped", async () => {
const front = new Front();
const a = new BroadcastProducer();
const b = new BroadcastProducer();
const ta = copy(a);
const tb = copy(b);
ta.write(10n);
ta.write(100n, 1, false);
front.serve(a.consume());
const sub = front.consumer.track("seq").subscribe({
delay: { max: null },
ranges: [
{ start: { time: 10n }, end: { time: 30n } },
{ start: { time: 100n }, end: { time: 200n } },
],
});
const ordered = sub.ordered();
try {
await settle();
expect(ordered.tryNextGroup()?.start).toBe(10n);
// The replacement places time 100 at group 80, which the window leaves out, and skips the
// rest of the first range.
ta.producer.abort(new StreamError(StreamCode.SessionClosed));
tb.producer.skipGroups(11n, 31n);
tb.write(80n);
tb.write(120n);
front.serve(b.consume());
await settle();
expect(ordered.tryNextGroup()?.start).toBe(120n);
} finally {
ordered.close();
front.consumer.close();
a.close();
b.close();
}
});

// A failed copy receives nothing more, so a window group under its cursor is no reason to hold it:
// it hands out what it holds and its failure is judged.
test("an ordered resumed reader does not hold a failed copy for a group it can no longer receive", async () => {
const front = new Front();
const a = new BroadcastProducer();
const b = new BroadcastProducer();
const ta = copy(a);
const tb = copy(b);
ta.write(10n);
ta.write(100n, 1, false);
front.serve(a.consume());
const sub = front.consumer.track("seq").subscribe({
delay: { max: null },
ranges: [
{ start: { time: 10n }, end: { time: 30n } },
{ start: { time: 100n }, end: { time: 200n } },
],
});
const ordered = sub.ordered();
try {
await settle();
expect(ordered.tryNextGroup()?.start).toBe(10n);
// The replacement places time 100 at group 80, which the window leaves out, then fails
// without 11 to 30 ever landing on it.
ta.producer.abort(new StreamError(StreamCode.SessionClosed));
tb.write(80n);
tb.write(120n);
front.serve(b.consume());
await settle();
tb.producer.abort(new StreamError(StreamCode.SessionClosed));
await settle();
expect(ordered.tryNextGroup()?.start).toBe(120n);
} finally {
ordered.close();
front.consumer.close();
a.close();
b.close();
}
});

// A read holding the replacement's ordered cursor on a group the window leaves out, for a lower
// window group it still owes, wakes when that group lands on the copy. Mirrors the Rust
// `a_key_order_read_holding_a_copy_wakes_when_the_owed_group_lands`.
test("an ordered resumed reader holding a copy wakes when the owed group lands", async () => {
const front = new Front();
const a = new BroadcastProducer();
const b = new BroadcastProducer();
const ta = copy(a);
const tb = copy(b);
ta.write(10n);
ta.write(100n, 1, false);
front.serve(a.consume());
const sub = front.consumer.track("seq").subscribe({
delay: { max: null },
ranges: [
{ start: { time: 10n }, end: { time: 30n } },
{ start: { time: 100n }, end: { time: 200n } },
],
});
const ordered = sub.ordered();
try {
await settle();
expect(ordered.tryNextGroup()?.start).toBe(10n);
// The replacement places time 100 at group 80, which the window leaves out, while the window
// still owes the rest of the first range: the read holds its cursor on 80.
ta.producer.abort(new StreamError(StreamCode.SessionClosed));
tb.write(80n);
tb.write(120n);
front.serve(b.consume());
await settle();
const next = ordered.nextGroup();
expect(await isPending(next)).toBe(true);
tb.write(20n);
expect(await isPending(next)).toBe(false);
expect((await next)?.start).toBe(20n);
} finally {
ordered.close();
front.consumer.close();
a.close();
b.close();
}
});

// A copy's take may pass the group it offered, such as one missing its head, and return a later one:
// the reader judges the group it got against its window, not the one offered.
test("a resumed reader drops a taken group outside its window when the offered one was passed", async () => {
const front = new Front();
const a = new BroadcastProducer();
const b = new BroadcastProducer();
const ta = copy(a);
ta.write(10n);
ta.write(100n, 1, false);
front.serve(a.consume());
const sub = front.consumer.track("seq").subscribe({
delay: { max: null },
ranges: [
{ start: { time: 10n }, end: { time: 10n } },
{ start: { time: 100n }, end: { time: 200n } },
],
});
try {
await settle();
expect(hooks.servingResolved(sub).map((range) => range?.start)).toEqual([10n, 100n]);
// The replacement holds group 10 from frame 1 only, which a bounded copy gives up with no fill to
// ask, and places time 100 at group 80, which the window leaves out.
const tb = defined(b.createTrack("seq", { maxAge: null }));
const tail = hooks.receiveGroup(tb, { start: 10n, offset: 1 });
tail.writeFrame({ payload: enc.encode("10.1"), timestamp: Timestamp.unscaled(10n) });
tail.finish();
for (const key of [80n, 120n]) {
const group = tb.createGroup(key);
group.writeFrame({ payload: enc.encode(`${key}.0`), timestamp: Timestamp.unscaled(key) });
group.finish();
}
ta.producer.abort(new StreamError(StreamCode.SessionClosed));
front.serve(b.consume());
await settle();
// Group 10 still goes out from the failed copy that holds it whole; 80 never does.
expect(drain(sub)).toEqual([10n, 120n]);
} finally {
sub.close();
front.consumer.close();
a.close();
b.close();
}
});

test("a routed read right after an update picks its group under the new preferences", async () => {
const front = new Front();
const a = new BroadcastProducer();
Expand Down
Loading