@streamsy/core 0.10.0 → 0.12.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.
@@ -1,11 +1,193 @@
1
1
  import { L as Storage, Q as ProducerId, R as ZERO_OFFSET, V as next, W as StorageFault, rt as StreamId } from "../streamsy-HKC10a_V.js";
2
- import { n as CommitBoundary, t as layer } from "../layer-CwD1bD5X.js";
3
- import { a as MutationRejected, t as layer$1 } from "../layer-DZOWeK0B.js";
4
- import { i as OwnerRecords, n as CommitHooks, t as ProjectionMarks } from "../projection-marks-RqurLPLA.js";
2
+ import { n as CommitBoundary, t as layer } from "../layer-Bf40J6so.js";
3
+ import { a as MutationRejected, t as layer$1 } from "../layer-DjKTdIY5.js";
4
+ import { g as CommitHooks, h as ProjectionMarks, v as OwnerRecords } from "../marks-B-fXqEYG.js";
5
5
  import { Array, Cause, Context, Deferred, Effect, Exit, Fiber, Layer, Match, Option, Order, Predicate, PubSub, Queue, Record, Ref, Scope, Stream } from "effect";
6
6
  import { SqlError } from "effect/sql";
7
7
  import { describe, expect, it } from "vitest";
8
8
  import { TestClock } from "effect/testing";
