@kedem/okdb 3.0.0 → 3.0.1

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 (62) hide show
  1. package/CHANGELOG.md +38 -3
  2. package/README.md +68 -36
  3. package/bin/okdb +1 -1
  4. package/docs/auth-and-sync.md +30 -24
  5. package/docs/auth-permissions.md +5 -4
  6. package/docs/c-bridge.md +94 -0
  7. package/docs/change-log.md +78 -35
  8. package/docs/data-model.md +32 -8
  9. package/docs/deployment.md +42 -38
  10. package/docs/diagnostics.md +61 -125
  11. package/docs/embeddings.md +143 -51
  12. package/docs/files.md +53 -18
  13. package/docs/fts.md +48 -23
  14. package/docs/functions.md +107 -56
  15. package/docs/getting-started.md +125 -9
  16. package/docs/http-api.md +68 -11
  17. package/docs/http-cluster.md +80 -88
  18. package/docs/index.md +33 -15
  19. package/docs/indexes.md +53 -17
  20. package/docs/licensing.md +18 -4
  21. package/docs/logging.md +11 -22
  22. package/docs/manifest.json +4 -2
  23. package/docs/migration.md +40 -15
  24. package/docs/pipelines.md +96 -32
  25. package/docs/plugins.md +47 -15
  26. package/docs/process-registry.md +23 -24
  27. package/docs/processors.md +26 -23
  28. package/docs/querying.md +102 -29
  29. package/docs/queue.md +167 -51
  30. package/docs/resolved-fields.md +24 -1
  31. package/docs/subscriptions.md +4 -4
  32. package/docs/sync.md +9 -6
  33. package/docs/time-machine.md +40 -11
  34. package/docs/transactions.md +63 -15
  35. package/docs/ttl.md +34 -13
  36. package/docs/upgrade-2.0.md +32 -15
  37. package/docs/upgrade-2.1.md +10 -12
  38. package/docs/upgrade-3.0.md +144 -0
  39. package/docs/views.md +131 -42
  40. package/index.js +1 -1
  41. package/native/linux-x64-gnu/okdb +0 -0
  42. package/native/linux-x64-gnu/okdb-node.linux-x64-gnu.node +0 -0
  43. package/native-loader.js +1 -1
  44. package/okdb-native.js +1 -1
  45. package/package.json +1 -1
  46. package/types/environment.d.ts +32 -11
  47. package/types/errors.d.ts +20 -0
  48. package/types/features/admin.d.ts +3 -5
  49. package/types/features/api.d.ts +5 -7
  50. package/types/features/embeddings.d.ts +8 -7
  51. package/types/features/engines.d.ts +9 -1
  52. package/types/features/files.d.ts +2 -1
  53. package/types/features/fts.d.ts +3 -3
  54. package/types/features/functions.d.ts +14 -8
  55. package/types/features/pipelines.d.ts +10 -10
  56. package/types/features/queue.d.ts +15 -10
  57. package/types/features/sync.d.ts +7 -0
  58. package/types/features/time-machine.d.ts +3 -0
  59. package/types/index.d.ts +3 -0
  60. package/types/okdb.d.ts +70 -7
  61. package/types/options.d.ts +12 -8
  62. package/docs/OKDB-ARCHITECTURE.md +0 -1061
package/docs/pipelines.md CHANGED
@@ -1,17 +1,61 @@
1
1
  # Pipelines
2
2
 
