@kairos-es/core 1.0.0-alpha.3 → 1.0.0-alpha.5

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 (120) hide show
  1. package/README.md +3 -3
  2. package/dist/cjs/AppendCondition.js +1 -3
  3. package/dist/cjs/AppendCondition.js.map +1 -1
  4. package/dist/cjs/AppendIsOwned.js +6 -6
  5. package/dist/cjs/AppendIsOwned.js.map +1 -1
  6. package/dist/cjs/ContractStore.js +13 -4
  7. package/dist/cjs/ContractStore.js.map +1 -1
  8. package/dist/cjs/DcbEventStore.js +1 -1
  9. package/dist/cjs/DcbEventStore.js.map +1 -1
  10. package/dist/cjs/Event.js +87 -11
  11. package/dist/cjs/Event.js.map +1 -1
  12. package/dist/cjs/Projection.js +15 -9
  13. package/dist/cjs/Projection.js.map +1 -1
  14. package/dist/cjs/Query.js +59 -3
  15. package/dist/cjs/Query.js.map +1 -1
  16. package/dist/cjs/SubscribeMachine.js +20 -22
  17. package/dist/cjs/SubscribeMachine.js.map +1 -1
  18. package/dist/cjs/inMemory.js +113 -43
  19. package/dist/cjs/inMemory.js.map +1 -1
  20. package/dist/cjs/retryOnConflict.js +4 -10
  21. package/dist/cjs/retryOnConflict.js.map +1 -1
  22. package/dist/cjs/testing.js +2 -2
  23. package/dist/cjs/testing.js.map +1 -1
  24. package/dist/{dts → dts-cjs}/AppendCondition.d.ts +5 -7
  25. package/dist/{dts → dts-cjs}/AppendCondition.d.ts.map +1 -1
  26. package/dist/{dts → dts-cjs}/AppendIsOwned.d.ts +6 -6
  27. package/dist/{dts → dts-cjs}/AppendIsOwned.d.ts.map +1 -1
  28. package/dist/{dts → dts-cjs}/ContractStore.d.ts +7 -4
  29. package/dist/dts-cjs/ContractStore.d.ts.map +1 -0
  30. package/dist/{dts → dts-cjs}/DcbEventStore.d.ts +2 -2
  31. package/dist/{dts → dts-cjs}/DcbEventStore.d.ts.map +1 -1
  32. package/dist/dts-cjs/Event.d.ts +174 -0
  33. package/dist/dts-cjs/Event.d.ts.map +1 -0
  34. package/dist/{dts → dts-cjs}/Projection.d.ts +1 -1
  35. package/dist/{dts → dts-cjs}/Projection.d.ts.map +1 -1
  36. package/dist/{dts → dts-cjs}/Query.d.ts +19 -5
  37. package/dist/dts-cjs/Query.d.ts.map +1 -0
  38. package/dist/{dts → dts-cjs}/SubscribeMachine.d.ts +11 -15
  39. package/dist/dts-cjs/SubscribeMachine.d.ts.map +1 -0
  40. package/dist/{dts → dts-cjs}/inMemory.d.ts.map +1 -1
  41. package/dist/{dts → dts-cjs}/index.d.ts +1 -1
  42. package/dist/dts-cjs/package.json +3 -0
  43. package/dist/{dts → dts-cjs}/retryOnConflict.d.ts +1 -7
  44. package/dist/dts-cjs/retryOnConflict.d.ts.map +1 -0
  45. package/dist/{dts → dts-cjs}/testing.d.ts +1 -1
  46. package/dist/dts-esm/AppendCondition.d.ts +21 -0
  47. package/dist/dts-esm/AppendCondition.d.ts.map +1 -0
  48. package/dist/dts-esm/AppendIsOwned.d.ts +78 -0
  49. package/dist/dts-esm/AppendIsOwned.d.ts.map +1 -0
  50. package/dist/dts-esm/ContractStore.d.ts +62 -0
  51. package/dist/dts-esm/ContractStore.d.ts.map +1 -0
  52. package/dist/dts-esm/DcbEventStore.d.ts +64 -0
  53. package/dist/dts-esm/DcbEventStore.d.ts.map +1 -0
  54. package/dist/dts-esm/Event.d.ts +174 -0
  55. package/dist/dts-esm/Event.d.ts.map +1 -0
  56. package/dist/dts-esm/Projection.d.ts +124 -0
  57. package/dist/dts-esm/Projection.d.ts.map +1 -0
  58. package/dist/dts-esm/Query.d.ts +180 -0
  59. package/dist/dts-esm/Query.d.ts.map +1 -0
  60. package/dist/dts-esm/SubscribeMachine.d.ts +175 -0
  61. package/dist/dts-esm/SubscribeMachine.d.ts.map +1 -0
  62. package/dist/dts-esm/errors.d.ts +17 -0
  63. package/dist/dts-esm/errors.d.ts.map +1 -0
  64. package/dist/dts-esm/inMemory.d.ts +76 -0
  65. package/dist/dts-esm/inMemory.d.ts.map +1 -0
  66. package/dist/dts-esm/index.d.ts +40 -0
  67. package/dist/dts-esm/index.d.ts.map +1 -0
  68. package/dist/dts-esm/package.json +3 -0
  69. package/dist/dts-esm/retryOnConflict.d.ts +64 -0
  70. package/dist/dts-esm/retryOnConflict.d.ts.map +1 -0
  71. package/dist/dts-esm/testing.d.ts +39 -0
  72. package/dist/dts-esm/testing.d.ts.map +1 -0
  73. package/dist/esm/AppendCondition.js +1 -3
  74. package/dist/esm/AppendCondition.js.map +1 -1
  75. package/dist/esm/AppendIsOwned.js +6 -6
  76. package/dist/esm/AppendIsOwned.js.map +1 -1
  77. package/dist/esm/ContractStore.js +13 -4
  78. package/dist/esm/ContractStore.js.map +1 -1
  79. package/dist/esm/DcbEventStore.js +1 -1
  80. package/dist/esm/DcbEventStore.js.map +1 -1
  81. package/dist/esm/Event.js +87 -11
  82. package/dist/esm/Event.js.map +1 -1
  83. package/dist/esm/Projection.js +15 -9
  84. package/dist/esm/Projection.js.map +1 -1
  85. package/dist/esm/Query.js +56 -1
  86. package/dist/esm/Query.js.map +1 -1
  87. package/dist/esm/SubscribeMachine.js +21 -23
  88. package/dist/esm/SubscribeMachine.js.map +1 -1
  89. package/dist/esm/inMemory.js +114 -44
  90. package/dist/esm/inMemory.js.map +1 -1
  91. package/dist/esm/index.js +1 -1
  92. package/dist/esm/retryOnConflict.js +4 -10
  93. package/dist/esm/retryOnConflict.js.map +1 -1
  94. package/dist/esm/testing.js +2 -2
  95. package/dist/esm/testing.js.map +1 -1
  96. package/package.json +21 -11
  97. package/src/AppendCondition.ts +1 -1
  98. package/src/AppendIsOwned.ts +7 -7
  99. package/src/ContractStore.ts +25 -8
  100. package/src/DcbEventStore.ts +3 -3
  101. package/src/Event.ts +108 -11
  102. package/src/Projection.ts +19 -8
  103. package/src/Query.ts +74 -1
  104. package/src/SubscribeMachine.ts +38 -31
  105. package/src/inMemory.ts +123 -51
  106. package/src/index.ts +1 -1
  107. package/src/retryOnConflict.ts +6 -11
  108. package/src/testing.ts +2 -2
  109. package/testing/package.json +1 -1
  110. package/dist/dts/ContractStore.d.ts.map +0 -1
  111. package/dist/dts/Event.d.ts +0 -104
  112. package/dist/dts/Event.d.ts.map +0 -1
  113. package/dist/dts/Query.d.ts.map +0 -1
  114. package/dist/dts/SubscribeMachine.d.ts.map +0 -1
  115. package/dist/dts/retryOnConflict.d.ts.map +0 -1
  116. /package/dist/{dts → dts-cjs}/errors.d.ts +0 -0
  117. /package/dist/{dts → dts-cjs}/errors.d.ts.map +0 -0
  118. /package/dist/{dts → dts-cjs}/inMemory.d.ts +0 -0
  119. /package/dist/{dts → dts-cjs}/index.d.ts.map +0 -0
  120. /package/dist/{dts → dts-cjs}/testing.d.ts.map +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"SubscribeMachine.js","names":["_effect","require","_Event","DEFAULT_CATCH_UP_PAGE_SIZE","exports","DEFAULT_POLL_INTERVAL_MILLIS","subscriptionTuningFields","pollInterval","Schema","optionalWith","Number","pipe","positive","finite","exact","catchUpPageSize","Int","POLL_RETRY_SCHEDULE","Schedule","exponential","union","spaced","intersect","recurs","subscribeStream","deps","after","Stream","unwrapScoped","Effect","gen","wake","Queue","sliding","listener","listen","never","tap","offer","undefined","retry","runDrain","forkScoped","drainFrom","from","collected","cursor","events","fetch","ReadLimit","make","event","push","lastEvent","at","length","position","last","nextBatch","takeAll","Chunk","fromIterable","ignore","timeout","take","unfoldChunkEffect","ORIGIN","map","Option","some"],"sources":["../../src/SubscribeMachine.ts"],"sourcesContent":[null],"mappings":";;;;;;AAsEA,IAAAA,OAAA,GAAAC,OAAA;AAWA,IAAAC,MAAA,GAAAD,OAAA;AAjFA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmFA;;;;;;;AAOO,MAAME,0BAA0B,GAAAC,OAAA,CAAAD,0BAAA,GAAG,GAAG;AAE7C;;;;;;;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,CAAC,aAAS;IAClB,OAAO,IAAI,EAAE;MACX,OAAOE,aAAK,CAAC2B,OAAO,CAAC5B,IAAI,CAAC;MAC1B,MAAM;QAAEgB,MAAM;QAAEU;MAAI,CAAE,GAAG,OAAOd,SAAS,CAACC,IAAI,CAAC;MAC/C,IAAIG,MAAM,CAACQ,MAAM,GAAG,CAAC,EAAE;QACrB,OAAO,CAACK,aAAK,CAACC,YAAY,CAACd,MAAM,CAAC,EAAEU,IAAI,CAAU;MACpD;MACA;MACA;MACA,OAAO5B,cAAM,CAACiC,MAAM,CAClBjC,cAAM,CAACkC,OAAO,CAAC/B,aAAK,CAACgC,IAAI,CAACjC,IAAI,CAAC,EAAEN,IAAI,CAAClB,YAAY,CAAC,CACpD;IACH;EACF,CAAC,CAAC;EAEJ,OAAOoB,cAAM,CAACsC,iBAAiB,CAACvC,KAAK,IAAIwC,aAAM,EAAGtB,IAAI,IACpDf,cAAM,CAACsC,GAAG,CAACT,SAAS,CAACd,IAAI,CAAC,EAAEwB,cAAM,CAACC,IAAI,CAAC,CACzC;AACH,CAAC,CAAC,CACH;AAAAjE,OAAA,CAAAoB,eAAA,GAAAA,eAAA","ignoreList":[]}