9
+ // src/testing/projection-marks-contract.ts
10
+ const check = (condition, message) => condition ? Effect.void : Effect.die(/* @__PURE__ */ new Error(`Projection marks contract: ${message}`));
11
+ /** The pending work, sleep and stop/failure contract, shared by storage hosts and the standalone memory store. */
12
+ const projectionMarksContract = (marks) => Effect.gen(function* () {
13
+ const projection = "marks-contract";
14
+ const failure = {
15
+ at: 123,
16
+ reason: Option.some("invalid-record"),
17
+ message: "x".repeat(1100)
18
+ };
19
+ const savedFailure = {
20
+ ...failure,
21
+ message: "x".repeat(1e3)
22
+ };
23
+ const read = (params) => marks.read(projection, [params]).pipe(Effect.map((rows) => rows.get(params)));
24
+ yield* check((yield* marks.resume(projection)) === 0, "empty resume");
25
+ yield* marks.fail(projection, "a-stop", {
26
+ attempts: 2,
27
+ failure,
28
+ dueAt: Option.none()
29
+ });
30
+ yield* marks.fail(projection, "b-stop", {
31
+ attempts: 1,
32
+ failure: {
33
+ at: 124,
34
+ reason: Option.none(),
35
+ message: "handler"
36
+ },
37
+ dueAt: Option.none()
38
+ });
39
+ yield* check(Option.isNone(yield* marks.nextDue(projection)), "stops have no deadline");
40
+ yield* check((yield* marks.due(projection, Number.MAX_SAFE_INTEGER, 10)).length === 0, "stops never due");
41
+ const stoppedOnly = yield* marks.summary(projection, 4e3);
42
+ yield* check(stoppedOnly.stopped === 2 && stoppedOnly.fresh === 0 && stoppedOnly.sleeping === 0 && stoppedOnly.retryDue === 0 && stoppedOnly.backingOff === 0 && Option.isNone(stoppedOnly.nextDueAt), "stopped-only summary");
43
+ yield* Effect.orDie(marks.mark(projection, ["a-stop"]));
44
+ const raised = yield* read("a-stop");
45
+ yield* check(raised?.seq === 2 && raised.stopped && raised.attempts === 2 && Option.isSome(raised.failure) && raised.failure.value.at === 123 && Option.contains(raised.failure.value.reason, "invalid-record") && raised.failure.value.message === savedFailure.message, "mark preserves stop and truncated failure");
46
+ yield* marks.fail(projection, "future", {
47
+ attempts: 3,
48
+ failure,
49
+ dueAt: Option.some(6e3)
50
+ });
51
+ yield* marks.fail(projection, "past", {
52
+ attempts: 4,
53
+ failure,
54
+ dueAt: Option.some(3e3)
55
+ });
56
+ yield* Effect.orDie(marks.mark(projection, ["fresh"]));
57
+ yield* marks.fail("marks-other", "other", {
58
+ attempts: 1,
59
+ failure,
60
+ dueAt: Option.none()
61
+ });
62
+ yield* marks.sleep(projection, "sleeping", 0, 5e3);
63
+ const summary = yield* marks.summary(projection, 4e3);
64
+ yield* check(summary.fresh === 1 && summary.sleeping === 1 && summary.retryDue === 1 && summary.backingOff === 1 && summary.stopped === 2 && Option.contains(summary.nextDueAt, 0), "five disjoint summary counts");
65
+ const listed = yield* marks.failed(projection, 3);
66
+ yield* check(Array.join(Array.map(listed, (row) => row.params), ",") === "a-stop,b-stop,past", "failed is bounded, stopped first, then dueAt");
67
+ yield* check(Option.isSome(listed[1].failure) && Option.isNone(Option.getOrThrow(listed[1].failure).reason), "handler failure has no reason");
68
+ yield* check((yield* marks.failed(projection, 0)).length === 0, "zero failed limit");
69
+ yield* check((yield* marks.failed("absent", 10)).length === 0, "empty failed listing");
70
+ yield* check(Array.join(Array.map(yield* marks.due(projection, 4e3, 10), (row) => row.params), ",") === "fresh,past", "due excludes stops");
71
+ yield* check((yield* marks.retry(projection, "fresh")) === 0, "retry ignores fresh marks");
72
+ yield* check((yield* marks.retry(projection, "a-stop")) === 1, "retry selects stopped mark at dueAt zero");
73
+ yield* check((yield* marks.retry(projection, "a-stop")) === 0, "repeat retry changes nothing");
74
+ const retried = yield* read("a-stop");
75
+ yield* check(retried?.seq === 2 && retried.attempts === 2 && retried.dueAt === 0 && !retried.stopped && Option.isSome(retried.failure) && retried.failure.value.message === savedFailure.message, "retry preserves seq, attempts and failure");
76
+ yield* check((yield* marks.resume(projection)) === 1, "resume selects remaining stop");
77
+ yield* check((yield* marks.resume(projection)) === 0, "repeat resume changes nothing");
78
+ const resumed = yield* read("b-stop");
79
+ yield* check(resumed?.seq === 1 && resumed.attempts === 1 && resumed.dueAt === 0 && !resumed.stopped && Option.isSome(resumed.failure) && resumed.failure.value.at === 124, "resume preserves failure and attempts");
80
+ yield* check((yield* read("future"))?.dueAt === 6e3, "resume keeps backoff");
81
+ yield* check((yield* marks.summary("marks-other", 0)).stopped === 1, "projection isolation");
82
+ for (const dueAt of [Option.some(9e3), Option.none()]) {
83
+ yield* marks.fail(projection, "moved", {
84
+ attempts: 7,
85
+ failure,
86
+ dueAt
87
+ });
88
+ const before = yield* read("moved");
89
+ yield* Effect.orDie(marks.mark(projection, ["moved"]));
90
+ yield* marks.clear(projection, "moved", before.seq);
91
+ const kept = yield* read("moved");
92
+ yield* check(kept?.seq === before.seq + 1 && kept.attempts === 0 && kept.dueAt === 0 && !kept.stopped && Option.isNone(kept.failure), "clear moved seq resets all failure state");
93
+ yield* marks.clear(projection, "moved", kept.seq);
94
+ yield* check((yield* read("moved")) === void 0, "clear matching seq deletes");
95
+ }
96
+ yield* marks.clear(projection, "absent", 1);
97
+ yield* marks.remove(projection, "b-stop");
98
+ yield* check((yield* read("b-stop")) === void 0, "remove a failed mark");
99
+ yield* marks.fail(projection, "replace", {
100
+ attempts: 1,
101
+ failure,
102
+ dueAt: Option.none()
103
+ });
104
+ yield* marks.fail(projection, "replace", {
105
+ attempts: 2,
106
+ failure: {
107
+ at: 456,
108
+ reason: Option.none(),
109
+ message: "new"
110
+ },
111
+ dueAt: Option.some(7e3)
112
+ });
113
+ const replaced = yield* read("replace");
114
+ yield* check(replaced?.seq === 1 && replaced.attempts === 2 && !replaced.stopped && replaced.dueAt === 7e3 && Option.isSome(replaced.failure) && replaced.failure.value.at === 456 && replaced.failure.value.message === "new" && Option.isNone(replaced.failure.value.reason), "fail replaces failure fields and clears stop");
115
+ const timers = "timer-marks-contract";
116
+ const timer = (key) => marks.read(timers, [key]).pipe(Effect.map((rows) => rows.get(key)));
117
+ yield* marks.sleep(timers, "absent", 0, 5e3);
118
+ const inserted = yield* timer("absent");
119
+ yield* check(inserted.seq === 1 && inserted.dueAt === 5e3 && Option.contains(inserted.wakeAt, 5e3) && inserted.attempts === 0 && !inserted.stopped && Option.isNone(inserted.failure), "sleep inserts absent row");
120
+ yield* check((yield* marks.due(timers, 4999, 10)).length === 0, "not due before wake");
121
+ yield* check(Option.contains(yield* marks.nextDue(timers), 5e3), "nextDue includes sleep");
122
+ const dueSleep = yield* marks.due(timers, 5e3, 10);
123
+ yield* check(dueSleep.length === 1 && Option.contains(dueSleep[0].wakeAt, 5e3), "due at wake");
124
+ yield* check((yield* marks.retry(timers)) === 0 && (yield* marks.resume(timers)) === 0 && (yield* marks.failed(timers, 10)).length === 0 && (yield* timer("absent"))?.dueAt === 5e3, "retry resume failed ignore sleepers");
125
+ yield* marks.sleep(timers, "absent", 1, 6e3);
126
+ yield* check(Option.contains((yield* timer("absent")).wakeAt, 6e3), "matching sleep moves wake");
127
+ yield* Effect.orDie(marks.mark(timers, ["absent"]));
128
+ const woken = yield* timer("absent");
129
+ yield* check(woken.seq === 2 && woken.dueAt === 0 && Option.isNone(woken.wakeAt), "mark wakes sleep now");
130
+ yield* marks.sleep(timers, "absent", 1, 7e3);
131
+ const mismatch = yield* timer("absent");
132
+ yield* check(mismatch.seq === 2 && mismatch.dueAt === 0 && mismatch.attempts === 0 && !mismatch.stopped && Option.isNone(mismatch.wakeAt) && Option.isNone(mismatch.failure), "sleep mismatch stays fresh");
133
+ yield* marks.fail(timers, "absent", {
134
+ attempts: 3,
135
+ failure,
136
+ dueAt: Option.some(8e3)
137
+ });
138
+ yield* Effect.orDie(marks.mark(timers, ["absent"]));
139
+ yield* check((yield* timer("absent"))?.dueAt === 8e3, "mark preserves backoff");
140
+ yield* marks.sleep(timers, "absent", 3, 9e3);
141
+ const reset = yield* timer("absent");
142
+ yield* check(reset.attempts === 0 && !reset.stopped && Option.isNone(reset.failure) && Option.contains(reset.wakeAt, 9e3), "sleep resets failure state");
143
+ yield* marks.clear(timers, "absent", 2);
144
+ yield* check(Option.isNone((yield* timer("absent")).wakeAt) && (yield* timer("absent"))?.dueAt === 0, "clear mismatch clears sleep");
145
+ yield* marks.sleep(timers, "absent", 3, 9e3);
146
+ yield* marks.clear(timers, "absent", 3);
147
+ yield* check((yield* timer("absent")) === void 0, "clear matching sleep deletes");
148
+ for (const dueAt of [Option.some(1e4), Option.none()]) {
149
+ yield* marks.sleep(timers, "failed-sleep", 0, 9e3);
150
+ yield* marks.fail(timers, "failed-sleep", {
151
+ attempts: 1,
152
+ failure,
153
+ dueAt
154
+ });
155
+ yield* check(Option.isNone((yield* timer("failed-sleep")).wakeAt), "fail clears sleep");
156
+ yield* marks.remove(timers, "failed-sleep");
157
+ }
158
+ yield* marks.sleep(timers, "past-sleep", 0, 1);
159
+ yield* check(Option.contains((yield* timer("past-sleep")).wakeAt, 1) && (yield* marks.due(timers, 1e4, 10)).length === 1, "past wake stored unchanged");
160
+ });
161
+ /** Failure writes and state resets join their owner's transaction. */
162
+ const projectionMarksTransactionContract = (marks, boundary) => Effect.gen(function* () {
163
+ const failure = {
164
+ at: 1,
165
+ reason: Option.some("invalid-record"),
166
+ message: "bad"
167
+ };
168
+ yield* marks.fail("rollback-stop", "a", {
169
+ attempts: 2,
170
+ failure,
171
+ dueAt: Option.none()
172
+ });
173
+ yield* Effect.orDie(marks.mark("rollback-stop", ["a"]));
174
+ const before = (yield* marks.read("rollback-stop", ["a"])).get("a");
175
+ for (const change of [
176
+ marks.resume("rollback-stop"),
177
+ marks.sleep("rollback-stop", "a", 2, 20),
178
+ marks.clear("rollback-stop", "a", 1),
179
+ marks.fail("rollback-stop", "a", {
180
+ attempts: 3,
181
+ failure,
182
+ dueAt: Option.some(10)
183
+ })
184
+ ]) {
185
+ const exit = yield* Effect.exit(boundary.withTransaction(change.pipe(Effect.andThen(Effect.fail("rollback")))));
186
+ yield* check(exit._tag === "Failure", "transaction failed");
187
+ const after = (yield* marks.read("rollback-stop", ["a"])).get("a");
188
+ yield* check(after?.seq === before?.seq && after?.attempts === 2 && after.stopped && Option.isSome(after.failure) && after.failure.value.at === 1, "transaction rollback restores stop and failure");
189
+ }
190
+ });
9
191
  // src/testing/storage-contract.ts
