Skip to content

Commit 1499bc8

Browse files
committed
chore: update FFI bindings, WASM API, examples, docs, and dependency versions
FFI (nodedb-lite-ffi): - Add `handle_registry.rs`: opaque-handle registry used by C and JNI APIs to avoid raw pointer exposure. - Add `jni_bridge/document.rs`: JNI document engine bridge. - Update C header (`nodedb_lite.h`) and all FFI source files to match renamed storage types and new `Encryption` parameter on `open`. - Update JNI bridge (`array`, `core`, `mod`) to use handle registry. WASM (nodedb-lite-wasm): - Update `lib.rs` to use `PagedbStorageMem` and the new `vector_search` signature with `allowed_ids` parameter. - Update WASM README to reflect pagedb backend and new API surface. Docs: - README: update storage backend name from redb to pagedb throughout; update `vector_search` call sites to include the `allowed_ids` argument; add `nodedb-array` and `nodedb-physical` to dev-patch example. - `docs/lite-support-matrix.md`: remove reference to internal protocol notes directory. - `SECURITY.md`: minor copy cleanup. Workspace: - `Cargo.toml`: pin all nodedb-* dependency versions to `0.3`. Examples: - `live_sync.rs`, `load_test.rs`: update to new API signatures.
1 parent 9e60ef9 commit 1499bc8

21 files changed

Lines changed: 1870 additions & 1209 deletions

File tree

Cargo.toml

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,20 @@ homepage = "https://nodedb.dev"
1414
[workspace.dependencies]
1515
# Internal
1616
nodedb-lite = { path = "nodedb-lite", version = "0.1.0", default-features = false }
17-
nodedb-types = { version = "*" }
18-
nodedb-client = { version = "*" }
19-
nodedb-codec = { version = "*" }
20-
nodedb-crdt = { version = "*" }
21-
nodedb-query = { version = "*" }
22-
nodedb-spatial = { version = "*" }
23-
nodedb-graph = { version = "*" }
24-
nodedb-vector = { version = "*" }
25-
nodedb-fts = { version = "*" }
26-
nodedb-strict = { version = "*" }
27-
nodedb-columnar = { version = "*" }
28-
nodedb-sql = { version = "*" }
29-
nodedb-array = { version = "*" }
30-
nodedb-physical = { version = "*" }
17+
nodedb-types = { version = "0.3" }
18+
nodedb-client = { version = "0.3" }
19+
nodedb-codec = { version = "0.3" }
20+
nodedb-crdt = { version = "0.3" }
21+
nodedb-query = { version = "0.3" }
22+
nodedb-spatial = { version = "0.3" }
23+
nodedb-graph = { version = "0.3" }
24+
nodedb-vector = { version = "0.3" }
25+
nodedb-fts = { version = "0.3" }
26+
nodedb-strict = { version = "0.3" }
27+
nodedb-columnar = { version = "0.3" }
28+
nodedb-sql = { version = "0.3" }
29+
nodedb-array = { version = "0.3" }
30+
nodedb-physical = { version = "0.3" }
3131

3232
# Async
3333
tokio = { version = "1" }

README.md

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ NodeDB Lite replaces the usual SQLite + vector sidecar + ad hoc cache + custom s
5151

5252
NodeDB Lite is in **public beta** as of **v0.1.0 (2026-05-23)**. All engines listed in [`docs/lite-support-matrix.md`](docs/lite-support-matrix.md) are feature-complete and covered by tests. The public surface — the `NodeDb` trait, the supported SQL plan variants, the C FFI ABI, and the WASM / npm bindings — is stable; clients written against 0.1.0 will keep working through 1.0.
5353

54-
**v0.1.0 — Beta (today).** Use it for embedded workloads and for piloting Lite ↔ Origin sync. The public surface is stable; expect internal changes (redb layout, on-disk index format, sync-protocol internals) between minor releases. Patch and minor bumps will land as needed.
54+
**v0.1.0 — Beta (today).** Use it for embedded workloads and for piloting Lite ↔ Origin sync. The public surface is stable; expect internal changes (pagedb layout, on-disk index format, sync-protocol internals) between minor releases. Patch and minor bumps will land as needed.
5555

5656
**v1.0.0 — Production-ready (target: 2026-07-23).** What 1.0 guarantees:
5757

@@ -85,12 +85,12 @@ Pre-1.0 versions may change internals between releases — that work is critical
8585

