@blockcast/mmt-container 2.2.0-main.c4fa878f4ff4 → 2.2.0-main.caa271d80062

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (111) hide show
  1. package/README.md +34 -19
  2. package/dist/block-policy.d.ts +88 -16
  3. package/dist/block-policy.d.ts.map +1 -1
  4. package/dist/block-policy.js +164 -56
  5. package/dist/block-policy.js.map +3 -3
  6. package/dist/browser-runtime.js +2064 -388
  7. package/dist/browser-runtime.js.map +3 -3
  8. package/dist/carp-catalog.js.map +2 -2
  9. package/dist/catalog-fec-params.d.ts +18 -2
  10. package/dist/catalog-fec-params.d.ts.map +1 -1
  11. package/dist/catalog-fec-params.js +29 -1
  12. package/dist/catalog-fec-params.js.map +2 -2
  13. package/dist/catalog-network-source.js.map +2 -2
  14. package/dist/cmaf-block-assembler.js +92 -1
  15. package/dist/cmaf-block-assembler.js.map +2 -2
  16. package/dist/cmcd-producer.d.ts +60 -47
  17. package/dist/cmcd-producer.d.ts.map +1 -1
  18. package/dist/cmcd-producer.js +138 -109
  19. package/dist/cmcd-producer.js.map +2 -2
  20. package/dist/codec-utils.d.ts.map +1 -1
  21. package/dist/codec-utils.js +92 -1
  22. package/dist/codec-utils.js.map +2 -2
  23. package/dist/delivery-catalog.js +26 -16
  24. package/dist/delivery-catalog.js.map +2 -2
  25. package/dist/delta-fallback-config.js +5 -1
  26. package/dist/delta-fallback-config.js.map +3 -3
  27. package/dist/fec-manager.d.ts +163 -20
  28. package/dist/fec-manager.d.ts.map +1 -1
  29. package/dist/fec-manager.js +863 -110
  30. package/dist/fec-manager.js.map +3 -3
  31. package/dist/fec-state.js +5 -1
  32. package/dist/fec-state.js.map +2 -2
  33. package/dist/fec-worker-setup.d.ts +1 -1
  34. package/dist/fec-worker-setup.js +1 -1
  35. package/dist/fec-worker-setup.js.map +2 -2
  36. package/dist/held-layer-admission.js.map +2 -2
  37. package/dist/index.d.ts +4 -4
  38. package/dist/index.d.ts.map +1 -1
  39. package/dist/index.js +8 -2
  40. package/dist/index.js.map +2 -2
  41. package/dist/iso-block-locator.d.ts +64 -13
  42. package/dist/iso-block-locator.d.ts.map +1 -1
  43. package/dist/iso-block-locator.js +125 -25
  44. package/dist/iso-block-locator.js.map +2 -2
  45. package/dist/iso-bmff-timing.d.ts +10 -1
  46. package/dist/iso-bmff-timing.d.ts.map +1 -1
  47. package/dist/iso-bmff-timing.js +36 -2
  48. package/dist/iso-bmff-timing.js.map +2 -2
  49. package/dist/media-router.js.map +1 -1
  50. package/dist/mfu-reassembler.js.map +2 -2
  51. package/dist/mmtp-container-parser.d.ts +109 -12
  52. package/dist/mmtp-container-parser.d.ts.map +1 -1
  53. package/dist/mmtp-container-parser.js +312 -27
  54. package/dist/mmtp-container-parser.js.map +2 -2
  55. package/dist/mmtp-container-parser.no-modules.js +333 -32
  56. package/dist/mmtp-container-parser.no-modules.js.map +4 -4
  57. package/dist/mmtp-decode-pipeline.js +311 -27
  58. package/dist/mmtp-decode-pipeline.js.map +2 -2
  59. package/dist/mmtp-fec-session.js.map +2 -2
  60. package/dist/mmtp-router.d.ts +51 -12
  61. package/dist/mmtp-router.d.ts.map +1 -1
  62. package/dist/mmtp-router.js +723 -83
  63. package/dist/mmtp-router.js.map +3 -3
  64. package/dist/multicast-auth-catalog.js.map +2 -2
  65. package/dist/multicast-input.js.map +2 -2
  66. package/dist/multicast-manager.d.ts +31 -3
  67. package/dist/multicast-manager.d.ts.map +1 -1
  68. package/dist/multicast-manager.js +1698 -231
  69. package/dist/multicast-manager.js.map +3 -3
  70. package/dist/multicast-transport.js +28 -18
  71. package/dist/multicast-transport.js.map +2 -2
  72. package/dist/multicast-unwrap.js.map +2 -2
  73. package/dist/no-modules.d.ts +1 -0
  74. package/dist/no-modules.d.ts.map +1 -1
  75. package/dist/no-modules.js +333 -31
  76. package/dist/no-modules.js.map +4 -4
  77. package/dist/repair-fetch.d.ts +38 -8
  78. package/dist/repair-fetch.d.ts.map +1 -1
  79. package/dist/repair-fetch.js +286 -27
  80. package/dist/repair-fetch.js.map +3 -3
  81. package/dist/repair-layer-subscriptions.d.ts +6 -2
  82. package/dist/repair-layer-subscriptions.d.ts.map +1 -1
  83. package/dist/repair-layer-subscriptions.js +6 -3
  84. package/dist/repair-layer-subscriptions.js.map +2 -2
  85. package/dist/signaling.js.map +2 -2
  86. package/dist/timestamp-codec.js.map +2 -2
  87. package/dist/track-session.d.ts +1 -1
  88. package/dist/track-session.d.ts.map +1 -1
  89. package/dist/track-session.js +1 -0
  90. package/dist/track-session.js.map +2 -2
  91. package/dist/wasm-mfu-reassembler.js.map +2 -2
  92. package/dist/wasm-mmtp-container-parser.js +311 -27
  93. package/dist/wasm-mmtp-container-parser.js.map +2 -2
  94. package/package.json +8 -5
  95. package/schemas/catalog.schema.json +4 -0
  96. package/src/block-policy.ts +324 -83
  97. package/src/catalog-fec-params.ts +37 -1
  98. package/src/cmcd-producer.ts +189 -179
  99. package/src/codec-utils.ts +121 -1
  100. package/src/fec-manager.ts +818 -42
  101. package/src/fec-worker-setup.ts +2 -2
  102. package/src/index.ts +11 -2
  103. package/src/iso-block-locator.ts +167 -31
  104. package/src/iso-bmff-timing.ts +40 -1
  105. package/src/mmtp-container-parser.ts +355 -32
  106. package/src/mmtp-router.ts +665 -50
  107. package/src/multicast-manager.ts +145 -16
  108. package/src/no-modules.ts +3 -0
  109. package/src/repair-fetch.ts +366 -50
  110. package/src/repair-layer-subscriptions.ts +13 -5
  111. package/src/track-session.ts +4 -1
