@rotorsoft/act-tck 1.13.3 → 1.14.0

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.
package/dist/index.cjs CHANGED
@@ -43,6 +43,7 @@ __export(index_exports, {
43
43
  runCacheTck: () => runCacheTck,
44
44
  runLoggerTck: () => runLoggerTck,
45
45
  runStabilityTck: () => runStabilityTck,
46
+ runStorePropertyTck: () => runStorePropertyTck,
46
47
  runStoreTck: () => runStoreTck,
47
48
  uid: () => uid
48
49
  });
@@ -278,40 +279,242 @@ ${content}`;
278
279
  }).join("\n");
279
280
  }
280
281
 
282
+ // src/store-property-tck.ts
283
+ var import_vitest4 = require("@fast-check/vitest");
284
+ var import_vitest5 = require("vitest");
285
+ var streamArb = import_vitest4.fc.constantFrom("s1", "s2", "s3");
286
+ var commitArb = import_vitest4.fc.record({
287
+ stream: streamArb,
288
+ count: import_vitest4.fc.integer({ min: 1, max: 3 })
289
+ });
290
+ var claimStreamArb = import_vitest4.fc.constantFrom("a", "b", "c");
291
+ var opArb = import_vitest4.fc.oneof(
292
+ import_vitest4.fc.record({ kind: import_vitest4.fc.constant("commit"), stream: claimStreamArb }),
293
+ import_vitest4.fc.record({ kind: import_vitest4.fc.constant("claim") }),
294
+ import_vitest4.fc.record({ kind: import_vitest4.fc.constant("ack-all") }),
295
+ import_vitest4.fc.record({ kind: import_vitest4.fc.constant("block-all") })
296
+ );
297
+ var events = (count) => Array.from({ length: count }, () => inc(1));
298
+ var runStorePropertyTck = (options) => {
299
+ const numRuns = options.numRuns ?? 100;
300
+ (0, import_vitest5.describe)(`TCK / Store properties / ${options.name}`, () => {
301
+ let store;
302
+ (0, import_vitest5.beforeAll)(async () => {
303
+ store = await options.factory();
304
+ await store.seed();
305
+ });
306
+ (0, import_vitest5.afterAll)(async () => {
307
+ await store.dispose();
308
+ });
309
+ const reset2 = async () => {
310
+ await store.drop();
311
+ await store.seed();
312
+ };
313
+ (0, import_vitest5.describe)("commit version invariants", () => {
314
+ import_vitest4.test.prop([import_vitest4.fc.array(commitArb, { minLength: 0, maxLength: 30 })], {
315
+ numRuns
316
+ })(
317
+ "per-stream versions are 0..N-1 in commit order, regardless of interleaving",
318
+ async (commits) => {
319
+ await reset2();
320
+ const expected = /* @__PURE__ */ new Map();
321
+ for (const { stream, count } of commits) {
322
+ const before = expected.get(stream) ?? -1;
323
+ const committed = await store.commit(
324
+ stream,
325
+ events(count),
326
+ make_meta({ stream })
327
+ );
328
+ committed.forEach((e, i) => {
329
+ (0, import_vitest5.expect)(e.version).toBe(before + 1 + i);
330
+ });
331
+ expected.set(stream, before + count);
332
+ }
333
+ for (const stream of new Set(commits.map((c) => c.stream))) {
334
+ const seen = await collect(store, { stream, stream_exact: true });
335
+ seen.forEach((e, i) => {
336
+ (0, import_vitest5.expect)(e.version).toBe(i);
337
+ });
338
+ }
339
+ }
340
+ );
341
+ import_vitest4.test.prop([import_vitest4.fc.array(commitArb, { minLength: 1, maxLength: 20 })], {
342
+ numRuns
343
+ })(
344
+ "bad expectedVersion throws and commits no events",
345
+ async (commits) => {
346
+ await reset2();
347
+ for (const { stream: stream2, count } of commits) {
348
+ await store.commit(
349
+ stream2,
350
+ events(count),
351
+ make_meta({ stream: stream2 })
352
+ );
353
+ }
354
+ const stream = commits[0].stream;
355
+ const before = await collect(store, { stream, stream_exact: true });
356
+ await (0, import_vitest5.expect)(
357
+ store.commit(
358
+ stream,
359
+ [inc(1)],
360
+ make_meta({ stream }),
361
+ before.length
362
+ )
363
+ ).rejects.toThrow();
364
+ const after = await collect(store, { stream, stream_exact: true });
365
+ (0, import_vitest5.expect)(after.length).toBe(before.length);
366
+ }
367
+ );
368
+ });
369
+ (0, import_vitest5.describe)("claim/lease lifecycle invariants", () => {
370
+ import_vitest4.test.prop([import_vitest4.fc.array(opArb, { minLength: 1, maxLength: 30 })], {
371
+ numRuns
372
+ })(
373
+ "no leaks: claims are always acked or blocked, never lost",
374
+ async (ops) => {
375
+ await reset2();
376
+ await store.subscribe([
377
+ { stream: "a" },
378
+ { stream: "b" },
379
+ { stream: "c" }
380
+ ]);
381
+ let totalClaims = 0;
382
+ let totalResolved = 0;
383
+ let pending = [];
384
+ for (const op of ops) {
385
+ if (op.kind === "commit") {
386
+ await store.commit(
387
+ op.stream,
388
+ [inc(1)],
389
+ make_meta({ stream: op.stream })
390
+ );
391
+ } else if (op.kind === "claim") {
392
+ const claimed = await store.claim(5, 5, "worker", 6e4);
393
+ totalClaims += claimed.length;
394
+ pending = [...pending, ...claimed];
395
+ } else if (op.kind === "ack-all") {
396
+ const acked = await store.ack(pending);
397
+ totalResolved += acked.length;
398
+ pending = pending.filter(
399
+ (p) => !acked.find((a) => a.stream === p.stream)
400
+ );
401
+ } else {
402
+ const blocked = await store.block(
403
+ pending.map((p) => ({ ...p, error: "test" }))
404
+ );
405
+ totalResolved += blocked.length;
406
+ pending = pending.filter(
407
+ (p) => !blocked.find((b) => b.stream === p.stream)
408
+ );
409
+ }
410
+ }
411
+ (0, import_vitest5.expect)(totalResolved + pending.length).toBe(totalClaims);
412
+ }
413
+ );
414
+ import_vitest4.test.prop(
415
+ [
416
+ import_vitest4.fc.array(claimStreamArb, { minLength: 1, maxLength: 5 }),
417
+ import_vitest4.fc.array(claimStreamArb, { minLength: 0, maxLength: 5 })
418
+ ],
419
+ { numRuns }
420
+ )(
421
+ "ack advances the watermark monotonically per stream",
422
+ async (commitsA, commitsB) => {
423
+ await reset2();
424
+ const all = [.../* @__PURE__ */ new Set([...commitsA, ...commitsB, "a", "b", "c"])];
425
+ await store.subscribe(all.map((stream) => ({ stream })));
426
+ for (const stream of commitsA) {
427
+ await store.commit(
428
+ stream,
429
+ [inc(1)],
430
+ make_meta({ stream })
431
+ );
432
+ }
433
+ const acked1 = await store.ack(
434
+ await store.claim(10, 10, "worker", 6e4)
435
+ );
436
+ const watermark1 = new Map(all.map((stream) => [stream, -1]));
437
+ for (const l of acked1) watermark1.set(l.stream, l.at);
438
+ for (const stream of commitsB) {
439
+ await store.commit(
440
+ stream,
441
+ [inc(1)],
442
+ make_meta({ stream })
443
+ );
444
+ }
445
+ const acked2 = await store.ack(
446
+ await store.claim(10, 10, "worker", 6e4)
447
+ );
448
+ for (const lease of acked2) {
449
+ (0, import_vitest5.expect)(lease.at).toBeGreaterThanOrEqual(
450
+ watermark1.get(lease.stream)
451
+ );
452
+ }
453
+ }
454
+ );
455
+ import_vitest4.test.prop([import_vitest4.fc.array(claimStreamArb, { minLength: 1, maxLength: 5 })], {
456
+ numRuns
457
+ })("blocked streams cannot be claimed again", async (commits) => {
458
+ await reset2();
459
+ const streams = [...new Set(commits)];
460
+ await store.subscribe(streams.map((stream) => ({ stream })));
461
+ for (const stream of commits) {
462
+ await store.commit(
463
+ stream,
464
+ [inc(1)],
465
+ make_meta({ stream })
466
+ );
467
+ }
468
+ const claimed = await store.claim(10, 10, "worker", 6e4);
469
+ await store.block(claimed.map((l) => ({ ...l, error: "test" })));
470
+ const blockedSet = new Set(claimed.map((l) => l.stream));
471
+ await store.subscribe([{ stream: "ctrl" }]);
472
+ await store.commit(
473
+ "ctrl",
474
+ [inc(1)],
475
+ make_meta({ stream: "ctrl" })
476
+ );
477
+ const reclaim = await store.claim(10, 10, "worker2", 6e4);
478
+ for (const l of reclaim) (0, import_vitest5.expect)(blockedSet.has(l.stream)).toBe(false);
479
+ });
480
+ });
481
+ });
482
+ };
483
+
281
484
  // src/store-tck.ts
282
485
  var import_act = require("@rotorsoft/act");
283
- var import_vitest4 = require("vitest");
486
+ var import_vitest6 = require("vitest");
284
487
  var runStoreTck = (options) => {
285
- (0, import_vitest4.describe)(`TCK / Store / ${options.name}`, () => {
488
+ (0, import_vitest6.describe)(`TCK / Store / ${options.name}`, () => {
286
489
  let store;
287
490
  const caps = { ...options.capabilities };
288
- (0, import_vitest4.beforeAll)(async () => {
491
+ (0, import_vitest6.beforeAll)(async () => {
289
492
  store = await options.factory();
290
493
  await store.drop();
291
494
  await store.seed();
292
495
  });
293
- (0, import_vitest4.afterAll)(async () => {
496
+ (0, import_vitest6.afterAll)(async () => {
294
497
  await store.dispose();
295
498
  });
296
- (0, import_vitest4.describe)("commit", () => {
297
- (0, import_vitest4.it)("returns committed events with sequenced ids and versions", async () => {
499
+ (0, import_vitest6.describe)("commit", () => {
500
+ (0, import_vitest6.it)("returns committed events with sequenced ids and versions", async () => {
298
501
  const s = `commit-seq-${uid()}`;
299
502
  const committed = await store.commit(
300
503
  s,
301
504
  [inc(1), inc(2), dec(3)],
302
505
  make_meta({ stream: s })
303
506
  );
304
- (0, import_vitest4.expect)(committed).toHaveLength(3);
305
- (0, import_vitest4.expect)(committed[0].version).toBe(0);
306
- (0, import_vitest4.expect)(committed[1].version).toBe(1);
307
- (0, import_vitest4.expect)(committed[2].version).toBe(2);
308
- (0, import_vitest4.expect)(committed[0].name).toBe("Incremented");
309
- (0, import_vitest4.expect)(committed[2].data).toEqual({ amount: 3 });
507
+ (0, import_vitest6.expect)(committed).toHaveLength(3);
508
+ (0, import_vitest6.expect)(committed[0].version).toBe(0);
509
+ (0, import_vitest6.expect)(committed[1].version).toBe(1);
510
+ (0, import_vitest6.expect)(committed[2].version).toBe(2);
511
+ (0, import_vitest6.expect)(committed[0].name).toBe("Incremented");
512
+ (0, import_vitest6.expect)(committed[2].data).toEqual({ amount: 3 });
310
513
  for (let i = 1; i < committed.length; i++) {
311
- (0, import_vitest4.expect)(committed[i].id).toBeGreaterThan(committed[i - 1].id);
514
+ (0, import_vitest6.expect)(committed[i].id).toBeGreaterThan(committed[i - 1].id);
312
515
  }
313
516
  });
314
- (0, import_vitest4.it)("attaches correlation and stream metadata", async () => {
517
+ (0, import_vitest6.it)("attaches correlation and stream metadata", async () => {
315
518
  const s = `commit-meta-${uid()}`;
316
519
  const correlation = `cor-${uid()}`;
317
520
  const committed = await store.commit(
@@ -319,10 +522,10 @@ var runStoreTck = (options) => {
319
522
  [inc(1)],
320
523
  make_meta({ stream: s, correlation })
321
524
  );
322
- (0, import_vitest4.expect)(committed[0].stream).toBe(s);
323
- (0, import_vitest4.expect)(committed[0].meta.correlation).toBe(correlation);
525
+ (0, import_vitest6.expect)(committed[0].stream).toBe(s);
526
+ (0, import_vitest6.expect)(committed[0].meta.correlation).toBe(correlation);
324
527
  });
325
- (0, import_vitest4.it)("throws ConcurrencyError when expectedVersion is wrong", async () => {
528
+ (0, import_vitest6.it)("throws ConcurrencyError when expectedVersion is wrong", async () => {
326
529
  const s = `commit-cc-${uid()}`;
327
530
  await store.commit(
328
531
  s,
@@ -335,26 +538,26 @@ var runStoreTck = (options) => {
335
538
  make_meta({ stream: s }),
336
539
  0
337
540
  );
338
- await (0, import_vitest4.expect)(
541
+ await (0, import_vitest6.expect)(
339
542
  store.commit(s, [inc(1)], make_meta({ stream: s }), 0)
340
543
  ).rejects.toBeInstanceOf(import_act.ConcurrencyError);
341
544
  });
342
- (0, import_vitest4.it)("preserves prior events when a concurrent commit is rejected", async () => {
545
+ (0, import_vitest6.it)("preserves prior events when a concurrent commit is rejected", async () => {
343
546
  const s = `commit-cc-preserve-${uid()}`;
344
547
  await store.commit(
345
548
  s,
346
549
  [inc(1), inc(2)],
347
550
  make_meta({ stream: s })
348
551
  );
349
- await (0, import_vitest4.expect)(
552
+ await (0, import_vitest6.expect)(
350
553
  store.commit(s, [inc(3)], make_meta({ stream: s }), 0)
351
554
  ).rejects.toBeInstanceOf(import_act.ConcurrencyError);
352
555
  const found = await collect(store, { stream: s, stream_exact: true });
353
- (0, import_vitest4.expect)(found).toHaveLength(2);
556
+ (0, import_vitest6.expect)(found).toHaveLength(2);
354
557
  });
355
558
  });
356
- (0, import_vitest4.describe)("query", () => {
357
- (0, import_vitest4.it)("filters by stream, names, correlation, limit, with_snaps", async () => {
559
+ (0, import_vitest6.describe)("query", () => {
560
+ (0, import_vitest6.it)("filters by stream, names, correlation, limit, with_snaps", async () => {
358
561
  const s1 = `q-s1-${uid()}`;
359
562
  const s2 = `q-s2-${uid()}`;
360
563
  const cor = `q-cor-${uid()}`;
@@ -372,23 +575,23 @@ var runStoreTck = (options) => {
372
575
  stream: s1,
373
576
  stream_exact: true
374
577
  });
375
- (0, import_vitest4.expect)(by_stream).toHaveLength(2);
578
+ (0, import_vitest6.expect)(by_stream).toHaveLength(2);
376
579
  const by_name = await collect(store, {
377
580
  stream: s2,
378
581
  stream_exact: true,
379
582
  names: ["Reset"]
380
583
  });
381
- (0, import_vitest4.expect)(by_name).toHaveLength(1);
382
- (0, import_vitest4.expect)(by_name[0].name).toBe("Reset");
584
+ (0, import_vitest6.expect)(by_name).toHaveLength(1);
585
+ (0, import_vitest6.expect)(by_name[0].name).toBe("Reset");
383
586
  const by_correlation = await collect(store, { correlation: cor });
384
- (0, import_vitest4.expect)(by_correlation).toHaveLength(5);
587
+ (0, import_vitest6.expect)(by_correlation).toHaveLength(5);
385
588
  const limited = await collect(store, {
386
589
  correlation: cor,
387
590
  limit: 2
388
591
  });
389
- (0, import_vitest4.expect)(limited).toHaveLength(2);
592
+ (0, import_vitest6.expect)(limited).toHaveLength(2);
390
593
  });
391
- (0, import_vitest4.it)("supports backward traversal", async () => {
594
+ (0, import_vitest6.it)("supports backward traversal", async () => {
392
595
  const s = `q-back-${uid()}`;
393
596
  const committed = await store.commit(
394
597
  s,
@@ -401,8 +604,8 @@ var runStoreTck = (options) => {
401
604
  stream_exact: true,
402
605
  backward: true
403
606
  });
404
- (0, import_vitest4.expect)(forward.map((e) => e.id)).toEqual(committed.map((c) => c.id));
405
- (0, import_vitest4.expect)(backward.map((e) => e.id)).toEqual(
607
+ (0, import_vitest6.expect)(forward.map((e) => e.id)).toEqual(committed.map((c) => c.id));
608
+ (0, import_vitest6.expect)(backward.map((e) => e.id)).toEqual(
406
609
  [...committed].reverse().map((c) => c.id)
407
610
  );
408
611
  const latest = await collect(store, {
@@ -411,10 +614,10 @@ var runStoreTck = (options) => {
411
614
  backward: true,
412
615
  limit: 1
413
616
  });
414
- (0, import_vitest4.expect)(latest).toHaveLength(1);
415
- (0, import_vitest4.expect)(latest[0].id).toBe(committed.at(-1).id);
617
+ (0, import_vitest6.expect)(latest).toHaveLength(1);
618
+ (0, import_vitest6.expect)(latest[0].id).toBe(committed.at(-1).id);
416
619
  });
417
- (0, import_vitest4.it)("after/before bound the id range", async () => {
620
+ (0, import_vitest6.it)("after/before bound the id range", async () => {
418
621
  const s = `q-bounds-${uid()}`;
419
622
  const committed = await store.commit(
420
623
  s,
@@ -426,7 +629,7 @@ var runStoreTck = (options) => {
426
629
  stream_exact: true,
427
630
  after: committed[0].id
428
631
  });
429
- (0, import_vitest4.expect)(after_first.map((e) => e.id)).toEqual(
632
+ (0, import_vitest6.expect)(after_first.map((e) => e.id)).toEqual(
430
633
  committed.slice(1).map((c) => c.id)
431
634
  );
432
635
  const before_last = await collect(store, {
@@ -434,11 +637,11 @@ var runStoreTck = (options) => {
434
637
  stream_exact: true,
435
638
  before: committed[committed.length - 1].id
436
639
  });
437
- (0, import_vitest4.expect)(before_last.map((e) => e.id)).toEqual(
640
+ (0, import_vitest6.expect)(before_last.map((e) => e.id)).toEqual(
438
641
  committed.slice(0, -1).map((c) => c.id)
439
642
  );
440
643
  });
441
- (0, import_vitest4.it)("created_after/created_before filter by timestamp", async () => {
644
+ (0, import_vitest6.it)("created_after/created_before filter by timestamp", async () => {
442
645
  const s = `q-ts-${uid()}`;
443
646
  const before = new Date(Date.now() - 6e4);
444
647
  const future = new Date(Date.now() + 6e4);
@@ -453,15 +656,15 @@ var runStoreTck = (options) => {
453
656
  created_after: before,
454
657
  created_before: future
455
658
  });
456
- (0, import_vitest4.expect)(in_window.length).toBe(1);
659
+ (0, import_vitest6.expect)(in_window.length).toBe(1);
457
660
  const out_of_window = await collect(store, {
458
661
  stream: s,
459
662
  stream_exact: true,
460
663
  created_after: future
461
664
  });
462
- (0, import_vitest4.expect)(out_of_window.length).toBe(0);
665
+ (0, import_vitest6.expect)(out_of_window.length).toBe(0);
463
666
  });
464
- (0, import_vitest4.it)("backward traversal short-circuits at `after` id boundary", async () => {
667
+ (0, import_vitest6.it)("backward traversal short-circuits at `after` id boundary", async () => {
465
668
  const s = `q-back-after-${uid()}`;
466
669
  const committed = await store.commit(
467
670
  s,
@@ -474,12 +677,12 @@ var runStoreTck = (options) => {
474
677
  backward: true,
475
678
  after: committed[0].id
476
679
  });
477
- (0, import_vitest4.expect)(got.map((e) => e.id)).toEqual([
680
+ (0, import_vitest6.expect)(got.map((e) => e.id)).toEqual([
478
681
  committed[2].id,
479
682
  committed[1].id
480
683
  ]);
481
684
  });
482
- (0, import_vitest4.it)("backward traversal short-circuits at `created_after` boundary", async () => {
685
+ (0, import_vitest6.it)("backward traversal short-circuits at `created_after` boundary", async () => {
483
686
  const s = `q-back-cafter-${uid()}`;
484
687
  await store.commit(
485
688
  s,
@@ -493,9 +696,9 @@ var runStoreTck = (options) => {
493
696
  backward: true,
494
697
  created_after: future
495
698
  });
496
- (0, import_vitest4.expect)(got).toHaveLength(0);
699
+ (0, import_vitest6.expect)(got).toHaveLength(0);
497
700
  });
498
- (0, import_vitest4.it)("backward traversal honors created_before by skipping newer events", async () => {
701
+ (0, import_vitest6.it)("backward traversal honors created_before by skipping newer events", async () => {
499
702
  const s = `q-back-ts-${uid()}`;
500
703
  await store.commit(s, [inc(1)], make_meta());
501
704
  const past = new Date(Date.now() - 6e4);
@@ -505,9 +708,9 @@ var runStoreTck = (options) => {
505
708
  backward: true,
506
709
  created_before: past
507
710
  });
508
- (0, import_vitest4.expect)(got).toHaveLength(0);
711
+ (0, import_vitest6.expect)(got).toHaveLength(0);
509
712
  });
510
- (0, import_vitest4.it)("stream_exact disables regex matching", async () => {
713
+ (0, import_vitest6.it)("stream_exact disables regex matching", async () => {
511
714
  const tag = uid();
512
715
  const a = `q-exact-${tag}`;
513
716
  const b = `q-exact-${tag}-extra`;
@@ -522,10 +725,10 @@ var runStoreTck = (options) => {
522
725
  make_meta({ stream: b })
523
726
  );
524
727
  const exact = await collect(store, { stream: a, stream_exact: true });
525
- (0, import_vitest4.expect)(exact).toHaveLength(1);
526
- (0, import_vitest4.expect)(exact[0].data).toEqual({ amount: 1 });
728
+ (0, import_vitest6.expect)(exact).toHaveLength(1);
729
+ (0, import_vitest6.expect)(exact[0].data).toEqual({ amount: 1 });
527
730
  });
528
- (0, import_vitest4.it)("plain regex without anchors is a substring match", async () => {
731
+ (0, import_vitest6.it)("plain regex without anchors is a substring match", async () => {
529
732
  const tag = uid();
530
733
  const inner = `qr-${tag}-inner`;
531
734
  const longer = `qr-${tag}-inner-extra`;
@@ -540,9 +743,9 @@ var runStoreTck = (options) => {
540
743
  make_meta({ stream: longer })
541
744
  );
542
745
  const got = await collect(store, { stream: `qr-${tag}-inner` });
543
- (0, import_vitest4.expect)(got.map((e) => e.stream).sort()).toEqual([inner, longer].sort());
746
+ (0, import_vitest6.expect)(got.map((e) => e.stream).sort()).toEqual([inner, longer].sort());
544
747
  });
545
- (0, import_vitest4.it)("caller-anchored `^name$` matches only the whole string", async () => {
748
+ (0, import_vitest6.it)("caller-anchored `^name$` matches only the whole string", async () => {
546
749
  const tag = uid();
547
750
  const inner = `qr-${tag}-anchor`;
548
751
  const longer = `qr-${tag}-anchor-extra`;
@@ -557,10 +760,10 @@ var runStoreTck = (options) => {
557
760
  make_meta({ stream: longer })
558
761
  );
559
762
  const got = await collect(store, { stream: `^qr-${tag}-anchor$` });
560
- (0, import_vitest4.expect)(got).toHaveLength(1);
561
- (0, import_vitest4.expect)(got[0].stream).toBe(inner);
763
+ (0, import_vitest6.expect)(got).toHaveLength(1);
764
+ (0, import_vitest6.expect)(got[0].stream).toBe(inner);
562
765
  });
563
- (0, import_vitest4.it)("caller-anchored `^prefix` matches by prefix", async () => {
766
+ (0, import_vitest6.it)("caller-anchored `^prefix` matches by prefix", async () => {
564
767
  const tag = uid();
565
768
  const a = `qr-${tag}-pfx-a`;
566
769
  const b = `qr-${tag}-pfx-b`;
@@ -581,18 +784,18 @@ var runStoreTck = (options) => {
581
784
  make_meta({ stream: other })
582
785
  );
583
786
  const got = await collect(store, { stream: `^qr-${tag}-pfx-` });
584
- (0, import_vitest4.expect)(got.map((e) => e.stream).sort()).toEqual([a, b].sort());
787
+ (0, import_vitest6.expect)(got.map((e) => e.stream).sort()).toEqual([a, b].sort());
585
788
  });
586
789
  });
587
- (0, import_vitest4.describe)("subscribe + claim + ack", () => {
588
- (0, import_vitest4.it)("subscribes new streams and is idempotent on repeat", async () => {
790
+ (0, import_vitest6.describe)("subscribe + claim + ack", () => {
791
+ (0, import_vitest6.it)("subscribes new streams and is idempotent on repeat", async () => {
589
792
  const s = `sub-${uid()}`;
590
793
  const first = await store.subscribe([{ stream: s }]);
591
- (0, import_vitest4.expect)(first.subscribed).toBe(1);
794
+ (0, import_vitest6.expect)(first.subscribed).toBe(1);
592
795
  const second = await store.subscribe([{ stream: s }]);
593
- (0, import_vitest4.expect)(second.subscribed).toBe(0);
796
+ (0, import_vitest6.expect)(second.subscribed).toBe(0);
594
797
  });
595
- (0, import_vitest4.it)("claims a subscribed stream and ack releases the lease", async () => {
798
+ (0, import_vitest6.it)("claims a subscribed stream and ack releases the lease", async () => {
596
799
  const s = `claim-${uid()}`;
597
800
  await store.subscribe([{ stream: s }]);
598
801
  await store.commit(
@@ -603,11 +806,11 @@ var runStoreTck = (options) => {
603
806
  const by = `worker-${uid()}`;
604
807
  const leased = await store.claim(100, 0, by, 1e4);
605
808
  const mine = leased.find((l) => l.stream === s);
606
- (0, import_vitest4.expect)(mine).toBeDefined();
607
- (0, import_vitest4.expect)(mine.by).toBe(by);
809
+ (0, import_vitest6.expect)(mine).toBeDefined();
810
+ (0, import_vitest6.expect)(mine.by).toBe(by);
608
811
  await store.ack([{ ...mine, at: mine.at + 1 }]);
609
812
  });
610
- (0, import_vitest4.it)("does not double-claim a held lease", async () => {
813
+ (0, import_vitest6.it)("does not double-claim a held lease", async () => {
611
814
  const s = `claim-held-${uid()}`;
612
815
  const other = `claim-other-${uid()}`;
613
816
  await store.subscribe([{ stream: s }]);
@@ -618,7 +821,7 @@ var runStoreTck = (options) => {
618
821
  );
619
822
  const leasedA = await store.claim(100, 0, `wA-${uid()}`, 1e5);
620
823
  const targetA = leasedA.find((l) => l.stream === s);
621
- (0, import_vitest4.expect)(targetA).toBeDefined();
824
+ (0, import_vitest6.expect)(targetA).toBeDefined();
622
825
  await store.subscribe([{ stream: other }]);
623
826
  await store.commit(
624
827
  other,
@@ -626,11 +829,11 @@ var runStoreTck = (options) => {
626
829
  make_meta({ stream: other })
627
830
  );
628
831
  const leasedB = await store.claim(100, 0, `wB-${uid()}`, 1e5);
629
- (0, import_vitest4.expect)(leasedB.length).toBeGreaterThan(0);
630
- (0, import_vitest4.expect)(leasedB.find((l) => l.stream === s)).toBeUndefined();
631
- (0, import_vitest4.expect)(leasedB.find((l) => l.stream === other)).toBeDefined();
832
+ (0, import_vitest6.expect)(leasedB.length).toBeGreaterThan(0);
833
+ (0, import_vitest6.expect)(leasedB.find((l) => l.stream === s)).toBeUndefined();
834
+ (0, import_vitest6.expect)(leasedB.find((l) => l.stream === other)).toBeDefined();
632
835
  });
633
- (0, import_vitest4.it)("supports dual frontiers (lagging + leading)", async () => {
836
+ (0, import_vitest6.it)("supports dual frontiers (lagging + leading)", async () => {
634
837
  const s = `claim-dual-${uid()}`;
635
838
  await store.subscribe([{ stream: s }]);
636
839
  await store.commit(
@@ -640,12 +843,12 @@ var runStoreTck = (options) => {
640
843
  );
641
844
  const first = await store.claim(100, 0, `w-${uid()}`, 1);
642
845
  const mine = first.find((l) => l.stream === s);
643
- (0, import_vitest4.expect)(mine).toBeDefined();
846
+ (0, import_vitest6.expect)(mine).toBeDefined();
644
847
  await store.ack([{ ...mine, at: mine.at + 1 }]);
645
848
  const second = await store.claim(0, 100, `w-${uid()}`, 1);
646
- (0, import_vitest4.expect)(second.find((l) => l.stream === s)).toBeDefined();
849
+ (0, import_vitest6.expect)(second.find((l) => l.stream === s)).toBeDefined();
647
850
  });
648
- (0, import_vitest4.it)("dedupes when both frontiers would return the same stream", async () => {
851
+ (0, import_vitest6.it)("dedupes when both frontiers would return the same stream", async () => {
649
852
  const s = `claim-dedup-${uid()}`;
650
853
  await store.subscribe([{ stream: s }]);
651
854
  await store.commit(
@@ -655,9 +858,9 @@ var runStoreTck = (options) => {
655
858
  );
656
859
  const claimed = await store.claim(100, 100, `w-${uid()}`, 1e5);
657
860
  const matches = claimed.filter((l) => l.stream === s);
658
- (0, import_vitest4.expect)(matches).toHaveLength(1);
861
+ (0, import_vitest6.expect)(matches).toHaveLength(1);
659
862
  });
660
- (0, import_vitest4.it)("silently ignores ack from the wrong holder", async () => {
863
+ (0, import_vitest6.it)("silently ignores ack from the wrong holder", async () => {
661
864
  const s = `ack-wrong-${uid()}`;
662
865
  const sibling = `ack-sibling-${uid()}`;
663
866
  await store.subscribe([{ stream: s }, { stream: sibling }]);
@@ -674,40 +877,40 @@ var runStoreTck = (options) => {
674
877
  const leased = await store.claim(100, 0, `right-${uid()}`, 1e5);
675
878
  const mine = leased.find((l) => l.stream === s);
676
879
  const sibling_lease = leased.find((l) => l.stream === sibling);
677
- (0, import_vitest4.expect)(mine).toBeDefined();
678
- (0, import_vitest4.expect)(sibling_lease).toBeDefined();
880
+ (0, import_vitest6.expect)(mine).toBeDefined();
881
+ (0, import_vitest6.expect)(sibling_lease).toBeDefined();
679
882
  const acked = await store.ack([
680
883
  { ...mine, by: "imposter" },
681
884
  sibling_lease
682
885
  ]);
683
- (0, import_vitest4.expect)(acked.length).toBeGreaterThan(0);
684
- (0, import_vitest4.expect)(acked.find((l) => l.stream === s)).toBeUndefined();
886
+ (0, import_vitest6.expect)(acked.length).toBeGreaterThan(0);
887
+ (0, import_vitest6.expect)(acked.find((l) => l.stream === s)).toBeUndefined();
685
888
  });
686
- (0, import_vitest4.it)("ack with a stale (lower) watermark does not throw", async () => {
889
+ (0, import_vitest6.it)("ack with a stale (lower) watermark does not throw", async () => {
687
890
  const s = `ack-stale-${uid()}`;
688
891
  await store.subscribe([{ stream: s }]);
689
892
  const by = `w-${uid()}`;
690
893
  const leased = await store.claim(100, 0, by, 1e5);
691
894
  const mine = leased.find((l) => l.stream === s);
692
- (0, import_vitest4.expect)(mine).toBeDefined();
693
- await (0, import_vitest4.expect)(
895
+ (0, import_vitest6.expect)(mine).toBeDefined();
896
+ await (0, import_vitest6.expect)(
694
897
  store.ack([{ ...mine, at: -5 }])
695
898
  ).resolves.toBeDefined();
696
899
  });
697
- (0, import_vitest4.it)("claim with no subscribed streams returns an empty array", async () => {
900
+ (0, import_vitest6.it)("claim with no subscribed streams returns an empty array", async () => {
698
901
  const fresh = await options.factory();
699
902
  try {
700
903
  await fresh.drop();
701
904
  await fresh.seed();
702
905
  const claimed = await fresh.claim(1, 1, `w-${uid()}`, 1e3);
703
- (0, import_vitest4.expect)(claimed).toEqual([]);
906
+ (0, import_vitest6.expect)(claimed).toEqual([]);
704
907
  } finally {
705
908
  await fresh.dispose();
706
909
  }
707
910
  });
708
911
  });
709
- (0, import_vitest4.describe)("lease semantics", () => {
710
- (0, import_vitest4.it)("returns retry=0 on first claim and increments on re-claim without ack", async () => {
912
+ (0, import_vitest6.describe)("lease semantics", () => {
913
+ (0, import_vitest6.it)("returns retry=0 on first claim and increments on re-claim without ack", async () => {
711
914
  const fresh = await options.factory();
712
915
  try {
713
916
  await fresh.drop();
@@ -721,17 +924,17 @@ var runStoreTck = (options) => {
721
924
  );
722
925
  const first = await fresh.claim(1, 0, `w-${uid()}`, 0);
723
926
  const f = first.find((l) => l.stream === s);
724
- (0, import_vitest4.expect)(f).toBeDefined();
725
- (0, import_vitest4.expect)(f.retry).toBe(0);
927
+ (0, import_vitest6.expect)(f).toBeDefined();
928
+ (0, import_vitest6.expect)(f.retry).toBe(0);
726
929
  const second = await fresh.claim(1, 0, `w-${uid()}`, 1e5);
727
930
  const sec = second.find((l) => l.stream === s);
728
- (0, import_vitest4.expect)(sec).toBeDefined();
729
- (0, import_vitest4.expect)(sec.retry).toBe(1);
931
+ (0, import_vitest6.expect)(sec).toBeDefined();
932
+ (0, import_vitest6.expect)(sec.retry).toBe(1);
730
933
  } finally {
731
934
  await fresh.dispose();
732
935
  }
733
936
  });
734
- (0, import_vitest4.it)("reports lagging=true from the lagging frontier and false from the leading frontier", async () => {
937
+ (0, import_vitest6.it)("reports lagging=true from the lagging frontier and false from the leading frontier", async () => {
735
938
  const fresh = await options.factory();
736
939
  try {
737
940
  await fresh.drop();
@@ -744,16 +947,47 @@ var runStoreTck = (options) => {
744
947
  make_meta({ stream: s })
745
948
  );
746
949
  const lag = await fresh.claim(1, 0, `w-${uid()}`, 0);
747
- (0, import_vitest4.expect)(lag.find((l) => l.stream === s)?.lagging).toBe(true);
950
+ (0, import_vitest6.expect)(lag.find((l) => l.stream === s)?.lagging).toBe(true);
748
951
  const lead = await fresh.claim(0, 1, `w-${uid()}`, 1e5);
749
- (0, import_vitest4.expect)(lead.find((l) => l.stream === s)?.lagging).toBe(false);
952
+ (0, import_vitest6.expect)(lead.find((l) => l.stream === s)?.lagging).toBe(false);
953
+ } finally {
954
+ await fresh.dispose();
955
+ }
956
+ });
957
+ });
958
+ import_vitest6.describe.skipIf(!caps.concurrent_claim)("concurrency (capability)", () => {
959
+ (0, import_vitest6.it)("never double-leases a stream across concurrent claimers", async () => {
960
+ const fresh = await options.factory();
961
+ try {
962
+ await fresh.drop();
963
+ await fresh.seed();
964
+ const streams = Array.from(
965
+ { length: 8 },
966
+ () => `concurrent-${uid()}`
967
+ );
968
+ await fresh.subscribe(streams.map((stream) => ({ stream })));
969
+ for (const stream of streams) {
970
+ await fresh.commit(
971
+ stream,
972
+ [inc(1)],
973
+ make_meta({ stream })
974
+ );
975
+ }
976
+ const owned = new Set(streams);
977
+ const [a, b] = await Promise.all([
978
+ fresh.claim(100, 100, `wA-${uid()}`, 6e4),
979
+ fresh.claim(100, 100, `wB-${uid()}`, 6e4)
980
+ ]);
981
+ const claimed = [...a, ...b].map((l) => l.stream).filter((stream) => owned.has(stream));
982
+ (0, import_vitest6.expect)(new Set(claimed).size).toBe(claimed.length);
983
+ (0, import_vitest6.expect)(claimed.length).toBe(owned.size);
750
984
  } finally {
751
985
  await fresh.dispose();
752
986
  }
753
987
  });
754
988
  });
755
- (0, import_vitest4.describe)("block", () => {
756
- (0, import_vitest4.it)("hides blocked streams from claim", async () => {
989
+ (0, import_vitest6.describe)("block", () => {
990
+ (0, import_vitest6.it)("hides blocked streams from claim", async () => {
757
991
  const s = `block-${uid()}`;
758
992
  await store.subscribe([{ stream: s }]);
759
993
  await store.commit(
@@ -763,18 +997,18 @@ var runStoreTck = (options) => {
763
997
  );
764
998
  const leased = await store.claim(100, 0, `w-${uid()}`, 1e5);
765
999
  const mine = leased.find((l) => l.stream === s);
766
- (0, import_vitest4.expect)(mine).toBeDefined();
1000
+ (0, import_vitest6.expect)(mine).toBeDefined();
767
1001
  const others = leased.filter((l) => l.stream !== s);
768
1002
  await store.ack(others);
769
1003
  const blocked = await store.block([
770
1004
  { ...mine, error: "boom" }
771
1005
  ]);
772
- (0, import_vitest4.expect)(blocked).toHaveLength(1);
773
- (0, import_vitest4.expect)(blocked[0].error).toBe("boom");
1006
+ (0, import_vitest6.expect)(blocked).toHaveLength(1);
1007
+ (0, import_vitest6.expect)(blocked[0].error).toBe("boom");
774
1008
  const again = await store.claim(100, 100, `w2-${uid()}`, 1e5);
775
- (0, import_vitest4.expect)(again.find((l) => l.stream === s)).toBeUndefined();
1009
+ (0, import_vitest6.expect)(again.find((l) => l.stream === s)).toBeUndefined();
776
1010
  });
777
- (0, import_vitest4.it)("rejects block calls from a different holder", async () => {
1011
+ (0, import_vitest6.it)("rejects block calls from a different holder", async () => {
778
1012
  const s = `block-wrong-${uid()}`;
779
1013
  await store.subscribe([{ stream: s }]);
780
1014
  await store.commit(
@@ -784,17 +1018,17 @@ var runStoreTck = (options) => {
784
1018
  );
785
1019
  const leased = await store.claim(100, 0, `right-${uid()}`, 1e5);
786
1020
  const mine = leased.find((l) => l.stream === s);
787
- (0, import_vitest4.expect)(mine).toBeDefined();
1021
+ (0, import_vitest6.expect)(mine).toBeDefined();
788
1022
  const others = leased.filter((l) => l.stream !== s);
789
1023
  await store.ack(others);
790
1024
  const blocked = await store.block([
791
1025
  { ...mine, by: "imposter", error: "no" }
792
1026
  ]);
793
- (0, import_vitest4.expect)(blocked).toHaveLength(0);
1027
+ (0, import_vitest6.expect)(blocked).toHaveLength(0);
794
1028
  });
795
1029
  });
796
- (0, import_vitest4.describe)("reset", () => {
797
- (0, import_vitest4.it)("rewinds a stream watermark to -1", async () => {
1030
+ (0, import_vitest6.describe)("reset", () => {
1031
+ (0, import_vitest6.it)("rewinds a stream watermark to -1", async () => {
798
1032
  const s = `reset-${uid()}`;
799
1033
  await store.subscribe([{ stream: s }]);
800
1034
  await store.commit(
@@ -804,15 +1038,15 @@ var runStoreTck = (options) => {
804
1038
  );
805
1039
  const leased = await store.claim(100, 0, `w-${uid()}`, 1e5);
806
1040
  const mine = leased.find((l) => l.stream === s);
807
- (0, import_vitest4.expect)(mine).toBeDefined();
1041
+ (0, import_vitest6.expect)(mine).toBeDefined();
808
1042
  await store.ack([{ ...mine, at: 99 }]);
809
- (0, import_vitest4.expect)(await store.reset([s])).toBe(1);
1043
+ (0, import_vitest6.expect)(await store.reset([s])).toBe(1);
810
1044
  const after = await store.claim(100, 0, `w2-${uid()}`, 1e5);
811
1045
  const back = after.find((l) => l.stream === s);
812
- (0, import_vitest4.expect)(back).toBeDefined();
813
- (0, import_vitest4.expect)(back.at).toBe(-1);
1046
+ (0, import_vitest6.expect)(back).toBeDefined();
1047
+ (0, import_vitest6.expect)(back.at).toBe(-1);
814
1048
  });
815
- (0, import_vitest4.it)("clears blocked status when resetting", async () => {
1049
+ (0, import_vitest6.it)("clears blocked status when resetting", async () => {
816
1050
  const s = `reset-blk-${uid()}`;
817
1051
  await store.subscribe([{ stream: s }]);
818
1052
  await store.commit(
@@ -825,17 +1059,17 @@ var runStoreTck = (options) => {
825
1059
  const others = leased.filter((l) => l.stream !== s);
826
1060
  await store.ack(others);
827
1061
  await store.block([{ ...mine, error: "boom" }]);
828
- (0, import_vitest4.expect)(await store.reset([s])).toBe(1);
1062
+ (0, import_vitest6.expect)(await store.reset([s])).toBe(1);
829
1063
  const after = await store.claim(100, 0, `w2-${uid()}`, 1e5);
830
- (0, import_vitest4.expect)(after.find((l) => l.stream === s)).toBeDefined();
1064
+ (0, import_vitest6.expect)(after.find((l) => l.stream === s)).toBeDefined();
831
1065
  });
832
- (0, import_vitest4.it)("returns 0 for unknown streams and empty input", async () => {
833
- (0, import_vitest4.expect)(await store.reset([`missing-${uid()}`])).toBe(0);
834
- (0, import_vitest4.expect)(await store.reset([])).toBe(0);
1066
+ (0, import_vitest6.it)("returns 0 for unknown streams and empty input", async () => {
1067
+ (0, import_vitest6.expect)(await store.reset([`missing-${uid()}`])).toBe(0);
1068
+ (0, import_vitest6.expect)(await store.reset([])).toBe(0);
835
1069
  });
836
1070
  });
837
- (0, import_vitest4.describe)("unblock", () => {
838
- (0, import_vitest4.it)("clears blocked flag and preserves the watermark", async () => {
1071
+ (0, import_vitest6.describe)("unblock", () => {
1072
+ (0, import_vitest6.it)("clears blocked flag and preserves the watermark", async () => {
839
1073
  const s = `unblock-${uid()}`;
840
1074
  await store.subscribe([{ stream: s }]);
841
1075
  await store.commit(
@@ -853,7 +1087,7 @@ var runStoreTck = (options) => {
853
1087
  await store.ack([{ ...m1, at: m1.at }]);
854
1088
  const before_block = await store.claim(100, 0, `w-${uid()}`, 1e5);
855
1089
  const m2 = before_block.find((l) => l.stream === s);
856
- (0, import_vitest4.expect)(m2).toBeDefined();
1090
+ (0, import_vitest6.expect)(m2).toBeDefined();
857
1091
  const watermark_before = m2.at;
858
1092
  await store.block([{ ...m2, error: "permanent" }]);
859
1093
  let blocked_flag;
@@ -863,15 +1097,15 @@ var runStoreTck = (options) => {
863
1097
  },
864
1098
  { stream: s, stream_exact: true, limit: 1 }
865
1099
  );
866
- (0, import_vitest4.expect)(blocked_flag).toBe(true);
867
- (0, import_vitest4.expect)(await store.unblock([s])).toBe(1);
1100
+ (0, import_vitest6.expect)(blocked_flag).toBe(true);
1101
+ (0, import_vitest6.expect)(await store.unblock([s])).toBe(1);
868
1102
  const after = await store.claim(100, 0, `w-${uid()}`, 1e5);
869
1103
  const back = after.find((l) => l.stream === s);
870
- (0, import_vitest4.expect)(back).toBeDefined();
871
- (0, import_vitest4.expect)(back.at).toBe(watermark_before);
872
- (0, import_vitest4.expect)(back.retry).toBe(0);
1104
+ (0, import_vitest6.expect)(back).toBeDefined();
1105
+ (0, import_vitest6.expect)(back.at).toBe(watermark_before);
1106
+ (0, import_vitest6.expect)(back.retry).toBe(0);
873
1107
  });
874
- (0, import_vitest4.it)("returns 0 when the stream is not blocked", async () => {
1108
+ (0, import_vitest6.it)("returns 0 when the stream is not blocked", async () => {
875
1109
  const s = `unblock-noop-${uid()}`;
876
1110
  await store.subscribe([{ stream: s }]);
877
1111
  await store.commit(
@@ -879,13 +1113,13 @@ var runStoreTck = (options) => {
879
1113
  [inc(1)],
880
1114
  make_meta({ stream: s })
881
1115
  );
882
- (0, import_vitest4.expect)(await store.unblock([s])).toBe(0);
1116
+ (0, import_vitest6.expect)(await store.unblock([s])).toBe(0);
883
1117
  });
884
- (0, import_vitest4.it)("returns 0 for unknown streams and empty input", async () => {
885
- (0, import_vitest4.expect)(await store.unblock([`missing-${uid()}`])).toBe(0);
886
- (0, import_vitest4.expect)(await store.unblock([])).toBe(0);
1118
+ (0, import_vitest6.it)("returns 0 for unknown streams and empty input", async () => {
1119
+ (0, import_vitest6.expect)(await store.unblock([`missing-${uid()}`])).toBe(0);
1120
+ (0, import_vitest6.expect)(await store.unblock([])).toBe(0);
887
1121
  });
888
- (0, import_vitest4.it)("only counts streams that were actually blocked", async () => {
1122
+ (0, import_vitest6.it)("only counts streams that were actually blocked", async () => {
889
1123
  const s1 = `unblock-mix-a-${uid()}`;
890
1124
  const s2 = `unblock-mix-b-${uid()}`;
891
1125
  await store.subscribe([{ stream: s1 }, { stream: s2 }]);
@@ -904,9 +1138,9 @@ var runStoreTck = (options) => {
904
1138
  const others = leased.filter((l) => l.stream !== s1);
905
1139
  await store.ack(others);
906
1140
  await store.block([{ ...m1, error: "boom" }]);
907
- (0, import_vitest4.expect)(await store.unblock([s1, s2])).toBe(1);
1141
+ (0, import_vitest6.expect)(await store.unblock([s1, s2])).toBe(1);
908
1142
  });
909
- (0, import_vitest4.it)("filter form: unblocks by stream pattern", async () => {
1143
+ (0, import_vitest6.it)("filter form: unblocks by stream pattern", async () => {
910
1144
  const tag = uid();
911
1145
  const s1 = `unblock-filter-${tag}-a`;
912
1146
  const s2 = `unblock-filter-${tag}-b`;
@@ -938,13 +1172,13 @@ var runStoreTck = (options) => {
938
1172
  const count = await store.unblock({
939
1173
  stream: `^unblock-filter-${tag}-`
940
1174
  });
941
- (0, import_vitest4.expect)(count).toBe(2);
1175
+ (0, import_vitest6.expect)(count).toBe(2);
942
1176
  const after = await store.claim(100, 0, `w-${uid()}`, 1e5);
943
- (0, import_vitest4.expect)(after.find((l) => l.stream === s3)).toBeUndefined();
944
- (0, import_vitest4.expect)(after.find((l) => l.stream === s1)).toBeDefined();
945
- (0, import_vitest4.expect)(after.find((l) => l.stream === s2)).toBeDefined();
1177
+ (0, import_vitest6.expect)(after.find((l) => l.stream === s3)).toBeUndefined();
1178
+ (0, import_vitest6.expect)(after.find((l) => l.stream === s1)).toBeDefined();
1179
+ (0, import_vitest6.expect)(after.find((l) => l.stream === s2)).toBeDefined();
946
1180
  });
947
- (0, import_vitest4.it)("filter form: empty filter unblocks every blocked stream", async () => {
1181
+ (0, import_vitest6.it)("filter form: empty filter unblocks every blocked stream", async () => {
948
1182
  const tag = uid();
949
1183
  const s1 = `unblock-empty-${tag}-a`;
950
1184
  const s2 = `unblock-empty-${tag}-b`;
@@ -968,9 +1202,9 @@ var runStoreTck = (options) => {
968
1202
  const count = await store.unblock({
969
1203
  stream: `^unblock-empty-${tag}-`
970
1204
  });
971
- (0, import_vitest4.expect)(count).toBe(2);
1205
+ (0, import_vitest6.expect)(count).toBe(2);
972
1206
  });
973
- (0, import_vitest4.it)("filter form: explicit blocked:false matches nothing", async () => {
1207
+ (0, import_vitest6.it)("filter form: explicit blocked:false matches nothing", async () => {
974
1208
  const tag = uid();
975
1209
  const s = `unblock-blocked-false-${tag}`;
976
1210
  await store.subscribe([{ stream: s }]);
@@ -979,7 +1213,7 @@ var runStoreTck = (options) => {
979
1213
  [inc(1)],
980
1214
  make_meta({ stream: s })
981
1215
  );
982
- (0, import_vitest4.expect)(
1216
+ (0, import_vitest6.expect)(
983
1217
  await store.unblock({
984
1218
  stream: `^unblock-blocked-false-${tag}`,
985
1219
  blocked: false
@@ -987,8 +1221,8 @@ var runStoreTck = (options) => {
987
1221
  ).toBe(0);
988
1222
  });
989
1223
  });
990
- (0, import_vitest4.describe)("reset filter form", () => {
991
- (0, import_vitest4.it)("resets streams matching a stream pattern", async () => {
1224
+ (0, import_vitest6.describe)("reset filter form", () => {
1225
+ (0, import_vitest6.it)("resets streams matching a stream pattern", async () => {
992
1226
  const tag = uid();
993
1227
  const s1 = `reset-filter-${tag}-a`;
994
1228
  const s2 = `reset-filter-${tag}-b`;
@@ -1019,7 +1253,7 @@ var runStoreTck = (options) => {
1019
1253
  );
1020
1254
  await store.ack(mine.map((l) => ({ ...l, at: l.at + 100 })));
1021
1255
  const count = await store.reset({ stream: `^reset-filter-${tag}-` });
1022
- (0, import_vitest4.expect)(count).toBe(2);
1256
+ (0, import_vitest6.expect)(count).toBe(2);
1023
1257
  const position_for = async (name) => {
1024
1258
  let at = null;
1025
1259
  await store.query_streams(
@@ -1030,11 +1264,11 @@ var runStoreTck = (options) => {
1030
1264
  );
1031
1265
  return at;
1032
1266
  };
1033
- (0, import_vitest4.expect)(await position_for(s1)).toBe(-1);
1034
- (0, import_vitest4.expect)(await position_for(s2)).toBe(-1);
1035
- (0, import_vitest4.expect)(await position_for(other)).toBeGreaterThan(-1);
1267
+ (0, import_vitest6.expect)(await position_for(s1)).toBe(-1);
1268
+ (0, import_vitest6.expect)(await position_for(s2)).toBe(-1);
1269
+ (0, import_vitest6.expect)(await position_for(other)).toBeGreaterThan(-1);
1036
1270
  });
1037
- (0, import_vitest4.it)("filter form: resets only blocked streams when blocked:true", async () => {
1271
+ (0, import_vitest6.it)("filter form: resets only blocked streams when blocked:true", async () => {
1038
1272
  const tag = uid();
1039
1273
  const s1 = `reset-blocked-${tag}-blocked`;
1040
1274
  const s2 = `reset-blocked-${tag}-fine`;
@@ -1057,11 +1291,11 @@ var runStoreTck = (options) => {
1057
1291
  stream: `^reset-blocked-${tag}-`,
1058
1292
  blocked: true
1059
1293
  });
1060
- (0, import_vitest4.expect)(count).toBe(1);
1294
+ (0, import_vitest6.expect)(count).toBe(1);
1061
1295
  });
1062
1296
  });
1063
- (0, import_vitest4.describe)("prioritize", () => {
1064
- (0, import_vitest4.it)("sets priority directly, overriding subscribe's max() rule", async () => {
1297
+ (0, import_vitest6.describe)("prioritize", () => {
1298
+ (0, import_vitest6.it)("sets priority directly, overriding subscribe's max() rule", async () => {
1065
1299
  const tag = uid();
1066
1300
  const s1 = `pri-${tag}-a`;
1067
1301
  const s2 = `pri-${tag}-b`;
@@ -1073,7 +1307,7 @@ var runStoreTck = (options) => {
1073
1307
  { stream: s1, stream_exact: true },
1074
1308
  3
1075
1309
  );
1076
- (0, import_vitest4.expect)(updated).toBe(1);
1310
+ (0, import_vitest6.expect)(updated).toBe(1);
1077
1311
  const got1 = {};
1078
1312
  const got2 = {};
1079
1313
  await store.query_streams(
@@ -1083,12 +1317,12 @@ var runStoreTck = (options) => {
1083
1317
  },
1084
1318
  { stream: `pri-${tag}-.*`, limit: 100 }
1085
1319
  );
1086
- (0, import_vitest4.expect)(got1.priority).toBe(3);
1087
- (0, import_vitest4.expect)(got2.priority).toBe(5);
1320
+ (0, import_vitest6.expect)(got1.priority).toBe(3);
1321
+ (0, import_vitest6.expect)(got2.priority).toBe(5);
1088
1322
  });
1089
1323
  });
1090
- (0, import_vitest4.describe)("lanes", () => {
1091
- (0, import_vitest4.it)("subscribe defaults lane to 'default' when omitted", async () => {
1324
+ (0, import_vitest6.describe)("lanes", () => {
1325
+ (0, import_vitest6.it)("subscribe defaults lane to 'default' when omitted", async () => {
1092
1326
  const s = `lane-default-${uid()}`;
1093
1327
  await store.subscribe([{ stream: s }]);
1094
1328
  const seen = [];
@@ -1096,9 +1330,9 @@ var runStoreTck = (options) => {
1096
1330
  stream: s,
1097
1331
  stream_exact: true
1098
1332
  });
1099
- (0, import_vitest4.expect)(seen).toEqual(["default"]);
1333
+ (0, import_vitest6.expect)(seen).toEqual(["default"]);
1100
1334
  });
1101
- (0, import_vitest4.it)("subscribe records the lane passed in", async () => {
1335
+ (0, import_vitest6.it)("subscribe records the lane passed in", async () => {
1102
1336
  const s = `lane-set-${uid()}`;
1103
1337
  await store.subscribe([{ stream: s, lane: "slow" }]);
1104
1338
  const seen = [];
@@ -1106,9 +1340,9 @@ var runStoreTck = (options) => {
1106
1340
  stream: s,
1107
1341
  stream_exact: true
1108
1342
  });
1109
- (0, import_vitest4.expect)(seen).toEqual(["slow"]);
1343
+ (0, import_vitest6.expect)(seen).toEqual(["slow"]);
1110
1344
  });
1111
- (0, import_vitest4.it)("subscribe re-lanes existing streams on subsequent calls", async () => {
1345
+ (0, import_vitest6.it)("subscribe re-lanes existing streams on subsequent calls", async () => {
1112
1346
  const s = `lane-upsert-${uid()}`;
1113
1347
  await store.subscribe([{ stream: s, lane: "slow" }]);
1114
1348
  await store.subscribe([{ stream: s, lane: "fast" }]);
@@ -1117,9 +1351,9 @@ var runStoreTck = (options) => {
1117
1351
  stream: s,
1118
1352
  stream_exact: true
1119
1353
  });
1120
- (0, import_vitest4.expect)(seen).toEqual(["fast"]);
1354
+ (0, import_vitest6.expect)(seen).toEqual(["fast"]);
1121
1355
  });
1122
- (0, import_vitest4.it)("claim() filters by lane when supplied and returns lane on the Lease", async () => {
1356
+ (0, import_vitest6.it)("claim() filters by lane when supplied and returns lane on the Lease", async () => {
1123
1357
  const tag = uid();
1124
1358
  const src1 = `lane-claim-src1-${tag}`;
1125
1359
  const src2 = `lane-claim-src2-${tag}`;
@@ -1143,19 +1377,19 @@ var runStoreTck = (options) => {
1143
1377
  const slow_mine = slow.filter(
1144
1378
  (l) => l.stream === sub_default || l.stream === sub_slow
1145
1379
  );
1146
- (0, import_vitest4.expect)(slow_mine.map((l) => l.stream)).toEqual([sub_slow]);
1147
- (0, import_vitest4.expect)(slow_mine[0]?.lane).toBe("slow");
1380
+ (0, import_vitest6.expect)(slow_mine.map((l) => l.stream)).toEqual([sub_slow]);
1381
+ (0, import_vitest6.expect)(slow_mine[0]?.lane).toBe("slow");
1148
1382
  await store.ack(slow_mine.map((l) => ({ ...l, at: l.at + 1 })));
1149
1383
  const all = await store.claim(50, 0, `w-all-${tag}`, 1e3);
1150
1384
  const all_mine = all.filter((l) => l.stream === sub_default || l.stream === sub_slow).map((l) => ({ stream: l.stream, lane: l.lane }));
1151
- (0, import_vitest4.expect)(all_mine).toEqual(
1152
- import_vitest4.expect.arrayContaining([
1385
+ (0, import_vitest6.expect)(all_mine).toEqual(
1386
+ import_vitest6.expect.arrayContaining([
1153
1387
  { stream: sub_default, lane: "default" },
1154
1388
  { stream: sub_slow, lane: "slow" }
1155
1389
  ])
1156
1390
  );
1157
1391
  });
1158
- (0, import_vitest4.it)("query_streams filters by lane", async () => {
1392
+ (0, import_vitest6.it)("query_streams filters by lane", async () => {
1159
1393
  const tag = uid();
1160
1394
  const a = `lane-q-a-${tag}`;
1161
1395
  const b = `lane-q-b-${tag}`;
@@ -1171,9 +1405,9 @@ var runStoreTck = (options) => {
1171
1405
  stream: `lane-q-.*-${tag}`,
1172
1406
  limit: 100
1173
1407
  });
1174
- (0, import_vitest4.expect)(seen.sort()).toEqual([a, c]);
1408
+ (0, import_vitest6.expect)(seen.sort()).toEqual([a, c]);
1175
1409
  });
1176
- (0, import_vitest4.it)("prioritize filters by lane", async () => {
1410
+ (0, import_vitest6.it)("prioritize filters by lane", async () => {
1177
1411
  const tag = uid();
1178
1412
  const a = `lane-pri-a-${tag}`;
1179
1413
  const b = `lane-pri-b-${tag}`;
@@ -1182,16 +1416,16 @@ var runStoreTck = (options) => {
1182
1416
  { stream: b, lane: `pfast-${tag}` }
1183
1417
  ]);
1184
1418
  const updated = await store.prioritize({ lane: `pslow-${tag}` }, 7);
1185
- (0, import_vitest4.expect)(updated).toBe(1);
1419
+ (0, import_vitest6.expect)(updated).toBe(1);
1186
1420
  const seen = /* @__PURE__ */ new Map();
1187
1421
  await store.query_streams((p) => seen.set(p.stream, p.priority), {
1188
1422
  stream: `lane-pri-.*-${tag}`,
1189
1423
  limit: 100
1190
1424
  });
1191
- (0, import_vitest4.expect)(seen.get(a)).toBe(7);
1192
- (0, import_vitest4.expect)(seen.get(b)).toBe(0);
1425
+ (0, import_vitest6.expect)(seen.get(a)).toBe(7);
1426
+ (0, import_vitest6.expect)(seen.get(b)).toBe(0);
1193
1427
  });
1194
- (0, import_vitest4.it)("reset filters by lane", async () => {
1428
+ (0, import_vitest6.it)("reset filters by lane", async () => {
1195
1429
  const tag = uid();
1196
1430
  const src = `lane-reset-src-${tag}`;
1197
1431
  const a = `lane-reset-a-${tag}`;
@@ -1209,7 +1443,7 @@ var runStoreTck = (options) => {
1209
1443
  const mine = leases.filter((l) => l.stream === a || l.stream === b);
1210
1444
  await store.ack(mine.map((l) => ({ ...l, at: l.at + 1 })));
1211
1445
  const count = await store.reset({ lane: `rslow-${tag}` });
1212
- (0, import_vitest4.expect)(count).toBe(1);
1446
+ (0, import_vitest6.expect)(count).toBe(1);
1213
1447
  const ats = /* @__PURE__ */ new Map();
1214
1448
  for (const name of [a, b]) {
1215
1449
  await store.query_streams((p) => ats.set(p.stream, p.at), {
@@ -1217,10 +1451,10 @@ var runStoreTck = (options) => {
1217
1451
  stream_exact: true
1218
1452
  });
1219
1453
  }
1220
- (0, import_vitest4.expect)(ats.get(a)).toBe(-1);
1221
- (0, import_vitest4.expect)(ats.get(b)).toBeGreaterThanOrEqual(0);
1454
+ (0, import_vitest6.expect)(ats.get(a)).toBe(-1);
1455
+ (0, import_vitest6.expect)(ats.get(b)).toBeGreaterThanOrEqual(0);
1222
1456
  });
1223
- (0, import_vitest4.it)("unblock filters by lane", async () => {
1457
+ (0, import_vitest6.it)("unblock filters by lane", async () => {
1224
1458
  const tag = uid();
1225
1459
  const src = `lane-ub-src-${tag}`;
1226
1460
  const a = `lane-ub-a-${tag}`;
@@ -1238,7 +1472,7 @@ var runStoreTck = (options) => {
1238
1472
  const mine = leases.filter((l) => l.stream === a || l.stream === b);
1239
1473
  await store.block(mine.map((l) => ({ ...l, error: "boom" })));
1240
1474
  const count = await store.unblock({ lane: `uslow-${tag}` });
1241
- (0, import_vitest4.expect)(count).toBe(1);
1475
+ (0, import_vitest6.expect)(count).toBe(1);
1242
1476
  const blocked = /* @__PURE__ */ new Map();
1243
1477
  for (const name of [a, b]) {
1244
1478
  await store.query_streams((p) => blocked.set(p.stream, p.blocked), {
@@ -1246,12 +1480,12 @@ var runStoreTck = (options) => {
1246
1480
  stream_exact: true
1247
1481
  });
1248
1482
  }
1249
- (0, import_vitest4.expect)(blocked.get(a)).toBe(false);
1250
- (0, import_vitest4.expect)(blocked.get(b)).toBe(true);
1483
+ (0, import_vitest6.expect)(blocked.get(a)).toBe(false);
1484
+ (0, import_vitest6.expect)(blocked.get(b)).toBe(true);
1251
1485
  });
1252
1486
  });
1253
- (0, import_vitest4.describe)("truncate", () => {
1254
- (0, import_vitest4.it)("seeds a tombstone when no snapshot is provided", async () => {
1487
+ (0, import_vitest6.describe)("truncate", () => {
1488
+ (0, import_vitest6.it)("seeds a tombstone when no snapshot is provided", async () => {
1255
1489
  const s = `trunc-tomb-${uid()}`;
1256
1490
  await store.commit(
1257
1491
  s,
@@ -1259,7 +1493,7 @@ var runStoreTck = (options) => {
1259
1493
  make_meta({ stream: s })
1260
1494
  );
1261
1495
  const result = await store.truncate([{ stream: s }]);
1262
- (0, import_vitest4.expect)(result.get(s)?.deleted).toBe(2);
1496
+ (0, import_vitest6.expect)(result.get(s)?.deleted).toBe(2);
1263
1497
  const remaining = [];
1264
1498
  await store.query(
1265
1499
  (e) => {
@@ -1267,12 +1501,12 @@ var runStoreTck = (options) => {
1267
1501
  },
1268
1502
  { stream: s, stream_exact: true }
1269
1503
  );
1270
- (0, import_vitest4.expect)(remaining).toHaveLength(1);
1271
- (0, import_vitest4.expect)(remaining[0].name).toBe(
1504
+ (0, import_vitest6.expect)(remaining).toHaveLength(1);
1505
+ (0, import_vitest6.expect)(remaining[0].name).toBe(
1272
1506
  "__tombstone__"
1273
1507
  );
1274
1508
  });
1275
- (0, import_vitest4.it)("seeds a snapshot when one is provided", async () => {
1509
+ (0, import_vitest6.it)("seeds a snapshot when one is provided", async () => {
1276
1510
  const s = `trunc-snap-${uid()}`;
1277
1511
  await store.commit(
1278
1512
  s,
@@ -1282,7 +1516,7 @@ var runStoreTck = (options) => {
1282
1516
  const result = await store.truncate([
1283
1517
  { stream: s, snapshot: { count: 7 } }
1284
1518
  ]);
1285
- (0, import_vitest4.expect)(result.get(s)?.deleted).toBe(1);
1519
+ (0, import_vitest6.expect)(result.get(s)?.deleted).toBe(1);
1286
1520
  const remaining = [];
1287
1521
  await store.query(
1288
1522
  (e) => {
@@ -1290,24 +1524,24 @@ var runStoreTck = (options) => {
1290
1524
  },
1291
1525
  { stream: s, stream_exact: true, with_snaps: true }
1292
1526
  );
1293
- (0, import_vitest4.expect)(remaining).toHaveLength(1);
1294
- (0, import_vitest4.expect)(remaining[0].name).toBe(
1527
+ (0, import_vitest6.expect)(remaining).toHaveLength(1);
1528
+ (0, import_vitest6.expect)(remaining[0].name).toBe(
1295
1529
  "__snapshot__"
1296
1530
  );
1297
- (0, import_vitest4.expect)(remaining[0].data).toEqual({ count: 7 });
1531
+ (0, import_vitest6.expect)(remaining[0].data).toEqual({ count: 7 });
1298
1532
  });
1299
- (0, import_vitest4.it)("returns an empty map for empty input", async () => {
1533
+ (0, import_vitest6.it)("returns an empty map for empty input", async () => {
1300
1534
  const result = await store.truncate([]);
1301
- (0, import_vitest4.expect)(result.size).toBe(0);
1535
+ (0, import_vitest6.expect)(result.size).toBe(0);
1302
1536
  });
1303
- (0, import_vitest4.it)("returns 0 deleted for streams that don't exist", async () => {
1537
+ (0, import_vitest6.it)("returns 0 deleted for streams that don't exist", async () => {
1304
1538
  const s = `trunc-missing-${uid()}`;
1305
1539
  const result = await store.truncate([{ stream: s }]);
1306
- (0, import_vitest4.expect)(result.get(s)?.deleted).toBe(0);
1540
+ (0, import_vitest6.expect)(result.get(s)?.deleted).toBe(0);
1307
1541
  });
1308
1542
  });
1309
- (0, import_vitest4.describe)("query_streams", () => {
1310
- (0, import_vitest4.it)("returns positions filtered by stream regex, exact, source, and source_exact", async () => {
1543
+ (0, import_vitest6.describe)("query_streams", () => {
1544
+ (0, import_vitest6.it)("returns positions filtered by stream regex, exact, source, and source_exact", async () => {
1311
1545
  const tag = uid();
1312
1546
  const proj1 = `qs-${tag}-projection-tickets`;
1313
1547
  const proj2 = `qs-${tag}-projection-users`;
@@ -1326,37 +1560,37 @@ var runStoreTck = (options) => {
1326
1560
  (p) => all.push({ stream: p.stream, source: p.source }),
1327
1561
  { stream: `qs-${tag}-.*` }
1328
1562
  );
1329
- (0, import_vitest4.expect)(all_result.count).toBe(4);
1330
- (0, import_vitest4.expect)(all_result.maxEventId).toBeGreaterThanOrEqual(-1);
1331
- (0, import_vitest4.expect)(all.map((p) => p.stream).sort()).toEqual(
1563
+ (0, import_vitest6.expect)(all_result.count).toBe(4);
1564
+ (0, import_vitest6.expect)(all_result.maxEventId).toBeGreaterThanOrEqual(-1);
1565
+ (0, import_vitest6.expect)(all.map((p) => p.stream).sort()).toEqual(
1332
1566
  [proj1, proj2, dyn1, dyn2].sort()
1333
1567
  );
1334
1568
  const projections = [];
1335
1569
  await store.query_streams((p) => projections.push(p.stream), {
1336
1570
  stream: `qs-${tag}-projection-.*`
1337
1571
  });
1338
- (0, import_vitest4.expect)(projections.sort()).toEqual([proj1, proj2].sort());
1572
+ (0, import_vitest6.expect)(projections.sort()).toEqual([proj1, proj2].sort());
1339
1573
  const exact = [];
1340
1574
  await store.query_streams((p) => exact.push(p.stream), {
1341
1575
  stream: dyn1,
1342
1576
  stream_exact: true
1343
1577
  });
1344
- (0, import_vitest4.expect)(exact).toEqual([dyn1]);
1578
+ (0, import_vitest6.expect)(exact).toEqual([dyn1]);
1345
1579
  const by_source = [];
1346
1580
  await store.query_streams((p) => by_source.push(p.stream), {
1347
1581
  stream: `qs-${tag}-.*`,
1348
1582
  source: `qs-${tag}-src-.*`
1349
1583
  });
1350
- (0, import_vitest4.expect)(by_source.sort()).toEqual([dyn1, dyn2].sort());
1584
+ (0, import_vitest6.expect)(by_source.sort()).toEqual([dyn1, dyn2].sort());
1351
1585
  const exact_source = [];
1352
1586
  await store.query_streams((p) => exact_source.push(p.stream), {
1353
1587
  stream: `qs-${tag}-.*`,
1354
1588
  source: src2,
1355
1589
  source_exact: true
1356
1590
  });
1357
- (0, import_vitest4.expect)(exact_source).toEqual([dyn2]);
1591
+ (0, import_vitest6.expect)(exact_source).toEqual([dyn2]);
1358
1592
  });
1359
- (0, import_vitest4.it)("paginates with limit + after (keyset)", async () => {
1593
+ (0, import_vitest6.it)("paginates with limit + after (keyset)", async () => {
1360
1594
  const tag = uid();
1361
1595
  const streams = [
1362
1596
  `qp-${tag}-a`,
@@ -1370,17 +1604,17 @@ var runStoreTck = (options) => {
1370
1604
  stream: `qp-${tag}-.*`,
1371
1605
  limit: 2
1372
1606
  });
1373
- (0, import_vitest4.expect)(page1).toHaveLength(2);
1607
+ (0, import_vitest6.expect)(page1).toHaveLength(2);
1374
1608
  const page2 = [];
1375
1609
  await store.query_streams((p) => page2.push(p.stream), {
1376
1610
  stream: `qp-${tag}-.*`,
1377
1611
  limit: 2,
1378
1612
  after: page1.at(-1)
1379
1613
  });
1380
- (0, import_vitest4.expect)(page2).toHaveLength(2);
1381
- (0, import_vitest4.expect)([...page1, ...page2].sort()).toEqual([...streams].sort());
1614
+ (0, import_vitest6.expect)(page2).toHaveLength(2);
1615
+ (0, import_vitest6.expect)([...page1, ...page2].sort()).toEqual([...streams].sort());
1382
1616
  });
1383
- (0, import_vitest4.it)("filters by blocked status", async () => {
1617
+ (0, import_vitest6.it)("filters by blocked status", async () => {
1384
1618
  const tag = uid();
1385
1619
  const s = `qb-${tag}`;
1386
1620
  const sibling = `qb-${tag}-other`;
@@ -1400,18 +1634,18 @@ var runStoreTck = (options) => {
1400
1634
  (p) => blocked.push({ stream: p.stream, error: p.error }),
1401
1635
  { stream: `qb-${tag}.*`, blocked: true }
1402
1636
  );
1403
- (0, import_vitest4.expect)(blocked).toHaveLength(1);
1404
- (0, import_vitest4.expect)(blocked[0].error).toBe("boom");
1637
+ (0, import_vitest6.expect)(blocked).toHaveLength(1);
1638
+ (0, import_vitest6.expect)(blocked[0].error).toBe("boom");
1405
1639
  const unblocked = [];
1406
1640
  await store.query_streams((p) => unblocked.push(p.stream), {
1407
1641
  stream: `qb-${tag}.*`,
1408
1642
  blocked: false
1409
1643
  });
1410
- (0, import_vitest4.expect)(unblocked).toEqual([sibling]);
1644
+ (0, import_vitest6.expect)(unblocked).toEqual([sibling]);
1411
1645
  });
1412
1646
  });
1413
- (0, import_vitest4.describe)("query_stats", () => {
1414
- (0, import_vitest4.it)("array input \u2014 returns head per stream, absent when not in input", async () => {
1647
+ (0, import_vitest6.describe)("query_stats", () => {
1648
+ (0, import_vitest6.it)("array input \u2014 returns head per stream, absent when not in input", async () => {
1415
1649
  const tag = uid();
1416
1650
  const sA = `qst-${tag}-a`;
1417
1651
  const sB = `qst-${tag}-b`;
@@ -1432,18 +1666,18 @@ var runStoreTck = (options) => {
1432
1666
  make_meta({ stream: sUnasked })
1433
1667
  );
1434
1668
  const stats = await store.query_stats([sA, sB]);
1435
- (0, import_vitest4.expect)(stats.size).toBe(2);
1436
- (0, import_vitest4.expect)(stats.get(sA)?.head.name).toBe("Incremented");
1437
- (0, import_vitest4.expect)((stats.get(sA)?.head.data).amount).toBe(2);
1438
- (0, import_vitest4.expect)(stats.get(sB)?.head.name).toBe("Decremented");
1439
- (0, import_vitest4.expect)((stats.get(sB)?.head.data).amount).toBe(5);
1440
- (0, import_vitest4.expect)(stats.has(sUnasked)).toBe(false);
1669
+ (0, import_vitest6.expect)(stats.size).toBe(2);
1670
+ (0, import_vitest6.expect)(stats.get(sA)?.head.name).toBe("Incremented");
1671
+ (0, import_vitest6.expect)((stats.get(sA)?.head.data).amount).toBe(2);
1672
+ (0, import_vitest6.expect)(stats.get(sB)?.head.name).toBe("Decremented");
1673
+ (0, import_vitest6.expect)((stats.get(sB)?.head.data).amount).toBe(5);
1674
+ (0, import_vitest6.expect)(stats.has(sUnasked)).toBe(false);
1441
1675
  const empty = await store.query_stats([]);
1442
- (0, import_vitest4.expect)(empty.size).toBe(0);
1676
+ (0, import_vitest6.expect)(empty.size).toBe(0);
1443
1677
  const unknown = await store.query_stats([`qst-${tag}-missing`]);
1444
- (0, import_vitest4.expect)(unknown.size).toBe(0);
1678
+ (0, import_vitest6.expect)(unknown.size).toBe(0);
1445
1679
  });
1446
- (0, import_vitest4.it)("tail returns the earliest event per stream", async () => {
1680
+ (0, import_vitest6.it)("tail returns the earliest event per stream", async () => {
1447
1681
  const tag = uid();
1448
1682
  const s = `qst-tail-${tag}`;
1449
1683
  await store.commit(
@@ -1465,12 +1699,12 @@ var runStoreTck = (options) => {
1465
1699
  tail: true
1466
1700
  });
1467
1701
  const r = stats.get(s);
1468
- (0, import_vitest4.expect)(r?.head.name).toBe("Incremented");
1469
- (0, import_vitest4.expect)((r?.head.data).amount).toBe(3);
1470
- (0, import_vitest4.expect)(r?.tail?.name).toBe("Incremented");
1471
- (0, import_vitest4.expect)((r?.tail?.data).amount).toBe(1);
1702
+ (0, import_vitest6.expect)(r?.head.name).toBe("Incremented");
1703
+ (0, import_vitest6.expect)((r?.head.data).amount).toBe(3);
1704
+ (0, import_vitest6.expect)(r?.tail?.name).toBe("Incremented");
1705
+ (0, import_vitest6.expect)((r?.tail?.data).amount).toBe(1);
1472
1706
  });
1473
- (0, import_vitest4.it)("count + names \u2014 full aggregates including framework markers", async () => {
1707
+ (0, import_vitest6.it)("count + names \u2014 full aggregates including framework markers", async () => {
1474
1708
  const tag = uid();
1475
1709
  const s = `qst-cn-${tag}`;
1476
1710
  await store.commit(
@@ -1489,13 +1723,13 @@ var runStoreTck = (options) => {
1489
1723
  names: true
1490
1724
  });
1491
1725
  const r = stats.get(s);
1492
- (0, import_vitest4.expect)(r?.count).toBe(4);
1493
- (0, import_vitest4.expect)(r?.names?.[import_act.SNAP_EVENT]).toBe(1);
1494
- (0, import_vitest4.expect)(r?.names?.Incremented).toBe(2);
1495
- (0, import_vitest4.expect)(r?.names?.Decremented).toBe(1);
1496
- (0, import_vitest4.expect)(r?.names?.[import_act.SNAP_EVENT]).toBe(1);
1726
+ (0, import_vitest6.expect)(r?.count).toBe(4);
1727
+ (0, import_vitest6.expect)(r?.names?.[import_act.SNAP_EVENT]).toBe(1);
1728
+ (0, import_vitest6.expect)(r?.names?.Incremented).toBe(2);
1729
+ (0, import_vitest6.expect)(r?.names?.Decremented).toBe(1);
1730
+ (0, import_vitest6.expect)(r?.names?.[import_act.SNAP_EVENT]).toBe(1);
1497
1731
  });
1498
- (0, import_vitest4.it)("exclude shifts head past filtered events; stream absent when all filtered", async () => {
1732
+ (0, import_vitest6.it)("exclude shifts head past filtered events; stream absent when all filtered", async () => {
1499
1733
  const tag = uid();
1500
1734
  const s = `qst-excl-${tag}`;
1501
1735
  const sAllOut = `qst-allout-${tag}`;
@@ -1510,23 +1744,23 @@ var runStoreTck = (options) => {
1510
1744
  make_meta({ stream: sAllOut })
1511
1745
  );
1512
1746
  const all = await store.query_stats([s]);
1513
- (0, import_vitest4.expect)(all.get(s)?.head.name).toBe("Incremented");
1514
- (0, import_vitest4.expect)((all.get(s)?.head.data).amount).toBe(3);
1747
+ (0, import_vitest6.expect)(all.get(s)?.head.name).toBe("Incremented");
1748
+ (0, import_vitest6.expect)((all.get(s)?.head.data).amount).toBe(3);
1515
1749
  const excl = await store.query_stats([s], {
1516
1750
  exclude: ["Incremented"]
1517
1751
  });
1518
- (0, import_vitest4.expect)(excl.get(s)?.head.name).toBe("Decremented");
1519
- (0, import_vitest4.expect)((excl.get(s)?.head.data).amount).toBe(2);
1752
+ (0, import_vitest6.expect)(excl.get(s)?.head.name).toBe("Decremented");
1753
+ (0, import_vitest6.expect)((excl.get(s)?.head.data).amount).toBe(2);
1520
1754
  const wipe = await store.query_stats([sAllOut], {
1521
1755
  exclude: ["Incremented", "Decremented", "Reset"]
1522
1756
  });
1523
- (0, import_vitest4.expect)(wipe.has(sAllOut)).toBe(false);
1757
+ (0, import_vitest6.expect)(wipe.has(sAllOut)).toBe(false);
1524
1758
  const no_tomb = await store.query_stats([s], {
1525
1759
  exclude: [import_act.TOMBSTONE_EVENT]
1526
1760
  });
1527
- (0, import_vitest4.expect)(no_tomb.get(s)?.head.name).toBe("Incremented");
1761
+ (0, import_vitest6.expect)(no_tomb.get(s)?.head.name).toBe("Incremented");
1528
1762
  });
1529
- (0, import_vitest4.it)("before \u2014 time travel narrows head/tail/count", async () => {
1763
+ (0, import_vitest6.it)("before \u2014 time travel narrows head/tail/count", async () => {
1530
1764
  const tag = uid();
1531
1765
  const s = `qst-tt-${tag}`;
1532
1766
  const c1 = await store.commit(
@@ -1551,15 +1785,15 @@ var runStoreTck = (options) => {
1551
1785
  before
1552
1786
  });
1553
1787
  const r = stats.get(s);
1554
- (0, import_vitest4.expect)(r?.count).toBe(1);
1555
- (0, import_vitest4.expect)(r?.head.id).toBe(c1[0].id);
1556
- (0, import_vitest4.expect)(r?.tail?.id).toBe(c1[0].id);
1788
+ (0, import_vitest6.expect)(r?.count).toBe(1);
1789
+ (0, import_vitest6.expect)(r?.head.id).toBe(c1[0].id);
1790
+ (0, import_vitest6.expect)(r?.tail?.id).toBe(c1[0].id);
1557
1791
  const empty = await store.query_stats([s], {
1558
1792
  before: 0
1559
1793
  });
1560
- (0, import_vitest4.expect)(empty.has(s)).toBe(false);
1794
+ (0, import_vitest6.expect)(empty.has(s)).toBe(false);
1561
1795
  });
1562
- (0, import_vitest4.it)("filter form \u2014 stream regex, stream_exact, empty {} match", async () => {
1796
+ (0, import_vitest6.it)("filter form \u2014 stream regex, stream_exact, empty {} match", async () => {
1563
1797
  const tag = uid();
1564
1798
  const sA = `qsf-${tag}-orders-1`;
1565
1799
  const sB = `qsf-${tag}-orders-2`;
@@ -1582,18 +1816,18 @@ var runStoreTck = (options) => {
1582
1816
  const orders = await store.query_stats({
1583
1817
  stream: `^qsf-${tag}-orders-`
1584
1818
  });
1585
- (0, import_vitest4.expect)([...orders.keys()].sort()).toEqual([sA, sB].sort());
1819
+ (0, import_vitest6.expect)([...orders.keys()].sort()).toEqual([sA, sB].sort());
1586
1820
  const exact = await store.query_stats({
1587
1821
  stream: sA,
1588
1822
  stream_exact: true
1589
1823
  });
1590
- (0, import_vitest4.expect)([...exact.keys()]).toEqual([sA]);
1824
+ (0, import_vitest6.expect)([...exact.keys()]).toEqual([sA]);
1591
1825
  const all = await store.query_stats({
1592
1826
  stream: `^qsf-${tag}-`
1593
1827
  });
1594
- (0, import_vitest4.expect)([...all.keys()].sort()).toEqual([sA, sB, sOther].sort());
1828
+ (0, import_vitest6.expect)([...all.keys()].sort()).toEqual([sA, sB, sOther].sort());
1595
1829
  });
1596
- (0, import_vitest4.it)("compose with query_streams for subscription-level filters", async () => {
1830
+ (0, import_vitest6.it)("compose with query_streams for subscription-level filters", async () => {
1597
1831
  const tag = uid();
1598
1832
  const a = `qsc-${tag}-a`;
1599
1833
  const b = `qsc-${tag}-b`;
@@ -1610,7 +1844,7 @@ var runStoreTck = (options) => {
1610
1844
  );
1611
1845
  const leased = await store.claim(100, 0, `w-${uid()}`, 1e5);
1612
1846
  const mine = leased.find((l) => l.stream === a);
1613
- (0, import_vitest4.expect)(mine).toBeDefined();
1847
+ (0, import_vitest6.expect)(mine).toBeDefined();
1614
1848
  const others = leased.filter((l) => l.stream !== a);
1615
1849
  await store.ack(others);
1616
1850
  await store.block([{ ...mine, error: "boom" }]);
@@ -1619,12 +1853,12 @@ var runStoreTck = (options) => {
1619
1853
  stream: `^qsc-${tag}-`,
1620
1854
  blocked: true
1621
1855
  });
1622
- (0, import_vitest4.expect)(blocked_names).toEqual([a]);
1856
+ (0, import_vitest6.expect)(blocked_names).toEqual([a]);
1623
1857
  const stats = await store.query_stats(blocked_names);
1624
- (0, import_vitest4.expect)(stats.get(a)?.head.name).toBe("Incremented");
1625
- (0, import_vitest4.expect)(stats.has(b)).toBe(false);
1858
+ (0, import_vitest6.expect)(stats.get(a)?.head.name).toBe("Incremented");
1859
+ (0, import_vitest6.expect)(stats.has(b)).toBe(false);
1626
1860
  });
1627
- (0, import_vitest4.it)("empty filter {} \u2014 matches every event-bearing stream", async () => {
1861
+ (0, import_vitest6.it)("empty filter {} \u2014 matches every event-bearing stream", async () => {
1628
1862
  const tag = uid();
1629
1863
  const a = `qse-${tag}-a`;
1630
1864
  const b = `qse-${tag}-b`;
@@ -1639,10 +1873,10 @@ var runStoreTck = (options) => {
1639
1873
  make_meta({ stream: b })
1640
1874
  );
1641
1875
  const all = await store.query_stats({});
1642
- (0, import_vitest4.expect)(all.has(a)).toBe(true);
1643
- (0, import_vitest4.expect)(all.has(b)).toBe(true);
1876
+ (0, import_vitest6.expect)(all.has(a)).toBe(true);
1877
+ (0, import_vitest6.expect)(all.has(b)).toBe(true);
1644
1878
  });
1645
- (0, import_vitest4.it)("stat-flag combinations \u2014 count-only, names-only, tail-only", async () => {
1879
+ (0, import_vitest6.it)("stat-flag combinations \u2014 count-only, names-only, tail-only", async () => {
1646
1880
  const tag = uid();
1647
1881
  const s = `qsfl-${tag}`;
1648
1882
  await store.commit(
@@ -1653,24 +1887,24 @@ var runStoreTck = (options) => {
1653
1887
  const c = await store.query_stats([s], {
1654
1888
  count: true
1655
1889
  });
1656
- (0, import_vitest4.expect)(c.get(s)?.count).toBe(3);
1657
- (0, import_vitest4.expect)(c.get(s)?.names).toBeUndefined();
1658
- (0, import_vitest4.expect)(c.get(s)?.tail).toBeUndefined();
1890
+ (0, import_vitest6.expect)(c.get(s)?.count).toBe(3);
1891
+ (0, import_vitest6.expect)(c.get(s)?.names).toBeUndefined();
1892
+ (0, import_vitest6.expect)(c.get(s)?.tail).toBeUndefined();
1659
1893
  const n = await store.query_stats([s], {
1660
1894
  names: true
1661
1895
  });
1662
- (0, import_vitest4.expect)(n.get(s)?.names).toEqual({ Incremented: 2, Decremented: 1 });
1663
- (0, import_vitest4.expect)(n.get(s)?.count).toBeUndefined();
1664
- (0, import_vitest4.expect)(n.get(s)?.tail).toBeUndefined();
1896
+ (0, import_vitest6.expect)(n.get(s)?.names).toEqual({ Incremented: 2, Decremented: 1 });
1897
+ (0, import_vitest6.expect)(n.get(s)?.count).toBeUndefined();
1898
+ (0, import_vitest6.expect)(n.get(s)?.tail).toBeUndefined();
1665
1899
  const t = await store.query_stats([s], { tail: true });
1666
- (0, import_vitest4.expect)(t.get(s)?.tail?.name).toBe("Incremented");
1667
- (0, import_vitest4.expect)((t.get(s)?.tail?.data).amount).toBe(1);
1668
- (0, import_vitest4.expect)(t.get(s)?.count).toBeUndefined();
1669
- (0, import_vitest4.expect)(t.get(s)?.names).toBeUndefined();
1900
+ (0, import_vitest6.expect)(t.get(s)?.tail?.name).toBe("Incremented");
1901
+ (0, import_vitest6.expect)((t.get(s)?.tail?.data).amount).toBe(1);
1902
+ (0, import_vitest6.expect)(t.get(s)?.count).toBeUndefined();
1903
+ (0, import_vitest6.expect)(t.get(s)?.names).toBeUndefined();
1670
1904
  });
1671
1905
  });
1672
- (0, import_vitest4.describe)("query_streams anchor contract", () => {
1673
- (0, import_vitest4.it)("plain regex without anchors is a substring match", async () => {
1906
+ (0, import_vitest6.describe)("query_streams anchor contract", () => {
1907
+ (0, import_vitest6.it)("plain regex without anchors is a substring match", async () => {
1674
1908
  const tag = uid();
1675
1909
  const inner = `qsr-${tag}-inner`;
1676
1910
  const longer = `qsr-${tag}-inner-extra`;
@@ -1684,9 +1918,9 @@ var runStoreTck = (options) => {
1684
1918
  await store.query_streams((p) => seen.push(p.stream), {
1685
1919
  stream: `qsr-${tag}-inner`
1686
1920
  });
1687
- (0, import_vitest4.expect)(seen.sort()).toEqual([inner, longer].sort());
1921
+ (0, import_vitest6.expect)(seen.sort()).toEqual([inner, longer].sort());
1688
1922
  });
1689
- (0, import_vitest4.it)("caller-anchored `^name$` matches only the whole string", async () => {
1923
+ (0, import_vitest6.it)("caller-anchored `^name$` matches only the whole string", async () => {
1690
1924
  const tag = uid();
1691
1925
  const inner = `qsr-${tag}-anchor`;
1692
1926
  const longer = `qsr-${tag}-anchor-extra`;
@@ -1695,9 +1929,9 @@ var runStoreTck = (options) => {
1695
1929
  await store.query_streams((p) => seen.push(p.stream), {
1696
1930
  stream: `^qsr-${tag}-anchor$`
1697
1931
  });
1698
- (0, import_vitest4.expect)(seen).toEqual([inner]);
1932
+ (0, import_vitest6.expect)(seen).toEqual([inner]);
1699
1933
  });
1700
- (0, import_vitest4.it)("caller-anchored `^prefix` matches by prefix", async () => {
1934
+ (0, import_vitest6.it)("caller-anchored `^prefix` matches by prefix", async () => {
1701
1935
  const tag = uid();
1702
1936
  const a = `qsr-${tag}-pfx-a`;
1703
1937
  const b = `qsr-${tag}-pfx-b`;
@@ -1711,11 +1945,11 @@ var runStoreTck = (options) => {
1711
1945
  await store.query_streams((p) => seen.push(p.stream), {
1712
1946
  stream: `^qsr-${tag}-pfx-`
1713
1947
  });
1714
- (0, import_vitest4.expect)(seen.sort()).toEqual([a, b].sort());
1948
+ (0, import_vitest6.expect)(seen.sort()).toEqual([a, b].sort());
1715
1949
  });
1716
1950
  });
1717
- (0, import_vitest4.describe)("prioritize anchor contract", () => {
1718
- (0, import_vitest4.it)("caller-anchored `^name$` filter matches only the whole string", async () => {
1951
+ (0, import_vitest6.describe)("prioritize anchor contract", () => {
1952
+ (0, import_vitest6.it)("caller-anchored `^name$` filter matches only the whole string", async () => {
1719
1953
  const tag = uid();
1720
1954
  const inner = `pr-${tag}-anchor`;
1721
1955
  const longer = `pr-${tag}-anchor-extra`;
@@ -1727,17 +1961,17 @@ var runStoreTck = (options) => {
1727
1961
  { stream: `^pr-${tag}-anchor$` },
1728
1962
  7
1729
1963
  );
1730
- (0, import_vitest4.expect)(updated).toBe(1);
1964
+ (0, import_vitest6.expect)(updated).toBe(1);
1731
1965
  const seen = /* @__PURE__ */ new Map();
1732
1966
  await store.query_streams((p) => seen.set(p.stream, p.priority), {
1733
1967
  stream: `pr-${tag}-anchor`
1734
1968
  });
1735
- (0, import_vitest4.expect)(seen.get(inner)).toBe(7);
1736
- (0, import_vitest4.expect)(seen.get(longer)).toBe(0);
1969
+ (0, import_vitest6.expect)(seen.get(inner)).toBe(7);
1970
+ (0, import_vitest6.expect)(seen.get(longer)).toBe(0);
1737
1971
  });
1738
1972
  });
1739
- (0, import_vitest4.describe)("query_streams head", () => {
1740
- (0, import_vitest4.it)("maxEventId tracks the highest committed id", async () => {
1973
+ (0, import_vitest6.describe)("query_streams head", () => {
1974
+ (0, import_vitest6.it)("maxEventId tracks the highest committed id", async () => {
1741
1975
  const s = `head-${uid()}`;
1742
1976
  await store.subscribe([{ stream: s }]);
1743
1977
  await store.commit(
@@ -1750,34 +1984,34 @@ var runStoreTck = (options) => {
1750
1984
  (p) => positions.push(p.stream),
1751
1985
  { stream: s, stream_exact: true, limit: 1 }
1752
1986
  );
1753
- (0, import_vitest4.expect)(maxEventId).toBeGreaterThanOrEqual(0);
1754
- (0, import_vitest4.expect)(positions).toEqual([s]);
1987
+ (0, import_vitest6.expect)(maxEventId).toBeGreaterThanOrEqual(0);
1988
+ (0, import_vitest6.expect)(positions).toEqual([s]);
1755
1989
  });
1756
1990
  });
1757
- (0, import_vitest4.describe)("seed_stream helper coverage", () => {
1758
- (0, import_vitest4.it)("commits N events with monotonically increasing ids", async () => {
1991
+ (0, import_vitest6.describe)("seed_stream helper coverage", () => {
1992
+ (0, import_vitest6.it)("commits N events with monotonically increasing ids", async () => {
1759
1993
  const s = `seed-${uid()}`;
1760
1994
  const committed = await seed_stream(store, s, 3);
1761
- (0, import_vitest4.expect)(committed).toHaveLength(3);
1995
+ (0, import_vitest6.expect)(committed).toHaveLength(3);
1762
1996
  for (let i = 1; i < committed.length; i++) {
1763
- (0, import_vitest4.expect)(committed[i].id).toBeGreaterThan(committed[i - 1].id);
1997
+ (0, import_vitest6.expect)(committed[i].id).toBeGreaterThan(committed[i - 1].id);
1764
1998
  }
1765
1999
  });
1766
2000
  });
1767
- import_vitest4.describe.skipIf(!caps.restore)("restore (capability)", () => {
2001
+ import_vitest6.describe.skipIf(!caps.restore)("restore (capability)", () => {
1768
2002
  beforeEach(async () => {
1769
2003
  await store.drop();
1770
2004
  await store.seed();
1771
2005
  });
1772
- const as_source = (events) => ({
2006
+ const as_source = (events2) => ({
1773
2007
  async query(callback) {
1774
- for (const e of events)
2008
+ for (const e of events2)
1775
2009
  await Promise.resolve(
1776
2010
  callback(
1777
2011
  e
1778
2012
  )
1779
2013
  );
1780
- return events.length;
2014
+ return events2.length;
1781
2015
  },
1782
2016
  async dispose() {
1783
2017
  }
@@ -1801,29 +2035,29 @@ var runStoreTck = (options) => {
1801
2035
  await cache.dispose();
1802
2036
  }
1803
2037
  };
1804
- (0, import_vitest4.it)("returns kept=0 on an empty source", async () => {
2038
+ (0, import_vitest6.it)("returns kept=0 on an empty source", async () => {
1805
2039
  const result = await restore(as_source([]));
1806
- (0, import_vitest4.expect)(result.kept).toBe(0);
1807
- (0, import_vitest4.expect)(result.duration_ms).toBeGreaterThanOrEqual(0);
1808
- (0, import_vitest4.expect)(result.dropped).toEqual({
2040
+ (0, import_vitest6.expect)(result.kept).toBe(0);
2041
+ (0, import_vitest6.expect)(result.duration_ms).toBeGreaterThanOrEqual(0);
2042
+ (0, import_vitest6.expect)(result.dropped).toEqual({
1809
2043
  closed_streams: 0,
1810
2044
  snapshots: 0
1811
2045
  });
1812
- const events = await collect(store, { limit: 10 });
1813
- (0, import_vitest4.expect)(events).toHaveLength(0);
2046
+ const events2 = await collect(store, { limit: 10 });
2047
+ (0, import_vitest6.expect)(events2).toHaveLength(0);
1814
2048
  });
1815
- (0, import_vitest4.it)("rebuilds a single stream and preserves `created` verbatim", async () => {
2049
+ (0, import_vitest6.it)("rebuilds a single stream and preserves `created` verbatim", async () => {
1816
2050
  const s = `restore-single-${uid()}`;
1817
2051
  const t0 = /* @__PURE__ */ new Date("2020-01-01T00:00:00.000Z");
1818
2052
  const t1 = /* @__PURE__ */ new Date("2020-01-02T00:00:00.000Z");
1819
2053
  const t2 = /* @__PURE__ */ new Date("2020-01-03T00:00:00.000Z");
1820
- const events = [
2054
+ const events2 = [
1821
2055
  event(1, s, 0, "Incremented", t0, { amount: 1 }),
1822
2056
  event(2, s, 1, "Incremented", t1, { amount: 2 }),
1823
2057
  event(3, s, 2, "Decremented", t2, { amount: 1 })
1824
2058
  ];
1825
- const result = await restore(as_source(events));
1826
- (0, import_vitest4.expect)(result.kept).toBe(3);
2059
+ const result = await restore(as_source(events2));
2060
+ (0, import_vitest6.expect)(result.kept).toBe(3);
1827
2061
  const back = [];
1828
2062
  await store.query(
1829
2063
  (e) => {
@@ -1831,8 +2065,8 @@ var runStoreTck = (options) => {
1831
2065
  },
1832
2066
  { stream: s, stream_exact: true }
1833
2067
  );
1834
- (0, import_vitest4.expect)(back).toHaveLength(3);
1835
- (0, import_vitest4.expect)(
2068
+ (0, import_vitest6.expect)(back).toHaveLength(3);
2069
+ (0, import_vitest6.expect)(
1836
2070
  back.map((e) => ({
1837
2071
  stream: e.stream,
1838
2072
  version: e.version,
@@ -1864,18 +2098,18 @@ var runStoreTck = (options) => {
1864
2098
  }
1865
2099
  ]);
1866
2100
  });
1867
- (0, import_vitest4.it)("rebuilds multiple streams interleaved", async () => {
2101
+ (0, import_vitest6.it)("rebuilds multiple streams interleaved", async () => {
1868
2102
  const a = `restore-multi-a-${uid()}`;
1869
2103
  const b = `restore-multi-b-${uid()}`;
1870
2104
  const t = /* @__PURE__ */ new Date("2020-06-01T00:00:00.000Z");
1871
- const events = [
2105
+ const events2 = [
1872
2106
  event(1, a, 0, "Incremented", t, { amount: 10 }),
1873
2107
  event(2, b, 0, "Incremented", t, { amount: 20 }),
1874
2108
  event(3, a, 1, "Decremented", t, { amount: 5 }),
1875
2109
  event(4, b, 1, "Incremented", t, { amount: 30 })
1876
2110
  ];
1877
- const result = await restore(as_source(events));
1878
- (0, import_vitest4.expect)(result.kept).toBe(4);
2111
+ const result = await restore(as_source(events2));
2112
+ (0, import_vitest6.expect)(result.kept).toBe(4);
1879
2113
  const aBack = [];
1880
2114
  const bBack = [];
1881
2115
  await store.query(
@@ -1890,10 +2124,10 @@ var runStoreTck = (options) => {
1890
2124
  },
1891
2125
  { stream: b, stream_exact: true }
1892
2126
  );
1893
- (0, import_vitest4.expect)(aBack.map((e) => e.version)).toEqual([0, 1]);
1894
- (0, import_vitest4.expect)(bBack.map((e) => e.version)).toEqual([0, 1]);
2127
+ (0, import_vitest6.expect)(aBack.map((e) => e.version)).toEqual([0, 1]);
2128
+ (0, import_vitest6.expect)(bBack.map((e) => e.version)).toEqual([0, 1]);
1895
2129
  });
1896
- (0, import_vitest4.it)("preserves Date `created` verbatim", async () => {
2130
+ (0, import_vitest6.it)("preserves Date `created` verbatim", async () => {
1897
2131
  const s = `restore-isoc-${uid()}`;
1898
2132
  const iso = "2021-07-15T12:34:56.789Z";
1899
2133
  await restore(
@@ -1916,10 +2150,10 @@ var runStoreTck = (options) => {
1916
2150
  },
1917
2151
  { stream: s, stream_exact: true }
1918
2152
  );
1919
- (0, import_vitest4.expect)(back).toHaveLength(1);
1920
- (0, import_vitest4.expect)(back[0].created.toISOString()).toBe(iso);
2153
+ (0, import_vitest6.expect)(back).toHaveLength(1);
2154
+ (0, import_vitest6.expect)(back[0].created.toISOString()).toBe(iso);
1921
2155
  });
1922
- (0, import_vitest4.it)("wipes pre-existing events before inserting", async () => {
2156
+ (0, import_vitest6.it)("wipes pre-existing events before inserting", async () => {
1923
2157
  const old = `restore-old-${uid()}`;
1924
2158
  await store.commit(
1925
2159
  old,
@@ -1935,14 +2169,14 @@ var runStoreTck = (options) => {
1935
2169
  stream: old,
1936
2170
  stream_exact: true
1937
2171
  });
1938
- (0, import_vitest4.expect)(old_back).toHaveLength(0);
2172
+ (0, import_vitest6.expect)(old_back).toHaveLength(0);
1939
2173
  const fresh_back = await collect(store, {
1940
2174
  stream: fresh,
1941
2175
  stream_exact: true
1942
2176
  });
1943
- (0, import_vitest4.expect)(fresh_back).toHaveLength(1);
2177
+ (0, import_vitest6.expect)(fresh_back).toHaveLength(1);
1944
2178
  });
1945
- (0, import_vitest4.it)("clears subscription/stream-position metadata", async () => {
2179
+ (0, import_vitest6.it)("clears subscription/stream-position metadata", async () => {
1946
2180
  const sub = `restore-sub-${uid()}`;
1947
2181
  await store.subscribe([{ stream: sub, source: "anything" }]);
1948
2182
  const collect_streams = async () => {
@@ -1953,12 +2187,12 @@ var runStoreTck = (options) => {
1953
2187
  return out;
1954
2188
  };
1955
2189
  const before = await collect_streams();
1956
- (0, import_vitest4.expect)(before.includes(sub)).toBe(true);
2190
+ (0, import_vitest6.expect)(before.includes(sub)).toBe(true);
1957
2191
  await restore(as_source([]));
1958
2192
  const after = await collect_streams();
1959
- (0, import_vitest4.expect)(after.includes(sub)).toBe(false);
2193
+ (0, import_vitest6.expect)(after.includes(sub)).toBe(false);
1960
2194
  });
1961
- (0, import_vitest4.it)("preserves snapshot events through restore", async () => {
2195
+ (0, import_vitest6.it)("preserves snapshot events through restore", async () => {
1962
2196
  const s = `restore-snap-${uid()}`;
1963
2197
  const t = /* @__PURE__ */ new Date("2020-04-01T00:00:00.000Z");
1964
2198
  await restore(
@@ -1979,13 +2213,13 @@ var runStoreTck = (options) => {
1979
2213
  stream_exact: true,
1980
2214
  with_snaps: true
1981
2215
  });
1982
- (0, import_vitest4.expect)(back).toHaveLength(1);
1983
- (0, import_vitest4.expect)(back[0].name).toBe(import_act.SNAP_EVENT);
2216
+ (0, import_vitest6.expect)(back).toHaveLength(1);
2217
+ (0, import_vitest6.expect)(back[0].name).toBe(import_act.SNAP_EVENT);
1984
2218
  });
1985
- (0, import_vitest4.it)("rewrites causation refs through the old\u2192new id map", async () => {
2219
+ (0, import_vitest6.it)("rewrites causation refs through the old\u2192new id map", async () => {
1986
2220
  const s = `restore-caus-${uid()}`;
1987
2221
  const t = /* @__PURE__ */ new Date("2020-08-01T00:00:00.000Z");
1988
- const events = [
2222
+ const events2 = [
1989
2223
  {
1990
2224
  id: 5,
1991
2225
  stream: s,
@@ -2024,7 +2258,7 @@ var runStoreTck = (options) => {
2024
2258
  }
2025
2259
  }
2026
2260
  ];
2027
- await restore(as_source(events));
2261
+ await restore(as_source(events2));
2028
2262
  const back = [];
2029
2263
  await store.query(
2030
2264
  (e) => {
@@ -2032,12 +2266,12 @@ var runStoreTck = (options) => {
2032
2266
  },
2033
2267
  { stream: s, stream_exact: true }
2034
2268
  );
2035
- (0, import_vitest4.expect)(back).toHaveLength(3);
2036
- (0, import_vitest4.expect)(back[0].meta.causation.event).toBeUndefined();
2037
- (0, import_vitest4.expect)(back[1].meta.causation.event?.id).toBe(back[0].id);
2038
- (0, import_vitest4.expect)(back[2].meta.causation.event?.id).toBe(back[1].id);
2269
+ (0, import_vitest6.expect)(back).toHaveLength(3);
2270
+ (0, import_vitest6.expect)(back[0].meta.causation.event).toBeUndefined();
2271
+ (0, import_vitest6.expect)(back[1].meta.causation.event?.id).toBe(back[0].id);
2272
+ (0, import_vitest6.expect)(back[2].meta.causation.event?.id).toBe(back[1].id);
2039
2273
  });
2040
- (0, import_vitest4.it)("leaves causation refs unmapped when the target isn't in the source", async () => {
2274
+ (0, import_vitest6.it)("leaves causation refs unmapped when the target isn't in the source", async () => {
2041
2275
  const s = `restore-orphan-${uid()}`;
2042
2276
  const t = /* @__PURE__ */ new Date("2020-09-01T00:00:00.000Z");
2043
2277
  await restore(
@@ -2065,9 +2299,9 @@ var runStoreTck = (options) => {
2065
2299
  },
2066
2300
  { stream: s, stream_exact: true }
2067
2301
  );
2068
- (0, import_vitest4.expect)(back[0].meta.causation.event?.id).toBe(999);
2302
+ (0, import_vitest6.expect)(back[0].meta.causation.event?.id).toBe(999);
2069
2303
  });
2070
- (0, import_vitest4.it)("rolls back atomically when the source throws mid-iteration", async () => {
2304
+ (0, import_vitest6.it)("rolls back atomically when the source throws mid-iteration", async () => {
2071
2305
  const original = `restore-pre-${uid()}`;
2072
2306
  const committed = await store.commit(
2073
2307
  original,
@@ -2093,7 +2327,7 @@ var runStoreTck = (options) => {
2093
2327
  async dispose() {
2094
2328
  }
2095
2329
  };
2096
- await (0, import_vitest4.expect)(restore(explosive)).rejects.toThrow("boom");
2330
+ await (0, import_vitest6.expect)(restore(explosive)).rejects.toThrow("boom");
2097
2331
  const back = [];
2098
2332
  await store.query(
2099
2333
  (e) => {
@@ -2101,10 +2335,10 @@ var runStoreTck = (options) => {
2101
2335
  },
2102
2336
  { stream: original, stream_exact: true }
2103
2337
  );
2104
- (0, import_vitest4.expect)(back).toHaveLength(3);
2105
- (0, import_vitest4.expect)(back.map((e) => e.id)).toEqual(committed.map((c) => c.id));
2338
+ (0, import_vitest6.expect)(back).toHaveLength(3);
2339
+ (0, import_vitest6.expect)(back.map((e) => e.id)).toEqual(committed.map((c) => c.id));
2106
2340
  });
2107
- (0, import_vitest4.it)("drop_snapshots: skips SNAP_EVENT rows and counts them", async () => {
2341
+ (0, import_vitest6.it)("drop_snapshots: skips SNAP_EVENT rows and counts them", async () => {
2108
2342
  const s = `restore-drop-snap-${uid()}`;
2109
2343
  const t = /* @__PURE__ */ new Date("2020-10-01T00:00:00.000Z");
2110
2344
  const result = await restore(
@@ -2123,19 +2357,19 @@ var runStoreTck = (options) => {
2123
2357
  ]),
2124
2358
  { drop_snapshots: true }
2125
2359
  );
2126
- (0, import_vitest4.expect)(result.kept).toBe(2);
2127
- (0, import_vitest4.expect)(result.dropped.snapshots).toBe(1);
2360
+ (0, import_vitest6.expect)(result.kept).toBe(2);
2361
+ (0, import_vitest6.expect)(result.dropped.snapshots).toBe(1);
2128
2362
  const back = await collect(store, {
2129
2363
  stream: s,
2130
2364
  stream_exact: true,
2131
2365
  with_snaps: true
2132
2366
  });
2133
- (0, import_vitest4.expect)(back).toHaveLength(2);
2134
- (0, import_vitest4.expect)(
2367
+ (0, import_vitest6.expect)(back).toHaveLength(2);
2368
+ (0, import_vitest6.expect)(
2135
2369
  back.every((e) => e.name !== import_act.SNAP_EVENT)
2136
2370
  ).toBe(true);
2137
2371
  });
2138
- (0, import_vitest4.it)("on_progress fires once per event (caller throttles)", async () => {
2372
+ (0, import_vitest6.it)("on_progress fires once per event (caller throttles)", async () => {
2139
2373
  const calls = [];
2140
2374
  const s = `restore-progress-${uid()}`;
2141
2375
  const t = /* @__PURE__ */ new Date("2021-02-01T00:00:00.000Z");
@@ -2146,11 +2380,11 @@ var runStoreTck = (options) => {
2146
2380
  ]),
2147
2381
  { on_progress: (p) => calls.push(p.processed) }
2148
2382
  );
2149
- (0, import_vitest4.expect)(calls).toEqual([1, 2]);
2383
+ (0, import_vitest6.expect)(calls).toEqual([1, 2]);
2150
2384
  });
2151
2385
  });
2152
- import_vitest4.describe.skipIf(!caps.pii_isolation)("pii_isolation (capability)", () => {
2153
- (0, import_vitest4.it)("commits and loads pii alongside data", async () => {
2386
+ import_vitest6.describe.skipIf(!caps.pii_isolation)("pii_isolation (capability)", () => {
2387
+ (0, import_vitest6.it)("commits and loads pii alongside data", async () => {
2154
2388
  const s = `pii-roundtrip-${uid()}`;
2155
2389
  const committed = await store.commit(
2156
2390
  s,
@@ -2163,8 +2397,8 @@ var runStoreTck = (options) => {
2163
2397
  ],
2164
2398
  make_meta({ stream: s })
2165
2399
  );
2166
- (0, import_vitest4.expect)(committed).toHaveLength(1);
2167
- (0, import_vitest4.expect)(committed[0].pii).toEqual({
2400
+ (0, import_vitest6.expect)(committed).toHaveLength(1);
2401
+ (0, import_vitest6.expect)(committed[0].pii).toEqual({
2168
2402
  email: "u@example.com",
2169
2403
  name: "Ursula"
2170
2404
  });
@@ -2175,11 +2409,11 @@ var runStoreTck = (options) => {
2175
2409
  },
2176
2410
  { stream: s, stream_exact: true }
2177
2411
  );
2178
- (0, import_vitest4.expect)(seen).toHaveLength(1);
2179
- (0, import_vitest4.expect)(seen[0].pii).toEqual({ email: "u@example.com", name: "Ursula" });
2180
- (0, import_vitest4.expect)(seen[0].data).toEqual({ amount: 1 });
2412
+ (0, import_vitest6.expect)(seen).toHaveLength(1);
2413
+ (0, import_vitest6.expect)(seen[0].pii).toEqual({ email: "u@example.com", name: "Ursula" });
2414
+ (0, import_vitest6.expect)(seen[0].data).toEqual({ amount: 1 });
2181
2415
  });
2182
- (0, import_vitest4.it)("passes through events without pii (pii is null or undefined on load)", async () => {
2416
+ (0, import_vitest6.it)("passes through events without pii (pii is null or undefined on load)", async () => {
2183
2417
  const s = `pii-none-${uid()}`;
2184
2418
  await store.commit(
2185
2419
  s,
@@ -2193,10 +2427,10 @@ var runStoreTck = (options) => {
2193
2427
  },
2194
2428
  { stream: s, stream_exact: true }
2195
2429
  );
2196
- (0, import_vitest4.expect)(seen).toHaveLength(1);
2197
- (0, import_vitest4.expect)(seen[0].pii == null).toBe(true);
2430
+ (0, import_vitest6.expect)(seen).toHaveLength(1);
2431
+ (0, import_vitest6.expect)(seen[0].pii == null).toBe(true);
2198
2432
  });
2199
- (0, import_vitest4.it)("wipes pii for every event on the stream via forget_pii", async () => {
2433
+ (0, import_vitest6.it)("wipes pii for every event on the stream via forget_pii", async () => {
2200
2434
  const s = `pii-forget-${uid()}`;
2201
2435
  await store.commit(
2202
2436
  s,
@@ -2215,9 +2449,9 @@ var runStoreTck = (options) => {
2215
2449
  make_meta({ stream: s })
2216
2450
  );
2217
2451
  const forget = store.forget_pii;
2218
- (0, import_vitest4.expect)(forget).toBeDefined();
2452
+ (0, import_vitest6.expect)(forget).toBeDefined();
2219
2453
  const wiped = await forget.call(store, s);
2220
- (0, import_vitest4.expect)(wiped).toBe(2);
2454
+ (0, import_vitest6.expect)(wiped).toBe(2);
2221
2455
  const seen = [];
2222
2456
  await store.query(
2223
2457
  (e) => {
@@ -2225,13 +2459,13 @@ var runStoreTck = (options) => {
2225
2459
  },
2226
2460
  { stream: s, stream_exact: true }
2227
2461
  );
2228
- (0, import_vitest4.expect)(seen).toHaveLength(2);
2462
+ (0, import_vitest6.expect)(seen).toHaveLength(2);
2229
2463
  for (const e of seen) {
2230
- (0, import_vitest4.expect)(e.pii == null).toBe(true);
2231
- (0, import_vitest4.expect)(e.data).toBeDefined();
2464
+ (0, import_vitest6.expect)(e.pii == null).toBe(true);
2465
+ (0, import_vitest6.expect)(e.data).toBeDefined();
2232
2466
  }
2233
2467
  });
2234
- (0, import_vitest4.it)("is idempotent \u2014 second forget_pii returns 0, no error", async () => {
2468
+ (0, import_vitest6.it)("is idempotent \u2014 second forget_pii returns 0, no error", async () => {
2235
2469
  const s = `pii-forget-idem-${uid()}`;
2236
2470
  await store.commit(
2237
2471
  s,
@@ -2246,11 +2480,11 @@ var runStoreTck = (options) => {
2246
2480
  );
2247
2481
  const forget = store.forget_pii;
2248
2482
  const first = await forget.call(store, s);
2249
- (0, import_vitest4.expect)(first).toBe(1);
2483
+ (0, import_vitest6.expect)(first).toBe(1);
2250
2484
  const second = await forget.call(store, s);
2251
- (0, import_vitest4.expect)(second).toBe(0);
2485
+ (0, import_vitest6.expect)(second).toBe(0);
2252
2486
  });
2253
- (0, import_vitest4.it)("only wipes the targeted stream \u2014 siblings untouched", async () => {
2487
+ (0, import_vitest6.it)("only wipes the targeted stream \u2014 siblings untouched", async () => {
2254
2488
  const sA = `pii-iso-a-${uid()}`;
2255
2489
  const sB = `pii-iso-b-${uid()}`;
2256
2490
  await store.commit(
@@ -2283,7 +2517,7 @@ var runStoreTck = (options) => {
2283
2517
  },
2284
2518
  { stream: sA, stream_exact: true }
2285
2519
  );
2286
- (0, import_vitest4.expect)(a[0].pii == null).toBe(true);
2520
+ (0, import_vitest6.expect)(a[0].pii == null).toBe(true);
2287
2521
  const b = [];
2288
2522
  await store.query(
2289
2523
  (e) => {
@@ -2291,9 +2525,9 @@ var runStoreTck = (options) => {
2291
2525
  },
2292
2526
  { stream: sB, stream_exact: true }
2293
2527
  );
2294
- (0, import_vitest4.expect)(b[0].pii).toEqual({ email: "bob@example.com" });
2528
+ (0, import_vitest6.expect)(b[0].pii).toEqual({ email: "bob@example.com" });
2295
2529
  });
2296
- (0, import_vitest4.it)("forget_pii on a stream with no pii events returns 0", async () => {
2530
+ (0, import_vitest6.it)("forget_pii on a stream with no pii events returns 0", async () => {
2297
2531
  const s = `pii-forget-empty-${uid()}`;
2298
2532
  await store.commit(
2299
2533
  s,
@@ -2301,14 +2535,14 @@ var runStoreTck = (options) => {
2301
2535
  make_meta({ stream: s })
2302
2536
  );
2303
2537
  const wiped = await store.forget_pii.call(store, s);
2304
- (0, import_vitest4.expect)(wiped).toBe(0);
2538
+ (0, import_vitest6.expect)(wiped).toBe(0);
2305
2539
  });
2306
2540
  });
2307
2541
  if (caps.notify) {
2308
- (0, import_vitest4.describe)("notify (capability)", () => {
2309
- (0, import_vitest4.it)("delivers a notification when a different instance commits", async () => {
2542
+ (0, import_vitest6.describe)("notify (capability)", () => {
2543
+ (0, import_vitest6.it)("delivers a notification when a different instance commits", async () => {
2310
2544
  const notify = store.notify;
2311
- (0, import_vitest4.expect)(notify).toBeDefined();
2545
+ (0, import_vitest6.expect)(notify).toBeDefined();
2312
2546
  const received = [];
2313
2547
  let resolve_arrived;
2314
2548
  const arrived = new Promise((res) => {
@@ -2327,9 +2561,9 @@ var runStoreTck = (options) => {
2327
2561
  make_meta({ stream })
2328
2562
  );
2329
2563
  await arrived;
2330
- (0, import_vitest4.expect)(received.length).toBeGreaterThanOrEqual(1);
2331
- (0, import_vitest4.expect)(received[0].stream).toBe(stream);
2332
- (0, import_vitest4.expect)(received[0].events.length).toBeGreaterThanOrEqual(1);
2564
+ (0, import_vitest6.expect)(received.length).toBeGreaterThanOrEqual(1);
2565
+ (0, import_vitest6.expect)(received[0].stream).toBe(stream);
2566
+ (0, import_vitest6.expect)(received[0].events.length).toBeGreaterThanOrEqual(1);
2333
2567
  } finally {
2334
2568
  await writer.dispose();
2335
2569
  await Promise.resolve(disposer());
@@ -2354,6 +2588,7 @@ var runStoreTck = (options) => {
2354
2588
  runCacheTck,
2355
2589
  runLoggerTck,
2356
2590
  runStabilityTck,
2591
+ runStorePropertyTck,
2357
2592
  runStoreTck,
2358
2593
  uid
2359
2594
  });