@hajewski/latticedb 0.15.0 → 0.17.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.
Files changed (41) hide show
  1. package/README.md +287 -26
  2. package/dist/database.d.ts +124 -7
  3. package/dist/database.d.ts.map +1 -1
  4. package/dist/database.js +117 -5
  5. package/dist/database.js.map +1 -1
  6. package/dist/embedding.d.ts +1 -1
  7. package/dist/embedding.js +1 -1
  8. package/dist/ffi/bindings.d.ts +11 -1
  9. package/dist/ffi/bindings.d.ts.map +1 -1
  10. package/dist/ffi/bindings.js +70 -1
  11. package/dist/ffi/bindings.js.map +1 -1
  12. package/dist/ffi/index.d.ts +93 -4
  13. package/dist/ffi/index.d.ts.map +1 -1
  14. package/dist/ffi/index.js +368 -43
  15. package/dist/ffi/index.js.map +1 -1
  16. package/dist/ffi/library.d.ts +59 -4
  17. package/dist/ffi/library.d.ts.map +1 -1
  18. package/dist/ffi/library.js +198 -36
  19. package/dist/ffi/library.js.map +1 -1
  20. package/dist/ffi/types.d.ts +52 -4
  21. package/dist/ffi/types.d.ts.map +1 -1
  22. package/dist/ffi/types.js +46 -0
  23. package/dist/ffi/types.js.map +1 -1
  24. package/dist/index.d.ts +6 -6
  25. package/dist/index.d.ts.map +1 -1
  26. package/dist/index.js +12 -5
  27. package/dist/index.js.map +1 -1
  28. package/dist/transaction.d.ts +18 -3
  29. package/dist/transaction.d.ts.map +1 -1
  30. package/dist/transaction.js +36 -4
  31. package/dist/transaction.js.map +1 -1
  32. package/dist/types.d.ts +29 -1
  33. package/dist/types.d.ts.map +1 -1
  34. package/dist/types.js.map +1 -1
  35. package/lib/darwin-arm64/liblattice.dylib +0 -0
  36. package/lib/darwin-x64/liblattice.dylib +0 -0
  37. package/lib/linux-arm64/liblattice.so +0 -0
  38. package/lib/linux-x64/liblattice.so +0 -0
  39. package/lib/win32-arm64/lattice.dll +0 -0
  40. package/lib/win32-x64/lattice.dll +0 -0
  41. package/package.json +1 -1