@@ -32,16 +32,28 @@ export type IsoRepairPlacement<T> = {
32
32
  readonly lostSsId: number;
33
33
  };
34
34
  }
35
- /** Not a block this stream can use; the repair symbol is dropped. */
35
+ /**
36
+ * Not a block this stream can use; the repair symbol is dropped. `ofSpan` is
37
+ * set when the repair stated only the first block of that repair-less span:
38
+ * the span holds more than one block, so no single repair group completes it.
39
+ */
36
40
  | {
37
41
  readonly status: 'conflict' | 'overlap' | 'stale' | 'ahead';
38
42
  readonly reason: string;
43
+ readonly ofSpan?: IsoBlockRange;
39
44
  };
40
45
  /**
41
46
  * Retention: the locator is never without one. Every call that can grow it
42
47
  * (`hold`, `placeRepair`) retires, behind the position it just saw, every
43
48
  * block, span and held source more than `retentionBlocks` blocks back, by the
44
- * one ISO horizon metric (`isoBlocksBehindLowerBound`). A block is measured
49
+ * one ISO horizon metric (`isoBlocksBehindLowerBound`). A held source stays
50
+ * while a pending hole holding it does: the hole's repair FETCH may still
51
+ * state its block, and closing the hole places it, so the span it leaves
52
+ * counts every source it received (BLO-52085). A pending hole the horizon
53
+ * passes stops being pending (its blocks can no longer be stated, and the
54
+ * release gate no longer waits for it), but keeps its sources until its
55
+ * owner closes it (`takeExpiredHoles`), so it still fails as the span it
56
+ * is. A block is measured
45
57
  * from its last SS_ID, so it stays while any SS_ID of it is inside the
46
58
  * horizon: a repair-less span has no length bound, and one measured from its
47
59
  * start could be retired the moment it is created, before the sources it
@@ -82,6 +94,15 @@ export declare class IsoBlockLocator<T> {
82
94
  get newest(): number | undefined;
83
95
  /** Advance `newest` to `position` if it is newer; retires nothing. */
