@kedem/okdb 2.3.5 → 2.5.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/CHANGELOG.md +427 -0
- package/algorithm-worker-thread.js +1 -1
- package/bin/okdb.js +1 -1
- package/docs/auth-and-sync.md +30 -5
- package/docs/auth-permissions.md +19 -6
- package/docs/change-log.md +79 -59
- package/docs/data-model.md +20 -18
- package/docs/deployment.md +25 -0
- package/docs/diagnostics.md +59 -17
- package/docs/embeddings.md +57 -6
- package/docs/fts.md +50 -5
- package/docs/functions.md +21 -8
- package/docs/http-api.md +139 -98
- package/docs/http-cluster.md +30 -8
- package/docs/indexes.md +5 -4
- package/docs/licensing.md +6 -1
- package/docs/logging.md +18 -0
- package/docs/migration.md +153 -2
- package/docs/pipelines.md +6 -1
- package/docs/plugins.md +12 -18
- package/docs/process-registry.md +50 -39
- package/docs/processors.md +40 -22
- package/docs/querying.md +50 -36
- package/docs/queue.md +110 -14
- package/docs/subscriptions.md +37 -24
- package/docs/sync.md +96 -37
- package/docs/time-machine.md +23 -17
- package/docs/transactions.md +11 -19
- package/docs/ttl.md +118 -67
- package/docs/upgrade-2.0.md +2 -2
- package/docs/views.md +75 -52
- package/okdb-functions-sandbox-worker.js +1 -1
- package/okdb-http-worker-child.js +1 -1
- package/okdb-views-bootstrap-worker.js +1 -1
- package/okdb.js +1 -1
- package/package.json +1 -1
- package/public/sections/db/parts/type-viewer.ok.js +1 -1
- package/public/sections/embeddings/parts/engines-overview.ok.js +1 -1
- package/public/sections/queue/parts/queue-jobs.ok.js +1 -1
- package/public/sections/system/modals/data-ops-modal.ok.js +1 -1
- package/types/environment.d.ts +320 -52
- package/types/features/admin.d.ts +8 -2
- package/types/features/api.d.ts +10 -16
- package/types/features/auth.d.ts +135 -16
- package/types/features/embeddings.d.ts +639 -31
- package/types/features/engines.d.ts +368 -14
- package/types/features/files.d.ts +0 -3
- package/types/features/fts.d.ts +98 -26
- package/types/features/functions.d.ts +175 -15
- package/types/features/mcp.d.ts +23 -10
- package/types/features/pipelines.d.ts +268 -9
- package/types/features/queue.d.ts +230 -34
- package/types/features/sync.d.ts +177 -14
- package/types/features/time-machine.d.ts +117 -16
- package/types/features/views.d.ts +230 -39
- package/types/index.d.ts +357 -254
- package/types/okdb.d.ts +397 -0
- package/types/options.d.ts +309 -48
- package/public/test-cron-input.html +0 -60
- package/public/test-json-input.html +0 -280
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,433 @@ All notable changes to `@kedem/okdb` are documented here. Format loosely follows
|
|
|
4
4
|
[Keep a Changelog](https://keepachangelog.com/en/1.0.0/); versions follow [SemVer](https://semver.org/).
|
|
5
5
|
Dates are release dates.
|
|
6
6
|
|
|
7
|
+
## [2.5.0] - 2026-09-28
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
|
|
11
|
+
- **`OKDB.clone(src, dst)` and `OKDB.reidentify(path)` — a copied store gets its own identity.**
|
|
12
|
+
A file-copied store (a test template, a restored backup) used to keep the original's `~system`
|
|
13
|
+
identity, so copies shared its UDP bus group (receiving each other's POKE/DRAIN/TYPE_DROP), sync
|
|
14
|
+
node id, node keypair, token secret and licence node binding. `clone()` copies a **closed** store
|
|
15
|
+
(refuses `STORE_IN_USE` while any env is open; `CLONE_DEST_NOT_EMPTY`, `CLONE_DEST_OVERLAPS_SOURCE`)
|
|
16
|
+
and marks the copy; `reidentify()` marks a copy you made yourself (e.g. a hot backup from
|
|
17
|
+
`db.migrate.backup()`); `okdb restore <backup> --path <dst> --new-identity` does both. The copy's
|
|
18
|
+
first `open()` mints a fresh id exactly once. Its copied history still counts as its own
|
|
19
|
+
(`originMode` filters treat former ids as self up to each env's fork clock, `db.formerIds`), so
|
|
20
|
+
FTS/views/indexes/time-machine are consistent without a rebuild; sync links and peer cursors are
|
|
21
|
+
dropped (it joins as a new node), secrets and keypair are regenerated, locks and leases dropped.
|
|
22
|
+
Node-bound licence activations report `wrong_node` on the copy. See
|
|
23
|
+
[Migration → Cloning a store](docs/migration.md).
|
|
24
|
+
- **`okdb shm-gc`** — deletes okdb shared-memory segments in `/dev/shm` that no process maps or
|
|
25
|
+
holds open (leaked by okdb ≤ 2.4.0, see Fixed). `--dry-run`; `--prefix` (default `-tmp-`: only
|
|
26
|
+
stores under `/tmp`); `--force` when some same-user processes' maps are unreadable. Linux only.
|
|
27
|
+
|
|
28
|
+
### Fixed
|
|
29
|
+
|
|
30
|
+
- **Four OKDB instances indexing FTS in one process deadlocked every write in that process.**
|
|
31
|
+
lmdb-js runs each async commit on a libuv thread-pool thread (`UV_THREADPOOL_SIZE`, default 4)
|
|
32
|
+
and keeps it while the commit callback is pending; the FTS commit held its post txn while its docs
|
|
33
|
+
txn needed a second thread, so four concurrent FTS commits took the whole pool and every later
|
|
34
|
+
commit in the process hung (logged as `writer STALL` on unrelated envs). Such nested holds are now
|
|
35
|
+
capped process-wide below the pool size. Workaround for older versions: `UV_THREADPOOL_SIZE=16`.
|
|
36
|
+
- **Shared-memory segments leaked forever.** Every env path ever opened left a `/dev/shm` entry
|
|
37
|
+
(one per env plus one boot-lock segment per store; millions on test machines), and a new store at
|
|
38
|
+
a reused path inherited the old one's clock, drain and writer-cell state. The last process to
|
|
39
|
+
close an env path now unlinks its segment; an opener racing that unlink keeps the segment alive or
|
|
40
|
+
moves to its successor, so cross-process clock/HLC state never splits. Run `okdb shm-gc` once to
|
|
41
|
+
clear leaks from older versions.
|
|
42
|
+
- **Cluster worker disconnected during `open()` never exited.** A worker the primary disconnected
|
|
43
|
+
while it was still booting missed the `disconnect` event and kept the store open indefinitely
|
|
44
|
+
(the `ppid === 1` backstop never fires under a subreaper such as systemd --user).
|
|
45
|
+
- **Two stores could share shared-memory state.** Segment names replaced every non-alphanumeric
|
|
46
|
+
character with `-`, so e.g. store `/a/b` with env `c-d` and store `/a/b-c` with env `d` shared one
|
|
47
|
+
segment (clock, HLC, compaction drain, writer cells); the boot-lock segment also collided with an
|
|
48
|
+
env named `boot`. Names now carry a hash of the full path.
|
|
49
|
+
- **`open()` failed for store paths longer than ~250 characters** (`shm_open failed: File name too
|
|
50
|
+
long`; ~30 on macOS). Segment names are now length-bounded.
|
|
51
|
+
- **A worker thread killed by `terminate()` mid-write blocked compaction.** Its writer cell stayed
|
|
52
|
+
claimed under the live host pid, pinning the env as shared and its writer count above zero. Cells
|
|
53
|
+
now record the owning thread and are released when the thread exits.
|
|
54
|
+
- **Views missed writes synced in from peers.** Sync views and every view's `$ref` / live map `$ref`
|
|
55
|
+
sections skipped remote-origin writes, which a rebuild then counted — live results and a rebuild
|
|
56
|
+
could disagree, and a later local update of such a doc undid a contribution never added. Views now
|
|
57
|
+
count every write. View storage version 6 → 7: on first open, affected views rebuild once — only
|
|
58
|
+
on stores that have (or had) a sync peer or are clones; all other views are restamped.
|
|
59
|
+
- **A failed `open()` leaked everything it had opened** (LMDB envs, shared memory, timers, registry
|
|
60
|
+
rows) for the life of the process, and `close()` then threw `INVALID_STATE`. It now tears down
|
|
61
|
+
before rethrowing the original error; the instance is left `STOPPED`.
|
|
62
|
+
- **`originMode` was ignored by async processors registered with `handler: '<name>'` or `module`**
|
|
63
|
+
(they received every write). It is now applied on every delivery path, including snapshot
|
|
64
|
+
bootstrap; the cursor still advances past filtered-out changes. **Behaviour change:** without an
|
|
65
|
+
explicit `originMode` these processors now get the documented default `'self'` — pass
|
|
66
|
+
`originMode: 'all'` to keep receiving synced-in writes (see [UPGRADING.md](UPGRADING.md)).
|
|
67
|
+
- **A copied store opened the original's `~log`.** Older stores recorded the `~log` env as an
|
|
68
|
+
absolute path; it is now stored relative and healed on open.
|
|
69
|
+
|
|
70
|
+
### Changed
|
|
71
|
+
|
|
72
|
+
- **Faster `open()`.** The live-subscriptions store (`~sub`) and its signal router are created on
|
|
73
|
+
first subscription use instead of at every open; licence signature verification is memoized per
|
|
74
|
+
process; a brand-new store records its storage migrations as done instead of running them; the
|
|
75
|
+
sync node keypair is minted on first use. A fresh store opens in about half the time.
|
|
76
|
+
- **Shared-memory segment names now end in a hash of the full store path** (a readable prefix is
|
|
77
|
+
kept, so stores under `/tmp` still start with `-tmp-`). **Old and new versions no longer share
|
|
78
|
+
segments: stop every process on a store and restart them together — no rolling upgrade across
|
|
79
|
+
this release** (see [UPGRADING.md](UPGRADING.md)). A live okdb ≤ 2.4.0 writer on the same store is
|
|
80
|
+
detected and logged.
|
|
81
|
+
- `close()` on a stopped instance is a no-op (a second `close()` used to throw `INVALID_STATE`);
|
|
82
|
+
plugins are stopped only if their `start()` succeeded, in reverse order.
|
|
83
|
+
- `writer STALL` log names a saturated libuv thread pool as a possible cause (it blamed fsync only).
|
|
84
|
+
|
|
85
|
+
## [2.4.0] - 2026-09-25
|
|
86
|
+
|
|
87
|
+
### Security
|
|
88
|
+
|
|
89
|
+
- **Sync link scope was not enforced by the node serving the data.** `/api/sync/delta` served
|
|
90
|
+
whatever envs the caller named, ignoring the link's `envs` list and direction — a peer linked
|
|
91
|
+
for env `a` (or linked receive-only) could pull env `b` just by asking, and a `poke` made the
|
|
92
|
+
poked node pull every env from the poker regardless of the link. The delta server now serves a
|
|
93
|
+
signed peer only `~system` plus the data envs the link lets it send to that peer (others are
|
|
94
|
+
omitted and listed in the response's `denied`); the pulling node applies only envs it asked for
|
|
95
|
+
and the link lets it receive, whatever the remote sends (a pre-fix peer can't push past the
|
|
96
|
+
link); a pull without an explicit env list (join, poke, `reconcilePeer`) asks for the link's
|
|
97
|
+
envs only; and a signed `poke` can only trigger a pull from the signer, never a named third
|
|
98
|
+
node. With no link anywhere the cluster stays in legacy full-mesh mode. Note that `~system`
|
|
99
|
+
(the control plane — `~sync_nodes`, `~sync_links`, `~tokens` hashes, `~licenses`, …) still
|
|
100
|
+
replicates with every registered peer: a link scopes data, not trust (see
|
|
101
|
+
[Auth and Sync → What a peer can do](docs/auth-and-sync.md#what-a-peer-can-do)).
|
|
102
|
+
- **`system_backup` (HTTP + MCP) could write a full copy of the store to any server path.** It now
|
|
103
|
+
writes only under the backup root — the new `backup.root` option, default `<store>-backups` next
|
|
104
|
+
to the store — rejecting `..`, other absolute paths and symlinks that resolve outside it
|
|
105
|
+
(`400 BACKUP_PATH_OUTSIDE_ROOT`) and existing non-empty directories (`409`). `destDir` is relative
|
|
106
|
+
to the root and optional; the route is marked destructive, so MCP clients must confirm it.
|
|
107
|
+
- **Per-env authorization was skipped on the files, queue, FTS and functions routes.** These
|
|
108
|
+
routes declare `access.scope: 'env'` (a string shorthand), but the permission check only read
|
|
109
|
+
`access.scope.env`, so no env was resolved: the protected `~` env gate did not apply (a token
|
|
110
|
+
with global `queue:read` could read `/api/env/~system/queue/...` without `protected:read`), and
|
|
111
|
+
per-env grants were ignored (a token granted `{ orders: ['files:read'] }` got 403 on
|
|
112
|
+
`/api/env/orders/files`). The shorthand now resolves the `:env` path param like
|
|
113
|
+
`scope: { env: 'params.env' }`.
|
|
114
|
+
- **Query filters could execute arbitrary code via `$where`.** Filters are compiled by `sift`,
|
|
115
|
+
whose `$where` operator compiles a string with `new Function` and runs it in-process — so any
|
|
116
|
+
caller able to pass a filter (`data:read` over HTTP `…/type/:type/query` and `…/count`, the MCP
|
|
117
|
+
query tool, FTS/vector post-filters, view definitions, subscription filters) could run code on
|
|
118
|
+
the server. Every call site now compiles through one helper (`src/core/okdb-query-filter.js`)
|
|
119
|
+
that allows only declarative operators; `$where` (string or function, at any nesting depth) is
|
|
120
|
+
rejected with `QUERY_OPERATOR_FORBIDDEN` (HTTP 400) and never evaluated. A view stored with
|
|
121
|
+
`$where` before this fix is not activated on open (logged; remove and re-create it), and a
|
|
122
|
+
stored subscription filter using it never matches.
|
|
123
|
+
|
|
124
|
+
### Changed
|
|
125
|
+
|
|
126
|
+
- **FTS results are ranked by relevance (Okapi BM25).** Every token match used to score a flat
|
|
127
|
+
weight and AND-mode results came back in docId order, cut at `limit` — so "top 50" meant the
|
|
128
|
+
oldest 50 matches. Search now scores every matching doc with BM25 (k1 = 1.2, b = 0.75: term
|
|
129
|
+
frequency, inverse document frequency, doc-length normalization) and returns the best `limit`
|
|
130
|
+
across **all** matches (bounded top-k; ties break oldest-first). `score` is the BM25 value on
|
|
131
|
+
`ftsQuery`/`searchDocs` rows and `ftsScore` on `query({ fts })` rows; `maxScore` is now the
|
|
132
|
+
query's BM25 upper bound (was `numTerms × 2`). Prefix mode scores an exact word above a
|
|
133
|
+
prefix-only completion. Storage: tf and doc length ride along as marker terms in the existing
|
|
134
|
+
posting lists (no new sub-DBs), index format 4 → 5. **Existing indexes upgrade in place on
|
|
135
|
+
open** (a re-scan that only adds the markers — no clear), so search keeps answering throughout,
|
|
136
|
+
ranked by idf alone until the upgrade finishes; `fts.ready(type)` resolves when it has.
|
|
137
|
+
- **Hybrid `query({ fts, vector })`**: row `score` is now the actual fused RRF value (was a
|
|
138
|
+
rank-derived placeholder), and `fts.weight` / `vector.weight` (default 1) scale each signal's
|
|
139
|
+
contribution to the fusion.
|
|
140
|
+
- **Bus POKE is throttled per `(env, type)`**: the first change sends immediately and further
|
|
141
|
+
changes within `OKDB_BUS_POKE_WINDOW_MS` (default 10 ms; `0` = unthrottled) collapse into one
|
|
142
|
+
trailing datagram, so a sustained writer no longer sends one datagram per changed document. A
|
|
143
|
+
process that is the only holder of an env delivers pokes in-process with no datagram.
|
|
144
|
+
- **Views over small sources bootstrap in place.** A view whose source has fewer than
|
|
145
|
+
`OKDB_VIEWS_BOOTSTRAP_WORKER_MIN_DOCS` documents (default 5000) is bootstrapped on the calling
|
|
146
|
+
thread instead of spawning a bootstrap worker.
|
|
147
|
+
- **Timing knobs are overridable by env var** (defaults unchanged, meant for tests):
|
|
148
|
+
`OKDB_COMPACT_CLOSE_GRACE_MS`, `OKDB_COMPACT_DRAIN_TIMEOUT_MS`,
|
|
149
|
+
`OKDB_CLUSTER_RESPAWN_BACKOFF_MS`, `OKDB_FTS_DROP_COMMITTED_TIMEOUT_MS`,
|
|
150
|
+
`OKDB_READER_CHECK_MIN_INTERVAL_MS`, `OKDB_LOG_FLUSH_MS`, `OKDB_ENV_RELEASE_GRACE_MS`.
|
|
151
|
+
`OKDB_QUEUE_RECONCILE_MS` is now taken as given (it had a 2 s floor).
|
|
152
|
+
|
|
153
|
+
### Fixed
|
|
154
|
+
|
|
155
|
+
- **Embeddings on synced peers**: the indexer's `start()` now ensures its `doc_status` type, so
|
|
156
|
+
it exists on peers that received the pipeline by sync.
|
|
157
|
+
- **FTS filters starved at the default limit.** `ftsQuery(type, name, text, filter)` applied the
|
|
158
|
+
filter AFTER taking the top `limit` (default 50) hits, so a selective filter returned nothing
|
|
159
|
+
unless `limit` was raised; `query({ fts })` over-fetched a fixed 200 candidates with the same
|
|
160
|
+
failure beyond that. The filter (and a `query` index constraint) is now applied while ranking:
|
|
161
|
+
candidates stream best-first until `limit` rows pass or the matches run out. An explicit
|
|
162
|
+
`fts.limit` in `query()` still caps how many FTS candidates are considered.
|
|
163
|
+
|
|
164
|
+
- **Cron jobs silently stopped recurring.** A permanently failed run (`markJobFail`) and a claim
|
|
165
|
+
timeout with no tries left (reconcile) left a cron job `failed` forever, and a done run wrote
|
|
166
|
+
`done` and rescheduled in a second commit (a crash between the two ended the series) while
|
|
167
|
+
emitting `queue:done` for a job that went straight back to pending. Every terminal path of a cron
|
|
168
|
+
run now re-queues the same row as `pending` at the next cron time (`tries: 0`, the finished run
|
|
169
|
+
recorded in `job.last_run`) in the one write that ends the run, and emits the new
|
|
170
|
+
`queue:rescheduled` event instead of `queue:done`/`queue:failed`. A run's own retries still go
|
|
171
|
+
first; `cancelJob` is the one path that stops a series.
|
|
172
|
+
- **A cancelled or timed-out job kept swallowing its idempotency key.** `cancelJob` and reconcile's
|
|
173
|
+
timeout → `failed` didn't release `idempotency_key`, so a later enqueue with that key returned
|
|
174
|
+
the dead job's id and queued nothing. Keys now dedup against live (pending/running) jobs only and
|
|
175
|
+
every terminal state releases them; a terminal row still holding one (written before this fix)
|
|
176
|
+
is released in the same commit as the new job.
|
|
177
|
+
- **Orphan payloads from enqueue.** The payload was committed before the job, so a duplicate
|
|
178
|
+
idempotency key or a lost race left payloads with no job (e.g. 6 jobs, 8 payloads). Payload and
|
|
179
|
+
job are now one transaction, and `removeJob` (incl. `done_ttl`/`failed_ttl: 0` retention) deletes
|
|
180
|
+
both in one commit.
|
|
181
|
+
- **`queue.list` paging repeated rows and failed with filters.** The next page started at (and
|
|
182
|
+
repeated) the previous page's last row, rows sharing one `when` were mis-paged, and
|
|
183
|
+
`list({ type or status, cursor })` threw "prefix cannot be combined with startIndex/endIndex".
|
|
184
|
+
Cursors are now opaque exclusive strings that page every type/status/sort/direction combination
|
|
185
|
+
with no repeats or gaps (`list({ type, sort: 'priority' })` also works now — it needed a missing
|
|
186
|
+
index). A cursor reused with a different filter, or an old index-key array cursor, throws
|
|
187
|
+
`BAD_PARAM`. **Breaking for callers that built or inspected cursors** — treat them as opaque.
|
|
188
|
+
- **Cancelling a job didn't stop its running handler.** `ctx` had no abort signal and the
|
|
189
|
+
auto-heartbeat's cancel detection was dead (`markJobHeartbeat` resolved quietly on a lost claim).
|
|
190
|
+
Handlers now get `ctx.signal` (an `AbortSignal`), aborted on cancel (`JOB_CANCELLED` — at once in
|
|
191
|
+
the cancelling process, at the next heartbeat elsewhere), on a lost claim (`CLAIM_LOST`), or when
|
|
192
|
+
`stop(timeout)` runs out (`WORKER_STOPPING`). Cancellation is cooperative — handlers are never
|
|
193
|
+
killed. `markJobHeartbeat` now rejects on a lost claim (`NOT_FOUND` / `INVALID_STATE` /
|
|
194
|
+
`CLAIM_MISMATCH`). Queue-worker engines pass the signal to the function sandbox
|
|
195
|
+
(`functions.run(name, payload, { signal })`), which cancels the function and contains it if it
|
|
196
|
+
doesn't unwind.
|
|
197
|
+
- **`stop(timeout)` could run a job twice.** On timeout it released the claims of handlers still
|
|
198
|
+
running, so another consumer started the same job concurrently. It now aborts their `ctx.signal`
|
|
199
|
+
and keeps the claim (still heartbeated) until each handler settles: then the job is completed
|
|
200
|
+
(resolved) or released to pending without burning a try (threw). A process that exits first
|
|
201
|
+
leaves the claim to reconcile (at-least-once).
|
|
202
|
+
- **Changing a pipeline's embedder model mixed vectors from two models in one index.** A patched
|
|
203
|
+
embedder `model` with the same dims was accepted with only a note to rebuild, vectors did not
|
|
204
|
+
record their model, and chunks re-embed only when their text changes — so new and edited docs
|
|
205
|
+
landed in the new model's space next to old vectors, silently degrading search. The indexer now
|
|
206
|
+
records the embedder fingerprint (`{ type, model, dims }`) next to the pipeline's vectors; when
|
|
207
|
+
the configured embedder no longer matches (patched model, `replaceMember`, an indexer re-pointed
|
|
208
|
+
at another embedder, or a change arriving by sync) the pipeline is **stale**: new embeds are held
|
|
209
|
+
(`stats().waiting.reason: 'EMBEDDER_CHANGED'`, never mixed), `stats().vector_space`,
|
|
210
|
+
`embeddings.vectorSpace(name)` and `pipelines.get()` (`stale`, `vector_space`) report it, the
|
|
211
|
+
admin pipeline card shows **needs re-embed**, and search keeps serving the old vectors with
|
|
212
|
+
`meta.stale` + `meta.warning` on the query/nearest endpoints. `rebuild()` ("Re-embed all")
|
|
213
|
+
re-embeds with the new model and clears it; a patch that keeps the fingerprint (new `api_key`,
|
|
214
|
+
`url`, a no-op) changes nothing. Nothing is re-embedded automatically. Also: the query-embedder
|
|
215
|
+
instance a passive node builds from the durable record is now rebuilt when that record's config
|
|
216
|
+
changes (it kept the old model), and the indexer's hash→vector cache is cleared on a model change.
|
|
217
|
+
|
|
218
|
+
- **A view with a custom `bucket.project` made the whole store fail to re-open.** The projection
|
|
219
|
+
was a function, which persistence silently dropped, so on the next `open()` the stored bucket had
|
|
220
|
+
neither `preset` nor `project` and compiling it threw `Unknown bucket preset: undefined` — and
|
|
221
|
+
`views.rebuild()` of any other view threw too (its bootstrap worker re-opens the store). A custom
|
|
222
|
+
projection is now referenced by **name**: register it process-wide with
|
|
223
|
+
`OKDB.registerBucketProjection(name, fn)` before `open()` and set `bucket.project: '<name>'`,
|
|
224
|
+
which persists and recompiles on reopen, peers and rebuild (and can be created over HTTP).
|
|
225
|
+
`create()` refuses a function with `BUCKET_PROJECT_NOT_PERSISTABLE` and an unregistered name with
|
|
226
|
+
`BUCKET_PROJECT_UNKNOWN`. **Breaking for callers passing a function** — register it and pass its
|
|
227
|
+
name instead.
|
|
228
|
+
- **One bad stored view definition no longer fails `open()`.** Generalizing the `$where` guard: any
|
|
229
|
+
stored view whose definition can't be compiled at boot (unregistered custom reducer or projection,
|
|
230
|
+
a pre-fix function-projection bucket, a forbidden operator) is held back with a logged error —
|
|
231
|
+
`views.get()` returns `null`, `views.getMeta()` reports `state: 'error'` with the error code,
|
|
232
|
+
every other view boots and rebuilds normally, and `views.remove()` still works. `views.rebuild()`
|
|
233
|
+
of a held-back view retries the compile and fully re-derives it on success. Existing stores that
|
|
234
|
+
hold a pre-fix projection view open again; that view is held back (`BUCKET_CONFIG_INVALID`) until
|
|
235
|
+
removed and re-created.
|
|
236
|
+
- **Custom reducers ignored documents that already existed when the view was created.** The
|
|
237
|
+
bootstrap-worker eligibility check skipped every `$`-prefixed key while looking for custom
|
|
238
|
+
reducer names — which always start with `$` — so the scan ran on a worker thread that had no such
|
|
239
|
+
reducer and silently dropped it: after `create()` the value was `null` and only later writes
|
|
240
|
+
counted. Custom-reducer (and custom-projection) views now bootstrap on the main thread, so
|
|
241
|
+
bootstrap, live writes and `views.rebuild()` agree, including custom sub-reducers inside
|
|
242
|
+
`$group`/`$ref`.
|
|
243
|
+
- **Custom reducers across a reopen.** A reducer name nothing resolves used to be dropped silently
|
|
244
|
+
(a typo, or a stored view opened before `registerReducer` ran — the view then never updated that
|
|
245
|
+
reducer again). `create()` now refuses it with `VIEW_UNKNOWN_REDUCER`; the new process-wide
|
|
246
|
+
`OKDB.registerViewReducer(name, { apply })` (before `open()`) keeps such views live from boot;
|
|
247
|
+
a stored view whose reducer is only registered later via `env.views.registerReducer` is held back
|
|
248
|
+
at `open()` and fully re-derived when it is registered, so no write is lost.
|
|
249
|
+
- **`registerReducer('$group')` (or `'$ref'`) was accepted and then silently shadowed** by the
|
|
250
|
+
built-in. Every built-in reducer name and `$ref` are now rejected with `VIEW_REDUCER_CONFLICT`.
|
|
251
|
+
- **TTL items could outlive their expiry indefinitely in an idle env.** The sweep timer was armed
|
|
252
|
+
only by `setTTL()`/`clearTTL()` and at open — never re-armed after a timer-driven sweep, and
|
|
253
|
+
never armed by a TTL set through the write option (`put(..., { ttl })`, HTTP PUT `ttl`) or a
|
|
254
|
+
type's `defaultTTL` — so, with no further writes, `put(..., { ttl: 200 })` was still readable
|
|
255
|
+
long after it expired. Every path that sets an expiry now arms the single per-env timer when the
|
|
256
|
+
expiry is earlier than its target (no re-arm otherwise), every sweep re-arms it for the next
|
|
257
|
+
expiry (immediately when a `batchSize`-capped sweep leaves due items), and a sweep error retries
|
|
258
|
+
after 1 s. When only unremovable items are due (FK `restrict`), sweeps back off (1 s → 10 s)
|
|
259
|
+
instead of spinning — also on the write path, which previously re-swept on every write. The
|
|
260
|
+
timer stays `unref()`'d and is cleared on close.
|
|
261
|
+
- **`db.range(it)` / `env.range(it)` never ended**: they looped until lmdb's `iterate()` returned
|
|
262
|
+
`null`, but it returns `{ value, done }` results, so the generator yielded `{ done: true }`
|
|
263
|
+
forever. It now yields each item and stops at `done`; plain iterables are accepted too.
|
|
264
|
+
- **`POST /api[/env/:env]/transaction` rejected a bare-array body** with 400 `VALIDATION_ERROR`
|
|
265
|
+
("operations is required"), although the handler and the route's own example use one. The route
|
|
266
|
+
now uses `http.bodyMode: 'array'` (implemented in request validation: a bare-array body binds to
|
|
267
|
+
the route's single array input field), so both `{ "operations": [...] }` and `[...]` validate.
|
|
268
|
+
- **Queue: `markJobComplete` / `markJobFail` / `markJobProgress` with a `null` claim id acted on
|
|
269
|
+
another worker's claimed job** — the ownership check was skipped. They (and the
|
|
270
|
+
`completeJob`/`failJob` aliases) now throw `CLAIM_REQUIRED` without a claim id, and
|
|
271
|
+
`CLAIM_MISMATCH` for a claim that is not the job's current one.
|
|
272
|
+
- **Queue: `updateBucket` skipped its version check** (it passed a bare version where `update`
|
|
273
|
+
expects `{ ifVersion }`), so a concurrent token claim could be overwritten. It now retries
|
|
274
|
+
against a fresh read on a version conflict.
|
|
275
|
+
- **Queue: `list({ bucket, tag })` ignored both filters.** `tag` matches any of a job's `tags`,
|
|
276
|
+
`bucket` any of its `buckets[].id` (or the legacy `bucket`); `limit` counts matching jobs.
|
|
277
|
+
- **Auth: `verifyPassword` could crash the process** — on a scrypt error it rejected and then fell
|
|
278
|
+
through to `timingSafeEqual` inside the callback (an uncaught exception), and a stored hash of
|
|
279
|
+
the wrong length threw the same way. It now rejects cleanly on a scrypt error and returns
|
|
280
|
+
`false` for a malformed stored hash. `hashPassword` had the same fall-through.
|
|
281
|
+
- **Admin log History was dead: `GET /api/system/logs` returned 500** (`getRange: unrecognized
|
|
282
|
+
option "0"` — a stale 3-argument call) and loaded every stored log row into memory before
|
|
283
|
+
filtering. It now walks the ts index newest-first (a `[level|node|feature, ts]` index for a
|
|
284
|
+
single-valued filter), examines at most 5 000 rows per call and pages with an opaque
|
|
285
|
+
`next_cursor` (`"<ts>:<key>"`; same-ts rows are neither skipped nor repeated). A sparse filter
|
|
286
|
+
can return a short page with a non-null cursor — keep paging until it is `null`.
|
|
287
|
+
- **Export blocked the event loop and ignored backpressure.** `exportToStream` wrote every row in
|
|
288
|
+
one synchronous loop (200k docs: one ≈0.6 s stall, ≈52 MB buffered in the stream). It now reads
|
|
289
|
+
and writes 1 000-row chunks, awaits `drain` when `write()` returns `false` and yields between
|
|
290
|
+
chunks (200k docs: longest stall ≈10–47 ms, ≈0.3 MB buffered). Consistency is documented as it
|
|
291
|
+
is: per chunk (each key at most once), not point-in-time — use `backup()` for a snapshot.
|
|
292
|
+
- **`migrate.backup()` dropped data a restored store needed.** Time-machine history
|
|
293
|
+
(`<env>/time-machine/`) is now copied (LMDB native copy, just before its env); an env whose
|
|
294
|
+
directory name differs from its name (`ws:one` → `ws-one`) was copied where the restored
|
|
295
|
+
registry never looked and came back **empty**; `~fts` is still not copied (derived), but a store
|
|
296
|
+
opened without its `~fts` files now rebuilds every READY index from the documents instead of
|
|
297
|
+
serving silently empty search. Blobs are copied after all metadata, without the `tmp/` staging
|
|
298
|
+
dir; `~processes` is skipped; `envNames` always includes `~system`; the destination must be
|
|
299
|
+
new/empty and outside the store (`BACKUP_DEST_NOT_EMPTY`, `BACKUP_DEST_INSIDE_STORE`); an
|
|
300
|
+
`okdb-backup.json` manifest marks a complete backup. New `okdb restore <dir> --path <target>`.
|
|
301
|
+
- **Removed / unknown constructor options were silently accepted.** `workers` now throws
|
|
302
|
+
`WORKERS_REMOVED` and a boolean `sync` throws `SYNC_OPTION_REMOVED` (the `sync` settings object
|
|
303
|
+
is unchanged); any other unknown top-level key logs one warning naming it, with a did-you-mean
|
|
304
|
+
for near-misses (`procesors` → `processors`). The `db.workers` error and the inline-processor
|
|
305
|
+
messages now cite documents that exist.
|
|
306
|
+
- **Foreign-key `onDelete` silently did nothing when a key or type contained `@`.** The reverse-ref
|
|
307
|
+
index joined `target@targetKey@source@sourceKey@field` into one string and split it back on
|
|
308
|
+
`@`, so an email/URL key mis-parsed: `cascade` left the child behind, `restrict` let the parent
|
|
309
|
+
be deleted (leaving the child dangling), and `set_null` was never applied. Index rows are now
|
|
310
|
+
structured array keys (every component round-trips exactly), and readers never parse a key
|
|
311
|
+
string. The 2.4.0 storage migration `fk-ref-index-structured-keys` drops each env's index and
|
|
312
|
+
re-derives it from the FK schemas + source docs on first open; a leftover old-format row is
|
|
313
|
+
skipped, never misread. Same fix for numeric source keys (previously stringified, so their
|
|
314
|
+
cascade/set_null was skipped too), for the cascade cycle guard (`'a@b'`+`'c'` collided with
|
|
315
|
+
`'a'`+`'b@c'` and skipped a delete), and for dropping type `A` sweeping index rows of type
|
|
316
|
+
`A@x`. Clearing ref violations for key `a` no longer also clears those of key `a@b`. A store
|
|
317
|
+
opened by 2.4.0 is refused by older builds (`STORE_VERSION_NEWER`).
|
|
318
|
+
- **A queue job could stay `running` after its handler finished.** Completing or failing a job was
|
|
319
|
+
a single version-checked write, so a concurrent write to the same row by the claimant itself — an
|
|
320
|
+
un-awaited `ctx.markProgress()`, the auto-heartbeat — made it fail with "Version mismatch". The
|
|
321
|
+
worker only logged a warning; the job then sat `running` until its claim expired and was failed
|
|
322
|
+
or run again. Complete, fail and release now re-read and retry while the claim is still ours,
|
|
323
|
+
and give up only when the claim was actually lost.
|
|
324
|
+
- **`ctx.heartbeat()` shrank the claim to ~1 s** when the handler had no explicit `ttl`, so
|
|
325
|
+
another process's reconcile could take over a job that was still running. Manual and automatic
|
|
326
|
+
heartbeats now extend by the ttl the job was claimed with.
|
|
327
|
+
- **`max_tries: null` (documented as unlimited) was stored as 1.** An explicit `null` on enqueue,
|
|
328
|
+
on a job-type default or as the queue's `default_max_tries` now means unlimited retries.
|
|
329
|
+
- **Queue handler results were dropped.** A local handler's return value, or the `result` passed
|
|
330
|
+
to `markJobComplete`, is now stored on the done job as `job.result` (when JSON-serializable and
|
|
331
|
+
≤ 16 KB; otherwise `null`). A manual `retryJob` clears it.
|
|
332
|
+
- **A synced node could skip a storage migration on its own files.** The `~migrations` log in
|
|
333
|
+
`~system` replicated to peers, and startup trusted any row by id — so a node that pulled a row
|
|
334
|
+
from an already-upgraded peer never ran that migration on its own layout. `~migrations` is now
|
|
335
|
+
node-local: left out of sync deltas and refused when a not-yet-fixed peer sends it. For rows
|
|
336
|
+
already replicated into existing stores, a row counts when this store wrote it, or when this
|
|
337
|
+
store's own (never replicated) layout stamp already covers the migration's version — so a
|
|
338
|
+
lagging node migrates, and a node whose own row was overwritten by a peer's does not re-run it.
|
|
339
|
+
- **Vector and hybrid `query()` returned nothing from the vector side for chunked pipelines.**
|
|
340
|
+
`env.query(type, filter, { vector })` looked documents up under the raw chunk keys
|
|
341
|
+
(`docKey\tchunkHash`), so vector-only queries returned `[]` and hybrid `{ fts, vector }` quietly
|
|
342
|
+
degraded to FTS-only. Vector hits are now mapped to their source documents — one row per doc,
|
|
343
|
+
best chunk wins, the matched chunk exposed as `chunkHash` + `chunk: { start, end }` — with chunk
|
|
344
|
+
candidates over-fetched so `limit` counts documents. New
|
|
345
|
+
`okdb.embeddings.searchDocs(name, query, { limit })` / `pipeline.api.searchDocs()` is the
|
|
346
|
+
document-level search; `search()` stays chunk-level.
|
|
347
|
+
- **`POST …/pipelines/:pipeline/query` returned chunk hits, so `limit: 10` could yield 5 documents.**
|
|
348
|
+
It now returns one row per document; pass `chunks: true` for the raw chunk-level hits.
|
|
349
|
+
`…/nearest` is unchanged.
|
|
350
|
+
- **`POST /api/env/:env/type/:type/query` with `options.vector` failed with 500** (the async hybrid
|
|
351
|
+
result was iterated as an array). Rows now also carry `score`/`vectorScore`/`ftsScore` and chunk
|
|
352
|
+
info when present.
|
|
353
|
+
- **Several processes starting on a brand-new store could crash natively.** lmdb-js (3.5.x) has a
|
|
354
|
+
bug affecting concurrent opens: an LMDB open that overlaps another process's commit to the same
|
|
355
|
+
env can move the shared transaction id backwards, and later writes then fail with `SIGSEGV` in
|
|
356
|
+
`mdb_cursor_put`, `MDB_PROBLEM`, an LMDB assertion, or a silently lost commit. On a fresh path
|
|
357
|
+
every booting process opens the same system envs while the others make their first writes to
|
|
358
|
+
them, so ≈1% of 6-process fresh boots crashed. `open()` now takes a cross-process **boot lock**
|
|
359
|
+
while the store is being initialised (an env it opens at boot has no data file yet), so those
|
|
360
|
+
boots run one at a time; `close()` joins it only while a peer is initialising. A dead or stale
|
|
361
|
+
holder is taken over, and a waiter that exceeds `OKDB_BOOT_LOCK_TIMEOUT_MS` (default 60 s) logs
|
|
362
|
+
a warning and proceeds unserialised. An established store is not serialised, so opening a
|
|
363
|
+
process alongside a peer that is actively writing — and runtime `createEnvironment()` /
|
|
364
|
+
`removeEnvironment()` — remain exposed until the issue is fixed upstream; staggered starts keep
|
|
365
|
+
that window small (see [Roles & Deployment](docs/deployment.md)).
|
|
366
|
+
- **Concurrent opens of a fresh path could also die with `SIGBUS` or hang.** A process attaching
|
|
367
|
+
to a shared-memory segment in the instant between a peer creating it and sizing it mapped a
|
|
368
|
+
0-byte object and crashed on first access; the segment is now sized by whoever attaches first.
|
|
369
|
+
And `open()` could hang forever in "features + processors" when a peer won the race to build an
|
|
370
|
+
index: `indexReady()` waited on a promise only the building process resolves — it now also
|
|
371
|
+
follows the stored index status.
|
|
372
|
+
- **Live subscriptions could come up disabled on one of several concurrently booting processes.**
|
|
373
|
+
The process that lost the race to create the `~sub` types logged "already registered" and ran
|
|
374
|
+
with subscriptions off; setup is now race-safe. Subscription routing is also lazy: a process
|
|
375
|
+
does per-change subscription work only while it holds an open subscription connection, and
|
|
376
|
+
sessions are indexed by `[dataEnv, type]` (20k writes with 200 sessions: 8.2 s → 0.4 s CPU).
|
|
377
|
+
- **`fts.ready()` waited forever when another process finished the build.** A pending `ready()`
|
|
378
|
+
was only woken by a build end in its own instance; it now also follows the stored index status.
|
|
379
|
+
- **Compaction could crash or stall processes running live FTS.** Lock handles kept across a
|
|
380
|
+
compaction's reopen wrote to the closed pre-swap env ("The environment is already closed.",
|
|
381
|
+
uncatchable); a process opening during a peer's compaction crash-looped on `FTS_DRAINING`; a
|
|
382
|
+
processor drain parked on the compaction held up the env close for its whole grace period; and
|
|
383
|
+
the FTS posting + docs compound write parked on the drain while already holding its writer slot
|
|
384
|
+
— a self-deadlock that made every non-forced `compact()` over a live FTS drain defer. All four
|
|
385
|
+
are fixed (drain-quantum writes are released on close and re-run after the reopen). A lone
|
|
386
|
+
process now skips the close grace period, so its `env.compact()` takes ≈0.1–0.25 s instead of
|
|
387
|
+
3–4 s. A write rejected at the compaction gate no longer leaks a writer admission slot.
|
|
388
|
+
- **Views could double-count or miss writes made while they bootstrapped.** A delayed `~views`
|
|
389
|
+
poke could activate a second copy of a view while `create()` was still running (every later
|
|
390
|
+
write applied twice, e.g. 3 500 instead of 3 000); the bootstrap scan and its change replay could
|
|
391
|
+
both count a document written during the scan; a write in flight at a sync view's hand-off to
|
|
392
|
+
live processing could be lost; `rebuild()`/`stop()` could race a running scan (12 000 counted for
|
|
393
|
+
10 000 docs); and the view-rebuild lease was never awaited. Activation is now idempotent, the scan
|
|
394
|
+
leaves every document changed after the create-time clock to the replay, and a sync view's final
|
|
395
|
+
replay and its `ready` flip happen in one write, so counts are exact for inserts. Known limitation: a sync view can
|
|
396
|
+
still double-count an _update or delete_ of an already-scanned document during its bootstrap;
|
|
397
|
+
`views.rebuild()` corrects it. An interrupted bootstrap is not resumed — the next `open()`
|
|
398
|
+
rebuilds the view.
|
|
399
|
+
- **`close()` during a view bootstrap could hang process exit.** Terminating the bootstrap worker
|
|
400
|
+
in the middle of an LMDB write left lmdb's native write thread waiting forever. The worker is now
|
|
401
|
+
cancelled cooperatively at a batch boundary and closes its own store (`terminate()` only after
|
|
402
|
+
`OKDB_VIEW_WORKER_CANCEL_TIMEOUT_MS`, default 10 s); `create()` resolves after the worker exits,
|
|
403
|
+
and no worker starts into a closing env. The bootstrap's change replay runs in chunks
|
|
404
|
+
(`OKDB_VIEWS_REPLAY_QUANTUM`, default 1 000) and yields, instead of one long loop stall.
|
|
405
|
+
- **The change-feed could announce a same-process write without its previous value.** A poke-driven
|
|
406
|
+
drain could reach a change between its commit and the in-process event, emit it without
|
|
407
|
+
`prevValue`, and the richer in-process event was then dropped as a duplicate. The drain now
|
|
408
|
+
leaves such changes to the in-process event.
|
|
409
|
+
- **Functions failed to compile under load.** Evaluating a function's source was bounded by a
|
|
410
|
+
hard-coded 100 ms wall clock, so a busy process got spurious `FUNCTION_SCRIPT_COMPILE_FAILED`.
|
|
411
|
+
The bound is now 1 s (`OKDB_FN_COMPILE_TIMEOUT_MS`).
|
|
412
|
+
- **`functions.run(name, payload, { timeoutMs })` ignored `timeoutMs`.** It now overrides the
|
|
413
|
+
stored `runtime.timeoutMs` for that call; it must be a positive finite number
|
|
414
|
+
(`FUNCTION_INVALID_TIMEOUT`) and is capped at `OKDB_FN_MAX_TIMEOUT_MS` (default 600 s).
|
|
415
|
+
- **Materializer pipelines committed once per document.** Each op was its own awaited durable
|
|
416
|
+
write; a drained batch now applies in one transaction (chunks of 2 000 ops), with license write
|
|
417
|
+
accounting unchanged — 6 000 docs ≈3.0 s → ≈0.9 s.
|
|
418
|
+
- **Embeddings: `createPipeline` dropped the indexer's `flushQuantum` / `drainDeadlineMs`**, so
|
|
419
|
+
they could not be tuned per pipeline; both are now passed through (defaults 32 changes and
|
|
420
|
+
10 min). **`flush()` resolved silently when it timed out**, reporting "indexed" while the
|
|
421
|
+
cursor still trailed; `api.flush({ timeoutMs })` / `indexer.flush()` now reject with
|
|
422
|
+
`INDEXER_FLUSH_TIMEOUT` (default 30 s) — **callers that relied on it always resolving must
|
|
423
|
+
handle the rejection**.
|
|
424
|
+
- **Cluster: pause/resume and lease hand-offs took up to 2 s to show in `~processes`.** The
|
|
425
|
+
supervisor now republishes a worker's row (100 ms debounce) when its processing state changes,
|
|
426
|
+
not only on the heartbeat. The CLI's cluster banner no longer calls the supervisor "the
|
|
427
|
+
processor".
|
|
428
|
+
- **Docs: `OKDB_BUS_SECRET` was documented but never read.** The bus is namespaced automatically by
|
|
429
|
+
the store's identity (`okdb-<db id>`) — a namespace, not authentication; there is nothing to
|
|
430
|
+
configure. The HTTP-cluster docs also wrongly said the supervisor stays out of the request path:
|
|
431
|
+
on Linux/macOS it accepts every new connection (`NODE_CLUSTER_SCHED_POLICY=none` opts out; see
|
|
432
|
+
[HTTP Clustering → Connection distribution](docs/http-cluster.md#connection-distribution)).
|
|
433
|
+
|
|
7
434
|
## [2.3.5] - 2026-09-24
|
|
8
435
|
|
|
9
436
|
### Fixed
|