10
192
  /** Executable Bun edge: a fresh scoped Layer and virtual clock for every case. */
11
193
  const id = StreamId.make("s");
@@ -253,7 +435,66 @@ const StorageContract = {
253
435
  expect((yield* current).currentOffset).toBe(ZERO_OFFSET);
254
436
  expect(yield* PubSub.takeUpTo(committed, Infinity)).toEqual([]);
255
437
  }));
256
- recordsTest("R7 projection marks raise seq, clear by seq, defer, and list due marks in order", ({ marks }) => Effect.gen(function* () {
438
+ recordsTest("R7c retry selects failed marks, preserves attempts and seq, and rolls back", ({ boundary, marks }) => Effect.gen(function* () {
439
+ expect(yield* marks.retry("retry")).toBe(0);
440
+ yield* Effect.orDie(marks.mark("retry", [
441
+ "fresh",
442
+ "a",
443
+ "b"
444
+ ]));
445
+ yield* Effect.orDie(marks.mark("retry", ["a"]));
446
+ yield* marks.fail("retry", "a", {
447
+ attempts: 3,
448
+ dueAt: Option.some(1e4),
449
+ failure: {
450
+ at: 1,
451
+ reason: Option.none(),
452
+ message: "failed"
453
+ }
454
+ });
455
+ yield* marks.fail("retry", "b", {
456
+ attempts: 1,
457
+ dueAt: Option.some(2e4),
458
+ failure: {
459
+ at: 1,
460
+ reason: Option.none(),
461
+ message: "failed"
462
+ }
463
+ });
464
+ yield* marks.fail("other", "a", {
465
+ attempts: 2,
466
+ dueAt: Option.some(3e4),
467
+ failure: {
468
+ at: 1,
469
+ reason: Option.none(),
470
+ message: "failed"
471
+ }
472
+ });
473
+ expect(yield* marks.retry("retry", "absent")).toBe(0);
474
+ expect(yield* marks.retry("retry", "fresh")).toBe(0);
475
+ expect(yield* marks.retry("retry", "a")).toBe(1);
476
+ expect((yield* marks.read("retry", ["a"])).get("a")).toEqual({
477
+ params: "a",
478
+ seq: 2,
479
+ attempts: 3,
480
+ dueAt: 0,
481
+ wakeAt: Option.none(),
482
+ stopped: false,
483
+ failure: Option.some({
484
+ at: 1,
485
+ reason: Option.none(),
486
+ message: "failed"
487
+ })
488
+ });
489
+ const failed = yield* Effect.exit(boundary.withTransaction(marks.retry("retry").pipe(Effect.andThen(Effect.fail("rollback")))));
490
+ expect(Exit.isFailure(failed)).toBe(true);
491
+ expect((yield* marks.read("retry", ["b"])).get("b")?.dueAt).toBe(2e4);
492
+ expect(yield* marks.retry("retry")).toBe(1);
493
+ expect(yield* marks.retry("retry")).toBe(0);
494
+ expect((yield* marks.failed("retry", 1e3)).length).toBe(2);
495
+ expect((yield* marks.read("other", ["a"])).get("a")?.dueAt).toBe(3e4);
496
+ }));
497
+ recordsTest("R7 projection marks raise seq, clear by seq, fail, and list due marks in order", ({ marks }) => Effect.gen(function* () {
257
498
  expect(yield* marks.nextDue("p")).toEqual(Option.none());
258
499
  yield* Effect.orDie(marks.mark("p", ["a", "b"]));
259
500
  yield* Effect.orDie(marks.mark("p", ["a"]));
@@ -268,13 +509,19 @@ const StorageContract = {
268
509
  params: "a",
269
510
  seq: 2,
270
511
  attempts: 0,
271
- dueAt: 0
512
+ dueAt: 0,
513
+ wakeAt: Option.none(),
514
+ stopped: false,
515
+ failure: Option.none()
272
516
  });
273
517
  expect(read.get("b")).toEqual({
274
518
  params: "b",
275
519
  seq: 1,
276
520
  attempts: 0,
277
- dueAt: 0
521
+ dueAt: 0,
522
+ wakeAt: Option.none(),
523
+ stopped: false,
524
+ failure: Option.none()
278
525
  });
279
526
  expect(yield* marks.nextDue("p")).toEqual(Option.some(0));
280
527
  yield* marks.clear("p", "a", 1);
@@ -282,18 +529,41 @@ const StorageContract = {
282
529
  yield* marks.clear("p", "a", 2);
283
530
  expect((yield* marks.read("p", ["a"])).size).toBe(0);
284
531
  expect((yield* marks.read("q", ["a"])).get("a")?.seq).toBe(1);
285
- yield* marks.defer("p", "b", 1, 5e3);
532
+ yield* marks.fail("p", "b", {
533
+ attempts: 1,
534
+ dueAt: Option.some(5e3),
535
+ failure: {
536
+ at: 1,
537
+ reason: Option.none(),
538
+ message: "failed"
539
+ }
540
+ });
286
541
  yield* Effect.orDie(marks.mark("p", ["b"]));
287
542
  expect((yield* marks.read("p", ["b"])).get("b")).toEqual({
288
543
  params: "b",
289
544
  seq: 2,
290
545
  attempts: 1,
291
- dueAt: 5e3
546
+ dueAt: 5e3,
547
+ wakeAt: Option.none(),
548
+ stopped: false,
549
+ failure: Option.some({
550
+ at: 1,
551
+ reason: Option.none(),
552
+ message: "failed"
553
+ })
292
554
  });
293
- expect(yield* marks.deferred("p")).toBe(1);
555
+ expect((yield* marks.failed("p", 1e3)).length).toBe(1);
294
556
  expect(yield* marks.nextDue("p")).toEqual(Option.some(5e3));
295
- yield* marks.defer("p", "c", 2, 3e3);
296
- expect(yield* marks.deferred("p")).toBe(2);
557
+ yield* marks.fail("p", "c", {
558
+ attempts: 2,
559
+ dueAt: Option.some(3e3),
560
+ failure: {
561
+ at: 1,
562
+ reason: Option.none(),
563
+ message: "failed"
564
+ }
565
+ });
566
+ expect((yield* marks.failed("p", 1e3)).length).toBe(2);
297
567
  yield* Effect.orDie(marks.mark("p", ["e", "d"]));
298
568
  expect(Array.map(yield* marks.due("p", 4e3, 10), (row) => row.params)).toEqual([
299
569
  "d",
@@ -309,7 +579,7 @@ const StorageContract = {
309
579
  ]);
310
580
  yield* marks.remove("p", "b");
311
581
  yield* marks.remove("p", "absent");
312
- expect(yield* marks.deferred("p")).toBe(1);
582
+ expect((yield* marks.failed("p", 1e3)).length).toBe(1);
313
583
  const many = Array.makeBy(150, (index) => `m${String(index).padStart(3, "0")}`);
314
584
  yield* Effect.orDie(marks.mark("many", many));
315
585
  yield* Effect.orDie(marks.mark("many", many));
@@ -318,6 +588,80 @@ const StorageContract = {
318
588
  expect(Array.every([...all.values()], (row) => row.seq === 2)).toBe(true);
319
589
  expect(yield* marks.due("many", 0, 1e3)).toHaveLength(150);
320
590
  }));
591
+ recordsTest("R7b projection mark summaries have disjoint fresh, due retry and backoff counts", ({ marks }) => Effect.gen(function* () {
592
+ expect(yield* marks.summary("summary", 3e3)).toEqual({
593
+ fresh: 0,
594
+ sleeping: 0,
595
+ retryDue: 0,
596
+ backingOff: 0,
597
+ stopped: 0,
598
+ nextDueAt: Option.none()
599
+ });
600
+ yield* Effect.orDie(marks.mark("summary", ["fresh"]));
601
+ yield* marks.fail("summary", "past", {
602
+ attempts: 1,
603
+ dueAt: Option.some(2e3),
604
+ failure: {
605
+ at: 1,
606
+ reason: Option.none(),
607
+ message: "failed"
608
+ }
609
+ });
610
+ yield* marks.fail("summary", "now", {
611
+ attempts: 2,
612
+ dueAt: Option.some(3e3),
613
+ failure: {
614
+ at: 1,
615
+ reason: Option.none(),
616
+ message: "failed"
617
+ }
618
+ });
619
+ yield* marks.fail("summary", "future", {
620
+ attempts: 3,
621
+ dueAt: Option.some(4e3),
622
+ failure: {
623
+ at: 1,
624
+ reason: Option.none(),
625
+ message: "failed"
626
+ }
627
+ });
628
+ yield* marks.fail("other", "future", {
629
+ attempts: 1,
630
+ dueAt: Option.some(5e3),
631
+ failure: {
632
+ at: 1,
633
+ reason: Option.none(),
634
+ message: "failed"
635
+ }
636
+ });
637
+ expect(yield* marks.summary("summary", 3e3)).toEqual({
638
+ fresh: 1,
639
+ sleeping: 0,
640
+ retryDue: 2,
641
+ backingOff: 1,
642
+ stopped: 0,
643
+ nextDueAt: Option.some(0)
644
+ });
645
+ yield* marks.remove("summary", "fresh");
646
+ expect(yield* marks.summary("summary", 1e3)).toEqual({
647
+ fresh: 0,
648
+ sleeping: 0,
649
+ retryDue: 0,
650
+ backingOff: 3,
651
+ stopped: 0,
652
+ nextDueAt: Option.some(2e3)
653
+ });
654
+ expect(yield* marks.summary("summary", 4e3)).toEqual({
655
+ fresh: 0,
656
+ sleeping: 0,
657
+ retryDue: 3,
658
+ backingOff: 0,
659
+ stopped: 0,
660
+ nextDueAt: Option.some(2e3)
661
+ });
662
+ }));
663
+ recordsTest("R7d stops, failures, resume, listings and moved seq resets", ({ marks }) => projectionMarksContract(marks));
664
+ recordsTest("R7e failure, resume and clear roll back with the boundary", ({ boundary, marks }) => projectionMarksTransactionContract(marks, boundary));
321
665
  recordsTest("R8 marks written by a commit hook commit and roll back with the write", ({ boundary, hooks, marks }) => Effect.gen(function* () {
322
666
  yield* hooks.beforeCommit((ids) => marks.mark("p", [...ids]));
323
667
  yield* mutate(create());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@streamsy/core",
3
- "version": "0.10.0",
3
+ "version": "0.12.0",
4
4
  "description": "Effect-first Durable Streams protocol, storage contract, memory layer and toolkit.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -1,24 +0,0 @@
1
- import { Context, Effect } from "effect";
2
- // src/internal/owner-records.ts
3
- var OwnerRecords = class extends Context.Service()("@streamsy/core/internal/OwnerRecords") {};
4
- // src/internal/commit-hooks.ts
5
- var CommitHooks = class extends Context.Service()("@streamsy/core/internal/CommitHooks") {};
6
- /** Shared registry for storage boundaries: register in a scope, run in order. */
7
- const commitHookRegistry = () => {
8
- const hooks = /* @__PURE__ */ new Set();
9
- const beforeCommit = (hook) => Effect.acquireRelease(Effect.sync(() => {
10
- const entry = { hook };
11
- hooks.add(entry);
12
- return entry;
13
- }), (entry) => Effect.sync(() => {
14
- hooks.delete(entry);
15
- })).pipe(Effect.asVoid);
16
- const run = (ids) => ids.size === 0 || hooks.size === 0 ? Effect.void : Effect.forEach([...hooks], (entry) => entry.hook(ids), { discard: true });
17
- return {
18
- beforeCommit,
19
- run
20
- };
21
- };
22
- // src/internal/projection-marks.ts
23
- var ProjectionMarks = class extends Context.Service()("@streamsy/core/internal/ProjectionMarks") {};
24
- export { OwnerRecords as i, CommitHooks as n, commitHookRegistry as r, ProjectionMarks as t };