84
96
  observe(position: number): void;
97
+ /**
98
+ * The newest source SS_ID noted with `noteSource` (RFC 1982 order). Unlike
99
+ * `newest`, a repair never moves it: a repair can run ahead of its sources,
100
+ * a source cannot run ahead of the sources sent before it except by
101
+ * reordering.
102
+ */
103
+ get newestSource(): number | undefined;
104
+ /** Note a received source's SS_ID; true when it is the newest one yet. */
105
+ noteSource(ssId: number): boolean;
85
106
  /** Held sources evicted by `heldCapacity` (never by the horizon itself). */
86
107
  get heldEvicted(): number;
87
108
  /** Number of known blocks and spans. */
@@ -95,8 +116,16 @@ export declare class IsoBlockLocator<T> {
95
116
  block: IsoBlockRange;
96
117
  esi: number;
97
118
  } | null;
98
- /** Number of pending holes. */
119
+ /** Number of holes not closed yet, pending or past the horizon. */
99
120
  get holeCount(): number;
121
+ /**
122
+ * The pending holes the horizon has passed since the last call, in the
123
+ * order it passed them. Each is no longer pending: no repair states a block
124
+ * in it (that repair is `stale`, as for a span the horizon retired) and the
125
+ * release gate does not wait for it. Its owner must close it
126
+ * (`closeHolesWithin`), which turns it into a span that is not kept here.
127
+ */
128
+ takeExpiredHoles(): IsoBlockRange[];
100
129
  /** The stated block (never a span) ending exactly at `end`. */
101
130
  blockEndingAt(end: number): IsoBlockRange | undefined;
102
131
  /** The known block or span starting exactly at `start`. */
