@mmmnt/feat-adapter-kurrent 0.0.0-bootstrap.0 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026, Moment
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,5 +1,397 @@
1
1
  # @mmmnt/feat-adapter-kurrent
2
2
 
3
- This 0.0.0-bootstrap.0 release is a placeholder that reserves the package name so its npm trusted publisher can be configured. It contains no code.
3
+ Service adapter for Feat that turns a **KurrentDB `$all` log into a capture
4
+ window**: every event the system appends to a namespaced stream during a
5
+ scenario becomes a captured record, in log order. An unpredicted append fails
6
+ the suite by prediction inversion. The adapter is built on the official
7
+ `@kurrent/kurrentdb-client`.
4
8
 
5
- Install 0.1.0 or later, published from [mmmnt/feature](https://github.com/mmmnt/feature) by CI with provenance.
9
+ ```jsonc
10
+ // feat.config.json
11
+ "services": {
12
+ "orderStore": {
13
+ "adapter": "@mmmnt/feat-adapter-kurrent",
14
+ "consistency": "eventual",
15
+ "convergenceTimeout": 5000,
16
+ "options": {
17
+ "connectionStringEnv": "FEAT_KURRENT_URL" // or "connectionString": literal
18
+ }
19
+ }
20
+ }
21
+ ```
22
+
23
+ ```
24
+ predict success:
25
+ response 202 OrderAccepted { orderId: @when.orderId }
26
+ orderStore has [ OrderPlaced with OrderPlacedEvent { orderId: @when.orderId } ]
27
+ ```
28
+
29
+ Part of [Feature](https://github.com/mmmnt/feature), the `.feat` execution
30
+ specification language.
31
+
32
+ ## What it observes, and how
33
+
34
+ The adapter declares `observes = { diff: "native", state: true }`.
35
+
36
+ - **Diff (native).** The `$all` log is the change feed. `startCapture()`
37
+ appends a marker to the fence stream `feat-fence.<ns>` and keeps the marker's
38
+ commit position as an exclusive cursor, so there is no inclusive or exclusive
39
+ ambiguity at the start of the window. `peekCapture()` and `stopCapture()` read
40
+ `$all` forwards from that cursor with a server-side stream-name prefix filter
41
+ (`<ns>.` and `$$<ns>.`) and return what the system wrote, in commit-position
42
+ order. The order is the log's: total, even across streams.
43
+ - **State.** `read()` reads the namespace's streams forwards, so `contains`
44
+ assertions see what is stored, not only what changed.
45
+ - **Settle (a proof, not a timeout).** After the system's writes returned,
46
+ `settle()` appends a fence marker, reads `$all` from the cursor until an event
47
+ at or beyond the marker's position is seen, and answers `true`. Every write
48
+ committed before the marker is then visible to the capture. It also proves an
49
+ absence: an empty window settles `true`. It answers `false` when no window is
50
+ open, when the marker is not read back within `settleTimeoutMs`, or when the
51
+ append or the read fails (a paused or unreachable node answers `false`, never
52
+ `true`). The fence marker is never in a capture.
53
+ - **No `deliver()`.** KurrentDB has no inbound trigger; a stimulus is the
54
+ system's own append.
55
+
56
+ Declare the service `eventual`: `settle()` ends the convergence wait on proof,
57
+ and `convergenceTimeout` is the ceiling when it cannot vouch. `eventual`
58
+ services compare predictions unordered by default; write `has ordered [ ... ]`
59
+ when the log order is part of the prediction.
60
+
61
+ ### The captured record
62
+
63
+ ```
64
+ { type: <event type>, key: <stream, without the namespace prefix>,
65
+ payload: <the event's JSON data>, timestamp: <created time, ms>,
66
+ metadata: { revision, commitPosition } }
67
+ ```
68
+
69
+ What a capture keeps and drops:
70
+
71
+ - Events of streams outside the namespace are nobody's effect and are not
72
+ captured.
73
+ - Events the adapter itself wrote (metadata `{ "feat": "instrument" }`: fence
74
+ markers and fault placeholders) are never captured, peeked or read.
75
+ - Server-written system events (types starting with `$`) are dropped, except
76
+ `$streamDeleted` and `$metadata`. A soft delete or a metadata change by the
77
+ system is therefore captured, with key `$$<stream>` and type `$metadata`.
78
+ - Events that are not JSON are dropped.
79
+
80
+ ### The `$tb` metadata rule
81
+
82
+ On KurrentDB 26.2.3 the first append to a stream after a soft delete makes the
83
+ server write `$$<stream>/$metadata` with a body of exactly `{ "$tb": n }`, where
84
+ `n` is below the Int64 maximum. That record is the server's, not the system's,
85
+ so the capture drops it. A soft delete by the system writes the same body with
86
+ `n` equal to the Int64 maximum (`9223372036854775807`; the client delivers it as
87
+ the JSON number 2^63). That is the system's effect and is captured. A body with
88
+ any other key, or an `n` that is not a non-negative integer below the maximum,
89
+ is captured. (Founder ruling 2026-11-09, "Kurrent $tb A".)
90
+
91
+ ## Install
92
+
93
+ ```sh
94
+ npm install --save-dev @mmmnt/feature @mmmnt/feat-adapter-kurrent
95
+ ```
96
+
97
+ - Node 20 or later (`engines.node` is `>=20`). The adapter is ESM.
98
+ - No peer dependencies. `@kurrent/kurrentdb-client` (pinned at 1.3.2) and
99
+ `@mmmnt/feat-fault-proxy` are regular dependencies.
100
+ - The supported product is KurrentDB. The adapter's tests run against
101
+ `kurrentplatform/kurrentdb:26.2.3`, a single secure dev node
102
+ (`KURRENTDB_DEV=true`, projections off, `tlsVerifyCert=false`) with an
103
+ admin user and non-admin `writer` and `reader` users. The adapter does not
104
+ need projections: streams are found by an `$all` prefix scan, not `$streams`.
105
+ Kurrent Cloud works through `connectionString`; nothing here needs AWS.
106
+ - **A cluster is not verified.** Commit positions are positions in one node's
107
+ log, so `settle()` is a proof only when the append and the read go to the same
108
+ node. A single node is the tested shape.
109
+ - The instrument identity must be able to read `$all`, which KurrentDB allows
110
+ for an admin identity. Any other identity is refused at `setup()` with
111
+ `ALL_READ_DENIED`.
112
+ - The package ships `dist/` only. Its `fixtures/` helpers are internal.
113
+
114
+ ## Configuration
115
+
116
+ A complete service entry. Every key under `options` is optional except that a
117
+ connection string must be supplied one way or the other.
118
+
119
+ ```jsonc
120
+ "services": {
121
+ "orderStore": {
122
+ "adapter": "@mmmnt/feat-adapter-kurrent",
123
+ "consistency": "eventual",
124
+ "convergenceTimeout": 5000,
125
+ "options": {
126
+ "connectionStringEnv": "FEAT_KURRENT_URL", // name of the variable holding the connection string
127
+ // "connectionString": "kurrentdb://localhost:2113?tls=false", // or a literal; wins over connectionStringEnv
128
+ "system": { // env-var NAMES for the instrument's credentials
129
+ "username": "FEAT_KURRENT_USER",
130
+ "password": "FEAT_KURRENT_PASSWORD"
131
+ },
132
+ "settleTimeoutMs": 5000, // default 5000
133
+ "nodeMajor": 24, // the Node major the TLS host rule judges by; default the running Node's
134
+ "proxy": { // transport faults on the system's path
135
+ "api": "http://127.0.0.1:8474", // Toxiproxy API
136
+ "upstream": "127.0.0.1:2113", // host:port of the node, as Toxiproxy reaches it
137
+ "name": "kurrent", // product label of the proxy name feat-<ns>-<name>; default "kurrent"
138
+ "container": "kurrentdb", // the node's container; without it BrokerLoss is not offered
139
+ "metrics": "http://127.0.0.1:8474/metrics", // Toxiproxy /metrics URL
140
+ "runtime": "docker" // container runtime CLI; default "docker"
141
+ }
142
+ }
143
+ }
144
+ }
145
+ ```
146
+
147
+ | Option | Meaning |
148
+ | --- | --- |
149
+ | `connectionString` | A literal `kurrentdb://` or `kurrentdb+discover://` string. |
150
+ | `connectionStringEnv` | The name of an environment variable holding the string. Used when `connectionString` is absent. Neither set, or the variable unset or empty, is a configuration error at `setup()`. |
151
+ | `system` | `{ username, password }`: the **names** of two environment variables. Their values replace the credentials in the connection string. Both must be set. The config carries references, never secrets. |
152
+ | `settleTimeoutMs` | How long `settle()` may take to read its fence marker back. Default 5000. Keep `convergenceTimeout` at or above it. |
153
+ | `nodeMajor` | An integer, 1 or more (anything else is refused at `setup()` with `OPTIONS_INVALID`), that overrides the Node major the TLS host rule uses, so a scenario can put the adapter "on Node 24 or 26" without a second Node. Default: the running Node's major. |
154
+ | `proxy` | A Toxiproxy in front of KurrentDB for `Connection` faults. `api` and `upstream` are required. See below. |
155
+
156
+ The adapter does not reject unknown keys under `options`; a misspelled option is
157
+ ignored. `connectionString` and `connectionStringEnv` may both appear; the
158
+ literal wins.
159
+
160
+ The adapter's own client (capture, fence, read, seed, reset) connects to the
161
+ node **directly** and never through the proxy.
162
+
163
+ ## A minimal spec
164
+
165
+ ```
166
+ feat 1.0
167
+
168
+ spec SPEC-ORD-010 "PlaceOrder appends to the order stream"
169
+ context Orders
170
+ aggregate Order
171
+ type command
172
+ status agreed
173
+
174
+ construct:
175
+ handler at features/place-order/handler.ts
176
+ touches features/place-order/**
177
+
178
+ enforce:
179
+ append OrderPlaced to the stream orders-<orderId>
180
+ rejects CONCURRENCY_CONFLICT when the store reports a wrong expected version
181
+
182
+ contract:
183
+ input PlaceOrderInput
184
+ response OrderAccepted
185
+ event OrderPlacedEvent
186
+ event OrderSeededEvent
187
+ error Refusal
188
+
189
+ scenario "a first order is appended":
190
+ given:
191
+ A customer has an earlier order in another stream.
192
+ seed orderStore [ OrderSeeded with OrderSeededEvent { stream: "orders-o-0", orderId: "o-0" } ]
193
+ when: PlaceOrder { orderId: "o-1" }
194
+ predict success:
195
+ response 202 OrderAccepted { orderId: @when.orderId }
196
+ orderStore has [ OrderPlaced with OrderPlacedEvent { orderId: @when.orderId } ]
197
+
198
+ scenario "a competing writer created the stream first":
199
+ given:
200
+ fault orderStore AppendToStream WRONG_EXPECTED_VERSION { stream: "orders-o-2" } until reset
201
+ when: PlaceOrder { orderId: "o-2" }
202
+ predict rejection CONCURRENCY_CONFLICT:
203
+ response 409 Refusal { code: "CONCURRENCY_CONFLICT" }
204
+ orderStore has []
205
+ ```
206
+
207
+ The seed record's event type is `OrderSeeded`. It goes to the stream named in
208
+ `values.stream` (`orders-o-0`), or to a stream named after the record type when
209
+ `values` has no string `stream`. The whole of `values`, `stream` included, is
210
+ the event data. Seeds are written before the window opens, so they are never in
211
+ a capture. The fault line must say `until reset`: a count of `once` or
212
+ `times <n>` is refused (see the fault table).
213
+
214
+ ## Namespaces
215
+
216
+ The runner derives a namespace per spec file, exactly `^s[0-9a-f]{12}$`
217
+ (SPEC-RT-006), and hands it to the adapter as the config's top-level
218
+ `namespace`. It is never an option. Because the form is fixed-length with no
219
+ dot, no namespace is a prefix of another.
220
+
221
+ - A stream is stored as `<ns>.<stream>`. The spec writes `orders-o-1`; the
222
+ adapter reports `orders-o-1`. The system under test must write to the prefixed
223
+ names. Seeds, fault details and read hints take the relative name and the
224
+ adapter adds the prefix.
225
+ - Capture, read and reset are all scoped to the prefix. A write outside every
226
+ namespace is nobody's effect.
227
+ - The fence stream is `feat-fence.<ns>`, outside the user prefix.
228
+ - `reset()` soft-deletes the namespace's streams. It does not tombstone them: a
229
+ tombstoned stream name is dead forever.
230
+
231
+ ## Seed, read and reset
232
+
233
+ - **`seed(records)`** appends each record to `<ns>.<stream>` with stream state
234
+ `ANY`, before the window.
235
+ - **`read(query)`** reads the namespace's streams forwards and returns the
236
+ events as records (`metadata: { revision }`). With hints, `contains`
237
+ assertions that carry a `key.stream` literal name the streams to read; the
238
+ adapter reads those and may return no others. Without hints it finds every
239
+ stream the namespace has ever held by an `$all` prefix scan. A soft-deleted or
240
+ never-written stream reads as empty, so state is not resurrected from `$all`.
241
+ Instrument events, `$`-typed events and non-JSON events are skipped.
242
+ - **`reset()`** disarms every transport fault and restores a paused or stopped
243
+ container, clears and soft-deletes every stream of the namespace (clearing
244
+ stream metadata first, which removes an `ACCESS_DENIED` ACL), and closes the
245
+ window.
246
+
247
+ ## Faults
248
+
249
+ All logical faults are armed `until reset`: the product keeps no record of a
250
+ refusal it issued. `firedFaults` is not implemented, so evidence is
251
+ `unobserved`. A fault line with any other count is refused with
252
+ `FAULT_UNSUPPORTED` before it has an effect.
253
+
254
+ | Fault | Operation | Counts | Detail | What the system sees |
255
+ | --- | --- | --- | --- | --- |
256
+ | `WRONG_EXPECTED_VERSION` | `AppendToStream` | `until reset` | `{ stream }` (required) | The adapter appends an instrument event to the stream, so a stream the system expects **not** to exist now exists, and the server refuses the append with `WRONG_EXPECTED_VERSION`. It fires only for appends that expect `NoStream`; an append with `ANY` succeeds. |
257
+ | `ACCESS_DENIED` | `AppendToStream` | `until reset` | `{ stream }` (required) | The adapter sets the stream's `$acl` write role to one nobody holds, so the server refuses a non-admin writer's append with `ACCESS_DENIED`. `$admins` bypass ACLs, so the **system must connect as a non-admin** user. |
258
+ | `Timeout` | `Connection` | `until reset` | none | Needs `options.proxy`. Toxiproxy stalls the stream and never delivers; the system's call runs into its own deadline. Armed downstream (the library default; the adapter passes no direction), so on an established connection the node may apply a request whose answer the system never hears. |
259
+ | `ConnectionReset` | `Connection` | `until reset` | none | Needs `options.proxy`. Toxiproxy resets the connection (default direction upstream, on the request path). |
260
+ | `Partition` | `Connection` | `until reset` | none | Needs `options.proxy`. The proxy is disabled: the system's connections fail. |
261
+ | `BrokerLoss` | `Connection` | `until reset` | none | Needs `options.proxy.container`. The container is paused with the runtime's CLI. Exclusive and serial. |
262
+
263
+ Under a transport fault the system's gRPC client reports `UNAVAILABLE`,
264
+ `DEADLINE_EXCEEDED` or `CANCELLED`.
265
+
266
+ Not offered: `STREAM_DELETED` (a tombstone is irreversible and would poison the
267
+ namespace), `NOT_LEADER` (no native way to produce it), timeouts on the product
268
+ itself (those are `Connection.Timeout`), and `once` or `times` counts for every
269
+ fault. A race between the system's read and write cannot be produced without
270
+ sitting in the call path.
271
+
272
+ ### Transport faults and broker loss
273
+
274
+ Set `options.proxy` and the catalog gains `Connection.Timeout`,
275
+ `Connection.ConnectionReset` and `Connection.Partition`. Adding
276
+ `options.proxy.container` adds `Connection.BrokerLoss`. The mechanism is
277
+ [`@mmmnt/feat-fault-proxy`](https://github.com/mmmnt/feature/blob/main/adapters/fault-proxy/README.md) (SPEC-FPX-001): one
278
+ Toxiproxy proxy per namespace and product, named `feat-<ns>-<name>`.
279
+
280
+ - A transport fault is on the **system's path only**. The adapter observes on
281
+ its own direct connection, so under a fault the capture, the fence and the
282
+ state read still work, and an absence under a fault is still provable.
283
+ - Point the system's client at the proxy's listen address (`proxyListen()` on
284
+ the adapter). KurrentDB's gRPC over HTTP/2 passes through Toxiproxy's TCP
285
+ proxy unchanged.
286
+ - Give the system a **single-node connection string** (no gossip discovery,
287
+ which would hand the client the node's advertised address and bypass the
288
+ proxy), and either a certificate that names the proxy host or
289
+ `tlsVerifyCert=false` on a dev node.
290
+ - Whether a fault was consumed is unobserved: the proxy reports bytes, not
291
+ activations.
292
+ - `BrokerLoss` pauses the node's container, which every namespace and every spec
293
+ file shares. It is an exclusive fault: the harness runs it only in the serial
294
+ pass with one worker and `FEAT_SERIAL=1`, and refuses it elsewhere with
295
+ `FAULT_REQUIRES_SERIAL`. Keep it in a spec file of its own. While the node is
296
+ paused `settle()` answers `false`, not `true`; `reset()` unpauses it.
297
+ - A `Connection` fault without `options.proxy`, or `BrokerLoss` without
298
+ `options.proxy.container`, is not in the catalog and is refused with
299
+ `FAULT_UNSUPPORTED`.
300
+
301
+ ## The TLS host rule (SPEC-ADPKUR-004)
302
+
303
+ Node 26 refuses an IP address as the TLS server name
304
+ (`ERR_INVALID_ARG_VALUE`). `@grpc/grpc-js` 1.14.7 sets the server name to the
305
+ remote host unconditionally, and `@kurrent/kurrentdb-client` 1.3.2 has no
306
+ channel option to stop it, so a `kurrentdb://` string with `tls=true` (the
307
+ default when `tls` is absent) and an IP host cannot connect on Node 26.
308
+ `tlsVerifyCert=false` does not help, because the name is still set. The
309
+ upstream issue is
310
+ [grpc/grpc-node#3131](https://github.com/grpc/grpc-node/issues/3131); the rule
311
+ can go when grpc-js stops sending an IP as the server name.
312
+
313
+ The rule applies to the adapter's own connection (the system's client is the
314
+ system's concern), host by host, in order:
315
+
316
+ | Connection string | What the adapter does |
317
+ | --- | --- |
318
+ | Host exactly `127.0.0.1` or `::1`, `tls=true` | Connects as `localhost`. Only the host changes: credentials, port, path and every parameter are as written. This applies on **every** Node major, so one path serves the whole CI matrix. `[0:0:0:0:0:0:0:1]` is the same host as `::1`. |
319
+ | Any other IP literal, `tls=true`, Node 26 or later (or `options.nodeMajor` 26 or later) | `setup()` throws `TLS_HOST_UNSUPPORTED` before connecting. The detail names the host and says to use a hostname the certificate names, or `tls=false`. It carries no credential. |
320
+ | A hostname, `kurrentdb+discover://`, `tls=false`, or a non-loopback IP on Node below 26 | Left exactly as written. |
321
+
322
+ A string with several hosts is judged host by host; the first refused host is
323
+ the one the detail names. The loopback test is exact, not `127.0.0.0/8`:
324
+ `localhost` never resolves to `127.0.0.2`, so that address is refused on Node 26.
325
+ `[::ffff:127.0.0.1]` is an IPv4-mapped IPv6 literal: an IP host, not a loopback
326
+ host, so it is refused on Node 26.
327
+
328
+ Consequences:
329
+
330
+ - If you verify the certificate and relied on an IP SAN for `127.0.0.1`, the
331
+ certificate must now name `localhost`.
332
+ - `@kurrent/kurrentdb-client` 1.3.2 cannot parse a **bracketed IPv6** host. Only
333
+ `::1`, which the rule rewrites to `localhost`, can reach a node over IPv6.
334
+ - `0.0.0.0` reaches a local node on Linux and macOS but is judged by the rule
335
+ like any non-loopback IP, so on Node 26 it is refused.
336
+
337
+ Two methods let a host check the rule without a network: `connectionRefusal()`
338
+ returns the code `setup()` would refuse with (or `undefined`), and
339
+ `connectionTarget()` returns the string the client is created from. Neither
340
+ connects, and neither throws for a refusal.
341
+
342
+ ## Errors and refusals
343
+
344
+ Adapter errors are `KurrentAdapterError`, with a `code` and a `detail`.
345
+
346
+ | Code | Raised by | When |
347
+ | --- | --- | --- |
348
+ | `NAMESPACE_INVALID` | construction | The namespace does not match `^s[0-9a-f]{12}$`. Defensive: the runner never passes another. |
349
+ | `ALL_READ_DENIED` | `setup()` | The instrument credentials cannot read `$all`. |
350
+ | `TLS_HOST_UNSUPPORTED` | `setup()` | An IP host other than `127.0.0.1` and `::1`, with `tls=true`, on Node 26 or later. |
351
+ | `OPTIONS_INVALID` | `setup()` | `options.nodeMajor` is present and is not an integer of 1 or more. Refused before any connection. |
352
+ | `FAULT_UNSUPPORTED` | `fault()` | The fault is not in the catalog (including `Connection` without `options.proxy` and `BrokerLoss` without `container`), or the count is not `until reset`, or an `AppendToStream` fault has no `detail.stream`. The detail lists the catalog. |
353
+
354
+ Plain `Error`s (no code) report a missing connection string
355
+ (`connectionString`, or `connectionStringEnv` naming a set variable) and
356
+ `options.system` naming variables that are not both set. Errors from the
357
+ Toxiproxy layer keep the codes of `@mmmnt/feat-fault-proxy`
358
+ (`PROXY_UNREACHABLE`, `PROXY_NOT_OPEN`, `FAULT_UNSUPPORTED`,
359
+ `CONTAINER_NOT_FOUND`, `CONTAINER_RUNTIME_UNAVAILABLE`).
360
+
361
+ ## Limitations
362
+
363
+ - `settle()` does not prove writes the system starts after its handler returned
364
+ (the ADR-0021 boundary), and a cluster is not verified (see Install).
365
+ - `read()` without a hint and `reset()` find the namespace's streams by scanning
366
+ `$all` from the start, so their cost grows with the log. `reset()` leaves the
367
+ fence stream `feat-fence.<ns>` in place; it holds only instrument markers.
368
+ - Non-JSON events are not captured or read.
369
+ - `WRONG_EXPECTED_VERSION` fires only for appends that expect `NoStream`.
370
+ `ACCESS_DENIED` needs a non-admin system identity. Neither can be armed
371
+ `once`.
372
+ - The `options.proxy` block needs a Toxiproxy server you run; the adapter does
373
+ not start one. `Timeout` can leave a write applied on an established
374
+ connection (see the fault table).
375
+ - Options are validated only for `nodeMajor`: unknown keys are ignored.
376
+
377
+ ## Specs and design
378
+
379
+ - [`observe.feat`](https://github.com/mmmnt/feature/blob/main/adapters/kurrent/observe.feat): SPEC-ADPKUR-001, namespaced capture, state,
380
+ settle, reset and faults.
381
+ - [`transport.feat`](https://github.com/mmmnt/feature/blob/main/adapters/kurrent/transport.feat): SPEC-ADPKUR-002, transport faults on the
382
+ system's path (integration tier).
383
+ - [`broker-loss.feat`](https://github.com/mmmnt/feature/blob/main/adapters/kurrent/broker-loss.feat): SPEC-ADPKUR-003, broker loss
384
+ (integration tier, serial).
385
+ - [`node26-tls-host.feat`](https://github.com/mmmnt/feature/blob/main/adapters/kurrent/node26-tls-host.feat): SPEC-ADPKUR-004, the TLS
386
+ host rule (spec tier).
387
+ - [`DESIGN.md`](https://github.com/mmmnt/feature/blob/main/adapters/kurrent/DESIGN.md): the client choice, the settle proof, the
388
+ namespace, the faults and the TLS host rule, with sources.
389
+
390
+ The generated suites run under `feat run` against throwaway containers
391
+ (`kurrentplatform/kurrentdb:26.2.3`, `ghcr.io/shopify/toxiproxy:2.12.0`) that
392
+ the fixture starts and removes on exit. They are not part of the package's
393
+ `test` script.
394
+
395
+ ## License
396
+
397
+ MIT. Docs: https://github.com/mmmnt/feature/wiki
@@ -0,0 +1,35 @@
1
+ import type { FeatServiceAdapter } from "@mmmnt/feat-types";
2
+ export type KurrentAdapterErrorCode = "NAMESPACE_INVALID" | "ALL_READ_DENIED" | "FAULT_UNSUPPORTED" | "TLS_HOST_UNSUPPORTED" | "OPTIONS_INVALID";
3
+ export declare class KurrentAdapterError extends Error {
4
+ readonly code: KurrentAdapterErrorCode;
5
+ readonly detail: string;
6
+ constructor(code: KurrentAdapterErrorCode, detail: string);
7
+ }
8
+ export interface KurrentProxyOptions {
9
+ /** Toxiproxy API base URL. */
10
+ api: string;
11
+ /** host:port of the product as Toxiproxy reaches it (it can differ from the instrument's address). */
12
+ upstream: string;
13
+ /** The product label of the proxy name `feat-<ns>-<name>`. Default "kurrent". */
14
+ name?: string;
15
+ /** The product's container, for BrokerLoss. Without it BrokerLoss is not in the catalog. */
16
+ container?: string;
17
+ metrics?: string;
18
+ runtime?: string;
19
+ }
20
+ export interface KurrentOptions {
21
+ connectionString?: string;
22
+ /** Name of the environment variable holding the connection string. */
23
+ connectionStringEnv?: string;
24
+ /** Names of the environment variables holding the instrument's credentials. */
25
+ system?: {
26
+ username: string;
27
+ password: string;
28
+ };
29
+ settleTimeoutMs?: number;
30
+ proxy?: KurrentProxyOptions;
31
+ /** The Node major the TLS host rule judges by (SPEC-ADPKUR-004). Default: the running Node's. */
32
+ nodeMajor?: number;
33
+ }
34
+ export declare function createAdapter(config: Record<string, unknown>): FeatServiceAdapter;
35
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,EAIV,kBAAkB,EAGnB,MAAM,mBAAmB,CAAC;AAE3B,MAAM,MAAM,uBAAuB,GAAG,mBAAmB,GAAG,iBAAiB,GAAG,mBAAmB,GAAG,sBAAsB,GAAG,iBAAiB,CAAC;AAEjJ,qBAAa,mBAAoB,SAAQ,KAAK;IAE1C,QAAQ,CAAC,IAAI,EAAE,uBAAuB;IACtC,QAAQ,CAAC,MAAM,EAAE,MAAM;gBADd,IAAI,EAAE,uBAAuB,EAC7B,MAAM,EAAE,MAAM;CAK1B;AAED,MAAM,WAAW,mBAAmB;IAClC,8BAA8B;IAC9B,GAAG,EAAE,MAAM,CAAC;IACZ,sGAAsG;IACtG,QAAQ,EAAE,MAAM,CAAC;IACjB,iFAAiF;IACjF,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,4FAA4F;IAC5F,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,cAAc;IAC7B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,sEAAsE;IACtE,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,+EAA+E;IAC/E,MAAM,CAAC,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC;IAChD,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,KAAK,CAAC,EAAE,mBAAmB,CAAC;IAC5B,iGAAiG;IACjG,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AA0eD,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,kBAAkB,CAEjF"}
package/dist/index.js ADDED
@@ -0,0 +1,493 @@
1
+ // @mmmnt/feat-adapter-kurrent (SPEC-ADPKUR-001, -002, -003, -004) — KurrentDB as a Feat service.
2
+ //
3
+ // The `$all` log is the change feed: it is totally ordered by log position, and the position of an
4
+ // append (AppendResult.position) is a position in that same log. That is the whole of settle: append a
5
+ // fence marker after the system's writes returned, read `$all` until an event at or beyond the marker's
6
+ // position is seen, and every earlier write is visible to the capture. It proves absence too.
7
+ //
8
+ // The adapter's own (instrument) client is connected to the product directly and never through a
9
+ // proxy; transport faults (Connection.*) are armed on a Toxiproxy proxy in front of the SYSTEM's path
10
+ // through @mmmnt/feat-fault-proxy (SPEC-FPX-001).
11
+ import { ANY, KurrentDBClient, START, jsonEvent, streamNameFilter, } from "@kurrent/kurrentdb-client";
12
+ import { isIP } from "node:net";
13
+ import { createFaultProxy } from "@mmmnt/feat-fault-proxy";
14
+ export class KurrentAdapterError extends Error {
15
+ code;
16
+ detail;
17
+ constructor(code, detail) {
18
+ super(`${code}: ${detail}`);
19
+ this.code = code;
20
+ this.detail = detail;
21
+ this.name = "KurrentAdapterError";
22
+ }
23
+ }
24
+ const NAMESPACE_PATTERN = /^s[0-9a-f]{12}$/;
25
+ const INSTRUMENT_MARKER = { feat: "instrument" };
26
+ const WHOLE_LOG = Number.MAX_SAFE_INTEGER;
27
+ const POLL_MS = 25;
28
+ /** Event types a capture keeps from the system's own stream-level events. */
29
+ const KEPT_SYSTEM_TYPES = new Set(["$streamDeleted", "$metadata"]);
30
+ /** 9223372036854775807 as the JSON number a JS client delivers: 2^63. */
31
+ const INT64_MAX_AS_NUMBER = 2 ** 63;
32
+ const CONNECTION_FAULTS = ["Timeout", "ConnectionReset", "Partition"];
33
+ /** Node refuses an IP address as the TLS servername from this major on (SPEC-ADPKUR-004). */
34
+ const IP_SERVERNAME_REFUSED_FROM = 26;
35
+ function after(a, b) {
36
+ return a.commit > b.commit || (a.commit === b.commit && a.prepare > b.prepare);
37
+ }
38
+ /**
39
+ * The `$metadata` record the server writes on the first append after a soft delete: a body that is exactly
40
+ * `{ $tb: n }` with n below the Int64 maximum (founder ruling 2026-11-09, Kurrent $tb A). A soft delete by the
41
+ * system writes the maximum, which the client delivers as the JSON number 2^63, and is the system's effect.
42
+ */
43
+ function isServerTruncateBefore(type, data) {
44
+ if (type !== "$metadata" || typeof data !== "object" || data === null || Array.isArray(data))
45
+ return false;
46
+ const keys = Object.keys(data);
47
+ if (keys.length !== 1 || keys[0] !== "$tb")
48
+ return false;
49
+ const n = data.$tb;
50
+ return typeof n === "number" && Number.isInteger(n) && n >= 0 && n < INT64_MAX_AS_NUMBER;
51
+ }
52
+ /** The WHATWG form of an IP literal, so `[0:0:0:0:0:0:0:1]` and `[::1]` are one host; the literal as written when it does not parse. */
53
+ function canonicalIp(literal) {
54
+ try {
55
+ return new URL(`http://${literal.includes(":") ? `[${literal}]` : literal}`).hostname.replace(/^\[|\]$/g, "");
56
+ }
57
+ catch {
58
+ return literal;
59
+ }
60
+ }
61
+ /** The authority of a connection string split so each host can be judged and replaced on its own. */
62
+ function splitAuthority(raw) {
63
+ const m = /^([a-z][a-z0-9+.-]*:\/\/)([^/?#]*)(.*)$/is.exec(raw);
64
+ if (m === null)
65
+ return undefined;
66
+ const authority = m[2];
67
+ const at = authority.lastIndexOf("@");
68
+ return { head: m[1] + authority.slice(0, at + 1), hosts: authority.slice(at + 1).split(","), tail: m[3] };
69
+ }
70
+ /** One `host[:port]` entry of the host list: the host without its brackets, and the port with its colon. */
71
+ function splitHost(entry) {
72
+ if (entry.startsWith("[")) {
73
+ const end = entry.indexOf("]");
74
+ if (end > 0)
75
+ return { host: entry.slice(1, end), port: entry.slice(end + 1) };
76
+ }
77
+ const colon = entry.lastIndexOf(":");
78
+ return colon < 0 ? { host: entry, port: "" } : { host: entry.slice(0, colon), port: entry.slice(colon) };
79
+ }
80
+ /** The client's default is tls=true, so only an explicit false turns it off. */
81
+ function tlsOn(raw) {
82
+ const query = raw.split("#")[0].split("?")[1] ?? "";
83
+ for (const [k, v] of new URLSearchParams(query))
84
+ if (k.toLowerCase() === "tls")
85
+ return v.toLowerCase() !== "false";
86
+ return true;
87
+ }
88
+ function errorType(e) {
89
+ return typeof e === "object" && e !== null && "type" in e && typeof e.type === "string"
90
+ ? e.type
91
+ : undefined;
92
+ }
93
+ function sleep(ms) {
94
+ return new Promise((resolve) => setTimeout(resolve, ms));
95
+ }
96
+ /** Reject after `ms` so a call into a product that no longer answers (a paused container) cannot hang the harness. */
97
+ function within(promise, ms) {
98
+ let timer;
99
+ const deadline = new Promise((_, reject) => {
100
+ timer = setTimeout(() => reject(new Error(`no answer within ${ms} ms`)), ms);
101
+ });
102
+ promise.catch(() => { });
103
+ return Promise.race([promise, deadline]).finally(() => clearTimeout(timer));
104
+ }
105
+ class KurrentAdapter {
106
+ observes = { diff: "native", state: true };
107
+ faults;
108
+ namespace;
109
+ options;
110
+ settleTimeoutMs;
111
+ client;
112
+ proxy;
113
+ opened;
114
+ /** The window: the last position read (exclusive cursor) and what has been captured since. */
115
+ cursor;
116
+ captured = [];
117
+ windowOpen = false;
118
+ constructor(config) {
119
+ const ns = config.namespace;
120
+ if (typeof ns !== "string" || !NAMESPACE_PATTERN.test(ns)) {
121
+ throw new KurrentAdapterError("NAMESPACE_INVALID", `'${String(ns)}' does not match ${NAMESPACE_PATTERN.source}, the pattern the runner derives`);
122
+ }
123
+ this.namespace = ns;
124
+ this.options = config.options ?? {};
125
+ this.settleTimeoutMs = this.options.settleTimeoutMs ?? 5000;
126
+ const catalog = {
127
+ AppendToStream: { WRONG_EXPECTED_VERSION: ["reset"], ACCESS_DENIED: ["reset"] },
128
+ };
129
+ const proxy = this.options.proxy;
130
+ if (proxy !== undefined) {
131
+ this.proxy = createFaultProxy({
132
+ api: proxy.api,
133
+ product: proxy.name ?? "kurrent",
134
+ upstream: proxy.upstream,
135
+ namespace: ns,
136
+ ...(proxy.container !== undefined ? { container: proxy.container } : {}),
137
+ ...(proxy.metrics !== undefined ? { metrics: proxy.metrics } : {}),
138
+ ...(proxy.runtime !== undefined ? { runtime: proxy.runtime } : {}),
139
+ });
140
+ catalog.Connection = Object.fromEntries(this.proxy.catalog.map((f) => [f, ["reset"]]));
141
+ }
142
+ this.faults = catalog;
143
+ }
144
+ reportedNamespace() {
145
+ return this.namespace;
146
+ }
147
+ /** The address the system under test connects to when `options.proxy` is configured (host side of the proxy). */
148
+ proxyListen() {
149
+ return this.opened?.listen;
150
+ }
151
+ // ── naming ────────────────────────────────────────────────────────────────
152
+ get prefix() {
153
+ return `${this.namespace}.`;
154
+ }
155
+ get metaPrefix() {
156
+ return `$$${this.namespace}.`;
157
+ }
158
+ get fenceStream() {
159
+ return `feat-fence.${this.namespace}`;
160
+ }
161
+ full(stream) {
162
+ return `${this.prefix}${stream}`;
163
+ }
164
+ /** The namespace-relative key of a stream name, or undefined outside the namespace. */
165
+ relative(streamId) {
166
+ if (streamId.startsWith(this.prefix))
167
+ return streamId.slice(this.prefix.length);
168
+ if (streamId.startsWith(this.metaPrefix))
169
+ return `$$${streamId.slice(this.metaPrefix.length)}`;
170
+ return undefined;
171
+ }
172
+ // ── the instrument connection ─────────────────────────────────────────────
173
+ /**
174
+ * SPEC-ADPKUR-004: with tls on, a host that is exactly 127.0.0.1 or ::1 is replaced by `localhost` (only the host),
175
+ * and any other IP literal is refused on a Node that refuses an IP servername. A `+discover` string is left as written.
176
+ */
177
+ tlsHostRule(raw) {
178
+ const parts = splitAuthority(raw);
179
+ if (parts === undefined || /^kurrentdb\+discover:/i.test(raw) || !tlsOn(raw))
180
+ return { target: raw };
181
+ const major = this.options.nodeMajor ?? Number(process.versions.node.split(".")[0]);
182
+ let refusal;
183
+ const hosts = parts.hosts.map((entry) => {
184
+ const { host, port } = splitHost(entry);
185
+ if (isIP(host) === 0)
186
+ return entry;
187
+ const ip = canonicalIp(host);
188
+ if (ip === "127.0.0.1" || ip === "::1")
189
+ return `localhost${port}`;
190
+ if (major >= IP_SERVERNAME_REFUSED_FROM) {
191
+ refusal ??= new KurrentAdapterError("TLS_HOST_UNSUPPORTED", `the host ${ip} is an IP address and the connection string has tls=true: Node ${major} refuses an IP address as the TLS server name; use a hostname the certificate names, or tls=false`);
192
+ }
193
+ return entry;
194
+ });
195
+ return { target: parts.head + hosts.join(",") + parts.tail, ...(refusal !== undefined ? { refusal } : {}) };
196
+ }
197
+ resolveConnection() {
198
+ const o = this.options;
199
+ const raw = o.connectionString ?? (o.connectionStringEnv !== undefined ? process.env[o.connectionStringEnv] : undefined);
200
+ if (raw === undefined || raw === "") {
201
+ throw new Error(`the kurrent service '${"key"}' has no connectionString (or connectionStringEnv naming a set variable)`);
202
+ }
203
+ const { target, refusal } = this.tlsHostRule(raw);
204
+ return { target: this.withCredentials(target), ...(refusal !== undefined ? { refusal } : {}) };
205
+ }
206
+ /** The string the client is created from, no network; a refused host stays as written (setup() throws for it). */
207
+ connectionTarget() {
208
+ return this.resolveConnection().target;
209
+ }
210
+ /** The code setup() would refuse with for the connection string (SPEC-ADPKUR-004), or undefined; no network, never throws. */
211
+ connectionRefusal() {
212
+ return this.resolveConnection().refusal?.code;
213
+ }
214
+ connectionString() {
215
+ const { target, refusal } = this.resolveConnection();
216
+ if (refusal !== undefined)
217
+ throw refusal;
218
+ return target;
219
+ }
220
+ withCredentials(raw) {
221
+ const o = this.options;
222
+ if (o.system === undefined)
223
+ return raw;
224
+ const user = process.env[o.system.username];
225
+ const pass = process.env[o.system.password];
226
+ if (user === undefined || pass === undefined) {
227
+ throw new Error(`options.system names the variables ${o.system.username} and ${o.system.password}, which are not both set`);
228
+ }
229
+ const url = new URL(raw);
230
+ url.username = user;
231
+ url.password = pass;
232
+ return url.toString();
233
+ }
234
+ db() {
235
+ if (this.client === undefined)
236
+ this.client = KurrentDBClient.connectionString(this.connectionString());
237
+ return this.client;
238
+ }
239
+ async setup() {
240
+ // A config refusal, before any connection (SPEC-ADPKUR-004: nodeMajor is an integer, 1 or more).
241
+ const major = this.options.nodeMajor;
242
+ if (major !== undefined && !(typeof major === "number" && Number.isInteger(major) && major >= 1)) {
243
+ throw new KurrentAdapterError("OPTIONS_INVALID", `options.nodeMajor must be an integer, 1 or more; got ${typeof major === "string" ? JSON.stringify(major) : String(major)}`);
244
+ }
245
+ const db = this.db();
246
+ try {
247
+ for await (const _ of db.readAll({ fromPosition: START, maxCount: 1 }))
248
+ break;
249
+ }
250
+ catch (e) {
251
+ if (errorType(e) === "access-denied") {
252
+ throw new KurrentAdapterError("ALL_READ_DENIED", "the instrument credentials cannot read the $all stream");
253
+ }
254
+ throw e;
255
+ }
256
+ if (this.proxy !== undefined)
257
+ this.opened = await this.proxy.open();
258
+ }
259
+ async teardown() {
260
+ this.windowOpen = false;
261
+ this.cursor = undefined;
262
+ try {
263
+ if (this.proxy !== undefined)
264
+ await this.proxy.close();
265
+ }
266
+ finally {
267
+ this.opened = undefined;
268
+ const client = this.client;
269
+ this.client = undefined;
270
+ if (client !== undefined)
271
+ await client.dispose().catch(() => { });
272
+ }
273
+ }
274
+ // ── reading $all ──────────────────────────────────────────────────────────
275
+ /**
276
+ * Read `$all` forwards from the cursor with a server-side stream-name prefix filter. Namespace events are
277
+ * accumulated as captured records (instrument events and system events other than the kept ones are
278
+ * dropped); the cursor advances past everything seen. Returns the position of the last event seen
279
+ * (the fence stream included when asked for), if any.
280
+ */
281
+ async drain(withFence, deadlineMs) {
282
+ const db = this.db();
283
+ const prefixes = withFence ? [this.prefix, this.metaPrefix, this.fenceStream] : [this.prefix, this.metaPrefix];
284
+ const from = this.cursor;
285
+ const fromPosition = from ?? START;
286
+ const options = {
287
+ fromPosition,
288
+ maxCount: WHOLE_LOG,
289
+ filter: streamNameFilter({ prefixes }),
290
+ ...(deadlineMs !== undefined ? { deadline: deadlineMs } : {}),
291
+ };
292
+ let last;
293
+ for await (const resolved of db.readAll(options)) {
294
+ const event = resolved.event;
295
+ if (event === undefined)
296
+ continue;
297
+ const position = event.position;
298
+ // fromPosition is inclusive: skip what the cursor already passed.
299
+ if (from !== undefined && !after(position, from))
300
+ continue;
301
+ last = position;
302
+ this.cursor = position;
303
+ const key = this.relative(event.streamId);
304
+ if (key === undefined)
305
+ continue;
306
+ if (this.isInstrument(event.metadata))
307
+ continue;
308
+ if (event.type.startsWith("$") && !KEPT_SYSTEM_TYPES.has(event.type))
309
+ continue;
310
+ if (isServerTruncateBefore(event.type, event.data))
311
+ continue;
312
+ if (event.isJson === false)
313
+ continue;
314
+ this.captured.push({
315
+ type: event.type,
316
+ key,
317
+ payload: (event.data ?? {}),
318
+ timestamp: new Date(event.created).getTime(),
319
+ metadata: { revision: Number(event.revision), commitPosition: Number(position.commit) },
320
+ });
321
+ }
322
+ return last;
323
+ }
324
+ isInstrument(metadata) {
325
+ return typeof metadata === "object" && metadata !== null && metadata.feat === "instrument";
326
+ }
327
+ async appendMarker(stream, deadline) {
328
+ const result = await this.db().appendToStream(stream, jsonEvent({ type: "feat.marker", data: {}, metadata: INSTRUMENT_MARKER }), { streamState: ANY, ...(deadline !== undefined ? { deadline } : {}) });
329
+ if (result.position === undefined)
330
+ throw new Error(`the append to '${stream}' reported no log position`);
331
+ return result.position;
332
+ }
333
+ // ── the window ────────────────────────────────────────────────────────────
334
+ async startCapture() {
335
+ this.cursor = await this.appendMarker(this.fenceStream);
336
+ this.captured = [];
337
+ this.windowOpen = true;
338
+ }
339
+ async peekCapture() {
340
+ if (!this.windowOpen)
341
+ return [];
342
+ await this.drain(false);
343
+ return [...this.captured];
344
+ }
345
+ async stopCapture() {
346
+ if (!this.windowOpen)
347
+ return [];
348
+ await this.drain(false);
349
+ const records = this.captured;
350
+ this.captured = [];
351
+ this.windowOpen = false;
352
+ this.cursor = undefined;
353
+ return records;
354
+ }
355
+ async settle() {
356
+ if (!this.windowOpen)
357
+ return false;
358
+ const deadline = Date.now() + this.settleTimeoutMs;
359
+ try {
360
+ const marker = await within(this.appendMarker(this.fenceStream, Math.max(this.settleTimeoutMs, 1)), Math.max(this.settleTimeoutMs, 1));
361
+ while (Date.now() < deadline) {
362
+ const remaining = Math.max(deadline - Date.now(), 1);
363
+ const seen = await within(this.drain(true, remaining), remaining);
364
+ if (seen !== undefined && !after(marker, seen))
365
+ return true;
366
+ await sleep(POLL_MS);
367
+ }
368
+ return false;
369
+ }
370
+ catch {
371
+ return false;
372
+ }
373
+ }
374
+ // ── state ─────────────────────────────────────────────────────────────────
375
+ /** Every stream the namespace has ever held, found by an `$all` prefix scan (projections are not required). */
376
+ async namespaceStreams() {
377
+ const seen = new Set();
378
+ const withMetadata = new Set();
379
+ for await (const resolved of this.db().readAll({
380
+ fromPosition: START,
381
+ maxCount: WHOLE_LOG,
382
+ filter: streamNameFilter({ prefixes: [this.prefix, this.metaPrefix] }),
383
+ })) {
384
+ const id = resolved.event?.streamId;
385
+ if (id === undefined)
386
+ continue;
387
+ if (id.startsWith(this.metaPrefix)) {
388
+ const stream = `${this.prefix}${id.slice(this.metaPrefix.length)}`;
389
+ withMetadata.add(stream);
390
+ seen.add(stream);
391
+ }
392
+ else if (id.startsWith(this.prefix))
393
+ seen.add(id);
394
+ }
395
+ return { streams: [...seen], withMetadata };
396
+ }
397
+ async read(query) {
398
+ const hinted = query.expect?.map((e) => e.key?.stream);
399
+ const names = hinted !== undefined && hinted.length > 0 && hinted.every((s) => typeof s === "string")
400
+ ? [...new Set(hinted)].map((s) => this.full(s))
401
+ : (await this.namespaceStreams()).streams;
402
+ const records = [];
403
+ for (const name of names) {
404
+ try {
405
+ for await (const resolved of this.db().readStream(name, { maxCount: WHOLE_LOG })) {
406
+ const event = resolved.event;
407
+ if (event === undefined || this.isInstrument(event.metadata))
408
+ continue;
409
+ if (event.type.startsWith("$") || event.isJson === false)
410
+ continue;
411
+ records.push({
412
+ type: event.type,
413
+ key: name.slice(this.prefix.length),
414
+ payload: (event.data ?? {}),
415
+ timestamp: new Date(event.created).getTime(),
416
+ metadata: { revision: Number(event.revision) },
417
+ });
418
+ }
419
+ }
420
+ catch (e) {
421
+ // A soft-deleted (or never written) stream reads as empty; state is not resurrected from $all.
422
+ const t = errorType(e);
423
+ if (t !== "stream-not-found" && t !== "stream-deleted")
424
+ throw e;
425
+ }
426
+ }
427
+ return records;
428
+ }
429
+ /** The stream of a seed: `values.stream` when the record names one, else its type. */
430
+ async seed(records) {
431
+ for (const r of records) {
432
+ const stream = typeof r.values.stream === "string" ? r.values.stream : r.type;
433
+ await this.db().appendToStream(this.full(stream), jsonEvent({ type: r.type, data: r.values }), { streamState: ANY });
434
+ }
435
+ }
436
+ // ── faults ────────────────────────────────────────────────────────────────
437
+ async fault(arm) {
438
+ const where = `${arm.operation}.${arm.fault}`;
439
+ const entry = this.faults[arm.operation]?.[arm.fault];
440
+ if (entry === undefined) {
441
+ throw new KurrentAdapterError("FAULT_UNSUPPORTED", `the fault '${where}' is not in the catalog (${this.describeCatalog()})`);
442
+ }
443
+ if (arm.times !== "reset") {
444
+ const asked = arm.times === 1 ? "once" : `times ${arm.times}`;
445
+ throw new KurrentAdapterError("FAULT_UNSUPPORTED", `the fault '${where}' declares only until reset, not ${asked}`);
446
+ }
447
+ if (arm.operation === "Connection") {
448
+ await this.proxy.arm(arm.fault);
449
+ return;
450
+ }
451
+ const stream = arm.detail?.stream;
452
+ if (typeof stream !== "string" || stream === "") {
453
+ throw new KurrentAdapterError("FAULT_UNSUPPORTED", `the fault '${where}' needs a detail { stream } naming the stream it applies to`);
454
+ }
455
+ const name = this.full(stream);
456
+ if (arm.fault === "WRONG_EXPECTED_VERSION") {
457
+ // A stream the system expects NOT to exist must exist: the instrument's placeholder is never a record.
458
+ await this.db().appendToStream(name, jsonEvent({ type: "feat.fault", data: {}, metadata: INSTRUMENT_MARKER }), { streamState: ANY });
459
+ }
460
+ else {
461
+ // The write role of the stream names a role nobody holds. $admins bypass ACLs, so the system must not be admin.
462
+ await this.db().setStreamMetadata(name, { acl: { writeRoles: ["nobody"] } });
463
+ }
464
+ }
465
+ describeCatalog() {
466
+ return Object.entries(this.faults)
467
+ .flatMap(([op, faults]) => Object.keys(faults).map((f) => `${op}.${f}`))
468
+ .join(", ");
469
+ }
470
+ async reset() {
471
+ if (this.proxy !== undefined && this.opened !== undefined)
472
+ await this.proxy.disarm();
473
+ const { streams, withMetadata } = await this.namespaceStreams();
474
+ for (const name of streams) {
475
+ if (withMetadata.has(name))
476
+ await this.db().setStreamMetadata(name, {});
477
+ try {
478
+ await this.db().deleteStream(name);
479
+ }
480
+ catch (e) {
481
+ if (errorType(e) !== "stream-not-found")
482
+ throw e;
483
+ }
484
+ }
485
+ this.windowOpen = false;
486
+ this.cursor = undefined;
487
+ this.captured = [];
488
+ }
489
+ }
490
+ export function createAdapter(config) {
491
+ return new KurrentAdapter(config);
492
+ }
493
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,iGAAiG;AACjG,EAAE;AACF,mGAAmG;AACnG,uGAAuG;AACvG,wGAAwG;AACxG,8FAA8F;AAC9F,EAAE;AACF,iGAAiG;AACjG,sGAAsG;AACtG,kDAAkD;AAElD,OAAO,EACL,GAAG,EACH,eAAe,EACf,KAAK,EACL,SAAS,EACT,gBAAgB,GACjB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAChC,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAc3D,MAAM,OAAO,mBAAoB,SAAQ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AC;QAChE,KAAK,MAAM,IAAI,IAAI,OAAO,EAAE,CAAC;YAC3B,IAAI,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC;gBAAE,MAAM,IAAI,CAAC,EAAE,EAAE,CAAC,iBAAiB,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;YACxE,IAAI,CAAC;gBACH,MAAM,IAAI,CAAC,EAAE,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;YACrC,CAAC;YAAC,OAAO,CAAC,EAAE,CAAC;gBACX,IAAI,SAAS,CAAC,CAAC,CAAC,KAAK,kBAAkB;oBAAE,MAAM,CAAC,CAAC;YACnD,CAAC;QACH,CAAC;QACD,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;QACxB,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC;QACxB,IAAI,CAAC,QAAQ,GAAG,EAAE,CAAC;IACrB,CAAC;CACF;AAED,MAAM,UAAU,aAAa,CAAC,MAA+B;IAC3D,OAAO,IAAI,cAAc,CAAC,MAAuB,CAAC,CAAC;AACrD,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,27 @@
1
1
  {
2
2
  "name": "@mmmnt/feat-adapter-kurrent",
3
- "version": "0.0.0-bootstrap.0",
4
- "description": "Placeholder that reserves the name for trusted publishing. Install 0.1.0 or later: KurrentDB service adapter for Feat: the $all log is the capture window, a fence marker read back through it makes settle truthful, and the namespace's streams are the state",
3
+ "version": "0.1.0",
4
+ "description": "KurrentDB service adapter for Feat: the $all log is the capture window, a fence marker read back through it makes settle truthful, and the namespace's streams are the state",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "files": [
9
+ "dist"
10
+ ],
11
+ "dependencies": {
12
+ "@kurrent/kurrentdb-client": "1.3.2",
13
+ "@mmmnt/feat-fault-proxy": "^0.1.0",
14
+ "@mmmnt/feat-types": "^0.2.0"
15
+ },
16
+ "devDependencies": {
17
+ "typescript": "^5.8.0",
18
+ "vitest": "^3.2.0",
19
+ "@mmmnt/feat-runtime": "^0.2.0",
20
+ "@mmmnt/feat-adapter-kit": "^0.1.7"
21
+ },
22
+ "engines": {
23
+ "node": ">=20"
24
+ },
5
25
  "license": "MIT",
6
26
  "repository": {
7
27
  "type": "git",
@@ -15,7 +35,9 @@
15
35
  "publishConfig": {
16
36
  "access": "public"
17
37
  },
18
- "files": [
19
- "README.md"
20
- ]
21
- }
38
+ "scripts": {
39
+ "build": "tsc -p tsconfig.json",
40
+ "typecheck": "tsc -p tsconfig.json --noEmit",
41
+ "test": "vitest run --exclude '**/observe.test.ts' --exclude '**/transport.test.ts' --exclude '**/broker-loss.test.ts' --exclude '**/node26-tls-host.test.ts' --passWithNoTests"
42
+ }
43
+ }