@rotorsoft/act-tck 1.38.19 → 1.38.21

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.
@@ -1 +1 @@
1
- {"version":3,"file":"store-tck.d.ts","sourceRoot":"","sources":["../../src/store-tck.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAQV,KAAK,EAIN,MAAM,sBAAsB,CAAC;AAc9B;;;;GAIG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B;;;;;;;;;;;OAWG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAC1B;;;;;;OAMG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAC3B;;;;;;;;;OASG;IACH,QAAQ,CAAC,iBAAiB,CAAC,EAAE,OAAO,CAAC;IACrC;;;;;;;OAOG;IACH,QAAQ,CAAC,aAAa,CAAC,EAAE,OAAO,CAAC;IACjC;;;;;;;;;OASG;IACH,QAAQ,CAAC,gBAAgB,CAAC,EAAE,OAAO,CAAC;IACpC;;;;;;;;OAQG;IACH,QAAQ,CAAC,cAAc,CAAC,EAAE,OAAO,CAAC;IAClC;;;;;;;;;;;;;;OAcG;IACH,QAAQ,CAAC,oBAAoB,CAAC,EAAE,OAAO,CAAC;IACxC;;;;;;;;OAQG;IACH,QAAQ,CAAC,gCAAgC,CAAC,EAAE,OAAO,CAAC;IACpD;;;;;;;;;;;;;;OAcG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;CAC7B,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB;;;;;;;OAOG;IACH,QAAQ,CAAC,OAAO,EAAE,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;IAC/C;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;IACxD;;OAEG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,iBAAiB,CAAC;CAC3C,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AACH,eAAO,MAAM,WAAW,YAAa,eAAe,KAAG,IAgzKtD,CAAC"}
1
+ {"version":3,"file":"store-tck.d.ts","sourceRoot":"","sources":["../../src/store-tck.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAQV,KAAK,EAIN,MAAM,sBAAsB,CAAC;AAe9B;;;;GAIG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B;;;;;;;;;;;OAWG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAC1B;;;;;;OAMG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAC3B;;;;;;;;;OASG;IACH,QAAQ,CAAC,iBAAiB,CAAC,EAAE,OAAO,CAAC;IACrC;;;;;;;OAOG;IACH,QAAQ,CAAC,aAAa,CAAC,EAAE,OAAO,CAAC;IACjC;;;;;;;;;OASG;IACH,QAAQ,CAAC,gBAAgB,CAAC,EAAE,OAAO,CAAC;IACpC;;;;;;;;OAQG;IACH,QAAQ,CAAC,cAAc,CAAC,EAAE,OAAO,CAAC;IAClC;;;;;;;;;;;;;;OAcG;IACH,QAAQ,CAAC,oBAAoB,CAAC,EAAE,OAAO,CAAC;IACxC;;;;;;;;OAQG;IACH,QAAQ,CAAC,gCAAgC,CAAC,EAAE,OAAO,CAAC;IACpD;;;;;;;;;;;;;;OAcG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;CAC7B,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB;;;;;;;OAOG;IACH,QAAQ,CAAC,OAAO,EAAE,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;IAC/C;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;IACxD;;OAEG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,iBAAiB,CAAC;CAC3C,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AACH,eAAO,MAAM,WAAW,YAAa,eAAe,KAAG,IAmgLtD,CAAC"}
package/dist/index.cjs CHANGED
@@ -189,9 +189,9 @@ var runCacheDifferentialTck = (options) => {
189
189
 
190
190
  // src/cache-tck.ts
191
191
  var import_vitest2 = require("vitest");
192
- var entry = (event_id, state = {}, stream = `s-${event_id}`) => ({
192
+ var entry = (event_id, state2 = {}, stream = `s-${event_id}`) => ({
193
193
  stream,
194
- state,
194
+ state: state2,
195
195
  version: event_id,
196
196
  event_id,
197
197
  patches: 1,
@@ -417,7 +417,7 @@ async function load_surface(entry2) {
417
417
  if (visited.has(abs)) return;
418
418
  const content = await import_node_fs.promises.readFile(abs, "utf8");
419
419
  visited.set(abs, content);
420
- const re_export = /^\s*(?:import|export)\b[^"';]*\bfrom\s+["'](\.[^"']+)["']/gm;
420
+ const re_export = /^\s*export\b[^"';]*\bfrom\s+["'](\.[^"']+)["']/gm;
421
421
  for (const m of content.matchAll(re_export)) {
422
422
  const rel = m[1].replace(/\.js$/, ".ts");
423
423
  const target = import_node_path.default.resolve(import_node_path.default.dirname(abs), rel);
@@ -1163,6 +1163,7 @@ var runStorePropertyTck = (options) => {
1163
1163
  // src/store-tck.ts
1164
1164
  var import_act2 = require("@rotorsoft/act");
1165
1165
  var import_vitest9 = require("vitest");
1166
+ var import_zod2 = require("zod");
1166
1167
  var runStoreTck = (options) => {
1167
1168
  (0, import_vitest9.describe)(`TCK / Store / ${options.name}`, () => {
1168
1169
  let store;
@@ -2196,7 +2197,7 @@ var runStoreTck = (options) => {
2196
2197
  const second = await store.claim(0, 100, `w-${uid()}`, 1);
2197
2198
  (0, import_vitest9.expect)(second.find((l) => l.stream === s)).toBeDefined();
2198
2199
  });
2199
- (0, import_vitest9.it)("does not starve a default-priority lagging stream under sustained high-priority load (ACT-1223)", async () => {
2200
+ (0, import_vitest9.it)("does not starve a default-priority lagging stream under sustained high-priority load", async () => {
2200
2201
  const fresh = await options.factory();
2201
2202
  try {
2202
2203
  await fresh.drop();
@@ -2598,7 +2599,7 @@ var runStoreTck = (options) => {
2598
2599
  const again = await store.claim(100, 100, `w2-${uid()}`, 1e5);
2599
2600
  (0, import_vitest9.expect)(again.find((l) => l.stream === s)).toBeUndefined();
2600
2601
  });
2601
- (0, import_vitest9.it)("returns the post-block row, not the caller's lease (#1382)", async () => {
2602
+ (0, import_vitest9.it)("returns the post-block row, not the caller's lease", async () => {
2602
2603
  const s = `block-returns-${uid()}`;
2603
2604
  await store.subscribe([{ stream: s }]);
2604
2605
  await store.commit(
@@ -2643,7 +2644,7 @@ var runStoreTck = (options) => {
2643
2644
  ]);
2644
2645
  (0, import_vitest9.expect)(blocked).toHaveLength(0);
2645
2646
  });
2646
- (0, import_vitest9.it)("re-blocking an already-blocked stream is a no-op (#1263)", async () => {
2647
+ (0, import_vitest9.it)("re-blocking an already-blocked stream is a no-op", async () => {
2647
2648
  const s = `block-twice-${uid()}`;
2648
2649
  await store.subscribe([{ stream: s }]);
2649
2650
  await store.commit(
@@ -2761,7 +2762,7 @@ var runStoreTck = (options) => {
2761
2762
  const leased = await store.claim(100, 100, `w-${uid()}`, 1e5);
2762
2763
  (0, import_vitest9.expect)(leased.find((l) => l.stream === s)).toBeDefined();
2763
2764
  });
2764
- (0, import_vitest9.it)("exposes a future deferred_at via query_streams (#1221)", async () => {
2765
+ (0, import_vitest9.it)("exposes a future deferred_at via query_streams", async () => {
2765
2766
  const deferred = `defer-qs-${uid()}`;
2766
2767
  const plain = `defer-qs-plain-${uid()}`;
2767
2768
  await store.subscribe([{ stream: deferred }, { stream: plain }]);
@@ -2816,7 +2817,7 @@ var runStoreTck = (options) => {
2816
2817
  (0, import_vitest9.expect)(await store.defer([`missing-${uid()}`], Date.now())).toBe(0);
2817
2818
  (0, import_vitest9.expect)(await store.defer([], Date.now())).toBe(0);
2818
2819
  });
2819
- (0, import_vitest9.it)("counts a duplicated stream name once (#1360)", async () => {
2820
+ (0, import_vitest9.it)("counts a duplicated stream name once", async () => {
2820
2821
  const s = `defer-dup-${uid()}`;
2821
2822
  await store.subscribe([{ stream: s }]);
2822
2823
  await store.commit(
@@ -2882,7 +2883,7 @@ var runStoreTck = (options) => {
2882
2883
  (0, import_vitest9.expect)(re.retry).toBe(0);
2883
2884
  await store.ack([{ ...re, at: 1e6 }]);
2884
2885
  });
2885
- (0, import_vitest9.it)("persists the lease's retry on a backoff-style due lease (#1262)", async () => {
2886
+ (0, import_vitest9.it)("persists the lease's retry on a backoff-style due lease", async () => {
2886
2887
  const s = `ackdefer-retry-${uid()}`;
2887
2888
  await store.subscribe([{ stream: s }]);
2888
2889
  await store.commit(
@@ -2902,7 +2903,7 @@ var runStoreTck = (options) => {
2902
2903
  (0, import_vitest9.expect)(re.retry).toBe(4);
2903
2904
  await store.ack([{ ...re, at: 1e6 }]);
2904
2905
  });
2905
- (0, import_vitest9.it)("advances the watermark to `at` while persisting the schedule on a partial-progress due lease (#1278)", async () => {
2906
+ (0, import_vitest9.it)("advances the watermark to `at` while persisting the schedule on a partial-progress due lease", async () => {
2906
2907
  const s = `ackadvance-${uid()}`;
2907
2908
  await store.subscribe([{ stream: s }]);
2908
2909
  const [e1] = await store.commit(
@@ -2992,7 +2993,7 @@ var runStoreTck = (options) => {
2992
2993
  (0, import_vitest9.expect)(await store.reset([`missing-${uid()}`])).toBe(0);
2993
2994
  (0, import_vitest9.expect)(await store.reset([])).toBe(0);
2994
2995
  });
2995
- (0, import_vitest9.it)("counts a duplicated stream name once (#1360)", async () => {
2996
+ (0, import_vitest9.it)("counts a duplicated stream name once", async () => {
2996
2997
  const s = `reset-dup-${uid()}`;
2997
2998
  await store.subscribe([{ stream: s }]);
2998
2999
  await store.commit(
@@ -3264,6 +3265,106 @@ var runStoreTck = (options) => {
3264
3265
  (0, import_vitest9.expect)(got1.priority).toBe(3);
3265
3266
  (0, import_vitest9.expect)(got2.priority).toBe(5);
3266
3267
  });
3268
+ (0, import_vitest9.it)("matches a stream pattern", async () => {
3269
+ const tag = uid();
3270
+ await store.subscribe([
3271
+ { stream: `pri-${tag}-proj-a` },
3272
+ { stream: `pri-${tag}-proj-b` },
3273
+ { stream: `pri-${tag}-audit-x` }
3274
+ ]);
3275
+ (0, import_vitest9.expect)(
3276
+ await store.prioritize({ stream: `^pri-${tag}-proj-.*$` }, 3)
3277
+ ).toBe(2);
3278
+ });
3279
+ (0, import_vitest9.it)("matches by source, skipping rows that have none", async () => {
3280
+ const tag = uid();
3281
+ await store.subscribe([
3282
+ { stream: `pri-${tag}-t1`, source: `pri-src-${tag}-users` },
3283
+ { stream: `pri-${tag}-t2`, source: `pri-src-${tag}-audit` },
3284
+ { stream: `pri-${tag}-t3` }
3285
+ ]);
3286
+ (0, import_vitest9.expect)(
3287
+ await store.prioritize(
3288
+ { source: `pri-src-${tag}-users`, source_exact: true },
3289
+ 4
3290
+ )
3291
+ ).toBe(1);
3292
+ (0, import_vitest9.expect)(
3293
+ await store.prioritize({ source: `^pri-src-${tag}-.*$` }, 6)
3294
+ ).toBe(2);
3295
+ });
3296
+ (0, import_vitest9.it)("matches by blocked state, both ways", async () => {
3297
+ const fresh = await options.factory();
3298
+ try {
3299
+ await fresh.drop();
3300
+ await fresh.seed();
3301
+ const tag = uid();
3302
+ const src = `pri-src-${tag}`;
3303
+ const ok = `pri-${tag}-ok`;
3304
+ const bad = `pri-${tag}-bad`;
3305
+ await fresh.commit(
3306
+ src,
3307
+ [inc(1)],
3308
+ make_meta({ stream: src })
3309
+ );
3310
+ await fresh.subscribe([
3311
+ { stream: ok, source: src },
3312
+ { stream: bad, source: src }
3313
+ ]);
3314
+ await correlate(fresh);
3315
+ const leases = await fresh.claim(2, 0, `w-${uid()}`, 5e3);
3316
+ const lease = leases.find((l) => l.stream === bad);
3317
+ await fresh.block([{ ...lease, error: "boom" }]);
3318
+ const scope = `^pri-${tag}-.*$`;
3319
+ (0, import_vitest9.expect)(
3320
+ await fresh.prioritize({ stream: scope, blocked: true }, 9)
3321
+ ).toBe(1);
3322
+ (0, import_vitest9.expect)(
3323
+ await fresh.prioritize({ stream: scope, blocked: false }, 9)
3324
+ ).toBe(1);
3325
+ } finally {
3326
+ await fresh.dispose();
3327
+ }
3328
+ });
3329
+ (0, import_vitest9.it)("an empty filter updates every row, and skips rows already at the value", async () => {
3330
+ const fresh = await options.factory();
3331
+ try {
3332
+ await fresh.drop();
3333
+ await fresh.seed();
3334
+ const tag = uid();
3335
+ await fresh.subscribe([
3336
+ { stream: `pri-${tag}-a` },
3337
+ { stream: `pri-${tag}-b`, priority: 5 }
3338
+ ]);
3339
+ (0, import_vitest9.expect)(await fresh.prioritize({}, 5)).toBe(1);
3340
+ (0, import_vitest9.expect)(await fresh.prioritize({}, 5)).toBe(0);
3341
+ } finally {
3342
+ await fresh.dispose();
3343
+ }
3344
+ });
3345
+ (0, import_vitest9.it)("claim returns higher-priority streams first under tied watermarks", async () => {
3346
+ const fresh = await options.factory();
3347
+ try {
3348
+ await fresh.drop();
3349
+ await fresh.seed();
3350
+ const tag = uid();
3351
+ const src = `pri-src-${tag}`;
3352
+ await fresh.commit(
3353
+ src,
3354
+ [inc(1), inc(2)],
3355
+ make_meta({ stream: src })
3356
+ );
3357
+ await fresh.subscribe([
3358
+ { stream: `pri-${tag}-low`, source: src, priority: 0 },
3359
+ { stream: `pri-${tag}-high`, source: src, priority: 5 }
3360
+ ]);
3361
+ await correlate(fresh);
3362
+ const leases = await fresh.claim(1, 0, `w-${uid()}`, 5e3);
3363
+ (0, import_vitest9.expect)(leases.map((l) => l.stream)).toEqual([`pri-${tag}-high`]);
3364
+ } finally {
3365
+ await fresh.dispose();
3366
+ }
3367
+ });
3267
3368
  });
3268
3369
  (0, import_vitest9.describe)("lanes", () => {
3269
3370
  (0, import_vitest9.it)("subscribe defaults lane to 'default' when omitted", async () => {
@@ -3477,7 +3578,7 @@ var runStoreTck = (options) => {
3477
3578
  });
3478
3579
  });
3479
3580
  (0, import_vitest9.describe)("long identifiers", () => {
3480
- (0, import_vitest9.it)("accepts a stream name well past 100 characters (#1420)", async () => {
3581
+ (0, import_vitest9.it)("accepts a stream name well past 100 characters", async () => {
3481
3582
  const tag = uid();
3482
3583
  const long = `${tag}-${"x".repeat(140)}`;
3483
3584
  await store.commit(
@@ -3500,7 +3601,7 @@ var runStoreTck = (options) => {
3500
3601
  });
3501
3602
  });
3502
3603
  (0, import_vitest9.describe)("truncate", () => {
3503
- (0, import_vitest9.it)("leaves subscriptions untouched for restart and retire alike (#1527)", async () => {
3604
+ (0, import_vitest9.it)("leaves subscriptions untouched for restart and retire alike", async () => {
3504
3605
  const tag = uid();
3505
3606
  const restarted = `trunc-restart-${tag}`;
3506
3607
  const retired = `trunc-retire-${tag}`;
@@ -3528,7 +3629,7 @@ var runStoreTck = (options) => {
3528
3629
  (0, import_vitest9.expect)(rows).toContain(restarted);
3529
3630
  (0, import_vitest9.expect)(rows).toContain(retired);
3530
3631
  });
3531
- (0, import_vitest9.it)("leaves a retired stream's surviving subscription unclaimable (#1527)", async () => {
3632
+ (0, import_vitest9.it)("leaves a retired stream's surviving subscription unclaimable", async () => {
3532
3633
  const lane = `inert-lane-${uid()}`;
3533
3634
  const s = `trunc-inert-${uid()}`;
3534
3635
  const [e] = await store.commit(
@@ -3590,7 +3691,7 @@ var runStoreTck = (options) => {
3590
3691
  );
3591
3692
  (0, import_vitest9.expect)(remaining[0].data).toEqual({ count: 7 });
3592
3693
  });
3593
- (0, import_vitest9.it)("leaves exactly one seed when a stream is listed twice (#1677)", async () => {
3694
+ (0, import_vitest9.it)("leaves exactly one seed when a stream is listed twice", async () => {
3594
3695
  const s = `trunc-dup-${uid()}`;
3595
3696
  await store.commit(
3596
3697
  s,
@@ -3612,7 +3713,7 @@ var runStoreTck = (options) => {
3612
3713
  (0, import_vitest9.expect)(remaining[0].data).toEqual({ count: 2 });
3613
3714
  (0, import_vitest9.expect)(result.get(s)?.deleted).toBe(1);
3614
3715
  });
3615
- (0, import_vitest9.it)("applies windowed targets before full ones (#1677)", async () => {
3716
+ (0, import_vitest9.it)("applies windowed targets before full ones", async () => {
3616
3717
  const s = `trunc-mix-${uid()}`;
3617
3718
  await store.commit(
3618
3719
  s,
@@ -3816,7 +3917,7 @@ var runStoreTck = (options) => {
3816
3917
  });
3817
3918
  });
3818
3919
  (0, import_vitest9.describe)("query_streams", () => {
3819
- (0, import_vitest9.it)("keyset pagination visits every stream regardless of name case (#1375)", async () => {
3920
+ (0, import_vitest9.it)("keyset pagination visits every stream regardless of name case", async () => {
3820
3921
  const tag = uid();
3821
3922
  const names = [
3822
3923
  `${tag}-Bravo`,
@@ -4011,7 +4112,7 @@ var runStoreTck = (options) => {
4011
4112
  });
4012
4113
  (0, import_vitest9.expect)(stats.size).toBe(0);
4013
4114
  });
4014
- (0, import_vitest9.it)("keyset pagination visits every stream regardless of name case (#1357)", async () => {
4115
+ (0, import_vitest9.it)("keyset pagination visits every stream regardless of name case", async () => {
4015
4116
  const tag = uid();
4016
4117
  const names = [
4017
4118
  `${tag}-Bravo`,
@@ -4304,6 +4405,43 @@ var runStoreTck = (options) => {
4304
4405
  });
4305
4406
  (0, import_vitest9.expect)([...all.keys()].sort()).toEqual([...streams].sort());
4306
4407
  });
4408
+ (0, import_vitest9.it)("pages the count and tail paths by limit + after too", async () => {
4409
+ const tag = uid();
4410
+ for (const s of [`qsc-${tag}-c`, `qsc-${tag}-a`, `qsc-${tag}-b`])
4411
+ await store.commit(
4412
+ s,
4413
+ [inc(1), inc(2)],
4414
+ make_meta({ stream: s })
4415
+ );
4416
+ const pattern = { stream: `qsc-${tag}-.*` };
4417
+ const counted = await store.query_stats(pattern, {
4418
+ count: true,
4419
+ names: true,
4420
+ limit: 2
4421
+ });
4422
+ (0, import_vitest9.expect)([...counted.keys()]).toEqual([`qsc-${tag}-a`, `qsc-${tag}-b`]);
4423
+ (0, import_vitest9.expect)(counted.get(`qsc-${tag}-a`)?.count).toBe(2);
4424
+ (0, import_vitest9.expect)(counted.get(`qsc-${tag}-a`)?.names).toEqual({ Incremented: 2 });
4425
+ const counted2 = await store.query_stats(pattern, {
4426
+ count: true,
4427
+ limit: 2,
4428
+ after: `qsc-${tag}-b`
4429
+ });
4430
+ (0, import_vitest9.expect)([...counted2.keys()]).toEqual([`qsc-${tag}-c`]);
4431
+ const tailed = await store.query_stats(pattern, {
4432
+ tail: true,
4433
+ limit: 2
4434
+ });
4435
+ (0, import_vitest9.expect)([...tailed.keys()]).toEqual([`qsc-${tag}-a`, `qsc-${tag}-b`]);
4436
+ (0, import_vitest9.expect)(tailed.get(`qsc-${tag}-a`)?.head.version).toBe(1);
4437
+ (0, import_vitest9.expect)(tailed.get(`qsc-${tag}-a`)?.tail?.version).toBe(0);
4438
+ const tailed2 = await store.query_stats(pattern, {
4439
+ tail: true,
4440
+ limit: 2,
4441
+ after: `qsc-${tag}-b`
4442
+ });
4443
+ (0, import_vitest9.expect)([...tailed2.keys()]).toEqual([`qsc-${tag}-c`]);
4444
+ });
4307
4445
  });
4308
4446
  import_vitest9.describe.skipIf(!caps.source_matches)(
4309
4447
  "query_streams source_matches (capability)",
@@ -4434,6 +4572,52 @@ var runStoreTck = (options) => {
4434
4572
  (0, import_vitest9.expect)(positions).toEqual([s]);
4435
4573
  });
4436
4574
  });
4575
+ (0, import_vitest9.describe)("autoclose end-to-end", () => {
4576
+ const Ticket = (0, import_act2.state)({ TckTicket: import_zod2.z.object({ open: import_zod2.z.boolean() }) }).init(() => ({ open: false })).emits({
4577
+ TckTicketOpened: import_zod2.z.object({ title: import_zod2.z.string() }),
4578
+ TckTicketResolved: import_zod2.z.object({})
4579
+ }).patch({
4580
+ TckTicketOpened: () => ({ open: true }),
4581
+ TckTicketResolved: () => ({ open: false })
4582
+ }).on({ OpenTckTicket: import_zod2.z.object({ title: import_zod2.z.string() }) }).emit((a) => ["TckTicketOpened", { title: a.title }]).on({ ResolveTckTicket: import_zod2.z.object({}) }).emit(() => ["TckTicketResolved", {}]).autocloses({ is: "TckTicketResolved" }).build();
4583
+ const actor2 = { id: "tck", name: "tck" };
4584
+ const run = async (resolve) => {
4585
+ const fresh = await options.factory();
4586
+ await fresh.drop();
4587
+ await fresh.seed();
4588
+ const cache = new import_act2.InMemoryCache();
4589
+ const app = (0, import_act2.act)().withState(Ticket).build({ scoped: { store: fresh, cache } });
4590
+ const truncated = [];
4591
+ app.on("closed", (r) => truncated.push(...r.truncated.keys()));
4592
+ const stream = `ac-${uid()}`;
4593
+ try {
4594
+ await app.do("OpenTckTicket", { stream, actor: actor2 }, { title: "a" });
4595
+ if (resolve) await app.do("ResolveTckTicket", { stream, actor: actor2 }, {});
4596
+ await app.correlate();
4597
+ await app.drain();
4598
+ const surviving = [];
4599
+ await fresh.query((e) => surviving.push(String(e.name)), {
4600
+ stream,
4601
+ stream_exact: true
4602
+ });
4603
+ return { stream, truncated, surviving };
4604
+ } finally {
4605
+ await app.shutdown();
4606
+ await cache.dispose();
4607
+ await fresh.dispose();
4608
+ }
4609
+ };
4610
+ (0, import_vitest9.it)("closes a stream whose head is the terminal event, leaving a tombstone", async () => {
4611
+ const { stream, truncated, surviving } = await run(true);
4612
+ (0, import_vitest9.expect)(truncated).toContain(stream);
4613
+ (0, import_vitest9.expect)(surviving).toEqual([import_act2.TOMBSTONE_EVENT]);
4614
+ });
4615
+ (0, import_vitest9.it)("leaves a stream whose head is not the terminal event", async () => {
4616
+ const { stream, truncated, surviving } = await run(false);
4617
+ (0, import_vitest9.expect)(truncated).not.toContain(stream);
4618
+ (0, import_vitest9.expect)(surviving).toEqual(["TckTicketOpened"]);
4619
+ });
4620
+ });
4437
4621
  (0, import_vitest9.describe)("seed_stream helper coverage", () => {
4438
4622
  (0, import_vitest9.it)("commits N events with monotonically increasing ids", async () => {
4439
4623
  const s = `seed-${uid()}`;
@@ -5072,7 +5256,7 @@ var runStoreTck = (options) => {
5072
5256
  (0, import_vitest9.expect)(seen[0].pii).toEqual({ email: "u@example.com", name: "Ursula" });
5073
5257
  (0, import_vitest9.expect)(seen[0].data).toEqual({ amount: 1 });
5074
5258
  });
5075
- (0, import_vitest9.describe)("with_pii (#1675)", () => {
5259
+ (0, import_vitest9.describe)("with_pii", () => {
5076
5260
  const seed_pii = async (s) => await store.commit(
5077
5261
  s,
5078
5262
  [
@@ -5136,7 +5320,7 @@ var runStoreTck = (options) => {
5136
5320
  for (const e of seen) (0, import_vitest9.expect)(e.pii ?? null).toBeNull();
5137
5321
  });
5138
5322
  });
5139
- (0, import_vitest9.it)("round-trips a Date losslessly in pii, like data/meta (#1365/#1370/#1556)", async () => {
5323
+ (0, import_vitest9.it)("round-trips a Date losslessly in pii, like data/meta", async () => {
5140
5324
  const s = `pii-date-${uid()}`;
5141
5325
  const when = /* @__PURE__ */ new Date("2024-03-01T10:20:30.000Z");
5142
5326
  await store.commit(
@@ -5165,7 +5349,7 @@ var runStoreTck = (options) => {
5165
5349
  (0, import_vitest9.expect)(recovered(born)).toBe(when.getTime());
5166
5350
  (0, import_vitest9.expect)(typeof at).toBe(typeof born);
5167
5351
  });
5168
- (0, import_vitest9.it)("query_stats head/tail never carry pii \u2014 introspection surface is pii-safe (#1294)", async () => {
5352
+ (0, import_vitest9.it)("query_stats head/tail never carry pii \u2014 introspection surface is pii-safe", async () => {
5169
5353
  const s = `pii-stats-${uid()}`;
5170
5354
  await store.commit(
5171
5355
  s,