1
+ {"version":3,"file":"SubscribeMachine.js","names":["_effect","require","_Event","DEFAULT_CATCH_UP_PAGE_SIZE","exports","DEFAULT_POLL_INTERVAL_MILLIS","subscriptionTuningFields","pollInterval","Schema","optionalKey","Number","check","isGreaterThan","isFinite","catchUpPageSize","Int","POLL_RETRY_SCHEDULE","Schedule","max","min","exponential","spaced","recurs","subscribeStream","deps","after","Stream","unwrap","Effect","gen","wake","Queue","sliding","listener","listen","never","pipe","tap","offer","undefined","retry","runDrain","forkScoped","drainFrom","from","collected","cursor","events","fetch","ReadLimit","make","event","push","lastEvent","at","length","position","last","nextBatch","clear","ignore","timeout","take","paginate","ORIGIN","map","Option","some"],"sources":["../../src/SubscribeMachine.ts"],"sourcesContent":[null],"mappings":";;;;;;AAsEA,IAAAA,OAAA,GAAAC,OA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,CAAE;EACpC,CAAC,CAAC,CAACrB,IAAI,CAACR,cAAM,CAACY,KAAK,CAACxB,mBAAmB,CAAC,CAAC;EAE5C;;;;;;;;;;;;;EAaA,MAAM0C,SAAS,GACbd,IAAc,IAEdhB,cAAM,CAACC,GAAG,CAAC,aAAS;IAClB,OAAO,IAAI,EAAE;MACX;MACA;MACA,OAAOE,aAAK,CAAC4B,KAAK,CAAC7B,IAAI,CAAC;MACxB,MAAM;QAAEiB,MAAM;QAAEU;MAAI,CAAE,GAAG,OAAOd,SAAS,CAACC,IAAI,CAAC;MAC/C,IAAIG,MAAM,CAACQ,MAAM,GAAG,CAAC,EAAE;QACrB,OAAO,CAACR,MAAM,EAAEU,IAAI,CAAU;MAChC;MACA;MACA;MACA,OAAO7B,cAAM,CAACgC,MAAM,CAClBhC,cAAM,CAACiC,OAAO,CAAC9B,aAAK,CAAC+B,IAAI,CAAChC,IAAI,CAAC,EAAEN,IAAI,CAACjB,YAAY,CAAC,CACpD;IACH;EACF,CAAC,CAAC;EAEJ,OAAOmB,cAAM,CAACqC,QAAQ,CAACtC,KAAK,IAAIuC,aAAM,EAAGpB,IAAI,IAC3ChB,cAAM,CAACqC,GAAG,CACRP,SAAS,CAACd,IAAI,CAAC,EACf,CAAC,CAACG,MAAM,EAAEU,IAAI,CAAC,KAAK,CAACV,MAAM,EAAEmB,cAAM,CAACC,IAAI,CAACV,IAAI,CAAC,CAAU,CACzD,CACF;AACH,CAAC,CAAC,CACH;AAAArD,OAAA,CAAAmB,eAAA,GAAAA,eAAA","ignoreList":[]}
@@ -11,6 +11,67 @@ var _Event = require("./Event.js");
11
11
  var _errors = require("./errors.js");