8686
| Platform | Crate | Backend | Size |
8787
| ----------------------------------------- | ------------------ | ------------------------- | ------------------------------------------------------------------ |
88-
| Linux | `nodedb-lite` | redb (file-backed) | Native |
89-
| macOS | `nodedb-lite` | redb (file-backed) | Native |
90-
| Windows | `nodedb-lite` | redb (file-backed) | Native |
91-
| Android | `nodedb-lite-ffi` | redb + C FFI + Kotlin/JNI | Native |
92-
| iOS _(in progress — not in 0.1.0)_ | `nodedb-lite-ffi` | redb + C FFI (cbindgen) | Native _(requires macOS build environment — not yet built/tested)_ |
93-
| Browser | `nodedb-lite-wasm` | redb (in-memory + OPFS) | Target: < 10 MB |
88+
| Linux | `nodedb-lite` | pagedb (file-backed) | Native |
89+
| macOS | `nodedb-lite` | pagedb (file-backed) | Native |
90+
| Windows | `nodedb-lite` | pagedb (file-backed) | Native |
91+
| Android | `nodedb-lite-ffi` | pagedb + C FFI + Kotlin/JNI | Native |
92+
| iOS _(in progress — not in 0.1.0)_ | `nodedb-lite-ffi` | pagedb + C FFI (cbindgen) | Native _(requires macOS build environment — not yet built/tested)_ |
93+
| Browser | `nodedb-lite-wasm` | pagedb (in-memory + OPFS) | Target: < 10 MB |
9494

9595
## Packages
9696

@@ -107,11 +107,11 @@ npm install @nodedb/lite
107107
The Rust crate API in `0.1.0`:
108108