package/README.md CHANGED
@@ -8,7 +8,7 @@ TypeScript/Node.js bindings for [LatticeDB](https://github.com/jeffhajewski/latt
8
8
  npm install @hajewski/latticedb
9
9
  ```
10
10
 
11
- Published package tarballs are expected to bundle the native shared library for supported platforms.
11
+ Published package tarballs bundle the native shared library for Linux (x64, arm64), macOS (x64, arm64) and Windows (x64, arm64).
12
12
 
13
13
  If you are working from a source checkout, stage the native library into the package with:
14
14
 
@@ -30,6 +30,10 @@ zig build install --prefix /tmp/lattice-install
30
30
  export LATTICE_PREFIX=/tmp/lattice-install
31
31
  ```
32
32
 
33
+ `LATTICE_PREFIX` is searched under `<prefix>/lib`. On Windows, where `zig build install`
34
+ puts `lattice.dll` in `<prefix>/bin` and only the import library in `<prefix>/lib`,
35
+ `<prefix>/bin` is searched first, then `<prefix>/lib`.
36
+
33
37
  Alternatively, discovery can use `pkg-config`:
34
38
 
35
39
  ```bash
@@ -136,13 +140,60 @@ const db = new Database(path: string, options?: DatabaseOptions);
136
140
  interface DatabaseOptions {
137
141
  create?: boolean; // Create if not exists (default: false)
138
142
  readOnly?: boolean; // Open read-only (default: false)
139
- cacheSizeMb?: number; // Cache size in MB (default: 100)
140
- enableVectors?: boolean; // Preferred vector config flag
143
+ cacheSizeMb?: number; // Cache size in MB; unset: LATTICE_BUFFER_POOL_MB, else 100
144
+ enableWal?: boolean; // log commits so they survive a crash (default: true)
145
+ enableAdjacencyCache?: boolean; // Accepted; no effect on queries (default: false)
146
+ enableVectors?: boolean; // Create a vector index if the file has none
141
147
  enableVector?: boolean; // Deprecated compatibility alias
142
- vectorDimensions?: number; // Vector dimensions (default: 128)
148
+ vectorDimensions?: number; // Vector dimensions (default: 128; 0 = the file's)
149
+ lock?: boolean; // Take a file lock (default: true)
150
+ syncMode?: 'full' | 'normal'; // Unset: LATTICE_SYNC_MODE, else 'full'
151
+ fullFsync?: boolean; // macOS F_FULLFSYNC; unset: LATTICE_FULL_FSYNC, else off
152
+ vectorMetric?: 'cosine' | 'euclidean' | 'dot_product'; // For a new index (default: cosine)
153
+ vectorM?: number; // HNSW connections per node, 2..32 (default: 16)
154
+ vectorEfConstruction?: number; // HNSW build candidate list, 1..4096 (default: 200)
155
+ changefeedRetention?: ChangefeedRetention; // 'all', 'off', 'last:N', 'age:7d' (default: the file's)
143
156
  }
144
157
  ```
145
158
 
159
+ A database file records its vector index: dimensions, metric, `vectorM` and
160
+ `vectorEfConstruction`. A database that has an index opens with it whether or
161
+ not `enableVectors` is set, so reopening needs no vector options at all. Any
162
+ vector option you do pass (and `vectorDimensions` when `enableVectors` is set)
163
+ must match the file, or `open()` throws a `LatticeError` with code -18
164
+ (`ConfigMismatch`). The metric decides search distances, smallest first: cosine
165
+ distance (vectors stored at unit length), L2 distance, or the negative dot
166
+ product (vectors stored as given).
167
+
168
+ `syncMode: 'normal'` returns from a commit once the operating system has it: the
169
+ commit survives the process being killed, but a power cut or OS crash can lose
170
+ the most recent commits. The default, `'full'`, syncs the log on every commit.
171
+
172
+ A `syncMode` or `fullFsync` you pass wins over the `LATTICE_SYNC_MODE` and
173
+ `LATTICE_FULL_FSYNC` environment variables, which apply only when the option is
174
+ left unset.
175
+
176
+ `enableWal: false` logs nothing. Transactions, rollback, streams and the
177
+ changefeed work as with the log, but a commit reaches the file at the next
178
+ flush (`close()`, or when half the page cache holds changes) rather than when it
179
+ returns.
180
+
181
+ `changefeedRetention` sets how much of the changefeed the file keeps (see
182
+ [Durable Streams and Changefeeds](#durable-streams-and-changefeeds)).
183
+
184
+ `syncMode`, `fullFsync`, the three vector index options and
185
+ `changefeedRetention` need a native library with `lattice_open_v5`; against an
186
+ older one, setting any of them throws with code -14 (`Unsupported`). `deserialize()` takes the same options and passes
187
+ them through `lattice_deserialize_v5`, which needs the same newer library.
188
+
189
+ `readOnly: true` on a database that was not closed cleanly recovers it in
190
+ memory: the handle sees every committed transaction and nothing is written to
191
+ the files. A recovery that needs more than 64 MB plus four times the size of the
192
+ log and journal throws with code -10 (`Full`); open the database read-write once
193
+ to recover it on disk.
194
+
195
+ Node IDs, edge IDs and stream sequence numbers are `bigint`.
196
+
146
197
  #### Methods
147
198
 
148
199
  - `await db.open()` - Open the database connection
@@ -150,18 +201,33 @@ interface DatabaseOptions {
150
201
  - `await db.read(fn)` - Execute a read-only transaction
151
202
  - `await db.write(fn)` - Execute a read-write transaction
152
203
  - `await db.query(cypher, params?)` - Execute a Cypher query
204
+ - `await db.getNodesByLabel(label)` - IDs of every node with a label
153
205
  - `await db.vectorSearch(vector, options?)` - k-NN vector search
154
- - `await db.ftsSearch(query, options?)` - Full-text search
155
- - `await db.ftsSearchFuzzy(query, options?)` - Fuzzy full-text search
156
- - `await db.createNodePropertyIndex(label, property)` / `dropNodePropertyIndex(...)` - Manage explicit node equality indexes
157
- - `await db.createEdgePropertyIndex(edgeType, property)` / `dropEdgePropertyIndex(...)` - Manage explicit edge equality indexes
158
- - `await db.readStream(stream, options?)` - Read durable stream records by cursor
206
+ - `await db.createNodeFtsIndex(label, property)` / `dropNodeFtsIndex(...)` / `hasNodeFtsIndex(...)` - Manage full-text indexes on node properties
207
+ - `await db.createEdgeFtsIndex(edgeType, property)` / `dropEdgeFtsIndex(...)` / `hasEdgeFtsIndex(...)` - Manage full-text indexes on edge properties. A node index and a relationship index cannot share a name and property: the second is rejected as already existing
208
+ - `await db.ftsSearch(label, property, query, options?)` - Full-text search over one declared index
209
+ - `await db.ftsSearchFuzzy(label, property, query, options?)` - Fuzzy full-text search
210
+ - `await db.createNodePropertyIndex(label, property)` / `dropNodePropertyIndex(...)` - Manage explicit node property indexes
211
+ - `await db.createEdgePropertyIndex(edgeType, property)` / `dropEdgePropertyIndex(...)` - Manage explicit edge property indexes
212
+ - `await db.readStream(stream, options?)` - Read durable stream records by cursor. With `timeoutMs > 0` the wait runs on a worker thread, so the event loop keeps running and a commit from the same process can end the wait
159
213
  - `await db.getStreamOffset(stream, consumer)` - Read a committed consumer offset
160
- - `await db.changes(options?)` - Read the built-in graph changefeed
214
+ - `await db.changes(options?)` - Read the built-in graph changefeed. Rejects with `LatticeChangesTrimmedError` when retention has dropped the events after `afterSequence`, and with code -14 (`Unsupported`) when the policy is `'off'`
215
+ - `await db.changefeedStatus()` - The changefeed's policy and range: `{ retention, oldestSequence, lastSequence }`, `oldestSequence` null when it holds no events
216
+ - `await db.trimChangefeed()` - Apply the retention policy in full now; resolves to the number of events dropped
217
+ - `await db.checkpoint(mode = 'truncate')` - Fold the log into the database file now; resolves to `CheckpointStats` (see [Checkpoints](#checkpoints))
218
+ - `await db.setAutoCheckpoint(maxWalFrames, minIntervalMs = 0)` - Set when commits checkpoint from now on; `0` frames switches automatic checkpoints off
161
219
  - `await db.cacheClear()` - Clear the query cache
162
220
  - `await db.cacheStats()` - Get cache hit/miss statistics
163
221
  - `db.isOpen()` - Check if database is open
164
222
  - `db.getPath()` - Get database file path
223
+ - `db.serialize()` - Return the whole database as a `Uint8Array`
224
+
225
+ `deserialize(bytes, options?, copy = true)` opens a database from bytes produced by `serialize()`.
226
+ Its options mean what they mean to `new Database()`, apart from `create` and
227
+ `readOnly`, which it ignores. Bytes that hold a vector index open with the
228
+ configuration they record, and any vector option you pass must match it (code
229
+ -18, `ConfigMismatch`); `enableVectors` with the vector options creates and
230
+ configures an index in bytes that have none.
165
231
 
166
232
  ### Transaction
167
233
 
@@ -169,9 +235,13 @@ interface DatabaseOptions {
169
235
 
170
236
  - `await txn.getNode(nodeId)` - Get a node by ID, returns `Node` or `null`
171
237
  - `await txn.nodeExists(nodeId)` - Check if a node exists
172
- - `await txn.getProperty(nodeId, key)` - Get a property value
238
+ - `await txn.getProperty(nodeId, key)` - Get a property value, or `null` when the node does not have it
173
239
  - `await txn.getOutgoingEdges(nodeId)` - Get outgoing edges from a node
174
240
  - `await txn.getIncomingEdges(nodeId)` - Get incoming edges to a node
241
+ - `await txn.getOutgoingEdgesByType(nodeId, edgeType, ...)` / `getIncomingEdgesByType(...)` - Edges of one type
242
+ - `await txn.getNodesByLabel(label)` - IDs of every node with a label, as this transaction sees them
243
+ - `await txn.query(cypher, params?)` - Run Cypher inside this transaction
244
+ - `await txn.vectorSearch(...)` / `ftsSearch(...)` / `ftsSearchFuzzy(...)` - Searches inside this transaction
175
245
  - `await txn.findNodesByLabelProperty(label, property, value, limit?)` - Indexed node equality lookup
176
246
  - `await txn.findEdgesByTypeProperty(edgeType, property, value, limit?)` - Indexed edge equality lookup
177
247
  - `txn.isReadOnly()` / `txn.isActive()` - Transaction state
@@ -179,21 +249,21 @@ interface DatabaseOptions {
179
249
  #### Write Operations
180
250
 
181
251
  - `await txn.createNode({ labels, properties })` - Create a node
182
- - `await txn.deleteNode(nodeId)` - Delete a node
183
- - `await txn.setProperty(nodeId, key, value)` - Set a property
184
- - `await txn.setVector(nodeId, key, vector)` - Set a vector embedding
252
+ - `await txn.deleteNode(nodeId, { detach })` - Delete a node. A node that still has relationships is refused with code -17 (`HasRelationships`) and nothing is deleted, as Cypher's `DELETE` does; `{ detach: true }` deletes its relationships with it, as `DETACH DELETE` does. Deleting a node that does not exist does nothing.
253
+ - `await txn.setProperty(nodeId, key, value)` - Set a property. If a full-text index is declared for one of the node's labels and this property, the index is kept current.
254
+ - `await txn.setVector(nodeId, key, vector)` - Set the node's vector embedding. A node has one vector, which Cypher reads as `n.embedding`; `key` must be `"embedding"` (or `""`), and any other key is rejected with an unsupported-operation error. A vector with NaN or infinite components is rejected as an invalid argument.
185
255
  - `await txn.batchInsertVectors(label, vectors)` - Insert vector-bearing nodes in one call
186
256
  - `await txn.batchInsert(label, vectors)` - Deprecated compatibility alias for `batchInsertVectors`
187
- - `await db.createNodeFtsIndex(label, property)` - Declare a full-text index; writing that property keeps it current
188
257
  - `await txn.createEdge(sourceId, targetId, edgeType, options?)` - Create an edge
189
258
  - `await txn.deleteEdge(sourceId, targetId, edgeType)` - Delete an edge
190
259
  - `await txn.setEdgeProperty(edgeId, key, value)` - Set an edge property by stable edge ID
191
260
  - `await txn.getEdgeProperty(edgeId, key)` - Get an edge property by stable edge ID
192
261
  - `await txn.removeEdgeProperty(edgeId, key)` - Remove an edge property by stable edge ID
193
262
  - `txn.publishStream(stream, payload, kind?)` - Publish a durable stream record
263
+ - `txn.publishStreamGetSequence(stream, payload, kind?)` - Publish and return the record's sequence (`bigint`)
194
264
  - `txn.setStreamOffset(stream, consumer, sequence)` - Commit a durable consumer offset
195
265
  - `txn.trimStream(stream, throughSequence)` - Delete stream records through a sequence
196
- - `txn.commit()` / `txn.rollback()` - Commit or rollback
266
+ - `txn.commit()` / `txn.rollback()` - Commit or rollback. A commit that throws with code -7 (`TxnAborted`) has ended the transaction, and `rollback()` afterwards does nothing; after any other failure it stays open for `rollback()`
197
267
 
198
268
  ### Bulk Vector Insertion
199
269
 
@@ -222,9 +292,10 @@ await db.close();
222
292
 
223
293
  ### Property Indexes
224
294
 
225
- Property equality indexes are explicit and durable. Create them outside an
226
- active write transaction; lookup fails instead of silently scanning when the
227
- requested index does not exist.
295
+ Property indexes are explicit and durable. Create them outside an active write
296
+ transaction; lookup fails instead of silently scanning when the requested index
297
+ does not exist. The lookup methods find equal values; Cypher also reads the
298
+ indexes for ranges, `STARTS WITH` and `ORDER BY ... LIMIT`.
228
299
 
229
300
  ```typescript
230
301
  await db.createNodePropertyIndex("Person", "email");
@@ -287,16 +358,16 @@ Connect to Ollama, OpenAI, or compatible APIs:
287
358
  ```typescript
288
359
  import { EmbeddingClient, EmbeddingApiFormat } from "@hajewski/latticedb/embedding";
289
360
 
290
- // Ollama (default)
361
+ // Ollama (default). The endpoint is the full URL the client POSTs to.
291
362
  const client = new EmbeddingClient({
292
- endpoint: "http://localhost:11434",
363
+ endpoint: "http://localhost:11434/api/embeddings",
293
364
  });
294
365
  const vec = client.embed("hello world");
295
366
  client.close();
296
367
 
297
368
  // OpenAI-compatible API
298
369
  const openaiClient = new EmbeddingClient({
299
- endpoint: "https://api.openai.com/v1",
370
+ endpoint: "https://api.openai.com/v1/embeddings",
300
371
  model: "text-embedding-3-small",
301
372
  apiFormat: EmbeddingApiFormat.OpenAI,
302
373
  apiKey: "sk-...",
@@ -363,6 +434,43 @@ console.log(
363
434
  await db.cacheClear();
364
435
  ```
365
436
 
437
+ ### Checkpoints
438
+
439
+ A commit is durable once it is in the log (the `-wal` file beside the database).
440
+ A checkpoint writes the pages the log's commits changed into the database file
441
+ and can then empty the log. By default a commit runs one once the log holds 1000
442
+ frames (one frame per page, 4096 bytes); the `LATTICE_AUTO_CHECKPOINT_FRAMES`
443
+ environment variable sets another default (`0` for none), and
444
+ `setAutoCheckpoint` wins over it. Closing a database always folds the log into
445
+ the file.
446
+
447
+ ```typescript
448
+ import type { CheckpointStats } from '@hajewski/latticedb';
449
+
450
+ await db.setAutoCheckpoint(0); // commits never checkpoint; the log grows
451
+ // ... a burst of commits ...
452
+ const stats: CheckpointStats = await db.checkpoint('truncate');
453
+ console.log(stats.pagesFlushed, stats.durationNs, stats.checkpointLsn, stats.walTruncated);
454
+
455
+ await db.setAutoCheckpoint(4000, 1000); // every 4000 frames, at most once a second
456
+ ```
457
+
458
+ Modes (`CheckpointMode`): `'passive'` writes the changed pages unless one is in
459
+ use (then it writes nothing and reports 0 pages) and leaves the log in place;
460
+ `'full'` writes every changed page and leaves the log in place; `'truncate'` (the
461
+ default) does what `'full'` does and then empties the log, the only mode that
462
+ bounds its size. Any other mode throws a `TypeError`, and a negative or
463
+ fractional argument to `setAutoCheckpoint` a `RangeError`. `durationNs` and
464
+ `checkpointLsn` are `bigint`. `checkpoint` rejects with code -9 (`ReadOnly`) on a
465
+ read-only database and -8 (`LockTimeout`) if a transaction already has records
466
+ in the log; `setAutoCheckpoint` has no effect on a read-only database. Against a
467
+ native library without `lattice_checkpoint`, both reject with code -14
468
+ (`Unsupported`).
469
+
470
+ The interval is a trade-off. A larger one means fewer checkpoints, each a longer
471
+ pause for the commit that runs it, a longer `-wal` file and more to replay after
472
+ a crash. A smaller one means shorter pauses, more often.
473
+
366
474
  ### Durable Streams and Changefeeds
367
475
 
368
476
  Streams are durable named event logs stored inside the database file. Records are
@@ -394,16 +502,26 @@ await db.write(async (txn) => {
394
502
  graph events such as `node.insert`, `node.property_set`, `edge.delete`, and
395
503
  `edge.property_remove`, with payloads represented as normal TypeScript values.
396
504
 
505
+ A transaction's events describe its net effect (a property set several times
506
+ is one event, from its value before the transaction to its last value) and
507
+ come in an order that can be replayed as it comes: the edges it deletes, then
508
+ the nodes that exist after it, then the edges that exist after it, then the
509
+ nodes it deletes, each group by ascending id. So an edge is created after both
510
+ its nodes and deleted before either. See the
511
+ [changefeed guide](https://docs.latticedb.org/guides/changefeed) for the details
512
+ and for retention policies.
513
+
397
514
  ## Supported Property Types
398
515
 
399
516
  - `null` - Null value
400
517
  - `boolean` - Boolean
401
518
  - `number` - Integer or float
519
+ - `bigint` - 64-bit integer
402
520
  - `string` - UTF-8 string
403
521
  - `Uint8Array` - Binary data
404
522
  - `Float32Array` - Vector embeddings
405
-
406
- Nested arrays/objects are not currently exposed by the public bindings/C API.
523
+ - Arrays of any of these values, nested to any depth
524
+ - Plain objects with string keys, whose values are any of these, nested to any depth
407
525
 
408
526
  ## Error Handling
409
527
 
@@ -426,6 +544,148 @@ try {
426
544
  }
427
545
  ```
428
546
 
547
+ Errors from the native library are `LatticeError`s whose `code` is the C error
548
+ code; `LatticeErrorCode` (exported from the package root, with `QueryErrorStage`
549
+ for `LatticeQueryError.stage`; both are plain enums, readable at run time) names
550
+ them. For example -4 (not found, also from `createEdge` when either end does not
551
+ exist), -16 (another process holds the file), -17 (a plain `deleteNode` of a node
552
+ with relationships), -18 (open options that contradict the file's vector
553
+ index), -19 (`NeedsNewerWriter`: a writable open of a file that a newer
554
+ release has marked as not writable by this one; it still opens with
555
+ `readOnly: true`) and -11 (`VersionMismatch`: a file in a format too new for
556
+ this release to read at all, read-only or not).
557
+
558
+ A failed Cypher query throws a `LatticeQueryError`, a `LatticeError` that also
559
+ says where the query failed:
560
+
561
+ ```typescript
562
+ import { Database, LatticeQueryError } from "@hajewski/latticedb";
563
+
564
+ try {
565
+ await db.query("RETURN 1/0");
566
+ } catch (e) {
567
+ if (e instanceof LatticeQueryError) {
568
+ console.log(e.message); // Division by zero: 1 / 0
569
+ console.log(e.code); // -1
570
+ console.log(e.stage); // 4 (execution)
571
+ console.log(e.diagnosticCode); // DivisionByZero
572
+ console.log(e.location); // { line: 1, column: 9, length: 1 }
573
+ }
574
+ }
575
+ ```
576
+
577
+ `stage` is a `QueryErrorStage`: 1 parse, 2 semantic, 3 plan, 4 execution. Parse
578
+ and semantic failures have code -6 and execution failures -1, except that a
579
+ `DELETE` of a node with relationships has code -17 and a relationship created
580
+ to a node deleted earlier in the query -4, as `deleteNode` and `createEdge`
581
+ report them. A storage failure under a query has code -2 and an allocation
582
+ failure -13.
583
+
584
+ ## Electron
585
+
586
+ These bindings run in Electron's **main process** (or a utility process). They
587
+ call into `liblattice` through koffi, which requires Node integration, so a
588
+ sandboxed renderer cannot open a database — expose the database over IPC instead.
589
+
590
+ koffi ships prebuilt binaries, so `electron-rebuild` is not needed.
591
+
592
+ ### Unpack the native library from asar
593
+
594
+ `liblattice.{dylib,so,dll}` is a plain shared library, not a `.node` addon, so
595
+ Electron packagers do **not** unpack it automatically. Left inside `app.asar` it
596
+ is invisible to `dlopen()` / `LoadLibraryW()` even though `fs.existsSync()`
597
+ reports it as present. Unpack it:
598
+
599
+ electron-builder:
600
+
601
+ ```json
602
+ {
603
+ "build": {
604
+ "asarUnpack": ["**/node_modules/@hajewski/latticedb/lib/**"]
605
+ }
606
+ }
607
+ ```
608
+
609
+ `@electron/packager` (Electron Forge):
610
+
611
+ ```js
612
+ module.exports = {
613
+ packagerConfig: {
614
+ asar: { unpack: "**/node_modules/@hajewski/latticedb/lib/**" },
615
+ },
616
+ };
617
+ ```
618
+
619
+ Nothing else is required at runtime: the loader rewrites any `app.asar` path to
620
+ its `app.asar.unpacked` twin. The same glob is exported as
621
+ `ELECTRON_ASAR_UNPACK_GLOB` for packager configs generated from code.
622
+
623
+ ### Bundlers
624
+
625
+ Electron Forge's Webpack and Vite templates rewrite `__dirname`, which breaks the
626
+ lookup of the library bundled beside the module. Either mark the package external
627
+ so it is required from `node_modules` at runtime (webpack `externals`, Vite
628
+ `build.rollupOptions.external`), or ship the library through `extraResources` and
629
+ let the loader find it under `process.resourcesPath`:
630
+
631
+ ```json
632
+ {
633
+ "build": {
634
+ "extraResources": [
635
+ { "from": "node_modules/@hajewski/latticedb/lib/darwin-arm64", "to": "lib" }
636
+ ]
637
+ }
638
+ }
639
+ ```
640
+
641
+ Pick the source directory for the platform you are building. The published package
642
+ uses `lib/linux-x64` and `lib/linux-arm64` for Linux (glibc builds only); a package
643
+ staged locally with `npm run bundle:native` may carry a libc suffix instead
644
+ (`linux-x64-gnu`). The loader also accepts
645
+ `resources/lib/<platform>-<arch>/`, `resources/<platform>-<arch>/`, and the
646
+ library sitting next to the executable (electron-builder `extraFiles`).
647
+
648
+ `LATTICE_LIB_PATH` remains the explicit escape hatch — set it before the first
649
+ `db.open()` if the library lives somewhere else entirely.
650
+
651
+ ### Diagnosing packaging problems
652
+
653
+ ```typescript
654
+ import { isElectronRuntime, resolveLibraryPath } from "@hajewski/latticedb";
655
+
656
+ console.log(isElectronRuntime(), resolveLibraryPath());
657
+ ```
658
+
659
+ `resolveLibraryPath()` runs the full search without loading anything and returns
660
+ the path the loader would use, or `null`. When the library exists only inside a
661
+ packed archive, opening a database fails with an error naming the archived path
662
+ and the `asarUnpack` glob to add.
663
+
664
+ ### Windows
665
+
666
+ Windows x64 is built and tested in CI; Windows ARM64 is built but not run.
667
+ Published package tarballs bundle `lib/win32-x64/lattice.dll` and `lib/win32-arm64/lattice.dll`,
668
+ and koffi ships matching prebuilt `win32_x64` and `win32_arm64` binaries, so
669
+ nothing has to be compiled at install time.
670
+
671
+ Standalone release archives for Windows are `.zip` rather than `.tar.gz`, if you
672
+ would rather take `lattice.dll` from a release and ship it through
673
+ `extraResources`.
674
+
675
+ Building the library from a source checkout:
676
+
677
+ ```bash
678
+ # From the package directory; picks the target for the host architecture
679
+ npm run bundle:native
680
+
681
+ # Or cross-compile one explicitly from the repository root
682
+ zig build shared -Dtarget=aarch64-windows-gnu -Doptimize=ReleaseFast
683
+ ```
684
+
685
+ Note that `zig build shared` installs `lattice.dll` into `zig-out/bin` and leaves
686
+ only the import library `lattice.lib` in `zig-out/lib`. `bundle:native` and the
687
+ runtime loader both account for this; hand-written copy steps usually do not.
688
+
429
689
  ## Building from Source
430
690
 
431
691
  Requires Node.js 18+ and the LatticeDB native library.
@@ -445,8 +705,9 @@ npm test
445
705
 
446
706
  ## Requirements
447
707
 
448
- - Node.js 18+
449
- - The native LatticeDB library (`liblattice.dylib` / `liblattice.so`)
708
+ - Node.js 18+, or Electron's main process (see [Electron](#electron); the loader's asar handling is tested without running Electron, and no Electron version is tested)
709
+ - The native LatticeDB library (`liblattice.dylib` / `liblattice.so` /
710
+ `lattice.dll`)
450
711
 
451
712
  ## License
452
713
 
@@ -2,7 +2,8 @@
2
2
  * Database class for Lattice TypeScript bindings.
3
3
  */
4
4
  import { Transaction } from './transaction';
5
- import { QueryResult, VectorSearchResult, PropertyValue, VectorSearchOptions, FtsSearchOptions, StreamRecord } from './types';
5
+ import { QueryResult, VectorSearchResult, PropertyValue, VectorSearchOptions, FtsSearchOptions, StreamRecord, CheckpointStats } from './types';
6
+ import { SyncMode, VectorMetric, ChangefeedRetention, ChangefeedStatus, CheckpointMode } from './ffi';
6
7
  /**
7
8
  * Options for opening a database.
8
9
  */
@@ -11,17 +12,29 @@ export interface DatabaseOptions {
11
12
  create?: boolean;
12
13
  /** Open in read-only mode */
13
14
  readOnly?: boolean;
14
- /** Cache size in megabytes */
15
+ /**
16
+ * Cache size in megabytes. Unset, the LATTICE_BUFFER_POOL_MB environment
17
+ * variable decides if it is set, else 100; a size given here wins over it.
18
+ */
15
19
  cacheSizeMb?: number;
16
- /** Enable WAL-backed transactions (default: true) */
20
+ /** Log every commit so it survives a crash (default: true). Transactions work either way. */
17
21
  enableWal?: boolean;
18
- /** Enable in-memory graph adjacency cache */
22
+ /**
23
+ * Accepted for compatibility. Queries and the other methods here read edges
24
+ * from storage either way, so it does not change their speed or results.
25
+ */
19
26
  enableAdjacencyCache?: boolean;
20
- /** Enable vector storage and indexing */
27
+ /**
28
+ * Create a vector index if the database has none. A database that already
29
+ * has one opens with it whatever this says.
30
+ */
21
31
  enableVectors?: boolean;
22
- /** @deprecated Use enableVectors instead. Earliest removal is v0.6.0. */
32
+ /** @deprecated Use enableVectors instead. */
23
33
  enableVector?: boolean;
24
- /** Vector dimensions (default: 128) */
34
+ /**
35
+ * Vector dimensions when enableVectors is set (default: 128). It must match
36
+ * the index the file records, if it has one; 0 takes the file's.
37
+ */
25
38
  vectorDimensions?: number;
26
39
  /**
27
40
  * Take a lock on the file so two processes cannot tread on each other
@@ -31,6 +44,40 @@ export interface DatabaseOptions {
31
44
  * make concurrent access safe.
32
45
  */
33
46
  lock?: boolean;
47
+ /**
48
+ * When a commit waits for the disk. `'full'` syncs the log on every commit,
49
+ * so a commit that has returned survives a power cut. `'normal'` hands the
50
+ * commit to the operating system and returns: it survives the process being
51
+ * killed, but a power cut or OS crash can lose the most recent commits.
52
+ * Unset uses the LATTICE_SYNC_MODE environment variable, else full.
53
+ */
54
+ syncMode?: SyncMode;
55
+ /**
56
+ * On macOS, whether syncs ask the drive to flush its cache (F_FULLFSYNC).
57
+ * No effect elsewhere. Unset uses LATTICE_FULL_FSYNC, else off.
58
+ */
59
+ fullFsync?: boolean;
60
+ /**
61
+ * How a new vector index measures distance: `'cosine'` (1 - cos, vectors
62
+ * stored at unit length), `'euclidean'` (L2 distance) or `'dot_product'`
63
+ * (negative dot product). Unset means the file's, or cosine.
64
+ */
65
+ vectorMetric?: VectorMetric;
66
+ /** HNSW connections per node for a new index, 2..32. Unset: the file's, or 16. */
67
+ vectorM?: number;
68
+ /** HNSW build candidate list size for a new index, 1..4096. Unset: the file's, or 200. */
69
+ vectorEfConstruction?: number;
70
+ /**
71
+ * How much of the changefeed (see {@link Database.changes}) to keep:
72
+ * `'all'`, `'off'`, `'last:<events>'` or `'age:<duration>'` such as
73
+ * `'age:7d'`. The file records its policy. Unset keeps the file's, which is
74
+ * `'all'` unless something set another (for a new database, the
75
+ * LATTICE_CHANGEFEED_RETENTION environment variable). A value set here
76
+ * replaces the file's policy when the database is opened for writing; a
77
+ * read-only open never changes it. Retention drops the oldest events at
78
+ * checkpoints; {@link Database.trimChangefeed} applies it at once.
79
+ */
80
+ changefeedRetention?: ChangefeedRetention;
34
81
  }
35
82
  /**
36
83
  * Lattice database connection.
@@ -122,11 +169,29 @@ export declare class Database {
122
169
  timeoutMs?: number;
123
170
  }): Promise<StreamRecord[]>;
124
171
  getStreamOffset(stream: string, consumer: string): Promise<bigint | null>;
172
+ /**
173
+ * Read graph changefeed records from `__lattice_changes`: up to `limit`
174
+ * records with a sequence greater than `afterSequence`, oldest first.
175
+ * `afterSequence: 0n` reads from the oldest event held.
176
+ *
177
+ * Throws {@link LatticeChangesTrimmedError} when retention or a trim has
178
+ * dropped the events after `afterSequence` (the reader has missed changes),
179
+ * and a `LatticeError` with code `Unsupported` when the policy is `'off'`.
180
+ */
125
181
  changes(options?: {
126
182
  afterSequence?: bigint;
127
183
  limit?: number;
128
184
  timeoutMs?: number;
129
185
  }): Promise<StreamRecord[]>;
186
+ /** The changefeed's retention policy and the events it holds. */
187
+ changefeedStatus(): Promise<ChangefeedStatus>;
188
+ /**
189
+ * Apply the changefeed's retention policy in full now (checkpoints apply it
190
+ * a bounded number of events at a time) and make that durable. Returns the
191
+ * number of events dropped. Throws a `LatticeError` with code `LockTimeout`
192
+ * while a write transaction is open.
193
+ */
194
+ trimChangefeed(): Promise<bigint>;
130
195
  /**
131
196
  * Search for similar vectors.
132
197
  *
@@ -197,6 +262,48 @@ export declare class Database {
197
262
  nodeId: bigint;
198
263
  score: number;
199
264
  }>>;
265
+ /**
266
+ * Fold the log (the -wal file) into the database file now.
267
+ *
268
+ * A commit is durable once it is in the log; a checkpoint writes the pages
269
+ * the log's commits changed into the database file and can then empty the
270
+ * log. `'passive'` writes the changed pages unless one is in use, in which
271
+ * case it writes nothing and reports 0 pages, and leaves the log in place.
272
+ * `'full'` writes every changed page and leaves the log in place.
273
+ * `'truncate'` (the default, and what automatic checkpoints do) does what
274
+ * `'full'` does and then empties the log; it is the only mode that bounds the
275
+ * log's size.
276
+ *
277
+ * @param mode - `'passive'`, `'full'` or `'truncate'`; anything else throws a
278
+ * TypeError before the library is called
279
+ * @returns What the checkpoint did
280
+ * @throws LatticeError with code -9 (`ReadOnly`) on a read-only database,
281
+ * -8 (`LockTimeout`) if a transaction already has records in the log, -2
282
+ * (`IoError`) if writing failed (the log still holds every commit), and -14
283
+ * (`Unsupported`) if the native library has no `lattice_checkpoint`
284
+ */
285
+ checkpoint(mode?: CheckpointMode): Promise<CheckpointStats>;
286
+ /**
287
+ * Set when commits checkpoint from now on.
288
+ *
289
+ * A commit runs a `'truncate'` checkpoint once the log holds `maxWalFrames`
290
+ * frames (one frame is one page, usually 4096 bytes), and no sooner than
291
+ * `minIntervalMs` after the last automatic one. `maxWalFrames = 0` switches
292
+ * automatic checkpoints off: the log grows until {@link Database.checkpoint}
293
+ * runs, though closing still folds it into the file. Without this call the
294
+ * default is 1000 frames, or the LATTICE_AUTO_CHECKPOINT_FRAMES environment
295
+ * variable (0 for none); this call wins over the variable. It has no effect on
296
+ * a read-only database.
297
+ *
298
+ * A larger interval means fewer checkpoints, each a longer pause for the
299
+ * commit that runs it, a longer log on disk and more to replay after a crash.
300
+ * A smaller one means shorter pauses, more often.
301
+ *
302
+ * @throws RangeError if either argument is not a non-negative safe integer;
303
+ * LatticeError with code -14 (`Unsupported`) if the native library has no
304
+ * `lattice_set_auto_checkpoint`
305
+ */
306
+ setAutoCheckpoint(maxWalFrames: number, minIntervalMs?: number): Promise<void>;
200
307
  /**
201
308
  * Clear the query cache.
202
309
  *
@@ -239,6 +346,16 @@ export declare class Database {
239
346
  * await s3.send(new PutObjectCommand({ Bucket, Key, Body: db.serialize(), IfMatch: etag }));
240
347
  * ```
241
348
  *
349
+ * The options mean what they mean to {@link Database}, apart from `create` and
350
+ * `readOnly`, which are ignored. Bytes that hold a vector index open with the
351
+ * configuration they record, and any vector option that is set must match it
352
+ * (code -18, `ConfigMismatch`, otherwise); `enableVectors` creates an index,
353
+ * configured by the vector options, in bytes that have none. `syncMode`,
354
+ * `fullFsync`, `vectorMetric`, `vectorM`, `vectorEfConstruction` and
355
+ * `changefeedRetention` (which sets the policy as an open does) need a
356
+ * native library with `lattice_deserialize_v5`; against an older one, setting
357
+ * any of them throws with code -14 (`Unsupported`).
358
+ *
242
359
  * The bytes are copied, so the caller may discard them as soon as this returns.
243
360
  * Changes made afterwards do not travel back to them.
244
361
  *
@@ -1 +1 @@
1
- {"version":3,"file":"database.d.ts","sourceRoot":"","sources":["../src/database.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EACL,WAAW,EACX,kBAAkB,EAClB,aAAa,EACb,mBAAmB,EACnB,gBAAgB,EAChB,YAAY,EACb,MAAM,SAAS,CAAC;AASjB;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,0CAA0C;IAC1C,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,6BAA6B;IAC7B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,8BAA8B;IAC9B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,qDAAqD;IACrD,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,6CAA6C;IAC7C,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,yCAAyC;IACzC,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,yEAAyE;IACzE,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,uCAAuC;IACvC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;;;;;;OAMG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED;;;;;;;;;;;;;;;;;GAiBG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