12
12
  var _Query = require("./Query.js");
13
13
  var _SubscribeMachine = require("./SubscribeMachine.js");
14
+ /**
15
+ * A copy of `event` that shares no mutable structure with it: fresh `data` bytes, a
16
+ * fresh `tags` array, a fresh `metadata` bag and a fresh `occurredAt`. Only `type`
17
+ * and `uuid`, which are strings, are carried as they are.
18
+ *
19
+ * Each copy is chosen for what it does on EVERY input the type admits, not on the
20
+ * common one. `data` is copied through the `Uint8Array` constructor and not with
21
+ * `slice`, because `DcbEvent` admits any `Uint8Array` subclass and a subclass may
22
+ * answer `slice` with a VIEW of the same memory — Node's `Buffer` does. A
23
+ * `DateTime.Utc` is an ordinary object whose fields can be written past its
24
+ * `readonly` type, so `occurredAt` is rebuilt from its instant rather than shared.
25
+ *
26
+ * ## Why the oracle copies at BOTH edges
27
+ *
28
+ * This store is the reference the SQL engines are judged against, and a SQL engine
29
+ * shares nothing with its caller: it serialises on the way in and builds fresh objects
30
+ * on the way out. A store that kept the caller's objects instead would let a caller
31
+ * rewrite the log AFTER the append — mutate a `Uint8Array`, push to a `tags` array,
32
+ * assign into a `metadata` bag — and every later read would see the rewritten event
33
+ * with no append, no position and no wake behind it. A reference that can be edited
34
+ * after the fact judges nothing.
35
+ *
36
+ * So `append` stores a copy (the log never holds a caller's object) and every read
37
+ * path hands out a copy (a reader cannot reach the log through what it was given).
38
+ * Copying on the way in alone would close the first route and leave the second open:
39
+ * the same object would then be shared by every reader of the log.
40
+ */
41
+ const copyEvent = event => ({
42
+ type: event.type,
43
+ data: new Uint8Array(event.data),
44
+ tags: [...event.tags],
45
+ uuid: event.uuid,
46
+ occurredAt: _effect.DateTime.makeUnsafe(_effect.DateTime.toEpochMillis(event.occurredAt)),
47
+ metadata: {
48
+ ...event.metadata
49
+ }
50
+ });
51
+ /**
52
+ * A copy of `query` that shares no array with it, taking only the keys the grammar
53
+ * defines.
54
+ *
55
+ * `subscribe` is the one verb that holds a query beyond its own call: the fetch seam
56
+ * judges it again on every page for as long as the subscription runs. Each SQL engine
57
+ * compiles its plan once, when the subscription starts, so an edit the caller makes
58
+ * to its own object afterwards reaches nothing there. The oracle has to answer the
59
+ * same, for the reason it copies events (above): a reference that the caller can
60
+ * change mid-stream judges nothing. Only `types` and `tags` are carried because they
61
+ * are all `matchesQueryItem` reads, and a key the grammar does not define was
62
+ * already refused at the contract decorator before this runs.
63
+ */
64
+ const copyQuery = query => ({
65
+ items: query.items.map(item => ({
66
+ types: [...item.types],
67
+ tags: [...item.tags]
68
+ }))
69
+ });
70
+ /** A `SequencedEvent` whose event is a `copyEvent` of the stored one. */
71
+ const copySequenced = sequenced => ({
72
+ event: copyEvent(sequenced.event),
73
+ position: sequenced.position
74
+ });
14
75
  /** Filter a snapshot by `query` and `after` (strict `position > after`). */
15
76
  const filterLog = (log, query, after) => log.filter(sequenced => (after === undefined || sequenced.position > after) && (0, _Query.matchesSequenced)(sequenced, query));
16
77
  /** The position of the last event in a slice, or `undefined` when empty. */
@@ -28,7 +89,7 @@ const readSnapshot = (log, query, options) => {
28
89
  // when there is nothing to report.
29
90
  const head = (options?.limit === undefined ? lastPosition(log) : lastPosition(limited)) ?? _Event.ORIGIN;
30
91
  return {
31
- events: _effect.Stream.fromIterable(limited),
92
+ events: _effect.Stream.fromIterable(limited.map(copySequenced)),
32
93
  head
33
94
  };
34
95
  };
