nedb-engine 3.1.0 → 3.2.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.
- package/README.md +105 -109
- package/index.js +1 -2
- package/nedb.darwin-arm64.node +0 -0
- package/nedb.darwin-x64.node +0 -0
- package/nedb.linux-arm64-gnu.node +0 -0
- package/nedb.linux-arm64-musl.node +0 -0
- package/nedb.linux-x64-gnu.node +0 -0
- package/nedb.linux-x64-musl.node +0 -0
- package/nedb.win32-x64-msvc.node +0 -0
- package/nedbd-v2-darwin-arm64 +0 -0
- package/nedbd-v2-darwin-x64 +0 -0
- package/nedbd-v2-linux-arm64 +0 -0
- package/nedbd-v2-linux-arm64-musl +0 -0
- package/nedbd-v2-linux-x64 +0 -0
- package/nedbd-v2-linux-x64-musl +0 -0
- package/nedbd-v2-win-x64.exe +0 -0
- package/package.json +6 -3
package/README.md
CHANGED
|
@@ -26,86 +26,114 @@ One Rust core → ships to **PyPI** and **npm** from a single source.
|
|
|
26
26
|
|
|
27
27
|
---
|
|
28
28
|
|
|
29
|
-
##
|
|
29
|
+
## New in 3.2.0 — wrap the databases you already run
|
|
30
30
|
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
NEDB adds **tamper-evident causal provenance to a database you already have**, in one line, without
|
|
32
|
+
rip-and-replace. Five adapters, one surface:
|
|
33
33
|
|
|
34
|
-
|
|
34
|
+
```python
|
|
35
|
+
from nedb import wrap_redis, wrap_sqlite, wrap_mysql, wrap_mongo, wrap_postgresql
|
|
35
36
|
|
|
36
|
-
|
|
37
|
-
|
|
37
|
+
r = wrap_redis(redis.Redis()) # or wrap_sqlite(sqlite3.connect("app.db")), ...
|
|
38
|
+
r.nedb.register("driver:*", "driver") # teach NEDB the host's shape
|
|
39
|
+
r.nedb.backfill() # import what is already there
|
|
40
|
+
r.nedb.shadow_writes = True # every future write is chained
|
|
38
41
|
|
|
39
|
-
|
|
40
|
-
returned 0 after reopen — while `verify()` reported all 30 objects healthy.** The content-addressed
|
|
41
|
-
objects were durable; the id-index entries that make them findable were gone.
|
|
42
|
+
r.set("driver:d1", json.dumps({"name": "Bob", "status": "active"}))
|
|
42
43
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
...free space, retry -> Ok reopen -> 30 rows
|
|
44
|
+
r.nedb.query('FROM driver WHERE status = "active"') # NQL over your Redis data
|
|
45
|
+
r.nedb.query('FROM driver AS OF 41') # what it looked like at seq 41
|
|
46
|
+
r.nedb.verify() # True — BLAKE2b chain intact
|
|
47
47
|
```
|
|
48
48
|
|
|
49
|
-
|
|
50
|
-
|
|
49
|
+
| wrapper | host | shadowing |
|
|
50
|
+
|---|---|---|
|
|
51
|
+
| `wrap_redis` | `redis.Redis` / compatible | automatic — every write command intercepted |
|
|
52
|
+
| `wrap_sqlite` | `sqlite3.Connection` | automatic — `execute()` intercepted post-write |
|
|
53
|
+
| `wrap_mysql` | DB-API 2.0 (mysql-connector, PyMySQL) | explicit `shadow_row()` |
|
|
54
|
+
| `wrap_mongo` | `pymongo.MongoClient` | explicit `shadow_row()` |
|
|
55
|
+
| `wrap_postgresql` | DB-API 2.0 (psycopg2, psycopg 3) | explicit `shadow_row()` |
|
|
56
|
+
|
|
57
|
+
**NEDB never writes into the host database's namespace.** Shadow data lives only in the NEDB engine.
|
|
58
|
+
|
|
59
|
+
Three backends behind the same surface, selected by `backend="auto"`: **nedbd over HTTP** (`nedbd_url=`),
|
|
60
|
+
**embedded v2/v3 DAG** (the Rust core, in-process, no server — `dag_path=` for a durable store,
|
|
61
|
+
`dag_tmk=` for AES-256-GCM at rest), or the **v1 in-process AOF** engine as a universal fallback. On the
|
|
62
|
+
DAG backend you also get `tip()`, `tip_collection()`, `since()` (changefeed) and `scan_status()`.
|
|
63
|
+
|
|
64
|
+
### 🟢 MIT licensed since 3.0.0
|
|
65
|
+
|
|
66
|
+
No production restriction, no copyleft, no Change Date. Use it in production, embed it commercially,
|
|
67
|
+
ship it closed-source, fork it, sell it. License review is a wall, not a speed bump — that wall is gone.
|
|
68
|
+
|
|
69
|
+
### Also in 3.2.0
|
|
70
|
+
|
|
71
|
+
- **A durability defect that pinned every embedded database.** The background flush ticker held a
|
|
72
|
+
strong `Arc<Db>` in an unconditional loop, so the handle was never dropped: the exclusive data-dir
|
|
73
|
+
`LOCK` was never released (reopening the same path *in the same process* failed with "locked by
|
|
74
|
+
another process" naming your own pid), every `open()` leaked a thread and the whole `Db`, and
|
|
75
|
+
flush-on-close could never fire. The ticker now holds a `Weak<Db>` and exits when its owner does.
|
|
76
|
+
**Live in 2.8.5 through 3.1.0 — upgrade if you embed the engine.**
|
|
77
|
+
- **`wrap_redis` crashed on any install without the native wheel** — the pure-Python fallback path
|
|
78
|
+
raised `AttributeError` from inside `wrap_redis()`. Fixed.
|
|
79
|
+
- **Prebuilt binaries for `linux-arm64` and musl/Alpine**, on npm and PyPI. Graviton, Ampere, Linux
|
|
80
|
+
containers on Apple Silicon, and Alpine images previously installed cleanly and then failed at
|
|
81
|
+
import.
|
|
82
|
+
- **CI actually runs the test suites.** Until now the only workflows fired on a version tag, so the
|
|
83
|
+
first automated opinion about a change arrived *after* it was published to three registries. All
|
|
84
|
+
26 suites now run on every push and pull request. It found four real defects in its first hour,
|
|
85
|
+
including two of the ones listed above.
|
|
51
86
|
|
|
52
|
-
|
|
87
|
+
---
|
|
53
88
|
|
|
54
|
-
|
|
55
|
-
flush from a failed one. Anything that takes a destructive or externally-visible action on the
|
|
56
|
-
strength of a persisted record needs to know.
|
|
89
|
+
## Earlier — 2.8.6 durability & recovery
|
|
57
90
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
db.try_flush_all()?; // Result<()> — id-index WAL + segment sync + MANIFEST
|
|
91
|
+
Three defects found by killing a real engine at every persistence boundary and by filling a real
|
|
92
|
+
filesystem to zero free blocks. **If you are on 2.8.5 or earlier, upgrade.**
|
|
61
93
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
94
|
+
**1. A failed flush silently discarded acknowledged writes.** `IdIndex::flush_write_buf` cleared every
|
|
95
|
+
buffered entry regardless of whether its disk write succeeded, so a flush that hit `ENOSPC` threw the
|
|
96
|
+
entry away and no later flush retried it. Reproduced on a full 22 MiB filesystem: 30 rows acknowledged
|
|
97
|
+
by `put() -> Ok`, then `list()` returned 0 after reopen — while `verify()` reported all 30 objects
|
|
98
|
+
healthy. The content-addressed objects were durable; the id-index entries that make them findable were
|
|
99
|
+
gone. An entry now leaves the WAL only when its write actually landed.
|
|
65
100
|
|
|
66
|
-
|
|
101
|
+
**2. Flush errors were unobservable.** `flush_all()` returns `()`, so a caller could not tell a durable
|
|
102
|
+
flush from a failed one.
|
|
67
103
|
|
|
68
|
-
|
|
104
|
+
```rust
|
|
105
|
+
db.try_flush_all()?; // Result<()> — use this when the outcome matters
|
|
106
|
+
db.flush_all(); // still logs; for ticker / Drop, nowhere to propagate
|
|
107
|
+
```
|
|
69
108
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
`
|
|
73
|
-
`
|
|
109
|
+
Also added: `Db::try_flush_manifest()` and `IdIndex::try_flush_write_buf()`.
|
|
110
|
+
|
|
111
|
+
**3. `repair` could not repair, and `since()` claimed "caught up" while behind.** The cold scan rebuilt
|
|
112
|
+
`seq_index`, per-collection tips, the Merkle head and `MANIFEST` — but never the id index, and
|
|
113
|
+
`start_cold_scan()` is a deliberate no-op on a warm store, so `nedb-cli repair` printed success on
|
|
114
|
+
exactly the database it exists to fix.
|
|
74
115
|
|
|
75
116
|
```bash
|
|
76
117
|
nedb-cli repair ./data
|
|
77
118
|
# repaired: 203 id-index entr(ies) rebuilt, 203 node(s) verified, flushed
|
|
78
119
|
```
|
|
79
120
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
database reopens **warm** instead of coming back up cold with an empty head.
|
|
87
|
-
|
|
88
|
-
Separately, `since()` set `has_more = hit_limit` alone. On a warm boot the seq index is empty **by
|
|
89
|
-
design** (that is why warm start is O(1)), so every lookup missed and `since()` returned zero nodes
|
|
90
|
-
with `has_more = false` — indistinguishable from genuinely up to date. A consumer following the
|
|
91
|
-
documented drain loop stopped one call in, with every record unread.
|
|
121
|
+
Every object carries its own `coll`, `id` and `seq`, so the index is fully derivable — nothing is
|
|
122
|
+
invented. Separately, `since()` set `has_more = hit_limit` alone; on a warm boot the seq index is empty
|
|
123
|
+
*by design*, so `since()` returned zero nodes with `has_more = false` — indistinguishable from
|
|
124
|
+
genuinely up to date, and a consumer following the documented drain loop stopped one call in with every
|
|
125
|
+
record unread. `has_more` is now true whenever the cursor is behind head, and `ScanStatus` gains
|
|
126
|
+
**`seq_index_ready`** — gate replication on that, not on `scan_complete`.
|
|
92
127
|
|
|
93
|
-
**
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
### Known sharp edge (documented, not changed)
|
|
98
|
-
|
|
99
|
-
`since()`'s cursor is **exclusive** and seqs start at 0, so `since(0, _)` returns `(0, head]` and the
|
|
100
|
-
very first write in a database (seq 0) is unreachable through any cursor value. Ten writes drain as
|
|
101
|
-
nine records. Changing the convention would break existing consumers; a replica seeded from
|
|
102
|
-
`since()` alone starts one record short.
|
|
128
|
+
**Known sharp edge (documented, not changed):** `since()`'s cursor is **exclusive** and seqs start at 0,
|
|
129
|
+
so `since(0, _)` returns `(0, head]` and the very first write (seq 0) is unreachable through any cursor
|
|
130
|
+
value. Ten writes drain as nine records. Changing the convention would break existing consumers.
|
|
103
131
|
|
|
104
132
|
---
|
|
105
133
|
|
|
106
|
-
## NEDB
|
|
134
|
+
## NEDB v3.2.0 — Production Stable
|
|
107
135
|
|
|
108
|
-
**Current stable: 2.
|
|
136
|
+
**Current stable: 3.2.0** — NEDB ships as **three version-aligned distributions** on one tag — `nedb-engine` (flagship), `crypto-database` (verifiable v2/v3 DAG), and `aof-db` (fast append-only) — across npm / PyPI / crates.io with native addons for **macOS (arm64 + x86_64), Linux (x86_64 + aarch64, glibc + musl) and Windows x86_64** (see [**Releasing**](#releasing) below). All native wheels (Linux + Windows on GitHub Actions; macOS on Codemagic M2 Mac Minis) **plus** the universal pure-Python wheel ship from a single `v*` tag, with the `nedbd-v2` binary bundled inside `pip install nedb-engine`.
|
|
109
137
|
|
|
110
138
|
### New in 2.8.0 — Cast: the database understands English
|
|
111
139
|
|
|
@@ -150,7 +178,7 @@ nedbd --dag --data ./data
|
|
|
150
178
|
NEDBD_DAG=1 NEDB_TMK=<32-byte-hex> nedbd --data ./data
|
|
151
179
|
|
|
152
180
|
curl http://127.0.0.1:7070/health
|
|
153
|
-
# {"ok":true,"version":"
|
|
181
|
+
# {"ok":true,"version":"3.2.0","service":"nedbd","engine":"dag","startup_ready":true,"encrypted":true}
|
|
154
182
|
|
|
155
183
|
# Tail the live event stream (new in v2.2.31)
|
|
156
184
|
curl http://127.0.0.1:7070/events
|
|
@@ -204,6 +232,24 @@ pip install nedb-engine # Python ≥ 3.8 — pure-Python + optional Rust na
|
|
|
204
232
|
npm install nedb-engine # Node ≥ 16 — napi-rs prebuilt binaries
|
|
205
233
|
```
|
|
206
234
|
|
|
235
|
+
### Prebuilt platforms
|
|
236
|
+
|
|
237
|
+
Both registries ship prebuilt binaries for:
|
|
238
|
+
|
|
239
|
+
| Platform | libc | Python wheel | Node addon |
|
|
240
|
+
|---|---|---|---|
|
|
241
|
+
| Linux x86_64 | glibc | ✅ manylinux | ✅ |
|
|
242
|
+
| Linux x86_64 | musl (Alpine) | ✅ musllinux | ✅ |
|
|
243
|
+
| Linux aarch64 (Graviton, Ampere, Apple-Silicon containers) | glibc | ✅ manylinux | ✅ |
|
|
244
|
+
| Linux aarch64 | musl (Alpine) | ✅ musllinux | ✅ |
|
|
245
|
+
| macOS arm64 + x86_64 | — | ✅ | ✅ |
|
|
246
|
+
| Windows x86_64 | MSVC | ✅ | ✅ |
|
|
247
|
+
|
|
248
|
+
On Python, any platform without a prebuilt wheel still installs: pip falls back
|
|
249
|
+
to the universal `py3-none-any` wheel and you get the pure-Python v1 AOF engine
|
|
250
|
+
(correct, slower, no embedded DAG). On Node there is no such fallback — an
|
|
251
|
+
unlisted platform has no addon.
|
|
252
|
+
|
|
207
253
|
---
|
|
208
254
|
|
|
209
255
|
## Python — 5-minute tour
|
|
@@ -303,58 +349,7 @@ Typed errors throughout: `NedbAuthError`, `NedbNotFound`, `NedbBadRequest`,
|
|
|
303
349
|
|
|
304
350
|
---
|
|
305
351
|
|
|
306
|
-
##
|
|
307
|
-
|
|
308
|
-
**One line. Any stack.** Wrap your existing connection and gain tamper-evident, causally-provable, bi-temporal storage *alongside* your app — no migration, no rip-and-replace. NEDB never touches your namespace; shadow data lives only in the embedded DAG engine.
|
|
309
|
-
|
|
310
|
-
| Language | Package | Redis | SQLite | MySQL | MongoDB | PostgreSQL |
|
|
311
|
-
|---|---|:---:|:---:|:---:|:---:|:---:|
|
|
312
|
-
| Python | `pip install nedb-engine` | ✅ | ✅ | ✅ | ✅ | ✅ |
|
|
313
|
-
| Node.js | `npm install nedb-engine` → `require('nedb-engine/wrap')` | ✅ | ✅ | ✅ | ✅ | ✅ |
|
|
314
|
-
| Rust | `nedb-wrap` (crates.io) | ✅ (`redis` feature) | 📋 engine-direct | 📋 engine-direct | 📋 engine-direct | 📋 engine-direct |
|
|
315
|
-
|
|
316
|
-
✅ adapter shipped · 📋 embed the DAG core directly (`Surface` trait, same contract)
|
|
317
|
-
|
|
318
|
-
The same contract everywhere — register → backfill → shadow → full NEDB API:
|
|
319
|
-
|
|
320
|
-
```python
|
|
321
|
-
# Python — every write auto-chained
|
|
322
|
-
import redis, json
|
|
323
|
-
from nedb import wrap_redis
|
|
324
|
-
|
|
325
|
-
r = wrap_redis(redis.Redis("localhost", 6379), db_name="rideshare",
|
|
326
|
-
dag_path="./nedb-data") # embedded v2/v3 DAG — no server
|
|
327
|
-
r.nedb.register("driver:*", "driver", value_parser=json.loads)
|
|
328
|
-
r.nedb.backfill()
|
|
329
|
-
r.nedb.shadow_writes = True
|
|
330
|
-
r.set("driver:d1", json.dumps({"name": "Bob", "status": "active"}))
|
|
331
|
-
r.nedb.query('FROM driver WHERE status = "active"')
|
|
332
|
-
r.nedb.verify() # → True — BLAKE2b chain intact
|
|
333
|
-
```
|
|
334
|
-
|
|
335
|
-
```js
|
|
336
|
-
// Node.js — same shape, real Rust DAG core via napi-rs
|
|
337
|
-
const { wrapRedis } = require('nedb-engine/wrap');
|
|
338
|
-
const r = wrapRedis(redisClient, { dbName: 'rideshare', dagPath: './nedb-data' });
|
|
339
|
-
r.nedb.register('driver:*', 'driver');
|
|
340
|
-
r.nedb.shadowWrites = true;
|
|
341
|
-
await r.set('driver:d1', JSON.stringify({ name: 'Bob' }));
|
|
342
|
-
r.nedb.query('FROM driver');
|
|
343
|
-
```
|
|
344
|
-
|
|
345
|
-
```rust
|
|
346
|
-
// Rust — embed the engine directly (nedb-wrap crate)
|
|
347
|
-
use nedb_wrap::Surface;
|
|
348
|
-
let s = Surface::in_memory(); // or Surface::open(path)?
|
|
349
|
-
s.register("driver:*", "driver");
|
|
350
|
-
s.shadow_writes.store(true, std::sync::atomic::Ordering::Relaxed);
|
|
351
|
-
s.shadow("driver:d1", serde_json::json!({"name": "Bob"}), true)?;
|
|
352
|
-
assert!(s.verify());
|
|
353
|
-
```
|
|
354
|
-
|
|
355
|
-
Engine selection (all languages): `nedbd` HTTP server if you point at one (v1 AOF, `--dag` v2, `--dag-v3` v3) → **embedded DAG** if the native wheel is installed → v1 in-process fallback. Pass `dag_path=` for a durable store, `dag_tmk=` for AES-256-GCM encryption.
|
|
356
|
-
|
|
357
|
-
## Redis layer-2 — wrap_redis() in depth
|
|
352
|
+
## Redis layer-2 — wrap_redis()
|
|
358
353
|
|
|
359
354
|
Already running on Redis? Wrap your connection in one line and gain NEDB features *alongside* your existing Redis app — no migration required.
|
|
360
355
|
|
|
@@ -964,7 +959,8 @@ Requires `GITHUB_TOKEN` (`repo` + `workflow` scope) in the environment. It never
|
|
|
964
959
|
## Authors
|
|
965
960
|
|
|
966
961
|
Built by **[Mark Allen Evans Jr.](https://interchained.org)** (INTERCHAINED, LLC)
|
|
967
|
-
with **
|
|
962
|
+
with the **Interchained AI fleet** on [Hyperagent](https://hyperagent.com/refer/J2G6TCD7) —
|
|
963
|
+
Vex (GLM · Claude Sonnet · Opus · Fable · GPT-6 Astra/Sol), across hundreds of sessions.
|
|
968
964
|
|
|
969
965
|
> *"Take one idea, turn it into an LP, then an app, then a system, then a platform, then infrastructure that is irreplaceable."*
|
|
970
966
|
|
package/index.js
CHANGED
|
@@ -15,8 +15,7 @@
|
|
|
15
15
|
// Escape hatch: set NEDB_NO_EXIT_FLUSH=1 to leave signal handling entirely to
|
|
16
16
|
// the host app (it can still call `db.flush()` itself).
|
|
17
17
|
//
|
|
18
|
-
// © INTERCHAINED LLC × Claude Opus
|
|
19
|
-
|
|
18
|
+
// © INTERCHAINED LLC × Vex (Interchained AI fleet: GLM · Claude · Opus · Fable · GPT-6)
|
|
20
19
|
const native = require('./native.js');
|
|
21
20
|
|
|
22
21
|
const Native = native.NedbCore;
|
package/nedb.darwin-arm64.node
CHANGED
|
Binary file
|
package/nedb.darwin-x64.node
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/nedb.linux-x64-gnu.node
CHANGED
|
Binary file
|
|
Binary file
|
package/nedb.win32-x64-msvc.node
CHANGED
|
Binary file
|
package/nedbd-v2-darwin-arm64
CHANGED
|
Binary file
|
package/nedbd-v2-darwin-x64
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/nedbd-v2-linux-x64
CHANGED
|
Binary file
|
|
Binary file
|
package/nedbd-v2-win-x64.exe
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nedb-engine",
|
|
3
|
-
"version": "3.1
|
|
4
|
-
"description": "NEDB
|
|
3
|
+
"version": "3.2.1",
|
|
4
|
+
"description": "NEDB \u2014 hash-chained, time-traveling, bi-temporal embedded database with Rust native core. SQL, Redis, MongoDB adapters. Causal Write Provenance. RESP2 wire protocol.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"exports": {
|
|
7
7
|
".": {
|
|
@@ -61,7 +61,10 @@
|
|
|
61
61
|
"additional": [
|
|
62
62
|
"aarch64-apple-darwin",
|
|
63
63
|
"x86_64-unknown-linux-gnu",
|
|
64
|
-
"x86_64-pc-windows-msvc"
|
|
64
|
+
"x86_64-pc-windows-msvc",
|
|
65
|
+
"aarch64-unknown-linux-gnu",
|
|
66
|
+
"x86_64-unknown-linux-musl",
|
|
67
|
+
"aarch64-unknown-linux-musl"
|
|
65
68
|
]
|
|
66
69
|
}
|
|
67
70
|
},
|