@@ -116,12 +145,30 @@ export declare class IsoBlockLocator<T> {
116
145
  hold(ssId: number, payload: T): boolean;
117
146
  /** Whether `ssId` is held unplaced. */
118
147
  isHeld(ssId: number): boolean;
148
+ /** The payload held unplaced for `ssId`, if any. */
149
+ heldSource(ssId: number): T | undefined;
150
+ /**
151
+ * The SS_IDs strictly between `a` and `b` that no repair has delimited a
152
+ * block of yet: those from the coverage end on, or all of them before the
153
+ * first repair. `missing` is the highest of them no source is held for;
154
+ * absent, every one of them arrived (C.5.2: SS_IDs are consecutive). Null
155
+ * when none lies past coverage. `flagged` is whether a source held among
156
+ * them satisfies `flag` (a RAP fragment, say): the held packets read as
157
+ * fec-multicast-00 Block Classification item 1 reads bounding packets.
158
+ */
159
+ undelimitedBetween(a: number, b: number, flag?: (payload: T) => boolean): {
160
+ start: number;
161
+ missing?: number;
162
+ flagged: boolean;
163
+ } | null;
119
164
  /**
120
165
  * Apply one repair symbol's `(SS_Start, SSB_length)`. The first repair of a
121
166
  * block states its range and places every held source in it; later repair
122
- * symbols of the same block change nothing. A range that contradicts a
123
- * known block (a different length, or an overlap with another block or a
124
- * span) fails closed: the repair symbol is dropped and no block changes.
167
+ * symbols of the same block change nothing. A repair whose range is exactly
168
+ * a repair-less span states that span's one block. A range that contradicts
169
+ * a known block (a different length, or an overlap with another block or
170
+ * with part of a span) fails closed: the repair symbol is dropped and no
171
+ * block changes.
125
172
  * A newly stated block retires behind its SS_Start (see the class note).
126
173
  * A block so far past `newest` that stating it would retire the position
127
174
  * `newest` is refused as `ahead`. When `newest` is a placed block's SS_Start
@@ -135,19 +182,23 @@ export declare class IsoBlockLocator<T> {
135
182
  */
136
183
  placeRepair(start: number, length: number): IsoRepairPlacement<T>;
137
184
  /**
138
- * Turn every pending hole inside `[start, start + length)` into a
139
- * repair-less span, claiming its held sources: its range FETCH ended, so
140
- * nothing more will state its blocks. Returns the spans, in SS_ID order.
185
+ * Turn every hole inside `[start, start + length)` into a repair-less span,
186
+ * claiming its held sources: its range FETCH ended, so nothing more will
187
+ * state its blocks. A hole the horizon passed (`takeExpiredHoles`) leaves a
188
+ * span that is not kept among the blocks, as the horizon would retire it at
189
+ * once; only `locate` finds it, until the next retirement, so its sources
190
+ * can be fed. Returns the spans, in SS_ID order.
141
191
  */
142
192
  closeHolesWithin(start: number, length: number): {
143
193
  block: IsoBlockRange;
144
194
  placed: IsoPlacedSource<T>[];
145
195
  }[];
146
196
  /**
147
- * Retire every block and span whose last SS_ID, and every held source,
148
- * lies more than `retentionBlocks` blocks behind `position`, with the shared
149
- * lower-bound metric (`isoBlocksBehindLowerBound`) every ISO interleave
150
- * horizon uses. Returns the retired block starts.
197
+ * Retire every block and span whose last SS_ID, and every held source
198
+ * outside a hole, lies more than `retentionBlocks` blocks behind
199
+ * `position`, with the shared lower-bound metric (`isoBlocksBehindLowerBound`)
200
+ * every ISO interleave horizon uses; a pending hole so far behind expires
201
+ * (`takeExpiredHoles`). Returns the retired block starts.
151
202
  */
152
203
  retireBehind(position: number): number[];
153
204
  /** Forget everything (publisher restart, track reset). */
@@ -1 +1 @@
1
- {"version":3,"file":"iso-block-locator.d.ts","sourceRoot":"","sources":["../src/iso-block-locator.ts"],"names":[],"mappings":"AA6BA,4EAA4E;AAC5E,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,6EAA6E;IAC7E,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAA;CACvB;AAED,kEAAkE;AAClE,MAAM,WAAW,eAAe,CAAC,CA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;;;OAMG;IACH,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE;IAkCxC,0DAA0D;IAC1D,KAAK,IAAI,IAAI;CAsBd"}
@@ -71,6 +71,15 @@ var IsoBlockLocator = class _IsoBlockLocator {
71
71
  this.#heldEvicted = 0;
72
72
  /** Pending holes (see `deferIncompleteGaps`): unstated, sources still held. */
73
73
  this.#holes = [];
74
+ /** Holes the horizon passed while pending: sources held until closed. */
75
+ this.#expired = [];
76
+ /** Of `#expired`, those `takeExpiredHoles` has not handed out yet. */
77
+ this.#newlyExpired = [];
78
+ /**
79
+ * Spans closed from expired holes: behind the horizon, so kept only for
80
+ * `locate` while their sources are fed, until the next retirement.
81
+ */
82
+ this.#closedBehind = [];
74
83
  /**
75
84
  * Keep a gap that is missing a source as a pending hole rather than a span,
76
85
  * so a repair FETCHed for it (draft-ramadan-moq-fec §7.5) can still state
@@ -92,7 +101,11 @@ var IsoBlockLocator = class _IsoBlockLocator {
92
101
  #retentionBlocks;
93
102
  #heldEvicted;
94
103
  #newest;
104
+ #newestSource;
95
105
  #holes;
106
+ #expired;
107
+ #newlyExpired;
108
+ #closedBehind;
96
109
  static #checkedRetention(retentionBlocks) {
97
110
  if (!Number.isSafeInteger(retentionBlocks) || retentionBlocks <= 0) {
98
111
  throw new Error(
@@ -129,6 +142,21 @@ var IsoBlockLocator = class _IsoBlockLocator {
129
142
  observe(position) {
130
143
  if (this.#newest === void 0 || serial32Precedes(this.#newest, position)) this.#newest = position;
131
144
  }
145
+ /**
146
+ * The newest source SS_ID noted with `noteSource` (RFC 1982 order). Unlike
147
+ * `newest`, a repair never moves it: a repair can run ahead of its sources,
148
+ * a source cannot run ahead of the sources sent before it except by
149
+ * reordering.
150
+ */
151
+ get newestSource() {
152
+ return this.#newestSource;
153
+ }
154
+ /** Note a received source's SS_ID; true when it is the newest one yet. */
155
+ noteSource(ssId) {
156
+ if (this.#newestSource !== void 0 && !serial32Precedes(this.#newestSource, ssId)) return false;
157
+ this.#newestSource = ssId;
158
+ return true;
159
+ }
132
160
  /** Held sources evicted by `heldCapacity` (never by the horizon itself). */
133
161
  get heldEvicted() {
134
162
  return this.#heldEvicted;
@@ -147,17 +175,29 @@ var IsoBlockLocator = class _IsoBlockLocator {
147
175
  }
148
176
  /** The known block or span containing `ssId`, with its ESI. */
149
177
  locate(ssId) {
150
- for (let i = this.#blocks.length - 1; i >= 0; i--) {
151
- const block = this.#blocks[i];
152
- if (isoBlockContains(block.start, block.length, ssId)) {
153
- return { block, esi: serial32Distance(block.start, ssId) };
178
+ for (const blocks of [this.#blocks, this.#closedBehind]) {
179
+ for (let i = blocks.length - 1; i >= 0; i--) {
180
+ const block = blocks[i];
181
+ if (isoBlockContains(block.start, block.length, ssId)) {
182
+ return { block, esi: serial32Distance(block.start, ssId) };
183
+ }
154
184
  }
155
185
  }
156
186
  return null;
157
187
  }
158
- /** Number of pending holes. */
188
+ /** Number of holes not closed yet, pending or past the horizon. */
159
189
  get holeCount() {
160
- return this.#holes.length;
190
+ return this.#holes.length + this.#expired.length;
191
+ }
192
+ /**
193
+ * The pending holes the horizon has passed since the last call, in the
194
+ * order it passed them. Each is no longer pending: no repair states a block
195
+ * in it (that repair is `stale`, as for a span the horizon retired) and the
196
+ * release gate does not wait for it. Its owner must close it
197
+ * (`closeHolesWithin`), which turns it into a span that is not kept here.
198
+ */
199
+ takeExpiredHoles() {
200
+ return this.#newlyExpired.splice(0);
161
201
  }
162
202
  /** The stated block (never a span) ending exactly at `end`. */
163
203
  blockEndingAt(end) {
@@ -210,12 +250,42 @@ var IsoBlockLocator = class _IsoBlockLocator {
210
250
  isHeld(ssId) {
211
251
  return this.#held.has(ssId);
212
252
  }
253
+ /** The payload held unplaced for `ssId`, if any. */
254
+ heldSource(ssId) {
255
+ return this.#held.get(ssId);
256
+ }
257
+ /**
258
+ * The SS_IDs strictly between `a` and `b` that no repair has delimited a
259
+ * block of yet: those from the coverage end on, or all of them before the
260
+ * first repair. `missing` is the highest of them no source is held for;
261
+ * absent, every one of them arrived (C.5.2: SS_IDs are consecutive). Null
262
+ * when none lies past coverage. `flagged` is whether a source held among
263
+ * them satisfies `flag` (a RAP fragment, say): the held packets read as
264
+ * fec-multicast-00 Block Classification item 1 reads bounding packets.
265
+ */
266
+ undelimitedBetween(a, b, flag) {
267
+ if (!serial32Precedes(a, b) || serial32Distance(a, b) <= 1) return null;
268
+ const first = a + 1 >>> 0;
269
+ const end = this.#coverageEnd;
270
+ const start = end !== void 0 && serial32Precedes(first, end) ? end : first;
271
+ if (!serial32Precedes(start, b)) return null;
272
+ const length = serial32Distance(start, b);
273
+ const missing = this.#highestMissing(start, length);
274
+ let flagged = false;
275
+ for (let i = 0; flag !== void 0 && !flagged && i < length; i++) {
276
+ const payload = this.#held.get(serial32Add(start, i));
277
+ flagged = payload !== void 0 && flag(payload);
278
+ }
279
+ return missing === void 0 ? { start, flagged } : { start, missing, flagged };
280
+ }
213
281
  /**
214
282
  * Apply one repair symbol's `(SS_Start, SSB_length)`. The first repair of a
215
283
  * block states its range and places every held source in it; later repair
216
- * symbols of the same block change nothing. A range that contradicts a
217
- * known block (a different length, or an overlap with another block or a
218
- * span) fails closed: the repair symbol is dropped and no block changes.
284
+ * symbols of the same block change nothing. A repair whose range is exactly
285
+ * a repair-less span states that span's one block. A range that contradicts
286
+ * a known block (a different length, or an overlap with another block or
287
+ * with part of a span) fails closed: the repair symbol is dropped and no
288
+ * block changes.
219
289
  * A newly stated block retires behind its SS_Start (see the class note).
220
290
  * A block so far past `newest` that stating it would retire the position
221
291
  * `newest` is refused as `ahead`. When `newest` is a placed block's SS_Start
@@ -234,7 +304,16 @@ var IsoBlockLocator = class _IsoBlockLocator {
234
304
  const known = this.blockAt(start);
235
305
  if (known !== void 0) {
236
306
  if (known.span) {
237
- return { status: "overlap", reason: `repair block ${start}+${length} falls inside a repair-less span` };
307
+ if (known.length === length) {
308
+ const block2 = { start, length, span: false };
309
+ this.#blocks[this.#blocks.indexOf(known)] = block2;
310
+ return { status: "placed", block: block2, placed: [] };
311
+ }
312
+ return length < known.length ? {
313
+ status: "overlap",
314
+ reason: `repair block ${start}+${length} is only the first block of repair-less span ${known.start}+${known.length}`,
315
+ ofSpan: known
316
+ } : { status: "overlap", reason: `repair block ${start}+${length} runs past repair-less span ${known.start}+${known.length}` };
238
317
  }
239
318
  if (known.length !== length) {
240
319
  return {
@@ -302,18 +381,28 @@ var IsoBlockLocator = class _IsoBlockLocator {
302
381
  return span === void 0 ? { status: "placed", block, placed } : { status: "placed", block, placed, span };
303
382
  }
304
383
  /**
305
- * Turn every pending hole inside `[start, start + length)` into a
306
- * repair-less span, claiming its held sources: its range FETCH ended, so
307
- * nothing more will state its blocks. Returns the spans, in SS_ID order.
384
+ * Turn every hole inside `[start, start + length)` into a repair-less span,
385
+ * claiming its held sources: its range FETCH ended, so nothing more will
386
+ * state its blocks. A hole the horizon passed (`takeExpiredHoles`) leaves a
387
+ * span that is not kept among the blocks, as the horizon would retire it at
388
+ * once; only `locate` finds it, until the next retirement, so its sources
389
+ * can be fed. Returns the spans, in SS_ID order.
308
390
  */
309
391
  closeHolesWithin(start, length) {
310
392
  const closed = [];
311
- for (const hole of [...this.#holes]) {
312
- if (!isoBlockContains(start, length, hole.start)) continue;
313
- this.#holes.splice(this.#holes.indexOf(hole), 1);
314
- const spanBlock = { start: hole.start, length: hole.length, span: true };
315
- closed.push({ block: spanBlock, placed: this.#claim(spanBlock) });
316
- this.#blocks.push(spanBlock);
393
+ for (const holes of [this.#holes, this.#expired]) {
394
+ for (const hole of [...holes]) {
395
+ if (!isoBlockContains(start, length, hole.start)) continue;
396
+ holes.splice(holes.indexOf(hole), 1);
397
+ const spanBlock = { start: hole.start, length: hole.length, span: true };
398
+ closed.push({ block: spanBlock, placed: this.#claim(spanBlock) });
399
+ if (holes === this.#holes) {
400
+ this.#blocks.push(spanBlock);
401
+ } else {
402
+ this.#closedBehind.push(spanBlock);
403
+ if (this.#newlyExpired.includes(hole)) this.#newlyExpired.splice(this.#newlyExpired.indexOf(hole), 1);
404
+ }
405
+ }
317
406
  }
318
407
  return closed.sort((x, y) => serial32Distance(start, x.block.start) - serial32Distance(start, y.block.start));
319
408
  }
@@ -327,15 +416,17 @@ var IsoBlockLocator = class _IsoBlockLocator {
327
416
  return void 0;
328
417
  }
329
418
  /**
330
- * Retire every block and span whose last SS_ID, and every held source,
331
- * lies more than `retentionBlocks` blocks behind `position`, with the shared
332
- * lower-bound metric (`isoBlocksBehindLowerBound`) every ISO interleave
333
- * horizon uses. Returns the retired block starts.
419
+ * Retire every block and span whose last SS_ID, and every held source
420
+ * outside a hole, lies more than `retentionBlocks` blocks behind
421
+ * `position`, with the shared lower-bound metric (`isoBlocksBehindLowerBound`)
422
+ * every ISO interleave horizon uses; a pending hole so far behind expires
423
+ * (`takeExpiredHoles`). Returns the retired block starts.
334
424
  */
335
425
  retireBehind(position) {
336
426
  this.observe(position);
337
427
  const horizon = this.#retentionBlocks;
338
428
  const retired = [];
429
+ this.#closedBehind.length = 0;
339
430
  for (let i = this.#blocks.length - 1; i >= 0; i--) {
340
431
  const block = this.#blocks[i];
341
432
  const last = serial32Add(block.start, block.length - 1);
@@ -347,10 +438,15 @@ var IsoBlockLocator = class _IsoBlockLocator {
347
438
  for (let i = this.#holes.length - 1; i >= 0; i--) {
348
439
  const hole = this.#holes[i];
349
440
  const last = serial32Add(hole.start, hole.length - 1);
350
- if (isoBlocksBehindLowerBound(last, position, this.#kMax) > horizon) this.#holes.splice(i, 1);
441
+ if (isoBlocksBehindLowerBound(last, position, this.#kMax) <= horizon) continue;
442
+ this.#holes.splice(i, 1);
443
+ this.#expired.push(hole);
444
+ this.#newlyExpired.push(hole);
351
445
  }
352
446
  for (const ssId of [...this.#held.keys()]) {
353
- if (isoBlocksBehindLowerBound(ssId, position, this.#kMax) > horizon) this.#held.delete(ssId);
447
+ if (isoBlocksBehindLowerBound(ssId, position, this.#kMax) > horizon && !this.#holes.some((hole) => isoBlockContains(hole.start, hole.length, ssId)) && !this.#expired.some((hole) => isoBlockContains(hole.start, hole.length, ssId))) {
448
+ this.#held.delete(ssId);
449
+ }
354
450
  }
355
451
  return retired;
356
452
  }
@@ -358,9 +454,13 @@ var IsoBlockLocator = class _IsoBlockLocator {
358
454
  reset() {
359
455
  this.#blocks.length = 0;
360
456
  this.#holes.length = 0;
457
+ this.#expired.length = 0;
458
+ this.#newlyExpired.length = 0;
459
+ this.#closedBehind.length = 0;
361
460
  this.#held.clear();
362
461
  this.#coverageEnd = void 0;
363
462
  this.#newest = void 0;
463
+ this.#newestSource = void 0;
364
464
  }
365
465
  #claim(block) {
366
466
  const placed = [];