@@ -80,7 +141,7 @@ const fetchPage = (log, query, from, limit) => {
80
141
  for (let index = firstIndexAfter(log, from); index < log.length && page.length < limit; index += 1) {
81
142
  const sequenced = log[index];
82
143
  if ((0, _Query.matchesSequenced)(sequenced, query)) {
83
- page.push(sequenced);
144
+ page.push(copySequenced(sequenced));
84
145
  }
85
146
  }
86
147
  return page;
@@ -97,7 +158,7 @@ const make = options => _effect.Effect.gen(function* () {
97
158
  const catchUpPageSize = options?.catchUpPageSize ?? _SubscribeMachine.DEFAULT_CATCH_UP_PAGE_SIZE;
98
159
  const pollInterval = options?.pollInterval ?? _SubscribeMachine.DEFAULT_POLL_INTERVAL_MILLIS;
99
160
  const log = yield* _effect.Ref.make([]);
100
- const mutex = yield* _effect.Effect.makeSemaphore(1);
161
+ const mutex = yield* _effect.Semaphore.make(1);
101
162
  const hub = yield* _effect.PubSub.unbounded();
102
163
  const nextPosition = yield* _effect.Ref.make(1n);
103
164
  const read = (query, options) =>
@@ -105,45 +166,51 @@ const make = options => _effect.Effect.gen(function* () {
105
166
  // is reentrant, so append's inner read re-enters. Here append inlines the
106
167
  // read logic instead, so a plain lock suffices.
107
168
  mutex.withPermits(1)(_effect.Effect.map(_effect.Ref.get(log), snapshot => readSnapshot(snapshot, query, options)));
108
- const append = (events, condition) =>
109
- // Critical section: check + commit are atomic (the exactly-one-wins guarantee).
110
- mutex.withPermits(1)(_effect.Effect.gen(function* () {
111
- const snapshot = yield* _effect.Ref.get(log);
112
- if (condition !== undefined) {
113
- const conflicts = filterLog(snapshot, condition.failIfEventsMatch, condition.after);
114
- // Detect by presence: any matching event after `condition.after`
115
- // fails the append. The error carries only the condition (see
116
- // `AppendConditionFailed`); a correct retry re-reads to the new head.
117
- if (conflicts.length > 0) {
118
- return yield* new _errors.AppendConditionFailed({
119
- condition
120
- });
169
+ const append = (events, condition) => _effect.Effect.suspend(() => {
170
+ // The events are copied when the append STARTS, before it waits for the
171
+ // permit, as each SQL engine serialises them before its first suspension:
172
+ // an edit the caller makes while this append is queued must not reach the
173
+ // log here when it could not reach theirs.
174
+ const owned = events.map(copyEvent);
175
+ // Critical section: check + commit are atomic (the exactly-one-wins guarantee).
176
+ return mutex.withPermits(1)(_effect.Effect.gen(function* () {
177
+ const snapshot = yield* _effect.Ref.get(log);
178
+ if (condition !== undefined) {
179
+ const conflicts = filterLog(snapshot, condition.failIfEventsMatch, condition.after);
180
+ // Detect by presence: any matching event after `condition.after`
181
+ // fails the append. The error carries only the condition (see
182
+ // `AppendConditionFailed`); a correct retry re-reads to the new head.
183
+ if (conflicts.length > 0) {
184
+ return yield* new _errors.AppendConditionFailed({
185
+ condition
186
+ });
187
+ }
121
188
  }
122
- }
123
- // Optional test seam between the conflict-check and the commit (see
124
- // `InMemoryStoreOptions.beforeCommit`). Defaults to `Effect.void`, a
125
- // synchronous no-op, so the shipped critical section stays atomic by
126
- // construction; the concurrency contract test injects `Effect.yieldNow()`
127
- // here to make the exactly-one-wins guard genuinely depend on the mutex.
128
- yield* beforeCommit;
129
- const start = yield* _effect.Ref.get(nextPosition);
130
- const appended = events.map((event, index) => ({
131
- event,
132
- position: start + BigInt(index)
189
+ // Optional test seam between the conflict-check and the commit (see
190
+ // `InMemoryStoreOptions.beforeCommit`). Defaults to `Effect.void`, a
191
+ // synchronous no-op, so the shipped critical section stays atomic by
192
+ // construction; the concurrency contract test injects `Effect.yieldNow()`
193
+ // here to make the exactly-one-wins guard genuinely depend on the mutex.
194
+ yield* beforeCommit;
195
+ const start = yield* _effect.Ref.get(nextPosition);
196
+ const appended = owned.map((event, index) => ({
197
+ event,
198
+ position: start + BigInt(index)
199
+ }));
200
+ const end = start + BigInt(events.length);
201
+ yield* _effect.Ref.set(log, [...snapshot, ...appended]);
202
+ yield* _effect.Ref.set(nextPosition, end);
203
+ // The hub is a WAKE SOURCE and nothing else: the subscribe machine never
204
+ // reads what it carries, and its poll delivers with or without one. That
205
+ // is why suppressing the publish is a legitimate test seam rather than a
206
+ // broken store (see `InMemoryStoreOptions.suppressWake`).
207
+ if (!suppressWake) {
208
+ yield* _effect.PubSub.publishAll(hub, appended);
209
+ }
210
+ // `events` is non-empty, so the last new position is `end - 1`.
211
+ return end - 1n;
133
212
  }));
134
- const end = start + BigInt(events.length);
135
- yield* _effect.Ref.set(log, [...snapshot, ...appended]);
136
- yield* _effect.Ref.set(nextPosition, end);
137
- // The hub is a WAKE SOURCE and nothing else: the subscribe machine never
138
- // reads what it carries, and its poll delivers with or without one. That
139
- // is why suppressing the publish is a legitimate test seam rather than a
140
- // broken store (see `InMemoryStoreOptions.suppressWake`).
141
- if (!suppressWake) {
142
- yield* _effect.PubSub.publishAll(hub, appended);
143
- }
144
- // `events` is non-empty, so the last new position is `end - 1`.
145
- return end - 1n;
146
- }));
213
+ });
147
214
  const subscribe = (query, after) =>
148
215
  // Take the hub seat HERE, before handing the machine its wake source, so the
149
216
  // subscription is established no later than the machine's first `fetch`. That
@@ -158,11 +225,14 @@ const make = options => _effect.Effect.gen(function* () {
158
225
  // exclusive cursor is what makes the catch-up/live seam exactly-once, so there
159
226
  // is nothing left here for a critical section to protect. `append` keeps its
160
227
  // permit, which is the whole exactly-one-wins guarantee.
161
- _effect.Stream.unwrapScoped(_effect.Effect.gen(function* () {
228
+ _effect.Stream.unwrap(_effect.Effect.gen(function* () {
229
+ // Taken when the subscription starts, as the SQL engines compile theirs
230
+ // (see `copyQuery`).
231
+ const judged = copyQuery(query);
162
232
  const wakes = yield* _effect.PubSub.subscribe(hub);
163
233
  return (0, _SubscribeMachine.subscribeStream)({
164
- fetch: (from, limit) => _effect.Effect.map(_effect.Ref.get(log), snapshot => fetchPage(snapshot, query, from, limit)),
165
- listen: _effect.Stream.fromQueue(wakes),
234
+ fetch: (from, limit) => _effect.Effect.map(_effect.Ref.get(log), snapshot => fetchPage(snapshot, judged, from, limit)),
235
+ listen: _effect.Stream.fromSubscription(wakes),
166
236
  pollInterval,
167
237
  catchUpPageSize
168
238
  }, after);
@@ -1 +1 @@
1
- {"version":3,"file":"inMemory.js","names":["_effect","require","_ContractStore","_DcbEventStore","_Event","_errors","_Query","_SubscribeMachine","filterLog","log","query","after","filter","sequenced","undefined","position","matchesSequenced","lastPosition","events","at","readSnapshot","options","matched","limited","limit","slice","head","ORIGIN","Stream","fromIterable","firstIndexAfter","low","high","length","mid","fetchPage","from","page","index","push","make","Effect","gen","beforeCommit","void","suppressWake","catchUpPageSize","DEFAULT_CATCH_UP_PAGE_SIZE","pollInterval","DEFAULT_POLL_INTERVAL_MILLIS","Ref","mutex","makeSemaphore","hub","PubSub","unbounded","nextPosition","read","withPermits","map","get","snapshot","append","condition","conflicts","failIfEventsMatch","AppendConditionFailed","start","appended","event","BigInt","end","set","publishAll","subscribe","unwrapScoped","wakes","subscribeStream","fetch","listen","fromQueue","DcbEventStoreInMemory","exports","Layer","effect","DcbEventStore","makeContractStore","makeInMemoryTestLayer"],"sources":["../../src/inMemory.ts"],"sourcesContent":[null],"mappings":";;;;;;AA2BA,IAAAA,OAAA,GAAAC,OAAA;AAEA,IAAAC,cAAA,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,CAAC;AAEJ;AACO,MAAMO,qBAAqB,GAAAC,OAAA,CAAAD,qBAAA,gBAA+BE,aAAK,CAACC,MAAM,CAC3EC,4BAAa,eACb5C,cAAM,CAACkB,GAAG,cAACnB,IAAI,EAAE,EAAE8C,gCAAiB,CAAC,CACtC;AAED;;;;;;;;;;;AAWO,MAAMC,qBAAqB,GAChClE,OAA6B,IAE7B8D,aAAK,CAACC,MAAM,CAACC,4BAAa,EAAE5C,cAAM,CAACkB,GAAG,CAACnB,IAAI,CAACnB,OAAO,CAAC,EAAEiE,gCAAiB,CAAC,CAAC;AAAAJ,OAAA,CAAAK,qBAAA,GAAAA,qBAAA","ignoreList":[]}
1
+ {"version":3,"file":"inMemory.js","names":["_effect","require","_ContractStore","_DcbEventStore","_Event","_errors","_Query","_SubscribeMachine","copyEvent","event","type","data","Uint8Array","tags","uuid","occurredAt","DateTime","makeUnsafe","toEpochMillis","metadata","copyQuery","query","items","map","item","types","copySequenced","sequenced","position","filterLog","log","after","filter","undefined","matchesSequenced","lastPosition","events","at","readSnapshot","options","matched","limited","limit","slice","head","ORIGIN","Stream","fromIterable","firstIndexAfter","low","high","length","mid","fetchPage","from","page","index","push","make","Effect","gen","beforeCommit","void","suppressWake","catchUpPageSize","DEFAULT_CATCH_UP_PAGE_SIZE","pollInterval","DEFAULT_POLL_INTERVAL_MILLIS","Ref","mutex","Semaphore","hub","PubSub","unbounded","nextPosition","read","withPermits","get","snapshot","append","condition","suspend","owned","conflicts","failIfEventsMatch","AppendConditionFailed","start","appended","BigInt","end","set","publishAll","subscribe","unwrap","judged","wakes","subscribeStream","fetch","listen","fromSubscription","DcbEventStoreInMemory","exports","Layer","effect","DcbEventStore","makeContractStore","makeInMemoryTestLayer"],"sources":["../../src/inMemory.ts"],"sourcesContent":[null],"mappings":";;;;;;AA2BA,IAAAA,OAAA,GAAAC,OAAA;AAEA,IAAAC,cAAA,GAAAD,OAAA;AAEA,IAAAE,cAAA,GAAAF,OAAA;AAEA,IAAAG,MA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tC;AAED;;;;;;;;;;;AAWO,MAAMC,qBAAqB,GAChCnE,OAA6B,IAE7B+D,aAAK,CAACC,MAAM,CAACC,4BAAa,EAAE7C,cAAM,CAACpC,GAAG,CAACmC,IAAI,CAACnB,OAAO,CAAC,EAAEkE,gCAAiB,CAAC,CAAC;AAAAJ,OAAA,CAAAK,qBAAA,GAAAA,qBAAA","ignoreList":[]}
@@ -42,21 +42,15 @@ var _effect = require("effect");
42
42
  * jitter draws from `Random.next`, a default service on the same footing as the
43
43
  * clock rather than a host `Math.random`. No `node:*`, no wall-clock reading, no
44
44
  * ungoverned RNG.
45
- *
46
- * Effect v3 caveat: the `Schedule` API below is the THREE-type-parameter
47
- * `Schedule<Out, In, R>` that `effect@3` exports, with `Schedule.intersect`. The
48
- * currently-published docs show a newer four-type-parameter `Schedule` without
49
- * `intersect` — do not copy them; this file is written against the installed
50
- * `effect@3` type definitions.
51
45
  */
52
46
 
53
47
  /**
54
48
  * The default conflict backoff: exponential from 20ms, jittered, capped at five
55
49
  * retries.
56
50
  *
57
- * `Schedule.intersect` continues only while BOTH schedules continue, so the
58
- * `recurs(5)` arm is what bounds the attempts and the exponential arm is what
59
- * spaces them. Jitter matters more here than in a typical backoff: contending
51
+ * `Schedule.max` continues only while BOTH schedules continue, waiting the longer
52
+ * of their two delays, so the `recurs(5)` arm is what bounds the attempts and the
53
+ * exponential arm is what spaces them. Jitter matters more here than in a typical backoff: contending
60
54
  * deciders conflict precisely because they read the same boundary at the same
61
55
  * time, so an unjittered backoff would re-synchronise them into the same conflict
62
56
  * on every round. The figures are the conventional starting point (Emmett,
@@ -64,7 +58,7 @@ var _effect = require("effect");
64
58
  * command with a tighter latency budget, or one contending harder, should pass its
65
59
  * own schedule.
66
60
  */
67
- const conflictBackoff = /*#__PURE__*/_effect.Schedule.intersect(/*#__PURE__*/_effect.Schedule.jittered(/*#__PURE__*/_effect.Schedule.exponential('20 millis', 2)), /*#__PURE__*/_effect.Schedule.recurs(5));
61
+ const conflictBackoff = /*#__PURE__*/_effect.Schedule.max([/*#__PURE__*/_effect.Schedule.jittered(/*#__PURE__*/_effect.Schedule.exponential('20 millis', 2)), /*#__PURE__*/_effect.Schedule.recurs(5)]);
68
62
  /**
69
63
  * Retry `command` while — and only while — it fails `AppendConditionFailed`.
70
64
  *
@@ -1 +1 @@
1
- {"version":3,"file":"retryOnConflict.js","names":["_effect","require","conflictBackoff","Schedule","intersect","jittered","exponential","recurs","retryOnConflict","command","schedule","Effect","retry","while","Predicate","isTagged","exports"],"sources":["../../src/retryOnConflict.ts"],"sourcesContent":[null],"mappings":";;;;;;AA4CA,IAAAA,OAAA,GAAAC,OAAA;AA5CA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+CA;;;;;;;;;;;;;;AAcA,MAAMC,eAAe,gBAAGC,gBAAQ,CAACC,SAAS,cACxCD,gBAAQ,CAACE,QAAQ,cAACF,gBAAQ,CAACG,WAAW,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,eACvDH,gBAAQ,CAACI,MAAM,CAAC,CAAC,CAAC,CACnB;AAED;;;;;;;;;;;;;;;;;;;;;;AAsBO,MAAMC,eAAe,GAAGA,CAC7BC,OAAuD,EACvDC,QAAA,GAIIR,eAAe,KAEnBS,cAAM,CAACC,KAAK,CAACH,OAAO,EAAE;EACpBC,QAAQ;EACRG,KAAK,EAAEC,iBAAS,CAACC,QAAQ,CAAC,uBAAuB;CAClD,CAAC;AAAAC,OAAA,CAAAR,eAAA,GAAAA,eAAA","ignoreList":[]}
1
+ {"version":3,"file":"retryOnConflict.js","names":["_effect","require","conflictBackoff","Schedule","max","jittered","exponential","recurs","retryOnConflict","command","schedule","Effect","retry","while","Predicate","isTagged","exports"],"sources":["../../src/retryOnConflict.ts"],"sourcesContent":[null],"mappings":";;;;;;AAsCA,IAAAA,OAAA,GAAAC,OAAA;AAtCA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyCA;;;;;;;;;;;;;;AAcA,MAAMC,eAAe,gBAAGC,gBAAQ,CAACC,GAAG,CAAC,cACnCD,gBAAQ,CAACE,QAAQ,cAACF,gBAAQ,CAACG,WAAW,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,eACvDH,gBAAQ,CAACI,MAAM,CAAC,CAAC,CAAC,CACnB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;AAsBO,MAAMC,eAAe,GAAGA,CAC7BC,OAAuD,EACvDC,QAAA,GAKIR,eAAe,KAEnBS,cAAM,CAACC,KAAK,CAACH,OAAO,EAAE;EACpBC,QAAQ;EACRG,KAAK,EAAEC,iBAAS,CAACC,QAAQ,CAAC,uBAAuB;CAClD,CAAC;AAAAC,OAAA,CAAAR,eAAA,GAAAA,eAAA","ignoreList":[]}
@@ -27,10 +27,10 @@ var _effect = require("effect");
27
27
  *
28
28
  * Ordering in the log is by `position` alone, so an event's `occurredAt` is
29
29
  * informational; pinning it to the epoch keeps serialised bytes and comparisons
30
- * stable across runs. Built via `DateTime.unsafeMake(0)` (the value is a
30
+ * stable across runs. Built via `DateTime.makeUnsafe(0)` (the value is a
31
31
  * compile-time constant, not read from the host clock).
32
32
  */
33
- const EPOCH = exports.EPOCH = /*#__PURE__*/_effect.DateTime.unsafeMake(0);
33
+ const EPOCH = exports.EPOCH = /*#__PURE__*/_effect.DateTime.makeUnsafe(0);
34
34
  /**
35
35
  * Build a fresh, deterministic uuid generator: a zero-based counter producing
36
36
  * RFC-4122 v4-shaped ids `00000000-0000-4000-8000-<counter as 12 hex digits>`,
@@ -1 +1 @@
1
- {"version":3,"file":"testing.js","names":["_effect","require","EPOCH","exports","DateTime","unsafeMake","makeSequentialUuid","counter","suffix","toString","padStart"],"sources":["../../src/testing.ts"],"sourcesContent":[null],"mappings":";;;;;;AAgBA,IAAAA,OAAA,GAAAC,OAAA;AAhBA;;;;;;;;;;;;;;;;;AAkBA;;;;;;;;AAQO,MAAMC,KAAK,GAAAC,OAAA,CAAAD,KAAA,gBAAGE,gBAAQ,CAACC,UAAU,CAAC,CAAC,CAAC;AAE3C;;;;;;;;;;;AAWO,MAAMC,kBAAkB,GAAGA,CAAA,KAAqB;EACrD,IAAIC,OAAO,GAAG,CAAC;EACf,OAAO,MAAK;IACV,MAAMC,MAAM,GAAGD,OAAO,CAACE,QAAQ,CAAC,EAAE,CAAC,CAACC,QAAQ,CAAC,EAAE,EAAE,GAAG,CAAC;IACrDH,OAAO,IAAI,CAAC;IACZ,OAAO,2BAA2BC,MAAM,EAAE;EAC5C,CAAC;AACH,CAAC;AAAAL,OAAA,CAAAG,kBAAA,GAAAA,kBAAA","ignoreList":[]}
1
+ {"version":3,"file":"testing.js","names":["_effect","require","EPOCH","exports","DateTime","makeUnsafe","makeSequentialUuid","counter","suffix","toString","padStart"],"sources":["../../src/testing.ts"],"sourcesContent":[null],"mappings":";;;;;;AAgBA,IAAAA,OAAA,GAAAC,OAAA;AAhBA;;;;;;;;;;;;;;;;;AAkBA;;;;;;;;AAQO,MAAMC,KAAK,GAAAC,OAAA,CAAAD,KAAA,gBAAGE,gBAAQ,CAACC,UAAU,CAAC,CAAC,CAAC;AAE3C;;;;;;;;;;;AAWO,MAAMC,kBAAkB,GAAGA,CAAA,KAAqB;EACrD,IAAIC,OAAO,GAAG,CAAC;EACf,OAAO,MAAK;IACV,MAAMC,MAAM,GAAGD,OAAO,CAACE,QAAQ,CAAC,EAAE,CAAC,CAACC,QAAQ,CAAC,EAAE,EAAE,GAAG,CAAC;IACrDH,OAAO,IAAI,CAAC;IACZ,OAAO,2BAA2BC,MAAM,EAAE;EAC5C,CAAC;AACH,CAAC;AAAAL,OAAA,CAAAG,kBAAA,GAAAA,kBAAA","ignoreList":[]}
@@ -9,15 +9,13 @@
9
9
  */
10
10
  import { Schema } from 'effect';
11
11
  export declare const AppendCondition: Schema.Struct<{
12
- failIfEventsMatch: Schema.Struct<{
13
- items: Schema.Array$<Schema.Struct<{
14
- types: Schema.Array$<Schema.brand<Schema.filter<typeof Schema.String>, "EventType">>;
15
- tags: Schema.Array$<Schema.brand<Schema.filter<typeof Schema.String>, "Tag">>;
12
+ readonly failIfEventsMatch: Schema.Struct<{
13
+ readonly items: Schema.$Array<Schema.Struct<{
14
+ readonly types: Schema.$Array<Schema.brand<Schema.String, "EventType">>;
15
+ readonly tags: Schema.$Array<Schema.brand<Schema.String, "Tag">>;
16
16
  }>>;
17
17
  }>;
18
- after: Schema.optionalWith<Schema.brand<Schema.filter<typeof Schema.BigInt>, "Position">, {
19
- exact: true;
20
- }>;
18
+ readonly after: Schema.optionalKey<Schema.brand<Schema.decodeTo<Schema.BigInt, Schema.String, never, never>, "Position">>;
21
19
  }>;
22
20
  export type AppendCondition = typeof AppendCondition.Type;
23
21
  //# sourceMappingURL=AppendCondition.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"AppendCondition.d.ts","sourceRoot":"","sources":["../../src/AppendCondition.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAI/B,eAAO,MAAM,eAAe;;;;;;;;;;EAG1B,CAAA;AACF,MAAM,MAAM,eAAe,GAAG,OAAO,eAAe,CAAC,IAAI,CAAA"}
1
+ {"version":3,"file":"AppendCondition.d.ts","sourceRoot":"","sources":["../../src/AppendCondition.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAI/B,eAAO,MAAM,eAAe;;;;;;;;EAG1B,CAAA;AACF,MAAM,MAAM,eAAe,GAAG,OAAO,eAAe,CAAC,IAAI,CAAA"}
@@ -30,21 +30,21 @@
30
30
  *
31
31
  * ## Present means refused, so a sanctioned append REMOVES the marker
32
32
  *
33
- * The check reads the tag through `Effect.serviceOption`, so its ABSENCE is the
33
+ * The check reads the service through `Effect.serviceOption`, so its ABSENCE is the
34
34
  * normal case and costs the `append` signature nothing — `DcbEventStore.append`
35
35
  * keeps `R = never` and no caller provides anything. Presence is what refuses.
36
36
  *
37
37
  * That shape decides how the two legitimate appends inside a bracket get through,
38
38
  * and there is only one route: run with the marker STRIPPED from the context
39
- * (`Effect.mapInputContext` over `Context.omit(AppendIsOwned)`). The bracket's own
39
+ * (`Effect.updateContext` over `Context.omit(AppendIsOwned)`). The bracket's own
40
40
  * closing append is issued outside the scope it provided the marker in, and the
41
- * codec's escape hatch strips it explicitly. Neither needs a second tag, a
41
+ * codec's escape hatch strips it explicitly. Neither needs a second service, a
42
42
  * sanctioning flag or a mutable cell, and there is no way to be exempt by
43
43
  * accident: an append is either lexically outside the marked region or it says in
44
44
  * as many words that it is removing the marker.
45
45
  */
46
46
  import { Context, Effect } from 'effect';
47
- declare const AppendIsOwned_base: Context.TagClass<AppendIsOwned, "@kairos-es/core/AppendIsOwned", {
47
+ declare const AppendIsOwned_base: Context.ServiceClass<AppendIsOwned, "@kairos-es/core/AppendIsOwned", {
48
48
  readonly by: string;
49
49
  }>;
50
50
  /**
@@ -52,7 +52,7 @@ declare const AppendIsOwned_base: Context.TagClass<AppendIsOwned, "@kairos-es/co
52
52
  * owns it.
53
53
  *
54
54
  * `by` is a human-readable owner name and exists for the defect message alone —
55
- * the refusal is decided by the tag's PRESENCE, never by this value, so nothing
55
+ * the refusal is decided by the service's PRESENCE, never by this value, so nothing
56
56
  * branches on it and no caller need agree on a vocabulary for it.
57
57
  */
58
58
  export declare class AppendIsOwned extends AppendIsOwned_base {
@@ -69,7 +69,7 @@ export declare class AppendIsOwned extends AppendIsOwned_base {
69
69
  * its escape hatch for a deliberate second append — which is what makes a defect
70
70
  * affordable here.
71
71
  *
72
- * `Effect.serviceOption` is what keeps this free: it reads the tag if present and
72
+ * `Effect.serviceOption` is what keeps this free: it reads the service if present and
73
73
  * adds NOTHING to the requirement channel, so every existing append is unchanged
74
74
  * and unprovisioned.
75
75
  */
@@ -1 +1 @@
1
- {"version":3,"file":"AppendIsOwned.d.ts","sourceRoot":"","sources":["../../src/AppendIsOwned.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;;iBAYvB,MAAM;;AAVvB;;;;;;;GAOG;AACH,qBAAa,aAAc,SAAQ,kBAGhC;CAAG;AAEN;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,oBAAoB,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,CAepD,CAAA"}
1
+ {"version":3,"file":"AppendIsOwned.d.ts","sourceRoot":"","sources":["../../src/AppendIsOwned.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;;iBAYvB,MAAM;;AAVvB;;;;;;;GAOG;AACH,qBAAa,aAAc,SAAQ,kBAGC;CAAG;AAEvC;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,oBAAoB,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,CAepD,CAAA"}
@@ -8,10 +8,13 @@
8
8
  * channel (`never` for the pure in-memory engine; `SqlError` for either SQL one).
9
9
  * The decorator wraps those mechanics with the policy the contract demands — the
10
10
  * policy the first two engines hand-duplicated, with the Postgres one even
11
- * needing a bespoke `catchAll`/`instanceof`:
11
+ * needing a bespoke `catchAll`/`instanceof` (Effect 3's `catchAll`, which Effect 4
12
+ * names `catch`):
12
13
  *
13
14
  * - `assertServableQuery` at every verb's entry (read, the append condition's
14
- * guard query, subscribe) — a non-servable query is a DEFECT in every engine;
15
+ * guard query, subscribe) — a non-servable query, or one carrying a key the
16
+ * grammar does not define, is a DEFECT in every engine, and an append condition
17
+ * carrying a key `AppendCondition` does not define is refused alongside it;
15
18
  * - `ReadLimit` decode on `read`'s `limit` — a negative/non-integer limit is a
16
19
  * DEFECT (so `read` keeps `E = never`), validated through the branded schema
17
20
  * even at an untyped boundary that reaches the store as `unknown`;
@@ -34,7 +37,7 @@
34
37
  */
35
38
  import type { Array as Arr, Scope } from 'effect';
36
39
  import { Effect, Stream } from 'effect';
37
- import type { AppendCondition } from './AppendCondition.js';
40
+ import { AppendCondition } from './AppendCondition.js';
38
41
  import type { DcbEventStore, ReadOptions, ReadResponse } from './DcbEventStore.js';
39
42
  import type { DcbEvent, Position, SequencedEvent } from './Event.js';
40
43
  import type { AppendConditionFailed } from './errors.js';
@@ -55,5 +58,5 @@ export interface RawDcbEventStore<E> {
55
58
  * Wrap a raw engine's mechanics with the shared contract-enforcement policy,
56
59
  * producing a full `DcbEventStore` service value.
57
60
  */
58
- export declare const makeContractStore: <E>(raw: RawDcbEventStore<E>) => DcbEventStore["Type"];
61
+ export declare const makeContractStore: <E>(raw: RawDcbEventStore<E>) => DcbEventStore["Service"];
59
62
  //# sourceMappingURL=ContractStore.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ContractStore.d.ts","sourceRoot":"","sources":["../../src/ContractStore.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,OAAO,KAAK,EAAE,KAAK,IAAI,GAAG,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAA;AACjD,OAAO,EAAE,MAAM,EAAqB,MAAM,EAAE,MAAM,QAAQ,CAAA;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAEnD,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAC/E,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAEjE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAA;AACrD,OAAO,EAAuB,KAAK,KAAK,EAAE,MAAM,SAAS,CAAA;AAKzD;;;;;;GAMG;AACH,MAAM,WAAW,gBAAgB,CAAC,CAAC;IACjC,QAAQ,CAAC,IAAI,EAAE,CACb,KAAK,EAAE,KAAK,EACZ,OAAO,CAAC,EAAE,WAAW,KAClB,MAAM,CAAC,MAAM,CAAC,YAAY,EAAE,CAAC,CAAC,CAAA;IACnC,QAAQ,CAAC,MAAM,EAAE,CACf,MAAM,EAAE,GAAG,CAAC,qBAAqB,CAAC,QAAQ,CAAC,EAC3C,SAAS,CAAC,EAAE,eAAe,KACxB,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,qBAAqB,GAAG,CAAC,CAAC,CAAA;IACvD,QAAQ,CAAC,SAAS,EAAE,CAClB,KAAK,EAAE,KAAK,EACZ,KAAK,CAAC,EAAE,QAAQ,KACb,MAAM,CAAC,MAAM,CAAC,cAAc,EAAE,CAAC,EAAE,KAAK,CAAC,KAAK,CAAC,CAAA;CACnD;AAED;;;GAGG;AACH,eAAO,MAAM,iBAAiB,GAAI,CAAC,EACjC,KAAK,gBAAgB,CAAC,CAAC,CAAC,KACvB,aAAa,CAAC,SAAS,CAoGxB,CAAA"}
@@ -1,5 +1,5 @@
1
1
  /**
2
- * The `DcbEventStore` contract: a `Context.Tag` with no bundled implementation.
2
+ * The `DcbEventStore` contract: a `Context.Service` with no bundled implementation.
3
3
  * Consumers supply a `Layer` (the in-memory one lives in this package; each SQL
4
4
  * engine is a package of its own — `@kairos-es/store-postgres` and
5
5
  * `@kairos-es/store-sqlite`).
@@ -39,7 +39,7 @@ export interface ReadResponse {
39
39
  readonly events: Stream.Stream<SequencedEvent>;
40
40
  readonly head: Position;
41
41
  }
42
- declare const DcbEventStore_base: Context.TagClass<DcbEventStore, "@kairos-es/core/DcbEventStore", {
42
+ declare const DcbEventStore_base: Context.ServiceClass<DcbEventStore, "@kairos-es/core/DcbEventStore", {
43
43
  /**
44
44
  * Read events matching `query` (empty query = all), optionally bounded by
45
45
  * `after`/`limit`. See head semantics in the module docs.
@@ -1 +1 @@
1
- {"version":3,"file":"DcbEventStore.d.ts","sourceRoot":"","sources":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