effect-durable-agent 0.1.0-alpha.13 → 0.1.0-alpha.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. package/dist/{compaction-CYItD6di.d.ts → compaction-DYAlYxx5.d.ts} +2 -2
  2. package/dist/index.d.ts +1 -1
  3. package/dist/{runtime-BRURBOyt.d.ts → runtime-Ca8Qw1fl.d.ts} +3 -3
  4. package/dist/services/compaction.d.ts +1 -1
  5. package/dist/services/runtime-layer.d.ts +4 -4
  6. package/dist/services/runtime-layer.js +2 -2
  7. package/dist/services/runtime.d.ts +1 -1
  8. package/dist/services/runtime.js +1 -1
  9. package/dist/services/session-query.d.ts +1 -1
  10. package/dist/services/session-query.js +1 -2
  11. package/dist/services/session-query.js.map +1 -1
  12. package/dist/services/session-state.d.ts +1 -1
  13. package/dist/services/session-state.js +1 -1
  14. package/dist/services/sink-registry.d.ts +2 -2
  15. package/dist/services/sink-registry.js +1 -1
  16. package/dist/services/span-names.d.ts +1 -1
  17. package/dist/services/span-names.js +1 -0
  18. package/dist/services/span-names.js.map +1 -1
  19. package/dist/{session-query-Dzdcr2xL.d.ts → session-query-dlbwukcq.d.ts} +2 -3
  20. package/dist/{session-state-Cm5sXbZW.d.ts → session-state-Cb_8YOre.d.ts} +35 -7
  21. package/dist/{session-state-DfYX21mA.js → session-state-Dk7Iie-r.js} +59 -9
  22. package/dist/session-state-Dk7Iie-r.js.map +1 -0
  23. package/dist/{sink-registry-CT3C3N5R.js → sink-registry-C2XFRBEV.js} +163 -135
  24. package/dist/sink-registry-C2XFRBEV.js.map +1 -0
  25. package/dist/{sink-registry-CU-WMK96.d.ts → sink-registry-DiZyYd5f.d.ts} +44 -41
  26. package/dist/testkit/layers.d.ts +5 -5
  27. package/dist/testkit/layers.js +2 -2
  28. package/package.json +1 -1
  29. package/dist/session-state-DfYX21mA.js.map +0 -1
  30. package/dist/sink-registry-CT3C3N5R.js.map +0 -1
@@ -1,12 +1,10 @@
1
- import { SequenceNumber, durablePosition } from "./types/core.js";
2
- import { dr as turnCompletedEventType, fr as turnFailedEventType, mr as turnStoppedEventType, pr as turnStartedEventType } from "./durable-BPHVFVvV.js";
1
+ import { SequenceNumber } from "./types/core.js";
3
2
  import { l as initialReducedState, o as foldReducedState } from "./reduced-state-Bz68V2H8.js";
4
- import { CommittedDurableEvent, EDASessionStore, EDASessionStoreError } from "./services/session-store.js";
3
+ import { EDASessionStore, EDASessionStoreError } from "./services/session-store.js";
5
4
  import { IdGenerator } from "./services/id-generator.js";
6
5
  import { n as SessionContext, t as EventFactory } from "./event-factory-QuC_UvyP.js";
7
6
  import { annotateEdaSpan } from "./services/tracing.js";
8
7
  import { EDAKeepAlive } from "./services/keep-alive.js";
9
- import { SessionEventObserver } from "./services/session-event-observer.js";
10
8
  import { EDAReducerRegistry } from "./services/reducer-registry.js";
11
9
  import { EDASinkName, SinkCheckpointStore } from "./services/sink-checkpoint-store.js";
12
10
  import * as Context from "effect/Context";
@@ -15,64 +13,78 @@ import * as Layer from "effect/Layer";
15
13
  import * as Schema from "effect/Schema";
16
14
  import * as Stream from "effect/Stream";
17
15
  import * as Cause from "effect/Cause";
16
+ import * as Queue from "effect/Queue";
18
17
  import * as Ref from "effect/Ref";
19
18
  import * as Scope from "effect/Scope";
20
- import * as PubSub from "effect/PubSub";
19
+ import * as Semaphore from "effect/Semaphore";
21
20
  import * as SynchronizedRef from "effect/SynchronizedRef";
22
- //#region src/services/live-event-bus.ts
23
- /** Conservative raw-delta cap for one open turn's live-only reconnect replay. */
24
- const activeTurnEphemeralReplayCapacity = 4096;
25
- /** Unbounded in-memory fanout plus bounded active-turn ephemeral replay. */
26
- var LiveEventBus = class LiveEventBus extends Context.Service()("@effect-durable-agent/LiveEventBus") {
27
- static Live = Layer.effect(LiveEventBus, Effect.gen(function* () {
28
- return makeLiveBus(yield* Effect.acquireRelease(PubSub.unbounded(), PubSub.shutdown), yield* Ref.make({
29
- events: [],
30
- overflowed: false
31
- }), yield* SessionEventObserver);
32
- }));
33
- /** Live bus for hosts that do not install an append-driven observer. */
34
- static Noop = LiveEventBus.Live.pipe(Layer.provide(SessionEventObserver.Noop));
35
- };
36
- const makeLiveBus = (pubsub, activeTurnReplay, observer) => ({
37
- publish: (event) => Effect.gen(function* () {
38
- yield* updateActiveTurnReplay(activeTurnReplay, event);
39
- yield* observer.onEvent(event);
40
- return yield* PubSub.publish(pubsub, event);
41
- }),
42
- subscribeQueue: () => PubSub.subscribe(pubsub),
43
- subscribe: () => Effect.map(PubSub.subscribe(pubsub), (subscription) => Stream.fromEffectRepeat(PubSub.take(subscription))),
44
- activeTurnReplay: () => Ref.get(activeTurnReplay)
45
- });
46
- const updateActiveTurnReplay = (ref, event) => Ref.update(ref, (state) => nextActiveTurnReplay(state, event));
47
- const nextActiveTurnReplay = (state, event) => {
48
- if (event.event.type === turnStartedEventType) return {
49
- turnId: event.event.payload.turnId,
50
- events: [],
51
- overflowed: false
52
- };
53
- if (event.event.type === turnCompletedEventType || event.event.type === turnFailedEventType || event.event.type === turnStoppedEventType) {
54
- const turnId = event.event.payload.turnId;
55
- return turnId === void 0 || state.turnId === void 0 || turnId === state.turnId ? {
56
- events: [],
57
- overflowed: false
58
- } : state;
59
- }
60
- if (event.event.durability !== "ephemeral" || state.turnId === void 0) return state;
61
- const events = [...state.events, event];
62
- if (events.length <= 4096) return {
63
- ...state,
64
- events
65
- };
21
+ //#region src/services/sink-inbox.ts
22
+ /** Durable payloads stay in the log; only bounded best-effort ephemeral work is retained. */
23
+ const ephemeralCapacity = 128;
24
+ const ephemeralByteCapacity = 256 * 1024;
25
+ /** An ephemeral update could not be measured as a JSON wire value. */
26
+ var SinkEphemeralEncodingError = class extends Schema.TaggedErrorClass()("SinkEphemeralEncodingError", { cause: Schema.Defect() }) {};
27
+ /**
28
+ * Coalesces durable heads without losing ephemeral ordering barriers. Publication never
29
+ * waits for delivery. Overflow drops the newest ephemeral update, never durable work.
30
+ */
31
+ const makeSinkInbox = Effect.fnUntraced(function* (initialHead) {
32
+ const wake = yield* Effect.acquireRelease(Queue.sliding(1), Queue.shutdown);
33
+ let head = initialHead;
34
+ const pending = [];
35
+ let pendingBytes = 0;
36
+ const notify = (throughSeq) => Effect.sync(() => {
37
+ head = SequenceNumber.make(Math.max(head, throughSeq));
38
+ Queue.offerUnsafe(wake, void 0);
39
+ });
40
+ const offerEphemeral = (event) => Effect.try({
41
+ try: () => {
42
+ const bytes = new TextEncoder().encode(JSON.stringify(event)).byteLength;
43
+ if (pending.length >= ephemeralCapacity || bytes > ephemeralByteCapacity - pendingBytes) return false;
44
+ pending.push({
45
+ event,
46
+ bytes
47
+ });
48
+ pendingBytes += bytes;
49
+ Queue.offerUnsafe(wake, void 0);
50
+ return true;
51
+ },
52
+ catch: (cause) => new SinkEphemeralEncodingError({ cause })
53
+ });
54
+ const poll = (cursor) => Effect.sync(() => {
55
+ while (pending.length > 0) {
56
+ const first = pending[0];
57
+ if (first === void 0) break;
58
+ if (first.event.position.seq > cursor) return {
59
+ _tag: "Durable",
60
+ throughSeq: first.event.position.seq
61
+ };
62
+ pending.shift();
63
+ pendingBytes -= first.bytes;
64
+ if (first.event.position.seq === cursor) return {
65
+ _tag: "Ephemeral",
66
+ event: first.event
67
+ };
68
+ }
69
+ return cursor < head ? {
70
+ _tag: "Durable",
71
+ throughSeq: head
72
+ } : void 0;
73
+ });
66
74
  return {
67
- ...state,
68
- events: events.slice(events.length - activeTurnEphemeralReplayCapacity),
69
- overflowed: true
75
+ notify,
76
+ offerEphemeral,
77
+ poll,
78
+ awaitWork: Queue.take(wake)
70
79
  };
71
- };
80
+ });
72
81
  //#endregion