3
- OKDB now has a base `pipelines` feature for storing environment-defined engine topologies in a synced `~pipelines` registry.
4
-
5
- This is the generic layer above `engines`.
3
+ A **pipeline** is a named, ordered group of [engines](#current-sdk-surface) stored in an
4
+ environment's `~pipelines` registry. It is the generic layer above `engines`.
6
5
 
7
6
  - engines remain standalone runtime units
8
7
  - pipelines group engines structurally
9
8
  - pipeline records live in the environment that defines them
10
9
  - pipeline records sync like other env data
11
10
 
11
+ > **Licensing.** Generic engines (`queue-worker`, `processor`, `materializer`) are a licensed
12
+ > feature, off on the free tier, so generic pipelines need a license that includes `engines`.
13
+ > **Embeddings pipelines** (created by `okdb.embeddings.createPipeline(...)`, see
14
+ > [Embeddings](./embeddings.md)) are free; the free tier allows up to 2 per environment
15
+ > (`pipelinesPerEnv`). See [Licensing](./licensing.md).
16
+
17
+ Every embeddings pipeline is also a pipeline record, so the registry API works on the free tier:
18
+
19
+ ```javascript
20
+ // a tiny deterministic embedder, so the example runs offline
21
+ okdb.embeddings.registerEmbedderFactory('toy', (config) => ({
22
+ async embed(text) {
23
+ const v = new Float32Array(config.dims);
24
+ for (const ch of String(text)) v[ch.charCodeAt(0) % config.dims] += 1;
25
+ return v;
26
+ },
27
+ async health() {
28
+ return { ok: true };
29
+ },
30
+ }));
31
+
32
+ await okdb.registerType('articles');
33
+ await okdb.embeddings.createPipeline('articles', {
34
+ source_type: 'articles',
35
+ field: 'body',
36
+ dims: 16,
37
+ embedder: { type: 'toy', dims: 16 },
38
+ });
39
+
40
+ const pipelines = okdb.env('default').pipelines;
41
+ const info = await pipelines.get('articles');
42
+ console.log(
43
+ info.health,
44
+ info.engines.map((m) => m.role),
45
+ ); // 'online' [ 'embedder', 'indexer', 'search' ]
46
+
47
+ await pipelines.stop('articles'); // status 'stopped'
48
+ await pipelines.start('articles'); // status 'active'
49
+ await pipelines.update('articles', { meta: { label: 'Articles' } });
50
+ console.log((await okdb.pipelines.list()).map((p) => `${p.env}/${p.name}`)); // [ 'default/articles' ]
51
+ await pipelines.remove('articles'); // also removes its env-owned engines
52
+ ```
53
+
12
54
  ---
13
55
 
14
- ## V1 record shape
56
+ ## Record shape
57
+
58
+ <!-- not-runnable: shape fragment -->
15
59
 
16
60
  ```javascript
17
61
  {
@@ -29,7 +73,7 @@ This is the generic layer above `engines`.
29
73
  }
30
74
  ```
31
75
 
32
- Rules in V1:
76
+ Rules:
33
77
 
34
78
  - `name` is required and must be a non-empty string
35
79
  - `template` must be `null`
@@ -58,10 +102,12 @@ Unlike env-scoped engines, pipelines do **not** use `~system` by default.
58
102
 
59
103
  ### Env-local facade
60
104
 
105
+ <!-- not-runnable: needs a license (engines) -->
106
+
61
107
  ```javascript
62
108
  const analytics = okdb.env('analytics');
63
109
 
64
- // Engines must already exist before a V1 pipeline record can be created.
110
+ // Engines must already exist before a pipeline record can be created.
65
111
  await analytics.pipelines.create({
66
112
  name: 'articles-ingest',
67
113
  template: null,
@@ -153,7 +199,7 @@ In practice that means an MCP client can:
153
199
  - call `template_preview` to inspect the concrete scaffold or embeddings-create plan
154
200
  - call `template_create` to execute that plan in a target environment
155
201
 
156
- Direct engine discovery/creation now lives in the dedicated `okdb_engine` tool instead:
202
+ Direct engine discovery/creation lives in the dedicated `okdb_engine` tool instead:
157
203
 
158
204
  - `action: "types"` lists registered engine kinds and their self-declared config metadata
159
205
  - `action: "create"` creates a direct env-scoped engine without a pipeline record
@@ -161,9 +207,7 @@ Direct engine discovery/creation now lives in the dedicated `okdb_engine` tool i
161
207
 
162
208
  ### Generic `queue-worker` engine
163
209
 
164
- Step 04 adds a generic `queue-worker` engine type that can run standalone or participate as a reusable pipeline member.
165
-
166
- In V1 it is:
210
+ A generic `queue-worker` engine type that can run standalone or participate as a reusable pipeline member. It is:
167
211
 
168
212
  - standalone-capable
169
213
  - pipeline-compatible
@@ -172,8 +216,10 @@ In V1 it is:
172
216
 
173
217
  Typical flow:
174
218
 
219
+ <!-- not-runnable: needs a license (engines) -->
220
+
175
221
  ```javascript
176
- const analytics = okdb.env('analytics');
222
+ const analytics = await okdb.createEnvironment('analytics');
177
223
 
178
224
  await analytics.functions.create({
179
225
  name: 'processArticleJob',
@@ -202,7 +248,9 @@ await analytics.pipelines.create({
202
248
  await analytics.queue.enqueue('article-ingest', { id: 'job-1' });
203
249
  ```
204
250
 
205
- `queue-worker` config shape in V1:
251
+ `queue-worker` config shape:
252
+
253
+ <!-- not-runnable: shape fragment -->
206
254
 
207
255
  ```javascript
208
256
  {
@@ -228,7 +276,7 @@ Config notes:
228
276
  - `handler.env` — optional env name for the function registry; defaults to the engine owning env
229
277
  - `concurrency`, `pollInterval`, `ttl` — forwarded to the underlying queue worker runtime
230
278
 
231
- Each claimed payload's function runs in the executing node's local sandbox thread (lazy, idle-reaped); `concurrency` bounds in-flight invocations — there is no pool to configure.
279
+ Each claimed payload's function runs in the executing process's function sandbox (see [Functions](./functions.md#runtime-model)); `concurrency` bounds in-flight invocations — there is no pool to configure.
232
280
 
233
281
  Behavior:
234
282
 
@@ -247,6 +295,8 @@ Runtime stats exposed through `engine.api.stats()` include:
247
295
 
248
296
  Minimal pipeline membership example:
249
297
 
298
+ <!-- not-runnable: needs a license (engines) -->
299
+
250
300
  ```javascript
251
301
  await analytics.pipelines.create({
252
302
  name: 'articles-ingest',
@@ -259,9 +309,7 @@ await analytics.pipelines.create({
259
309
 
260
310
  ### Generic `processor` engine
261
311
 
262
- Step 05 adds a generic `processor` engine type for change-log driven pipeline members.
263
-
264
- In V1 it is:
312
+ A generic `processor` engine type for change-log driven pipeline members. It is:
265
313
 
266
314
  - standalone-capable
267
315
  - pipeline-compatible
@@ -271,8 +319,10 @@ In V1 it is:
271
319
 
272
320
  Typical flow:
273
321
 
322
+ <!-- not-runnable: needs a license (engines) -->
323
+
274
324
  ```javascript
275
- const analytics = okdb.env('analytics');
325
+ const analytics = await okdb.createEnvironment('analytics');
276
326
 
277
327
  await analytics.registerType('articles');
278
328
 
@@ -302,7 +352,9 @@ await analytics.engines.createAndStartEngine('processor', 'article-projector', {
302
352
  await analytics.put('articles', 'a1', { title: 'Hello' });
303
353
  ```
304
354
 
305
- `processor` config shape in V1:
355
+ `processor` config shape:
356
+
357
+ <!-- not-runnable: shape fragment -->
306
358
 
307
359
  ```javascript
308
360
  {
@@ -334,10 +386,10 @@ Config notes:
334
386
  - `source_env` — optional env name for the source type; defaults to the engine owning env
335
387
  - `handler.env` — optional env name for the function registry; defaults to the engine owning env
336
388
  - `mode`, `bootstrap`, `originMode`, `batchSize`, `hydrateValues`, `cursorKey`, `lockMode`, `flushDebounce`, `flushInterval` — forwarded to the underlying processor runtime
337
- - `failOnHandlerError` — included in runtime metadata; V1 engine behavior treats handler failures as engine errors
389
+ - `failOnHandlerError` — included in runtime metadata; handler failures are treated as engine errors
338
390
  - `flushDebounce` — coalesces rapid write bursts into a single handler delivery after the quiet period
339
391
  - `flushInterval` — periodic poll; useful for `originMode: 'remote'` subscriptions where local writes don't trigger delivery
340
- - When `originMode: 'all'` or `'remote'`, the underlying processor automatically subscribes to `EVENTS.SYSTEM_POKE` for cross-process change notification. No additional configuration is needed for correct multi-process behavior.
392
+ - With `originMode: 'all'` or `'remote'`, the underlying processor wakes on writes made by other processes on the same store; no additional configuration is needed for correct multi-process behavior.
341
393
 
342
394
  Behavior:
343
395
 
@@ -361,6 +413,8 @@ Runtime stats exposed through `engine.api.stats()` / `engine.api.status()` inclu
361
413
 
362
414
  Minimal pipeline membership example:
363
415
 
416
+ <!-- not-runnable: needs a license (engines) -->
417
+
364
418
  ```javascript
365
419
  await analytics.pipelines.create({
366
420
  name: 'projection-pipeline',
@@ -373,7 +427,7 @@ await analytics.pipelines.create({
373
427
 
374
428
  ### `materializer` engine
375
429
 
376
- Step 10 adds a `materializer` engine type for deterministic source→target collection projection.
430
+ A `materializer` engine type for deterministic source→target collection projection.
377
431
 
378
432
  Unlike the generic `processor`, a materializer has an **explicit target type** and a **return-ops contract** that enables safe rebuild.
379
433
 
@@ -390,6 +444,8 @@ Key differences from `processor`:
390
444
 
391
445
  Typical flow:
392
446
 
447
+ <!-- not-runnable: needs a license (engines) -->
448
+
393
449
  ```javascript
394
450
  const analytics = await db.createEnvironment('analytics');
395
451
  await analytics.registerType('orders');
@@ -433,6 +489,8 @@ await engine.api.rebuild();
433
489
 
434
490
  `materializer` config shape:
435
491
 
492
+ <!-- not-runnable: shape fragment -->
493
+
436
494
  ```javascript
437
495
  {
438
496
  source_type: 'orders',
@@ -486,15 +544,21 @@ Engine API:
486
544
  - `engine.api.pause()` / `engine.api.resume()` — pause/resume consumption
487
545
  - `engine.api.retry()` — retry after error state
488
546
 
547
+ ### The `db.pipelines` aggregate
548
+
549
+ `okdb.pipelines` is a read-only view across every opened environment (mutations live on
550
+ `okdb.env(name).pipelines`):
551
+
489
552
  ```javascript
490
- const all = await okdb.pipelines.list();
491
- const analyticsOnly = await okdb.pipelines.list({ envName: 'analytics' });
492
- const record = await okdb.pipelines.get('analytics', 'articles-ingest');
553
+ const all = await okdb.pipelines.list(); // every opened env; each entry has `env`
554
+ const defaultOnly = await okdb.pipelines.list({ envName: 'default' });
555
+ const record = await okdb.pipelines.get('default', 'articles-ingest'); // null when absent
556
+ const owner = okdb.pipelines.findOwner('indexer', 'default:articles'); // { env, pipeline, role } or null
493
557
  ```
494
558
 
495
559
  ---
496
560
 
497
- ## Lifecycle behavior in V1
561
+ ## Lifecycle behavior
498
562
 
499
563
  The base feature is intentionally narrow.
500
564
 
@@ -513,7 +577,7 @@ Supported lifecycle operations:
513
577
  - `stop`
514
578
  - `remove`
515
579
 
516
- Topology is structurally immutable in V1:
580
+ Topology is structurally immutable:
517
581
 
518
582
  - changing engine membership is rejected
519
583
  - changing engine roles is rejected
@@ -541,7 +605,7 @@ Shared/global engines are preserved.
541
605
 
542
606
  ### HTTP routes
543
607
 
544
- Generic pipelines now expose env-scoped routes:
608
+ Generic pipelines expose env-scoped routes:
545
609
 
546
610
  - `GET /api/env/:env/pipelines`
547
611
  - `GET /api/env/:env/pipelines/:pipeline`
@@ -561,7 +625,7 @@ Read responses include derived pipeline/member inspection data such as:
561
625
 
562
626
  ### Admin visibility
563
627
 
564
- The admin UI now exposes pipelines and engines through three complementary views:
628
+ The admin UI exposes pipelines and engines through three complementary views:
565
629
 
566
630
  - **Queue → Workers** — create and manage `queue-worker` engines directly for the selected job type
567
631
  - **DB → Type detail** — open a type-scoped engines view for embeddings/vector pipelines, including shortcuts from the vector/index drill-ins back to the owning pipeline
@@ -579,14 +643,14 @@ Current behavior:
579
643
 
580
644
  ### Sync / runtime activation
581
645
 
582
- Synced pipeline declarations now reconcile through the same higher-level runtime activation seam used for synced engines.
646
+ With [sync](./sync.md) (a licensed feature), synced pipeline declarations reconcile through the same runtime activation path used for synced engines.
583
647
 
584
648
  That shared activation path runs:
585
649
 
586
650
  - after `OKDB.open()` startup restore
587
651
  - after each sync reconcile pass completes
588
652
 
589
- Behavior in V1:
653
+ Behavior:
590
654
 
591
655
  - env-scoped engine records still restore/start through the engine feature
592
656
  - pipeline records add a second reconciliation pass based on persisted pipeline `status`
@@ -605,7 +669,7 @@ Cluster expectation:
605
669
 
606
670
  ## Relation to embeddings
607
671
 
608
- Embeddings now use this generic pipeline model as their persisted grouping layer while keeping the richer `okdb.embeddings` facade.
672
+ Embeddings use this generic pipeline model as their persisted grouping layer while keeping the richer `okdb.embeddings` facade.
609
673
 
610
674
  Current behavior:
611
675
 
@@ -613,7 +677,7 @@ Current behavior:
613
677
  - that record uses the pipeline `storage_key` as its generic name
614
678
  - member roles are explicit and ordered: `embedder`, `indexer`, optional `worker`, `search`
615
679
  - the record is tagged with `meta.family = 'embeddings'` so specialized embeddings views can recognize it cleanly
616
- - embeddings lifecycle routes now delegate to the generic pipeline feature when a generic record exists
680
+ - embeddings lifecycle routes delegate to the generic pipeline feature when a generic record exists
617
681
 
618
682
  Embeddings-backed records also use `meta.lifecycleSkipRoles = ['embedder']`.
619
683
 
package/docs/plugins.md CHANGED
@@ -1,17 +1,27 @@
1
1
  # Plugins
2
2
 
3
- Plugins are first-class addons that extend OKDB before it opens. They integrate into the lifecycle cleanly: registered before `open()`, started after `open()`, stopped before `close()`.
3
+ Plugins are first-class addons that extend OKDB before it opens. They integrate into the lifecycle cleanly: registered before `open()`, started at the end of `open()`, stopped before `close()`.
4
+
5
+ > **3.0 notes.** The 2.x plugin contract is unchanged, with three differences: `start()` runs after the
6
+ > **whole** `open()` has finished (in 2.x it ran mid-open, before views and runtime declarations
7
+ > booted), so a plugin always sees a fully started instance but can no longer act before those boot;
8
+ > `okdb.api` and `okdb.admin` are stubs whose members throw `NOT_IMPLEMENTED_NATIVE` — drive the
9
+ > server through HTTP routes or the public facades instead; and `_`-prefixed internals of the 2.x
10
+ > JS implementation no longer exist. The standalone `okdb` CLI loads no plugins (as in 2.x):
11
+ > plugins exist where an application embeds okdb in Node.
4
12
 
5
13
  ---
6
14
 
7
15
  ## Registering a plugin
8
16
 
9
17
  ```javascript
18
+ const MyPlugin = { name: 'my-plugin', register: () => ({}) };
10
19
  const okdb = new OKDB('./db');
11
20
 
12
21
  okdb.plugins.register(MyPlugin, {/* options */});
13
22
 
14
23
  await okdb.open();
24
+ await okdb.close();
15
25
  ```
16
26
 
17
27
  Plugins must be registered **before** `okdb.open()`. Attempting to register after open throws `INVALID_STATE`.
@@ -24,7 +34,7 @@ A plugin module is a plain object with a `name`, an optional `requires` list, an
24
34
 
25
35
  ```javascript
26
36
  // my-plugin.js
27
- module.exports = {
37
+ const MyPlugin = {
28
38
  name: 'my-plugin',
29
39
 
30
40
  // Other plugin names that must be registered first
@@ -51,15 +61,20 @@ module.exports = {
51
61
  };
52
62
  },
53
63
  };
64
+ module.exports = MyPlugin;
54
65
  ```
55
66
 
67
+ <!-- continues -->
68
+
56
69
  ```javascript
57
- const MyPlugin = require('./my-plugin');
70
+ // const MyPlugin = require('./my-plugin');
71
+ const okdb = new OKDB('./db');
58
72
  okdb.plugins.register(MyPlugin, {/* options passed to register() */});
59
- await okdb.open();
73
+ await okdb.open(); // logs 'my-plugin started'
74
+ await okdb.close(); // logs 'my-plugin stopped'
60
75
  ```
61
76
 
62
- The instance is kept internally (`okdb.plugins._plugins[i].instance`) — it is **not** attached as a property on `okdb`. If callers need it, keep your own reference (e.g. export it from the plugin module).
77
+ The instance is kept internally — it is **not** attached as a property on `okdb`. If callers need it, keep your own reference (e.g. export it from the plugin module).
63
78
 
64
79
  :::note
65
80
  Plugin name must not conflict with existing OKDB properties (`env`, `put`, `get`, `http`, etc.). Registration throws `PLUGIN_NAME_CONFLICT` if there's a clash, `PLUGIN_ALREADY_REGISTERED` for a duplicate name, and `BAD_PLUGIN` when `name` is missing or `register()` doesn't return an object.
@@ -84,11 +99,19 @@ Plugin name must not conflict with existing OKDB properties (`env`, `put`, `get`
84
99
  Use `requires` to declare that another plugin must be registered first:
85
100
 
86
101
  ```javascript
87
- module.exports = {
102
+ const payments = {
88
103
  name: 'payments',
89
- requires: ['auth'], // 'auth' plugin must be registered before 'payments'
90
- register(okdb, options) { ... },
104
+ requires: ['auth'], // 'auth' plugin must be registered before 'payments'
105
+ register(okdb, options) {
106
+ return {};
107
+ },
91
108
  };
109
+ const okdb = new OKDB('./db');
110
+ try {
111
+ okdb.plugins.register(payments);
112
+ } catch (e) {
113
+ console.log(e.code); // PLUGIN_DEPENDENCY_MISSING
114
+ }
92
115
  ```
93
116
 
94
117
  OKDB checks this at registration time and throws `PLUGIN_DEPENDENCY_MISSING` if the dependency isn't registered yet.
@@ -100,7 +123,7 @@ OKDB checks this at registration time and throws `PLUGIN_DEPENDENCY_MISSING` if
100
123
  A common pattern is a plugin that ensures types and indexes exist at startup:
101
124
 
102
125
  ```javascript
103
- module.exports = {
126
+ const schemaPlugin = {
104
127
  name: 'schema',
105
128
  register(okdb, options) {
106
129
  return {
@@ -117,22 +140,31 @@ module.exports = {
117
140
  };
118
141
  },
119
142
  };
143
+ module.exports = schemaPlugin;
144
+
145
+ const okdb = new OKDB('./db');
146
+ okdb.plugins.register(schemaPlugin);
147
+ await okdb.open(); // types exist once open() resolves
148
+ await okdb.close();
120
149
  ```
121
150
 
122
151
  ---
123
152
 
124
153
  ## Listing registered plugins
125
154
 
155
+ `okdb.info` (and `GET /api/info`) includes the registered plugin names:
156
+
126
157
  ```javascript
127
- const names = okdb.plugins._plugins.map((p) => p.module.name);
128
- // e.g. ['schema', 'auth', 'payments']
158
+ const okdb = new OKDB('./db');
159
+ okdb.plugins.register({ name: 'schema', register: () => ({}) });
160
+ await okdb.open();
161
+ okdb.info.plugins; // → ['schema']
162
+ await okdb.close();
129
163
  ```
130
164
 
131
- `okdb.info` (and `GET /api/info`) also includes the plugin list:
165
+ <!-- not-runnable: needs a running server (the network) -->
132
166
 
133
167
  ```javascript
134
- okdb.info.plugins; // → ['schema', 'auth', 'payments']
135
-
136
- const info = await fetch('/api/info').then((r) => r.json());
168
+ const info = await fetch('http://localhost:8484/api/info').then((r) => r.json());
137
169
  info.data.plugins; // → ['schema', 'auth', 'payments']
138
170
  ```
@@ -24,7 +24,7 @@ hint. A forged or dropped bus packet can therefore neither trigger nor lose a co
24
24
  The primary entity is the **process**, not the processor. Each long-lived process publishes one
25
25
  `node` row:
26
26
 
27
- ```js
27
+ ```text
28
28
  {
29
29
  nodeKey, // identity: `${pid}:${startedAt}` (wall-clock startedAt — same-host, see Liveness)
30
30
  kind, // primary | http-server | cli | standalone | embedded
@@ -41,8 +41,8 @@ The primary entity is the **process**, not the processor. Each long-lived proces
41
41
  ```
42
42
 
43
43
  A processor (FTS, views, materializer, time-machine, …) is **not** a separate entity — it is summarized
44
- on the owner's `processing` facet (`processing.processors[]`). There are no worker pools in 2.0 —
45
- drains run on the claiming node's loop, so there is nothing pool-shaped to give its own row.
44
+ on the owner's `processing` facet (`processing.processors[]`). okdb has no worker pools —
45
+ drains run in the claiming process, so there is nothing pool-shaped to give its own row.
46
46
 
47
47
  ### Two stores, split by lifetime
48
48
 
@@ -58,8 +58,7 @@ writes emit **no** signal — the panel polls. Only desired-state/command writes
58
58
 
59
59
  HTTP-cluster workers (`http-server`) lack a stable cross-restart identity, so they do **not**
60
60
  self-register (they open the registry as readers). Their **supervisor** — which already tracks each
61
- child's pid/slot and heartbeats it — writes the child's `node` row (`publishChildRow`) and removes it on
62
- exit. Roots (primary/cli/standalone) and embedded nodes self-publish via their heartbeat.
61
+ child's pid/slot and heartbeats it — writes the child's `node` row and removes it on exit. Roots (primary/cli/standalone) and embedded nodes self-publish via their heartbeat.
63
62
 
64
63
  ### Liveness — wall-clock, read-time staleness
65
64
 
@@ -87,16 +86,16 @@ All routes require `system:read` (views) or `system:write` (control).
87
86
  > `GET /api/processes[/tree]` (the former `okdb.fleet` accessor alias was removed). Don't confuse it
88
87
  > with **processors** (`/api/processors/*`), the change-subscription primitives a process runs.
89
88
 
90
- | Method & path | Purpose |
91
- | ------------------------------------------- | -------------------------------------------------------------- |
92
- | `GET /api/processes` | flat list of live processes (grouped, each with `instances[]`) |
93
- | `GET /api/processes/tree` | nested process → instance → work tree (`supervisorKey`) |
94
- | `POST /api/processors/:id/pause`/`resume` | durable pause/resume of a processor (desired-state) |
95
- | `POST /api/processors/:id/retry` | retry an errored processor (durable command epoch) |
96
- | `POST /api/processors/cursor/reset` | reset a processor cursor to 0 (durable + command epoch) |
97
- | `POST /api/processes/:nodeKey/decommission` | gracefully stop a supervised process and keep it down |
98
- | `POST /api/processes/:nodeKey/recommission` | reverse a decommission/kill — the supervisor re-forks the slot |
99
- | `POST /api/processes/:nodeKey/kill?force=1` | hard-kill (guarded; see Control tiers) |
89
+ | Method & path | Purpose |
90
+ | ------------------------------------------- | ---------------------------------------------------------------- |
91
+ | `GET /api/processes` | flat list of live processes (grouped, each with `instances[]`) |
92
+ | `GET /api/processes/tree` | nested process → instance → work tree (`supervisorKey`) |
93
+ | `POST /api/processors/:id/pause`/`resume` | durable pause/resume of a processor (desired-state) |
94
+ | `POST /api/processors/:id/retry` | retry an errored processor (durable command epoch) |
95
+ | `POST /api/processors/cursor/reset` | reset a processor cursor to 0 (durable + command epoch) |
96
+ | `POST /api/processes/:nodeKey/decommission` | gracefully stop a supervised process and keep it down |
97
+ | `POST /api/processes/:nodeKey/recommission` | reverse a decommission/kill — the supervisor relaunches the slot |
98
+ | `POST /api/processes/:nodeKey/kill?force=1` | hard-kill (guarded; see Control tiers) |
100
99
 
101
100
  When the registry is off (`processes: false`), `/api/processes[/tree]` returns a degenerate
102
101
  single-root node so the API still answers.
@@ -118,10 +117,10 @@ target's supervisor) reconciles it.
118
117
  3. **Lifecycle — decommission / hard-kill** (routed through the **supervisor**, not by fighting the
119
118
  respawn loop):
120
119
  - **Decommission** (`decommissionable` kinds): the supervisor marks the slot dead (no respawn) and
121
- cleanly `disconnect()`s the child to drain in-flight work. Keyed by the **stable** `slotKey`
120
+ cleanly disconnects the child so it drains in-flight work. Keyed by the **stable** `slotKey`
122
121
  (`cluster:<port>/<slot>`), so it **survives a supervisor restart** — a restarted primary reloads
123
- the dead slots before its fork loop and does not revive them. **Recommission** clears the record
124
- and re-forks.
122
+ the dead slots before launching workers and does not revive them. **Recommission** clears the record
123
+ and relaunches the worker.
125
124
  - **Hard-kill** (`POST …/kill`): the last resort, guarded. Requires explicit `?force=1`. Rejected
126
125
  for non-killable kinds. Killing a **primary** additionally requires `?confirm=1` because it tears
127
126
  down the whole cluster (its workers self-exit on the primary's death). The supervisor `SIGKILL`s
@@ -150,7 +149,7 @@ embedded node is never killable and never self-terminates.
150
149
  ## Scope: same-host processes vs sync peers
151
150
 
152
151
  The registry covers **same-host, same-root** processes — they share the LMDB files, the UDP bus, and
153
- the `EnvSharedState` shmbuf. **Cross-machine sync-replication peers are a separate axis** (no shared
152
+ the per-env shared-memory segment. **Cross-machine sync-replication peers are a separate axis** (no shared
154
153
  LMDB; "kill" there would be a sync-protocol RPC) and are surfaced by the Sync view, not the process registry.
155
154
 
156
155
  ---
@@ -159,20 +158,20 @@ LMDB; "kill" there would be a sync-protocol RPC) and are surfaced by the Sync vi
159
158
 
160
159
  ```js
161
160
  // Default: publishes a `standalone` row (killable/controllable per the table above).
162
- const db = new OKDB('./data');
161
+ const a = new OKDB('./data');
163
162
 
164
163
  // Observe-only: appear in the registry, expose nothing controllable or killable.
165
- const db = new OKDB('./data', { processes: { kind: 'embedded', name: 'oasis-worker' } });
164
+ const b = new OKDB('./data', { processes: { kind: 'embedded', name: 'oasis-worker' } });
166
165
 
167
166
  // Reader only: read the registry, publish no row.
168
- const db = new OKDB('./data', { processes: { register: false } });
167
+ const c = new OKDB('./data', { processes: { register: false } });
169
168
 
170
169
  // Invisible: no registry at all.
171
- const db = new OKDB('./data', { processes: false });
170
+ const d = new OKDB('./data', { processes: false });
172
171
  ```
173
172
 
174
173
  `processes` also takes `name` (a label shown in the admin), `listenAddr`, and `kill: false` (see
175
- below). `bin/okdb` sets `kind` automatically (`primary` / `http-server` / `cli`).
174
+ below). The `okdb` CLI sets `kind` automatically (`primary` / `http-server` / `cli`).
176
175
 
177
176
  ---
178
177