109109
```rust
110-
use nodedb_lite::{NodeDbLite, RedbStorage};
110+
use nodedb_lite::{NodeDbLite, PagedbStorageMem};
111111
use nodedb_client::NodeDb;
112112

113113
// Open an in-memory database (peer_id uniquely identifies this device/replica):
114-
let storage = RedbStorage::open_in_memory()?;
114+
let storage = PagedbStorageMem::open_in_memory().await?;
115115
let db = NodeDbLite::open(storage, 1u64).await?;
116116

117117
// Insert a document
@@ -125,7 +125,8 @@ db.document_put("notes", doc).await?;
125125

126126
// Vector search
127127
db.vector_insert("articles", "a1", &embedding, None).await?;
128-
let results = db.vector_search("articles", &embedding, 10, None).await?;
128+
// vector_search(collection, query, k, filter, allowed_ids)
129+
let results = db.vector_search("articles", &embedding, 10, None, None).await?;
129130

130131
// Graph traversal
131132
use nodedb_types::id::NodeId;
@@ -140,7 +141,7 @@ The `NodeDb` trait is identical across Lite and Origin. Application code doesn't
140141
```rust
141142
// Works with both NodeDbLite (in-process) and NodeDbRemote (over network)
142143
async fn search(db: &dyn NodeDb, query: &[f32]) -> Result<Vec<Article>> {
143-
db.vector_search("articles", query, 10).await
144+
db.vector_search("articles", query, 10, None, None).await
144145
}
145146
```
146147

@@ -151,7 +152,7 @@ Moving from embedded to server is a connection string change, not a rewrite.
151152
Every write produces a delta. Deltas sync to Origin over WebSocket when online. Multiple devices converge regardless of operation order.
152153

153154
```
154-
Offline: App writes locally -> Loro generates delta -> delta persisted to redb
155+
Offline: App writes locally -> Loro generates delta -> delta persisted to pagedb
155156
Reconnect: Device opens WebSocket -> sends vector clock + accumulated deltas
156157
Cloud: Origin validates (RLS, UNIQUE, FK) -> merges -> pushes back missed changes
157158
Conflict: Rejected deltas -> dead-letter queue + CompensationHint -> device handles
@@ -233,9 +234,15 @@ nodedb-vector = { path = "../nodedb/nodedb-vector" }
233234
nodedb-fts = { path = "../nodedb/nodedb-fts" }
234235
nodedb-strict = { path = "../nodedb/nodedb-strict" }
235236
nodedb-columnar = { path = "../nodedb/nodedb-columnar" }
237+
nodedb-array = { path = "../nodedb/nodedb-array" }
236238
nodedb-sql = { path = "../nodedb/nodedb-sql" }
239+
nodedb-physical = { path = "../nodedb/nodedb-physical" }
237240
```
238241

239242
## License
240243

241-
Apache-2.0. See [LICENSE](LICENSE) for details.
244+
**Apache-2.0** — see [LICENSE](LICENSE). NodeDB Lite is fully open source, with
245+
**no BSL anywhere in its dependency tree**: it builds only on NodeDB's Apache-2.0
246+
engine and foundation crates. The Business Source License applies _only_ to the
247+
[NodeDB Origin](https://github.com/NodeDB-Lab/nodedb) server — never to Lite.
248+
Embed it anywhere: apps, browsers (WASM/OPFS), mobile, desktop, edge.

SECURITY.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,15 @@
22

33
## Supported versions
44

5-
| Version | Supported |
6-
| ------------ | --------- |
7-
| 0.1.0-beta.x | Yes |
5+
| Version | Supported |
6+
| ------- | --------- |
7+
| 0.1.x | Yes |
88

99
## Reporting a vulnerability
1010

1111
Please **do not** open a public GitHub issue for security vulnerabilities.
1212

13-
Report security issues by email to **security@nodedb.io**.
14-
15-
Decision pending: a permanent security contact address will be confirmed before the stable 0.1.0 release. If you receive no acknowledgement within 72 hours, follow up by opening a GitHub issue marked `[security]` with no vulnerability details included.
13+
Report security issues by email to **security@nodedb.io**. If you receive no acknowledgement within 72 hours, follow up by opening a GitHub issue marked `[security]` with no vulnerability details included.
1614

1715
## Disclosure process
1816

docs/lite-support-matrix.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,8 @@ drive a `NodeDbLite` instance against it.
8888
| Spatial insert / delete sync| `SpatialInsert` (`0xAA`/`0xAB`), `SpatialDelete` (`0xAC`/`0xAD`) | `tests/sync_interop_spatial.rs` |
8989
| Timeseries insert sync | Shares the `ColumnarInsert` (`0xA0`) frame | `tests/sync_interop_timeseries.rs` |
9090

91-
A clean public version of the sync wire contract (wire version,
92-
vector-clock encoding, frame catalogue) will land in `docs/` before 1.0;
93-
the internal protocol notes are maintained in the `resource/` directory.
91+
A documented public version of the sync wire contract (wire version,
92+
vector-clock encoding, frame catalogue) will land in `docs/` before 1.0.
9493

9594
---
9695

nodedb-lite-ffi/include/nodedb_lite.h

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,25 +38,43 @@ typedef struct NodeDbNodeDbHandle NodeDbNodeDbHandle;
3838
* The caller must call `nodedb_close` to free the handle.
3939
*
4040
* # Safety
41-
* `path` must be a valid null-terminated UTF-8 string.
41+
* - `path` must be a valid null-terminated UTF-8 string.
42+
* - `passphrase` must be NULL or a valid null-terminated UTF-8 string.
43+
*
44+
* Encryption convention:
45+
* - `passphrase` is NULL and `path` is `":memory:"` → `Encryption::Plaintext` (volatile data, safe).
46+
* - `passphrase` is NULL and `path` is a real path → returns NULL (silent plaintext persistent
47+
* storage is refused; pass an empty string to opt out explicitly).
48+
* - `passphrase` is `""` (empty string) → `Encryption::Plaintext` (explicit conscious opt-out).
49+
* - `passphrase` is a non-empty string → `Encryption::passphrase(passphrase)`.
50+
* - `passphrase` is non-NULL but invalid UTF-8 → returns NULL.
4251
*/
43-
struct NodeDbNodeDbHandle *nodedb_open(const char *path, uint64_t peer_id);
52+
struct NodeDbNodeDbHandle *nodedb_open(const char *path,
53+
uint64_t peer_id,
54+
const char *passphrase);
4455

4556
/**
4657
* Open or create a NodeDB-Lite database with an explicit memory budget.
4758
*
4859
* # Safety
49-
* `path` must be a valid null-terminated UTF-8 string.
60+
* - `path` must be a valid null-terminated UTF-8 string.
61+
* - `passphrase` must be NULL or a valid null-terminated UTF-8 string.
62+
*
63+
* See `nodedb_open` for the passphrase/encryption convention.
64+
* `memory_mb` of 0 uses the default memory budget.
5065
*/
5166
struct NodeDbNodeDbHandle *nodedb_open_with_config(const char *path,
5267
uint64_t peer_id,
53-
uint64_t memory_mb);
68+
uint64_t memory_mb,
69+
const char *passphrase);
5470

5571
/**
5672
* Close a NodeDB-Lite database and free the handle.
5773
*
5874
* # Safety
59-
* `handle` must be a valid pointer returned by `nodedb_open`, or NULL (no-op).
75+
* `handle` must be a token returned by `nodedb_open`, or NULL/0 (no-op).
76+
* The token is a `u64` id packed into a pointer-width integer; it is never
77+
* dereferenced as a raw pointer.
6078
*/
6179
void nodedb_close(struct NodeDbNodeDbHandle *handle);
6280

@@ -357,7 +375,10 @@ int32_t nodedb_graph_shortest_path(struct NodeDbNodeDbHandle *handle,
357375
* Insert a vector into a collection.
358376
*
359377
* # Safety
360-
* All pointer parameters must be valid. `embedding` must point to `dim` floats.
378+
* All pointer parameters must be valid. `embedding` must be non-null, properly
379+
* aligned for `f32`, and valid for exactly `dim` elements for the entire duration
380+
* of this call. No runtime length validation is possible; passing a mismatched
381+
* `dim` or a dangling pointer is immediate undefined behaviour.
361382
*/
362383
int32_t nodedb_vector_insert(struct NodeDbNodeDbHandle *handle,
363384
const char *collection,
@@ -371,7 +392,10 @@ int32_t nodedb_vector_insert(struct NodeDbNodeDbHandle *handle,
371392
* `*out_json` is only written on success. The caller must free via `nodedb_free_string`.
372393
*
373394
* # Safety
374-
* `query` must point to `dim` valid floats. `out_json` must not be null.
395+
* `query` must be non-null, properly aligned for `f32`, and valid for exactly `dim`
396+
* elements for the entire duration of this call. No runtime length validation is
397+
* possible; passing a mismatched `dim` or a dangling pointer is immediate undefined
398+
* behaviour. `out_json` must not be null.
375399
*/
376400
int32_t nodedb_vector_search(struct NodeDbNodeDbHandle *handle,
377401
const char *collection,

0 commit comments

Comments
 (0)