73
82
  //#region src/services/sink-registry.ts
83
+ function makeSink(sink) {
84
+ return sink;
85
+ }
74
86
  /** Convenience constructor preserving a sink's literal name/type information. */
75
- const EDASink = { make: (sink) => sink };
87
+ const EDASink = { make: makeSink };
76
88
  /** Registry and runner for app-provided EDA sinks. */
77
89
  var EDASinkRegistry = class EDASinkRegistry extends Context.Service()("@effect-durable-agent/EDASinkRegistry") {
78
90
  static Empty = Layer.succeed(EDASinkRegistry, {
@@ -88,13 +100,14 @@ const sinkCheckpointFormatVersion = 1;
88
100
  const makeSinkRegistry = (sinks) => Effect.gen(function* () {
89
101
  const session = yield* SessionContext;
90
102
  const store = yield* EDASessionStore;
91
- const liveBus = yield* LiveEventBus;
92
103
  const checkpointStore = yield* SinkCheckpointStore;
93
104
  const eventFactory = yield* EventFactory;
94
105
  const ids = yield* IdGenerator;
95
106
  const reducerRegistry = yield* EDAReducerRegistry;
96
107
  const keepAlive = yield* EDAKeepAlive;
97
108
  const started = yield* Ref.make(false);
109
+ const hydrationGate = yield* Semaphore.make(1);
110
+ const deliveries = [];
98
111
  const baseContext = (staged, publishEphemeral, scope, checkpoint) => ({
99
112
  sessionId: session.sessionId,
100
113
  checkpoint,
@@ -111,41 +124,73 @@ const makeSinkRegistry = (sinks) => Effect.gen(function* () {
111
124
  const checkpointRef = yield* SynchronizedRef.make(storedCheckpoint);
112
125
  const checkpoint = makeSinkCheckpoint(checkpointStore, sinkName, checkpointRef);
113
126
  const cursor = storedCheckpoint.afterSeq;
114
- const initial = {
115
- cursor,
116
- reduced: initialReducedState,
117
- reducerStates: reducerRegistry.initial
118
- };
119
- const hydrated = cursor === initialHead ? {
120
- cursor,
127
+ const cursorRef = yield* Ref.make(cursor);
128
+ if (cursor > initialHead) return yield* new EDASessionStoreError({ message: `Sink ${sink.name} cursor exceeds session head` });
129
+ const state = yield* Ref.make(sink.state === "none" ? void 0 : cursor === initialHead ? {
121
130
  reduced: initialProjection.reduced,
122
131
  reducerStates: initialProjection.reducerStates
123
- } : cursor <= SequenceNumber.make(0) ? initial : yield* store.eventsAfter(SequenceNumber.make(0)).pipe(Stream.takeWhile((event) => event.position.seq <= cursor), Stream.chunks, Stream.runFold(() => initial, (current, page) => ({
124
- cursor,
125
- reduced: foldReducedState(current.reduced, page),
126
- reducerStates: reducerRegistry.reduce(current.reducerStates, page)
127
- })));
128
- const state = yield* Ref.make(hydrated);
129
- const live = yield* liveBus.subscribeQueue().pipe(Scope.provide(scope));
132
+ } : cursor === 0 ? {
133
+ reduced: initialReducedState,
134
+ reducerStates: reducerRegistry.initial
135
+ } : void 0);
136
+ const inbox = yield* makeSinkInbox(initialHead).pipe(Scope.provide(scope));
137
+ deliveries.push({
138
+ sink,
139
+ inbox
140
+ });
141
+ const ensureProjection = Effect.fnUntraced(function* () {
142
+ const existing = yield* Ref.get(state);
143
+ if (existing !== void 0) return existing;
144
+ const hydrated = yield* store.eventsAfter(SequenceNumber.make(0)).pipe(Stream.takeWhile((event) => event.position.seq <= cursor), Stream.chunks, Stream.runFold(() => ({
145
+ reduced: initialReducedState,
146
+ reducerStates: reducerRegistry.initial
147
+ }), (current, page) => ({
148
+ reduced: foldReducedState(current.reduced, page),
149
+ reducerStates: reducerRegistry.reduce(current.reducerStates, page)
150
+ })), Effect.withSpan("agent.sink.hydrate", { attributes: {
151
+ "eda.sink.name": sink.name,
152
+ "eda.session.id": session.sessionId,
153
+ "eda.seq.through": cursor
154
+ } }), hydrationGate.withPermits(1));
155
+ if (hydrated.reduced.lastSeq !== cursor) return yield* new EDASessionStoreError({ message: `Sink ${sink.name} could not reconstruct its cursor` });
156
+ yield* Ref.set(state, hydrated);
157
+ return hydrated;
158
+ });
130
159
  const processDurableBatch = Effect.fnUntraced(function* (allEvents) {
131
160
  if (allEvents.length === 0) return;
132
- const current = yield* Ref.get(state);
133
- const fresh = allEvents.filter((entry) => entry.position.seq > current.cursor);
161
+ const currentCursor = yield* Ref.get(cursorRef);
162
+ const fresh = allEvents.filter((entry) => entry.position.seq > currentCursor);
134
163
  if (fresh.length === 0) return;
135
164
  const durable = sink.durable;
136
- const throughSeq = fresh.at(-1).position.seq;
137
- const nextReduced = foldReducedState(current.reduced, fresh);
138
- const nextReducerStates = reducerRegistry.reduce(current.reducerStates, fresh);
165
+ const last = fresh.at(-1);
166
+ if (last === void 0) return;
167
+ const throughSeq = last.position.seq;
168
+ const nextProjection = sink.state === "none" ? void 0 : yield* Effect.gen(function* () {
169
+ const current = yield* ensureProjection();
170
+ return {
171
+ reduced: foldReducedState(current.reduced, fresh),
172
+ reducerStates: reducerRegistry.reduce(current.reducerStates, fresh)
173
+ };
174
+ });
139
175
  const eventsForSink = durable === void 0 ? [] : filterInterested(fresh, durable.interests);
140
176
  if (durable !== void 0 && eventsForSink.length > 0) yield* Effect.gen(function* () {
141
177
  const staged = [];
142
- if ((yield* durable.process({
178
+ const rawBatch = {
143
179
  allEvents: fresh,
144
180
  events: eventsForSink,
145
- stateAfter: nextReduced,
146
- reducerStates: nextReducerStates,
147
181
  throughSeq
148
- }, baseContext(staged, publishEphemeral, scope, checkpoint)).pipe(Effect.as(true), Effect.catchCause((cause) => Cause.hasInterruptsOnly(cause) ? Effect.failCause(cause) : Effect.logError("EDA durable sink violated its infallible contract", {
182
+ };
183
+ const context = baseContext(staged, publishEphemeral, scope, checkpoint);
184
+ if ((yield* Effect.gen(function* () {
185
+ if (sink.durable === void 0) return;
186
+ if (sink.state === "none") return yield* sink.durable.process(rawBatch, context);
187
+ if (nextProjection === void 0) return yield* Effect.die("Projected sink missing its projection");
188
+ return yield* sink.durable.process({
189
+ ...rawBatch,
190
+ stateAfter: nextProjection.reduced,
191
+ reducerStates: nextProjection.reducerStates
192
+ }, context);
193
+ }).pipe(Effect.as(true), Effect.catchCause((cause) => Cause.hasInterruptsOnly(cause) ? Effect.failCause(cause) : Effect.logError("EDA durable sink violated its infallible contract", {
149
194
  cause: Cause.pretty(cause),
150
195
  sink: sink.name
151
196
  }).pipe(Effect.as(false))))) && staged.length > 0) {
@@ -154,67 +199,45 @@ const makeSinkRegistry = (sinks) => Effect.gen(function* () {
154
199
  }
155
200
  }).pipe(Effect.withSpan("agent.sink.drain", { attributes: {
156
201
  "eda.sink.name": sink.name,
157
- "eda.sink.cursor.before": current.cursor,
202
+ "eda.sink.cursor.before": currentCursor,
158
203
  "eda.sink.events.read": fresh.length,
159
204
  "eda.sink.events.interested": eventsForSink.length,
160
205
  "eda.sink.cursor.after": throughSeq
161
206
  } }));
162
207
  yield* commitSinkCheckpoint(checkpointStore, sinkName, checkpointRef, throughSeq);
163
- yield* Ref.set(state, {
164
- cursor: throughSeq,
165
- reduced: nextReduced,
166
- reducerStates: nextReducerStates
167
- });
168
- });
169
- const processDurableBatchWithKeepAlive = (events) => keepAlive.withActiveWork(`sink:${sink.name}`, processDurableBatch(events));
170
- const drainDurablesThrough = (targetHead) => Effect.gen(function* () {
171
- while (true) {
172
- const current = yield* Ref.get(state);
173
- if (current.cursor >= targetHead) return;
174
- const allEvents = yield* readCursorBatchThrough(store, current.cursor, targetHead, sink.durable?.batchSize);
175
- if (allEvents.length === 0) return;
176
- yield* processDurableBatchWithKeepAlive(allEvents);
177
- }
208
+ yield* Ref.set(cursorRef, throughSeq);
209
+ yield* Ref.set(state, nextProjection);
178
210
  });
179
- const processLiveDurable = (event) => Effect.gen(function* () {
180
- const current = yield* Ref.get(state);
181
- if (event.position.seq <= current.cursor) return;
182
- if (event.position.seq > current.cursor + 1) yield* drainDurablesThrough(SequenceNumber.make(event.position.seq - 1));
183
- const afterCatchup = yield* Ref.get(state);
184
- if (event.position.seq > afterCatchup.cursor + 1) {
185
- yield* Effect.logWarning("EDA sink runner could not catch up before live durable", {
186
- cursor: afterCatchup.cursor,
187
- eventSeq: event.position.seq,
188
- sink: sink.name
189
- });
190
- return;
191
- }
192
- yield* processDurableBatchWithKeepAlive([committedDurableFromPositioned(event)]);
211
+ const drainDurablesThrough = Effect.fnUntraced(function* (targetHead) {
212
+ const currentCursor = yield* Ref.get(cursorRef);
213
+ if (currentCursor >= targetHead) return;
214
+ const allEvents = yield* readCursorBatchThrough(store, currentCursor, targetHead, sink.durable?.batchSize);
215
+ if (allEvents.length === 0) return yield* new EDASessionStoreError({ message: `Sink ${sink.name} could not read its durable backlog` });
216
+ yield* processDurableBatch(allEvents);
193
217
  });
194
- const processLiveEphemeral = (event) => Effect.gen(function* () {
195
- const before = yield* Ref.get(state);
196
- if (event.position.seq < before.cursor) return;
197
- if (event.position.seq > before.cursor) yield* drainDurablesThrough(event.position.seq);
198
- const after = yield* Ref.get(state);
199
- if (event.position.seq !== after.cursor) return;
200
- if (sink.ephemeral === void 0 || !matchesInterest(event.event.type, sink.ephemeral.interests)) return;
201
- yield* sink.ephemeral.process(event, baseContext([], publishEphemeral, scope, checkpoint)).pipe(Effect.catchCause((cause) => Effect.logError("EDA sink ephemeral projection failed", {
202
- cause: String(cause),
218
+ const processEphemeral = Effect.fnUntraced(function* (event) {
219
+ if (sink.ephemeral === void 0) return;
220
+ if (sink.state !== "none") yield* ensureProjection();
221
+ yield* sink.ephemeral.process(event, baseContext([], publishEphemeral, scope, checkpoint)).pipe(Effect.catchCause((cause) => Cause.hasInterruptsOnly(cause) ? Effect.failCause(cause) : Effect.logError("EDA sink ephemeral projection failed", {
222
+ cause: Cause.pretty(cause),
203
223
  sink: sink.name
204
224
  })));
205
225
  });
206
- const processLiveEvent = (event) => event.event.durability === "durable" ? processLiveDurable(event) : processLiveEphemeral(event);
207
226
  return {
208
- runLoop: Effect.gen(function* () {
209
- yield* drainDurablesThrough(initialHead);
210
- return yield* Effect.forever(Effect.gen(function* () {
211
- yield* processLiveEvent(yield* PubSub.take(live));
212
- }));
213
- }).pipe(Effect.catchCause((cause) => Effect.logError("EDA sink runner failed", {
227
+ runLoop: Effect.forever(Effect.gen(function* () {
228
+ const currentCursor = yield* Ref.get(cursorRef);
229
+ const work = yield* inbox.poll(currentCursor);
230
+ if (work === void 0) {
231
+ yield* inbox.awaitWork;
232
+ return;
233
+ }
234
+ yield* keepAlive.withActiveWork(`sink:${sink.name}`, work._tag === "Durable" ? drainDurablesThrough(work.throughSeq) : processEphemeral(work.event));
235
+ yield* Effect.yieldNow;
236
+ })).pipe(Effect.catchCause((cause) => Cause.hasInterruptsOnly(cause) ? Effect.failCause(cause) : Effect.logError("EDA sink runner failed", {
214
237
  cause: Cause.pretty(cause),
215
238
  sink: sink.name
216
239
  }))),
217
- initialization: cursor === initialHead ? "reused" : cursor > 0 ? "replayed" : "empty"
240
+ initialization: sink.state === "none" ? "raw" : cursor === initialHead ? "reused" : cursor > 0 ? "deferred" : "empty"
218
241
  };
219
242
  });
220
243
  return {
@@ -224,8 +247,9 @@ const makeSinkRegistry = (sinks) => Effect.gen(function* () {
224
247
  const runners = yield* Effect.gen(function* () {
225
248
  const runners = yield* Effect.forEach(sinks, (sink) => makeSinkRunner(sink, input), { concurrency: 1 });
226
249
  yield* Effect.annotateCurrentSpan({
250
+ "eda.sinks.raw": runners.filter((runner) => runner.initialization === "raw").length,
227
251
  "eda.sinks.reused": runners.filter((runner) => runner.initialization === "reused").length,
228
- "eda.sinks.replayed": runners.filter((runner) => runner.initialization === "replayed").length,
252
+ "eda.sinks.deferred": runners.filter((runner) => runner.initialization === "deferred").length,
229
253
  "eda.sinks.empty": runners.filter((runner) => runner.initialization === "empty").length
230
254
  });
231
255
  return runners;
@@ -237,8 +261,16 @@ const makeSinkRegistry = (sinks) => Effect.gen(function* () {
237
261
  } }));
238
262
  yield* Effect.forEach(runners, (runner) => runner.runLoop.pipe(Effect.forkIn(input.scope)), { discard: true });
239
263
  }),
240
- notifyDurableHeadAdvanced: () => Effect.void,
241
- publishEphemeralToSinks: () => Effect.void
264
+ notifyDurableHeadAdvanced: (head) => Effect.forEach(deliveries, ({ inbox }) => inbox.notify(head), { discard: true }),
265
+ publishEphemeralToSinks: (event) => Effect.forEach(deliveries, ({ sink, inbox }) => {
266
+ if (sink.ephemeral === void 0 || !matchesInterest(event.event.type, sink.ephemeral.interests)) return Effect.void;
267
+ return Effect.gen(function* () {
268
+ if (!(yield* inbox.offerEphemeral(event))) yield* Effect.logWarning("EDA sink ephemeral buffer full", { sink: sink.name });
269
+ }).pipe(Effect.catchTag("SinkEphemeralEncodingError", (error) => Effect.logWarning("EDA sink ephemeral serialization failed", {
270
+ cause: error.cause,
271
+ sink: sink.name
272
+ })));
273
+ }, { discard: true })
242
274
  };
243
275
  });
244
276
  const makeSinkCheckpoint = (store, sinkName, checkpointRef) => ({
@@ -280,13 +312,9 @@ const encodeSinkState = (schema, state) => Effect.try({
280
312
  });
281
313
  const sinkCheckpointCodecError = (operation, cause) => new EDASessionStoreError({ message: cause instanceof Error ? `${operation} sink checkpoint: ${cause.message}` : `${operation} sink checkpoint: ${String(cause)}` });
282
314
  const readCursorBatchThrough = (store, afterSeq, throughSeq, batchSize = defaultBatchSize) => store.eventsAfter(afterSeq).pipe(Stream.takeWhile((event) => event.position.seq <= throughSeq), Stream.take(batchSize), Stream.runCollect, Effect.map((events) => Array.from(events)));
283
- const committedDurableFromPositioned = (event) => CommittedDurableEvent.make({
284
- event: event.event,
285
- position: durablePosition(event.position.seq)
286
- });
287
315
  const filterInterested = (events, interests) => events.filter((event) => matchesInterest(event.event.type, interests));
288
- const matchesInterest = (type, interests) => interests === void 0 || interests.some((interest) => interest === type);
316
+ const matchesInterest = (type, interests) => interests === void 0 || interests === "*" || interests.some((interest) => interest === type);
289
317
  //#endregion
290
- export { EDASinkRegistry as n, LiveEventBus as r, EDASink as t };
318
+ export { EDASinkRegistry as n, EDASink as t };
291
319
 
292
- //# sourceMappingURL=sink-registry-CT3C3N5R.js.map
320
+ //# sourceMappingURL=sink-registry-C2XFRBEV.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sink-registry-C2XFRBEV.js","names":[],"sources":["../src/services/sink-inbox.ts","../src/services/sink-registry.ts"],"sourcesContent":["import * as Effect from \"effect/Effect\";\nimport * as Queue from \"effect/Queue\";\nimport * as Schema from \"effect/Schema\";\n\nimport { SequenceNumber } from \"../types/core\";\nimport type { PositionedEvent } from \"../types/events\";\n\n/** Durable payloads stay in the log; only bounded best-effort ephemeral work is retained. */\nconst ephemeralCapacity = 128;\nconst ephemeralByteCapacity = 256 * 1024;\n\n/** An ephemeral update could not be measured as a JSON wire value. */\nexport class SinkEphemeralEncodingError extends Schema.TaggedErrorClass<SinkEphemeralEncodingError>()(\n \"SinkEphemeralEncodingError\",\n { cause: Schema.Defect() },\n) {}\n\n/** One ordered step on a sink's serialized delivery lane. */\ntype SinkWork =\n | { readonly _tag: \"Durable\"; readonly throughSeq: SequenceNumber }\n | { readonly _tag: \"Ephemeral\"; readonly event: PositionedEvent };\n\n/**\n * Coalesces durable heads without losing ephemeral ordering barriers. Publication never\n * waits for delivery. Overflow drops the newest ephemeral update, never durable work.\n */\nexport const makeSinkInbox = Effect.fnUntraced(function* (initialHead: SequenceNumber) {\n const wake = yield* Effect.acquireRelease(Queue.sliding<void>(1), Queue.shutdown);\n let head = initialHead;\n const pending: Array<{ readonly event: PositionedEvent; readonly bytes: number }> = [];\n let pendingBytes = 0;\n\n const notify = (throughSeq: SequenceNumber) =>\n Effect.sync(() => {\n head = SequenceNumber.make(Math.max(head, throughSeq));\n Queue.offerUnsafe(wake, undefined);\n });\n\n const offerEphemeral = (event: PositionedEvent) =>\n Effect.try({\n try: () => {\n const bytes = new TextEncoder().encode(JSON.stringify(event)).byteLength;\n if (pending.length >= ephemeralCapacity || bytes > ephemeralByteCapacity - pendingBytes) {\n return false;\n }\n pending.push({ event, bytes });\n pendingBytes += bytes;\n Queue.offerUnsafe(wake, undefined);\n return true;\n },\n catch: (cause) => new SinkEphemeralEncodingError({ cause }),\n });\n\n const poll = (cursor: SequenceNumber): Effect.Effect<SinkWork | undefined> =>\n Effect.sync(() => {\n while (pending.length > 0) {\n const first = pending[0];\n if (first === undefined) break;\n if (first.event.position.seq > cursor) {\n return { _tag: \"Durable\", throughSeq: first.event.position.seq };\n }\n pending.shift();\n pendingBytes -= first.bytes;\n if (first.event.position.seq === cursor) {\n return { _tag: \"Ephemeral\", event: first.event };\n }\n }\n return cursor < head ? { _tag: \"Durable\", throughSeq: head } : undefined;\n });\n\n return { notify, offerEphemeral, poll, awaitWork: Queue.take(wake) };\n});\n","import * as Cause from \"effect/Cause\";\nimport * as Context from \"effect/Context\";\nimport * as Effect from \"effect/Effect\";\nimport * as Layer from \"effect/Layer\";\nimport * as Ref from \"effect/Ref\";\nimport * as Schema from \"effect/Schema\";\nimport * as Scope from \"effect/Scope\";\nimport * as Semaphore from \"effect/Semaphore\";\nimport * as Stream from \"effect/Stream\";\nimport * as SynchronizedRef from \"effect/SynchronizedRef\";\n\nimport { foldReducedState, initialReducedState, type ReducedState } from \"../domain/reduced-state\";\nimport { EDAReducerRegistry, type EDAReducerStateSnapshot } from \"./reducer-registry\";\nimport { EventId, SessionId, SequenceNumber } from \"../types/core\";\nimport type {\n DurableEventEnvelope,\n EphemeralEventEnvelope,\n EventType,\n PositionedEvent,\n} from \"../types/events\";\nimport type { EDASessionStoreShape } from \"./session-store\";\nimport { type CommittedDurableEvent, EDASessionStore, EDASessionStoreError } from \"./session-store\";\nimport { EventFactory } from \"./event-factory\";\nimport type { EventFactoryShape } from \"./event-factory\";\nimport { IdGenerator } from \"./id-generator\";\nimport { EDAKeepAlive } from \"./keep-alive\";\nimport { makeSinkInbox } from \"./sink-inbox\";\nimport { SessionContext } from \"./session-context\";\nimport {\n EDASinkName,\n SinkCheckpointStore,\n type SinkCheckpointStoreShape,\n type StoredSinkCheckpoint,\n} from \"./sink-checkpoint-store\";\nimport { annotateEdaSpan } from \"./tracing\";\n\n/** Cursor-window input delivered to one durable sink drain. */\nexport interface EDASinkRawDurableBatch {\n /** All durable events replayed for this cursor window, including uninterested events. */\n readonly allEvents: ReadonlyArray<CommittedDurableEvent>;\n /** Events matching the sink's durable interests. */\n readonly events: ReadonlyArray<CommittedDurableEvent>;\n /** Durable sequence through which the sink may advance after success. */\n readonly throughSeq: SequenceNumber;\n}\n\n/** Cursor window with framework and app projections, enabled by default. */\nexport interface EDASinkDurableBatch extends EDASinkRawDurableBatch {\n /** Authoritative reduced state folded exactly through `throughSeq`. */\n readonly stateAfter: ReducedState;\n /** App-specific durable reducer states folded exactly through `throughSeq`. */\n readonly reducerStates: EDAReducerStateSnapshot;\n}\n\n/** Typed, sink-owned durable state stored independently from cursor advancement. */\nexport interface EDASinkCheckpoint {\n /** Decode current durable state, or return `initial` for a new or legacy cursor row. */\n readonly get: <State>(\n schema: Schema.Codec<State, unknown, never, never>,\n initial: State,\n ) => Effect.Effect<State, EDASessionStoreError>;\n /** Validate, encode, and durably save state without advancing the sink cursor. */\n readonly save: <State>(\n schema: Schema.Codec<State, unknown, never, never>,\n state: State,\n ) => Effect.Effect<void, EDASessionStoreError>;\n}\n\n/** Capabilities exposed to sink processors without granting raw store or bus access. */\nexport interface EDASinkContext {\n readonly sessionId: SessionId;\n /** Sink-owned checkpoint state, serialized with cursor commits and background writes. */\n readonly checkpoint: EDASinkCheckpoint;\n /** Build a framework durable event if the sink needs to emit one. */\n readonly events: EventFactoryShape;\n /** Mint an app durable event id for staged custom events. */\n readonly makeEventId: () => Effect.Effect<EventId>;\n /** Publish a best-effort live-only event. */\n readonly emitEphemeral: (\n event: EphemeralEventEnvelope,\n ) => Effect.Effect<PositionedEvent, EDASessionStoreError>;\n /** Stage durable events; the runner commits them after the sink succeeds. */\n readonly stageDurable: (event: DurableEventEnvelope) => Effect.Effect<void>;\n /** Fork background sink work into the session scope. */\n readonly forkScoped: (effect: Effect.Effect<unknown, unknown>) => Effect.Effect<void>;\n}\n\n/** `\"*\"` and omission select every event; an array selects exact event types. */\nexport type EDASinkInterests = \"*\" | ReadonlyArray<EventType | string>;\n\n/** Delivery policy shared by raw and projected durable consumers. */\ninterface EDADurableSinkOptions {\n readonly interests?: EDASinkInterests;\n readonly batchSize?: number;\n}\n\n/** Default durable consumer with framework and app projections at each cursor window. */\nexport interface EDAProjectedDurableSinkDefinition extends EDADurableSinkOptions {\n readonly process: (batch: EDASinkDurableBatch, ctx: EDASinkContext) => Effect.Effect<void, never>;\n}\n\n/** Raw consumer that never hydrates, folds, or retains a session projection. */\nexport interface EDARawDurableSinkDefinition extends EDADurableSinkOptions {\n readonly process: (\n batch: EDASinkRawDurableBatch,\n ctx: EDASinkContext,\n ) => Effect.Effect<void, never>;\n}\n\n/** Durable sink definition backed by a checkpoint and an app-owned delivery policy. */\nexport type EDADurableSinkDefinition = EDAProjectedDurableSinkDefinition;\n\n/** Best-effort live-only sink definition. */\nexport interface EDAEphemeralSinkDefinition {\n readonly interests?: EDASinkInterests;\n readonly process: (event: PositionedEvent, ctx: EDASinkContext) => Effect.Effect<void, never>;\n}\n\n/**\n * Named app integration hook with optional durable and ephemeral filters.\n *\n * Every sink runs on one serialized position-ordered lane. Sinks own retry and\n * terminal failure handling, so callbacks must have an infallible typed error\n * channel. An unexpected defect is logged and skipped before the durable checkpoint\n * advances. Ephemeral callbacks are best-effort and are only processed after the\n * durable prefix at their anchor sequence has been projected.\n */\ninterface EDASinkOptions {\n readonly name: string;\n readonly ephemeral?: EDAEphemeralSinkDefinition;\n}\n\n/** Existing consumers receive framework and app projections unless explicitly opted out. */\nexport interface EDAProjectedSink extends EDASinkOptions {\n readonly state?: \"projected\";\n readonly durable?: EDAProjectedDurableSinkDefinition;\n}\n\n/** Raw consumers retain only their cursor and sink-owned checkpoint payload. */\nexport interface EDARawSink extends EDASinkOptions {\n readonly state: \"none\";\n readonly durable?: EDARawDurableSinkDefinition;\n}\n\n/** The outer discriminant preserves contextual callback typing for inline default sinks. */\nexport type EDASink = EDAProjectedSink | EDARawSink;\n\n/** Projected and raw overloads preserve contextual callback inference and literal names. */\nfunction makeSink<const Sink extends EDAProjectedSink>(sink: Sink): Sink;\nfunction makeSink<const Sink extends EDARawSink>(sink: Sink): Sink;\nfunction makeSink<const Sink extends EDASink>(sink: Sink): Sink;\nfunction makeSink(sink: EDASink): EDASink {\n return sink;\n}\n\n/** Convenience constructor preserving a sink's literal name/type information. */\nexport const EDASink = { make: makeSink };\n\n/** Session-owned capabilities needed to start all registered sink runners. */\nexport interface EDASinkRunnerStartInput {\n readonly appendDurableBatch: (\n events: ReadonlyArray<DurableEventEnvelope>,\n ) => Effect.Effect<ReadonlyArray<CommittedDurableEvent>, EDASessionStoreError>;\n /** Immutable framework and app projections at one common durable head. */\n readonly initialProjection: {\n readonly reduced: ReducedState;\n readonly reducerStates: EDAReducerStateSnapshot;\n };\n readonly publishEphemeral: (\n event: EphemeralEventEnvelope,\n ) => Effect.Effect<PositionedEvent, EDASessionStoreError>;\n readonly scope: Scope.Scope;\n}\n\n/** Registry service coordinating durable checkpoints and live sink delivery. */\nexport interface EDASinkRegistryShape {\n readonly sinks: ReadonlyArray<EDASink>;\n /** Start long-lived sink runners. Safe to call once during session-state acquisition. */\n readonly startSinkRunners: (\n input: EDASinkRunnerStartInput,\n ) => Effect.Effect<void, EDASessionStoreError>;\n /** Coalesced non-blocking nudge that the durable log head advanced. */\n readonly notifyDurableHeadAdvanced: (head: SequenceNumber) => Effect.Effect<void>;\n /** Best-effort non-blocking delivery to ephemeral sink workers. */\n readonly publishEphemeralToSinks: (event: PositionedEvent) => Effect.Effect<void>;\n}\n\n/** Registry and runner for app-provided EDA sinks. */\nexport class EDASinkRegistry extends Context.Service<EDASinkRegistry, EDASinkRegistryShape>()(\n \"@effect-durable-agent/EDASinkRegistry\",\n) {\n static readonly Empty = Layer.succeed(EDASinkRegistry, {\n sinks: [],\n startSinkRunners: () => Effect.void,\n notifyDurableHeadAdvanced: () => Effect.void,\n publishEphemeralToSinks: () => Effect.void,\n } satisfies EDASinkRegistryShape);\n\n static readonly Live = (sinks: ReadonlyArray<EDASink>) =>\n Layer.effect(EDASinkRegistry, makeSinkRegistry(sinks));\n}\n\nconst defaultBatchSize = 100;\nconst sinkCheckpointFormatVersion = 1;\n\ninterface SinkProjection {\n readonly reduced: ReducedState;\n readonly reducerStates: EDAReducerStateSnapshot;\n}\n\ninterface SerializedSinkState {\n readonly formatVersion: typeof sinkCheckpointFormatVersion;\n readonly state: unknown;\n readonly updatedAtMs: number;\n}\n\nconst makeSinkRegistry = (sinks: ReadonlyArray<EDASink>) =>\n Effect.gen(function* () {\n const session = yield* SessionContext;\n const store = yield* EDASessionStore;\n const checkpointStore = yield* SinkCheckpointStore;\n const eventFactory = yield* EventFactory;\n const ids = yield* IdGenerator;\n const reducerRegistry = yield* EDAReducerRegistry;\n const keepAlive = yield* EDAKeepAlive;\n const started = yield* Ref.make(false);\n const hydrationGate = yield* Semaphore.make(1);\n const deliveries: Array<{\n readonly sink: EDASink;\n readonly inbox: Effect.Success<ReturnType<typeof makeSinkInbox>>;\n }> = [];\n\n const baseContext = (\n staged: Array<DurableEventEnvelope>,\n publishEphemeral: (\n event: EphemeralEventEnvelope,\n ) => Effect.Effect<PositionedEvent, EDASessionStoreError>,\n scope: Scope.Scope,\n checkpoint: EDASinkCheckpoint,\n ): EDASinkContext => ({\n sessionId: session.sessionId,\n checkpoint,\n events: eventFactory,\n makeEventId: ids.makeEventId,\n emitEphemeral: publishEphemeral,\n stageDurable: (event) => Effect.sync(() => staged.push(event)),\n forkScoped: (effect) => effect.pipe(Effect.forkIn(scope), Effect.asVoid),\n });\n\n const makeSinkRunner = Effect.fnUntraced(function* (\n sink: EDASink,\n { initialProjection, appendDurableBatch, publishEphemeral, scope }: EDASinkRunnerStartInput,\n ) {\n // Long-lived fibers capture the head and capabilities, not the initial projection.\n const initialHead = initialProjection.reduced.lastSeq;\n const sinkName = EDASinkName.make(sink.name);\n const storedCheckpoint = yield* checkpointStore.load(sinkName);\n const checkpointRef = yield* SynchronizedRef.make(storedCheckpoint);\n const checkpoint = makeSinkCheckpoint(checkpointStore, sinkName, checkpointRef);\n const cursor = storedCheckpoint.afterSeq;\n const cursorRef = yield* Ref.make(cursor);\n if (cursor > initialHead) {\n return yield* new EDASessionStoreError({\n message: `Sink ${sink.name} cursor exceeds session head`,\n });\n }\n // Keep only an exact projection seed; lagging workers reconstruct in their own scope.\n const state = yield* Ref.make<SinkProjection | undefined>(\n sink.state === \"none\"\n ? undefined\n : cursor === initialHead\n ? {\n reduced: initialProjection.reduced,\n reducerStates: initialProjection.reducerStates,\n }\n : cursor === 0\n ? { reduced: initialReducedState, reducerStates: reducerRegistry.initial }\n : undefined,\n );\n const inbox = yield* makeSinkInbox(initialHead).pipe(Scope.provide(scope));\n deliveries.push({ sink, inbox });\n const ensureProjection = Effect.fnUntraced(function* () {\n const existing = yield* Ref.get(state);\n if (existing !== undefined) return existing;\n const hydrated = yield* store.eventsAfter(SequenceNumber.make(0)).pipe(\n Stream.takeWhile((event) => event.position.seq <= cursor),\n Stream.chunks,\n Stream.runFold(\n (): SinkProjection => ({\n reduced: initialReducedState,\n reducerStates: reducerRegistry.initial,\n }),\n (current, page): SinkProjection => ({\n reduced: foldReducedState(current.reduced, page),\n reducerStates: reducerRegistry.reduce(current.reducerStates, page),\n }),\n ),\n Effect.withSpan(\"agent.sink.hydrate\", {\n attributes: {\n \"eda.sink.name\": sink.name,\n \"eda.session.id\": session.sessionId,\n \"eda.seq.through\": cursor,\n },\n }),\n hydrationGate.withPermits(1),\n );\n if (hydrated.reduced.lastSeq !== cursor) {\n return yield* new EDASessionStoreError({\n message: `Sink ${sink.name} could not reconstruct its cursor`,\n });\n }\n yield* Ref.set(state, hydrated);\n return hydrated;\n });\n\n const processDurableBatch = Effect.fnUntraced(function* (\n allEvents: ReadonlyArray<CommittedDurableEvent>,\n ) {\n if (allEvents.length === 0) {\n return;\n }\n\n const currentCursor = yield* Ref.get(cursorRef);\n const fresh = allEvents.filter((entry) => entry.position.seq > currentCursor);\n if (fresh.length === 0) {\n return;\n }\n\n const durable = sink.durable;\n const last = fresh.at(-1);\n if (last === undefined) return;\n const throughSeq = last.position.seq;\n const nextProjection =\n sink.state === \"none\"\n ? undefined\n : yield* Effect.gen(function* () {\n const current = yield* ensureProjection();\n return {\n reduced: foldReducedState(current.reduced, fresh),\n reducerStates: reducerRegistry.reduce(current.reducerStates, fresh),\n };\n });\n const eventsForSink =\n durable === undefined ? [] : filterInterested(fresh, durable.interests);\n\n if (durable !== undefined && eventsForSink.length > 0) {\n yield* Effect.gen(function* () {\n const staged: Array<DurableEventEnvelope> = [];\n const rawBatch: EDASinkRawDurableBatch = {\n allEvents: fresh,\n events: eventsForSink,\n throughSeq,\n };\n const context = baseContext(staged, publishEphemeral, scope, checkpoint);\n const delivery = Effect.gen(function* () {\n if (sink.durable === undefined) return;\n if (sink.state === \"none\") return yield* sink.durable.process(rawBatch, context);\n // The projected branch owns both construction and delivery of these fields.\n if (nextProjection === undefined)\n return yield* Effect.die(\"Projected sink missing its projection\");\n return yield* sink.durable.process(\n {\n ...rawBatch,\n stateAfter: nextProjection.reduced,\n reducerStates: nextProjection.reducerStates,\n },\n context,\n );\n });\n const completed = yield* delivery.pipe(\n Effect.as(true),\n Effect.catchCause((cause) =>\n Cause.hasInterruptsOnly(cause)\n ? Effect.failCause(cause)\n : Effect.logError(\"EDA durable sink violated its infallible contract\", {\n cause: Cause.pretty(cause),\n sink: sink.name,\n }).pipe(Effect.as(false)),\n ),\n );\n if (completed && staged.length > 0) {\n yield* annotateEdaSpan({ \"eda.sink.staged_events\": staged.length });\n yield* appendDurableBatch(staged);\n }\n }).pipe(\n Effect.withSpan(\"agent.sink.drain\", {\n attributes: {\n \"eda.sink.name\": sink.name,\n \"eda.sink.cursor.before\": currentCursor,\n \"eda.sink.events.read\": fresh.length,\n \"eda.sink.events.interested\": eventsForSink.length,\n \"eda.sink.cursor.after\": throughSeq,\n },\n }),\n );\n }\n\n yield* commitSinkCheckpoint(checkpointStore, sinkName, checkpointRef, throughSeq);\n yield* Ref.set(cursorRef, throughSeq);\n yield* Ref.set(state, nextProjection);\n });\n\n const drainDurablesThrough = Effect.fnUntraced(function* (targetHead: SequenceNumber) {\n const currentCursor = yield* Ref.get(cursorRef);\n if (currentCursor >= targetHead) return;\n const allEvents = yield* readCursorBatchThrough(\n store,\n currentCursor,\n targetHead,\n sink.durable?.batchSize,\n );\n if (allEvents.length === 0) {\n return yield* new EDASessionStoreError({\n message: `Sink ${sink.name} could not read its durable backlog`,\n });\n }\n yield* processDurableBatch(allEvents);\n });\n\n const processEphemeral = Effect.fnUntraced(function* (event: PositionedEvent) {\n if (sink.ephemeral === undefined) return;\n if (sink.state !== \"none\") yield* ensureProjection();\n yield* sink.ephemeral\n .process(event, baseContext([], publishEphemeral, scope, checkpoint))\n .pipe(\n Effect.catchCause((cause) =>\n Cause.hasInterruptsOnly(cause)\n ? Effect.failCause(cause)\n : Effect.logError(\"EDA sink ephemeral projection failed\", {\n cause: Cause.pretty(cause),\n sink: sink.name,\n }),\n ),\n );\n });\n\n const runLoop = Effect.forever(\n Effect.gen(function* () {\n const currentCursor = yield* Ref.get(cursorRef);\n const work = yield* inbox.poll(currentCursor);\n if (work === undefined) {\n yield* inbox.awaitWork;\n return;\n }\n yield* keepAlive.withActiveWork(\n `sink:${sink.name}`,\n work._tag === \"Durable\"\n ? drainDurablesThrough(work.throughSeq)\n : processEphemeral(work.event),\n );\n yield* Effect.yieldNow;\n }),\n ).pipe(\n Effect.catchCause((cause) =>\n Cause.hasInterruptsOnly(cause)\n ? Effect.failCause(cause)\n : Effect.logError(\"EDA sink runner failed\", {\n cause: Cause.pretty(cause),\n sink: sink.name,\n }),\n ),\n );\n\n return {\n runLoop,\n initialization:\n sink.state === \"none\"\n ? \"raw\"\n : cursor === initialHead\n ? \"reused\"\n : cursor > 0\n ? \"deferred\"\n : \"empty\",\n };\n });\n\n return {\n sinks,\n startSinkRunners: Effect.fnUntraced(function* (input: EDASinkRunnerStartInput) {\n const wasStarted = yield* Ref.getAndSet(started, true);\n if (wasStarted) {\n return;\n }\n const runners = yield* Effect.gen(function* () {\n const runners = yield* Effect.forEach(sinks, (sink) => makeSinkRunner(sink, input), {\n concurrency: 1,\n });\n yield* Effect.annotateCurrentSpan({\n \"eda.sinks.raw\": runners.filter((runner) => runner.initialization === \"raw\").length,\n \"eda.sinks.reused\": runners.filter((runner) => runner.initialization === \"reused\")\n .length,\n \"eda.sinks.deferred\": runners.filter((runner) => runner.initialization === \"deferred\")\n .length,\n \"eda.sinks.empty\": runners.filter((runner) => runner.initialization === \"empty\").length,\n });\n return runners;\n }).pipe(\n Effect.withSpan(\"agent.sinks.initialize\", {\n attributes: {\n sessionId: session.sessionId,\n \"eda.session.id\": session.sessionId,\n \"eda.seq.head\": input.initialProjection.reduced.lastSeq,\n \"eda.sinks.count\": sinks.length,\n },\n }),\n );\n // Catch-up can append events. Register every inbox before starting any delivery fiber.\n yield* Effect.forEach(\n runners,\n (runner) => runner.runLoop.pipe(Effect.forkIn(input.scope)),\n {\n discard: true,\n },\n );\n }),\n notifyDurableHeadAdvanced: (head) =>\n Effect.forEach(deliveries, ({ inbox }) => inbox.notify(head), { discard: true }),\n publishEphemeralToSinks: (event) =>\n Effect.forEach(\n deliveries,\n ({ sink, inbox }) => {\n if (\n sink.ephemeral === undefined ||\n !matchesInterest(event.event.type, sink.ephemeral.interests)\n )\n return Effect.void;\n return Effect.gen(function* () {\n const accepted = yield* inbox.offerEphemeral(event);\n if (!accepted) {\n yield* Effect.logWarning(\"EDA sink ephemeral buffer full\", { sink: sink.name });\n }\n }).pipe(\n Effect.catchTag(\"SinkEphemeralEncodingError\", (error) =>\n Effect.logWarning(\"EDA sink ephemeral serialization failed\", {\n cause: error.cause,\n sink: sink.name,\n }),\n ),\n );\n },\n { discard: true },\n ),\n } satisfies EDASinkRegistryShape;\n });\n\nconst makeSinkCheckpoint = (\n store: SinkCheckpointStoreShape,\n sinkName: EDASinkName,\n checkpointRef: SynchronizedRef.SynchronizedRef<StoredSinkCheckpoint>,\n): EDASinkCheckpoint => ({\n get: (schema, initial) =>\n SynchronizedRef.get(checkpointRef).pipe(\n Effect.flatMap((checkpoint) => {\n const serialized = serializedSinkState(checkpoint.payload);\n return serialized === undefined\n ? Effect.succeed(initial)\n : decodeSinkState(schema, serialized.state);\n }),\n ),\n save: (schema, state) =>\n encodeSinkState(schema, state).pipe(\n Effect.flatMap((encoded) => {\n const payload: SerializedSinkState = {\n formatVersion: sinkCheckpointFormatVersion,\n state: encoded,\n updatedAtMs: Date.now(),\n };\n return SynchronizedRef.modifyEffect(checkpointRef, (checkpoint) =>\n store.saveState(sinkName, payload).pipe(\n Effect.as([\n undefined,\n {\n afterSeq: checkpoint.afterSeq,\n payload,\n },\n ] as const),\n ),\n );\n }),\n ),\n});\n\nconst commitSinkCheckpoint = (\n store: SinkCheckpointStoreShape,\n sinkName: EDASinkName,\n checkpointRef: SynchronizedRef.SynchronizedRef<StoredSinkCheckpoint>,\n afterSeq: SequenceNumber,\n): Effect.Effect<void, EDASessionStoreError> =>\n SynchronizedRef.modifyEffect(checkpointRef, (checkpoint) =>\n store.commit(sinkName, afterSeq, checkpoint.payload).pipe(\n Effect.as([\n undefined,\n {\n afterSeq,\n payload: checkpoint.payload,\n },\n ] as const),\n ),\n );\n\nconst serializedSinkState = (payload: unknown): SerializedSinkState | undefined => {\n if (\n typeof payload !== \"object\" ||\n payload === null ||\n !(\"formatVersion\" in payload) ||\n payload.formatVersion !== sinkCheckpointFormatVersion ||\n !(\"state\" in payload) ||\n !(\"updatedAtMs\" in payload) ||\n typeof payload.updatedAtMs !== \"number\"\n ) {\n return undefined;\n }\n return {\n formatVersion: sinkCheckpointFormatVersion,\n state: payload.state,\n updatedAtMs: payload.updatedAtMs,\n };\n};\n\nconst decodeSinkState = <State>(\n schema: Schema.Codec<State, unknown, never, never>,\n encoded: unknown,\n): Effect.Effect<State, EDASessionStoreError> =>\n Effect.try({\n try: () => Schema.decodeUnknownSync(schema)(encoded),\n catch: (cause) => sinkCheckpointCodecError(\"decoding\", cause),\n });\n\nconst encodeSinkState = <State>(\n schema: Schema.Codec<State, unknown, never, never>,\n state: State,\n): Effect.Effect<unknown, EDASessionStoreError> =>\n Effect.try({\n try: () => Schema.encodeUnknownSync(schema)(state),\n catch: (cause) => sinkCheckpointCodecError(\"encoding\", cause),\n });\n\nconst sinkCheckpointCodecError = (operation: string, cause: unknown) =>\n new EDASessionStoreError({\n message:\n cause instanceof Error\n ? `${operation} sink checkpoint: ${cause.message}`\n : `${operation} sink checkpoint: ${String(cause)}`,\n });\n\nconst readCursorBatchThrough = (\n store: EDASessionStoreShape,\n afterSeq: SequenceNumber,\n throughSeq: SequenceNumber,\n batchSize = defaultBatchSize,\n) =>\n store.eventsAfter(afterSeq).pipe(\n Stream.takeWhile((event) => event.position.seq <= throughSeq),\n Stream.take(batchSize),\n Stream.runCollect,\n Effect.map((events) => Array.from(events)),\n );\n\nconst filterInterested = (\n events: ReadonlyArray<CommittedDurableEvent>,\n interests: EDASinkInterests | undefined,\n): ReadonlyArray<CommittedDurableEvent> =>\n events.filter((event) => matchesInterest(event.event.type, interests));\n\nconst matchesInterest = (\n type: EventType | string,\n interests: EDASinkInterests | undefined,\n): boolean =>\n interests === undefined || interests === \"*\" || interests.some((interest) => interest === type);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAQA,MAAM,oBAAoB;AAC1B,MAAM,wBAAwB,MAAM;;AAGpC,IAAa,6BAAb,cAAgD,OAAO,iBAA6C,EAClG,8BACA,EAAE,OAAO,OAAO,OAAO,EAAE,CAC3B,EAAE,CAAC;;;;;AAWH,MAAa,gBAAgB,OAAO,WAAW,WAAW,aAA6B;CACrF,MAAM,OAAO,OAAO,OAAO,eAAe,MAAM,QAAc,CAAC,GAAG,MAAM,QAAQ;CAChF,IAAI,OAAO;CACX,MAAM,UAA8E,CAAC;CACrF,IAAI,eAAe;CAEnB,MAAM,UAAU,eACd,OAAO,WAAW;EAChB,OAAO,eAAe,KAAK,KAAK,IAAI,MAAM,UAAU,CAAC;EACrD,MAAM,YAAY,MAAM,KAAA,CAAS;CACnC,CAAC;CAEH,MAAM,kBAAkB,UACtB,OAAO,IAAI;EACT,WAAW;GACT,MAAM,QAAQ,IAAI,YAAY,EAAE,OAAO,KAAK,UAAU,KAAK,CAAC,EAAE;GAC9D,IAAI,QAAQ,UAAU,qBAAqB,QAAQ,wBAAwB,cACzE,OAAO;GAET,QAAQ,KAAK;IAAE;IAAO;GAAM,CAAC;GAC7B,gBAAgB;GAChB,MAAM,YAAY,MAAM,KAAA,CAAS;GACjC,OAAO;EACT;EACA,QAAQ,UAAU,IAAI,2BAA2B,EAAE,MAAM,CAAC;CAC5D,CAAC;CAEH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