@nowledge/hawdb-ffi-linux-arm64-gnu 0.0.0-placeholder.0 → 0.33.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/README.md CHANGED
@@ -1,3 +1,7 @@
1
1
  # @nowledge/hawdb-ffi-linux-arm64-gnu
2
2
 
3
- This version only reserves the package name. It contains no library.
3
+ The HawDB 0.33.0 C ABI shared library (`libhawdb_ffi.so`) and its
4
+ header for `aarch64-unknown-linux-gnu`. Install `@nowledge/hawdb-bun` instead of
5
+ depending on this package directly; it selects the matching platform package.
6
+
7
+ See https://github.com/nowledge-co/hawdb/blob/main/docs/PREBUILT_LIBRARIES.md.
package/hawdb_ffi.h ADDED
@@ -0,0 +1,897 @@
1
+ /*
2
+ * Copyright 2026 Nowledge
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ /* Generated by cbindgen. Do not edit by hand. */
18
+
19
+
20
+ #pragma once
21
+
22
+ #include <stdarg.h>
23
+ #include <stdbool.h>
24
+ #include <stdint.h>
25
+ #include <stdlib.h>
26
+
27
+ #define HAWDB_RETAINED_ABI_V1 1
28
+
29
+ #define HAWDB_RETAINED_OK 0
30
+
31
+ #define HAWDB_RETAINED_EOF 1
32
+
33
+ #define HAWDB_RETAINED_BACKPRESSURE 2
34
+
35
+ #define HAWDB_RETAINED_INVALID_HANDLE 3
36
+
37
+ #define HAWDB_RETAINED_INVALID_ARGUMENT 4
38
+
39
+ #define HAWDB_RETAINED_PANIC 5
40
+
41
+ #define HAWDB_RETAINED_CLOSED 6
42
+
43
+ #define HAWDB_RETAINED_WORKING_UNIT_TOO_LARGE 7
44
+
45
+ #define HAWDB_RETAINED_EXECUTION_ERROR 8
46
+
47
+ #define HAWDB_RETAINED_RESULT_BUDGET 9
48
+
49
+ #define HAWDB_RETAINED_UNSUPPORTED_PLAN 10
50
+
51
+ #define HAWDB_RETAINED_UNSUPPORTED_LAYOUT 11
52
+
53
+ #define HAWDB_RETAINED_UNSUPPORTED_TYPE 12
54
+
55
+ #define HAWDB_RETAINED_COPY_REQUIRED 13
56
+
57
+ #define HAWDB_RETAINED_SELECTION_REQUIRES_MATERIALIZATION 14
58
+
59
+ #define HAWDB_RETAINED_INVALID_COLUMN 15
60
+
61
+ #define HAWDB_RETAINED_SIZE_OVERFLOW 16
62
+
63
+ #define HAWDB_RETAINED_STOPPED 17
64
+
65
+ #define HAWDB_RETAINED_ADMISSION_ERROR 18
66
+
67
+ #define HAWDB_RETAINED_INT64 1
68
+
69
+ #define HAWDB_RETAINED_FLOAT64 2
70
+
71
+ #define HAWDB_RETAINED_UINT64 3
72
+
73
+ #define HAWDB_RETAINED_PROPERTY 1
74
+
75
+ #define HAWDB_RETAINED_NODE_IDENTITY 2
76
+
77
+ #define HAWDB_RETAINED_READ_ONLY 1
78
+
79
+ #define HAWDB_RETAINED_BORROWED 2
80
+
81
+ #define HAWDB_RETAINED_REQUIRE_SOURCE_REUSE 1
82
+
83
+ #define HAWDB_RETAINED_REQUEST_WRITABLE 2
84
+
85
+ #define HAWDB_RETAINED_VALIDITY_ALL 1
86
+
87
+ #define HAWDB_RETAINED_VALIDITY_U64_LSB 2
88
+
89
+ #define HAWDB_RETAINED_NODE 1
90
+
91
+ #define HAWDB_RETAINED_NULL 2
92
+
93
+ #define HAWDB_RETAINED_BOOL 3
94
+
95
+ #define HAWDB_RETAINED_NODE_INT64 4
96
+
97
+ #define HAWDB_RETAINED_NODE_FLOAT64 5
98
+
99
+ #define HAWDB_RETAINED_UTF8 6
100
+
101
+ #define HAWDB_RETAINED_BINARY 7
102
+
103
+ #define HAWDB_RETAINED_UUID 8
104
+
105
+ #define HAWDB_RETAINED_LIST 9
106
+
107
+ #define HAWDB_RETAINED_MAP 10
108
+
109
+ #define HAWDB_RETAINED_VECTOR 11
110
+
111
+ /**
112
+ * An open HawDB database handle. Opaque to C callers.
113
+ */
114
+ typedef struct HawdbDatabase HawdbDatabase;
115
+
116
+ #if defined(HAWDB_BOUNDARY_PROFILING)
117
+ typedef struct BoundaryProfileSnapshot {
118
+ uint64_t allocation_calls;
119
+ uint64_t allocated_bytes;
120
+ uint64_t deallocation_calls;
121
+ uint64_t deallocated_bytes;
122
+ uint64_t reallocation_calls;
123
+ uint64_t live_requested_bytes;
124
+ uint64_t process_peak_requested_bytes;
125
+ uint64_t parameter_conversion_ns;
126
+ uint64_t engine_call_ns;
127
+ uint64_t result_conversion_ns;
128
+ } BoundaryProfileSnapshot;
129
+ #endif
130
+
131
+ /**
132
+ * A byte buffer the library hands to the caller.
133
+ *
134
+ * `ptr` is `len` bytes of UTF-8 text; it is NUL-terminated as a courtesy
135
+ * but `len` is authoritative and the content may not contain NUL bytes
136
+ * anyway (JSON escapes them). The caller owns every non-NULL `ptr` and
137
+ * releases it with [`hawdb_buffer_free`]. The library never retains or
138
+ * reuses a buffer it has returned.
139
+ */
140
+ typedef struct HawdbBuffer {
141
+ char *ptr;
142
+ uintptr_t len;
143
+ } HawdbBuffer;
144
+
145
+ /**
146
+ * All lengths are byte lengths. A zero batch/slot limit selects the Rust
147
+ * default. Unknown flags/versions refuse before ownership transfer.
148
+ */
149
+ typedef struct HawdbRetainedQueryV1 {
150
+ uint32_t abi_version;
151
+ uint32_t struct_size;
152
+ const char *cypher;
153
+ uint64_t cypher_len;
154
+ const char *params_json;
155
+ uint64_t params_len;
156
+ uint32_t batch_rows;
157
+ uint32_t outstanding_batches;
158
+ uint64_t batch_bytes;
159
+ uint32_t flags;
160
+ uint32_t reserved;
161
+ } HawdbRetainedQueryV1;
162
+
163
+ typedef struct HawdbRetainedCursorV1 {
164
+ uint32_t abi_version;
165
+ uint32_t struct_size;
166
+ uint64_t owner_namespace;
167
+ uint64_t owner_id;
168
+ uint64_t column_count;
169
+ } HawdbRetainedCursorV1;
170
+
171
+ /**
172
+ * Borrowed immutable range. data addresses the visible range; byte_offset is
173
+ * allocation provenance and must not be applied to data a second time. Keep
174
+ * the owner live and library mapped. A small slice retains its full capacity.
175
+ */
176
+ typedef struct HawdbRetainedBufferV1 {
177
+ uint32_t abi_version;
178
+ uint32_t struct_size;
179
+ const void *data;
180
+ uint64_t allocation_namespace;
181
+ uint64_t allocation_id;
182
+ uint64_t generation;
183
+ uint64_t retained_capacity_bytes;
184
+ uint64_t byte_offset;
185
+ uint64_t byte_length;
186
+ } HawdbRetainedBufferV1;
187
+
188
+ /**
189
+ * Selected indices address the physical rows, without gathering their values.
190
+ * Release owner_id explicitly. EOF never carries a live batch owner.
191
+ */
192
+ typedef struct HawdbRetainedBatchV1 {
193
+ uint32_t abi_version;
194
+ uint32_t struct_size;
195
+ uint64_t owner_namespace;
196
+ uint64_t owner_id;
197
+ uint64_t physical_rows;
198
+ uint64_t selected_rows;
199
+ uint64_t column_count;
200
+ struct HawdbRetainedBufferV1 selection;
201
+ } HawdbRetainedBatchV1;
202
+
203
+ /**
204
+ * Schema names borrow the supplied cursor/batch/column handle. They are UTF-8
205
+ * byte ranges, without a NUL-termination contract.
206
+ */
207
+ typedef struct HawdbRetainedSchemaV1 {
208
+ uint32_t abi_version;
209
+ uint32_t struct_size;
210
+ const char *name;
211
+ uint64_t name_len;
212
+ uint32_t data_type;
213
+ uint32_t role;
214
+ uint32_t nullable;
215
+ uint32_t flags;
216
+ } HawdbRetainedSchemaV1;
217
+
218
+ /**
219
+ * Independently owned read-only column, including its selection and validity.
220
+ * The validity bitmap consists of native u64 words; row r uses bit r % 64.
221
+ * Release this owner even when its parent batch was already released.
222
+ */
223
+ typedef struct HawdbRetainedColumnV1 {
224
+ uint32_t abi_version;
225
+ uint32_t struct_size;
226
+ uint64_t owner_namespace;
227
+ uint64_t owner_id;
228
+ uint64_t physical_rows;
229
+ uint64_t selected_rows;
230
+ struct HawdbRetainedSchemaV1 schema;
231
+ struct HawdbRetainedBufferV1 values;
232
+ struct HawdbRetainedBufferV1 selection;
233
+ struct HawdbRetainedBufferV1 validity;
234
+ uint32_t validity_kind;
235
+ uint32_t flags;
236
+ } HawdbRetainedColumnV1;
237
+
238
+ /**
239
+ * Status is 0 Open, 1 Completed, 2 Failed or 3 Closed. Earlier views remain
240
+ * readable after failure/close; only Completed makes the result final.
241
+ */
242
+ typedef struct HawdbRetainedStateV1 {
243
+ uint32_t abi_version;
244
+ uint32_t struct_size;
245
+ uint32_t status;
246
+ uint32_t terminal_code;
247
+ uint64_t visited_rows;
248
+ uint64_t emitted_rows;
249
+ uint64_t source_constructed_bytes;
250
+ uint64_t source_pinned_rows;
251
+ uint64_t source_pinned_pages;
252
+ } HawdbRetainedStateV1;
253
+
254
+ /**
255
+ * All pointers borrow this independently releasable owner. Scalars are original
256
+ * native-endian storage, not descriptor copies. Names are UTF-8, not NUL-ended.
257
+ * Containers and NULL have no data buffer. These are row views, not Arrow arrays.
258
+ */
259
+ typedef struct HawdbRetainedNodeV1 {
260
+ uint32_t abi_version;
261
+ uint32_t struct_size;
262
+ uint64_t owner_namespace;
263
+ uint64_t owner_id;
264
+ uint32_t kind;
265
+ uint32_t flags;
266
+ uint64_t child_count;
267
+ const void *data;
268
+ uint64_t byte_length;
269
+ const char *name;
270
+ uint64_t name_len;
271
+ } HawdbRetainedNodeV1;
272
+
273
+ #if defined(HAWDB_BOUNDARY_PROFILING)
274
+ /**
275
+ * Developer profiling build only. This observation is not an admission ledger
276
+ * or an allocator-capacity bound. NULL output is a no-op; no buffer is allocated.
277
+ *
278
+ * # Safety
279
+ * `out` must be NULL or point to writable `BoundaryProfileSnapshot` storage.
280
+ */
281
+ void hawdb_boundary_profile_snapshot(struct BoundaryProfileSnapshot *out);
282
+ #endif
283
+
284
+ /**
285
+ * Open a HawDB database at `path`, creating it if needed.
286
+ *
287
+ * `path` is `path_len` UTF-8 bytes and must not be NULL. `options_json`
288
+ * may be NULL or a JSON object. Every key is optional and names the typed
289
+ * Rust configuration field it sets; an absent key keeps the embedded
290
+ * default. Unknown keys and ill-typed values fail with `invalid_argument`.
291
+ *
292
+ * - `"read_only": bool` (default false). A read-only open uses strict
293
+ * recovery and never repairs a torn WAL tail.
294
+ * - `"durability": "sync_on_every_write" | "sync_on_checkpoint"` (default
295
+ * `"sync_on_every_write"`, power-loss safe). `"sync_on_checkpoint"`
296
+ * flushes each committed transaction's WAL to the OS before acknowledging
297
+ * it but synchronizes storage only at checkpoint boundaries, so a power
298
+ * failure may lose recently acknowledged transactions (never part of one).
299
+ * Branch creation, deletion and head publication stay power-loss safe.
300
+ * - `"max_read_result_rows": integer >= 0 | null` (default null). Host-wide
301
+ * read row ceiling; 0 and null mean no row ceiling.
302
+ * - `"max_read_intermediate_rows": integer >= 0 | null` (default null).
303
+ * Host-wide ceiling on the rows one relational SQL statement may scan,
304
+ * join or aggregate, independent of the rows it returns. null inherits
305
+ * `max_read_result_rows`; 0 means no intermediate row ceiling.
306
+ * - `"max_read_result_payload_bytes": integer > 0` (default 67108864).
307
+ * Host-wide read result payload budget; it can be tuned but not removed.
308
+ * - `"relational_monotonic_append_fast_path": bool` (default false). Opt-in
309
+ * metadata-only INSERT path for RowPage tables whose primary keys arrive
310
+ * in increasing order; other inserts fall back to the ordinary path.
311
+ *
312
+ * A read that exceeds a budget fails (`read_budget_exceeded`, or
313
+ * `resource_budget_exceeded` with a `resource_budget` object) rather than
314
+ * returning a partial result. Calls on one handle are serialized, so the
315
+ * handle has no group commit to configure.
316
+ *
317
+ * Returns a handle to pass to the other functions, or NULL on failure
318
+ * with `err_out` filled. Close the handle with [`hawdb_close`].
319
+ *
320
+ * # Safety
321
+ * `path` and `options_json` must be readable for `path_len` /
322
+ * `options_len` bytes or NULL; `err_out` must be NULL or writable
323
+ * [`HawdbBuffer`] storage. The returned handle is safe to use from
324
+ * multiple threads; calls are serialized internally.
325
+ */
326
+ struct HawdbDatabase *hawdb_open(const char *path,
327
+ uintptr_t path_len,
328
+ const char *options_json,
329
+ uintptr_t options_len,
330
+ struct HawdbBuffer *err_out);
331
+
332
+ /**
333
+ * Open an independent in-memory database using the embedded facade defaults.
334
+ * Close the returned handle with [`hawdb_close`]. Errors use the same output
335
+ * convention as [`hawdb_open`]; this does not create a temporary on-disk store.
336
+ *
337
+ * # Safety
338
+ * `err_out` must be NULL or point to writable [`HawdbBuffer`] storage.
339
+ */
340
+ struct HawdbDatabase *hawdb_open_in_memory(struct HawdbBuffer *err_out);
341
+
342
+ /**
343
+ * Close a database handle and release its resources.
344
+ *
345
+ * A transaction still open on the handle (see
346
+ * [`hawdb_begin_transaction`]) is rolled back: none of its statements are
347
+ * committed or visible after a reopen.
348
+ *
349
+ * # Safety
350
+ * `db` must be a handle returned by [`hawdb_open`] and not already
351
+ * closed. Passing NULL is a no-op.
352
+ */
353
+ void hawdb_close(struct HawdbDatabase *db);
354
+
355
+ /**
356
+ * Run one Cypher statement.
357
+ *
358
+ * `cypher` is `cypher_len` UTF-8 bytes and must not be NULL.
359
+ * `params_json` may be NULL or a JSON object mapping `$name` parameter
360
+ * names to values (`null`, bool, number, string, array, object, or the
361
+ * tagged forms `{"$binary": "<base64>"}` and `{"$uuid": "<text>"}`).
362
+ *
363
+ * On success returns true and `result_out` receives the result envelope
364
+ * `{"columns": [...], "rows": [[...], ...]}`; on failure returns false
365
+ * and `err_out` receives `{"kind", "message"}`.
366
+ *
367
+ * # Safety
368
+ * `db` must be a live [`hawdb_open`] handle; `cypher` and `params_json`
369
+ * must be readable for `cypher_len` / `params_len` bytes or NULL;
370
+ * `result_out` and `err_out` must be NULL or writable [`HawdbBuffer`]
371
+ * storage. A false return leaves the handle usable.
372
+ */
373
+ bool hawdb_query(struct HawdbDatabase *db,
374
+ const char *cypher,
375
+ uintptr_t cypher_len,
376
+ const char *params_json,
377
+ uintptr_t params_len,
378
+ struct HawdbBuffer *result_out,
379
+ struct HawdbBuffer *err_out);
380
+
381
+ /**
382
+ * Run one SQL statement.
383
+ *
384
+ * `params_json` may be NULL or a JSON array of positional `$1`
385
+ * parameters with the same value encoding as [`hawdb_query`]. Result
386
+ * and error conventions match [`hawdb_query`].
387
+ *
388
+ * # Safety
389
+ * Same contract as [`hawdb_query`].
390
+ */
391
+ bool hawdb_query_sql(struct HawdbDatabase *db,
392
+ const char *sql,
393
+ uintptr_t sql_len,
394
+ const char *params_json,
395
+ uintptr_t params_len,
396
+ struct HawdbBuffer *result_out,
397
+ struct HawdbBuffer *err_out);
398
+
399
+ /**
400
+ * Free a buffer returned by this library and zero the caller's
401
+ * [`HawdbBuffer`] so a second call is a safe no-op. Passing NULL for
402
+ * `buffer`, or a buffer whose `ptr` is NULL, is a no-op.
403
+ *
404
+ * # Safety
405
+ * `buffer` must be NULL or point to a [`HawdbBuffer`] whose `ptr` was
406
+ * allocated by this library and not already freed.
407
+ */
408
+ void hawdb_buffer_free(struct HawdbBuffer *buffer);
409
+
410
+ /**
411
+ * Copy the HawDB version string into `out`. The buffer is caller-owned
412
+ * like every other [`HawdbBuffer`]: release it with
413
+ * [`hawdb_buffer_free`].
414
+ *
415
+ * # Safety
416
+ * `out` must be NULL or point to writable [`HawdbBuffer`] storage.
417
+ */
418
+ void hawdb_version(struct HawdbBuffer *out);
419
+
420
+ /**
421
+ * The engine-wide persistent format version of this library. Two library
422
+ * builds with the same value open each other's databases. Before replacing
423
+ * the library with one whose value differs, export each database with
424
+ * [`hawdb_export`] using the old library and import it with
425
+ * [`hawdb_import`] using the new one.
426
+ */
427
+ uint32_t hawdb_format_version(void);
428
+
429
+ /**
430
+ * The newest logical dump format version this library writes and reads.
431
+ * [`hawdb_import`] accepts every dump version up to this one.
432
+ */
433
+ uint32_t hawdb_dump_format_version(void);
434
+
435
+ /**
436
+ * Export the handle's current snapshot as a logical dump directory at
437
+ * `dest_path` (`dest_len` UTF-8 bytes), which must not exist; its parent
438
+ * must. The dump is written beside the destination and moved onto it only
439
+ * when complete, with a move that never replaces an existing or
440
+ * concurrently created `dest_path`.
441
+ * The call holds the handle for its duration, so it reflects one consistent
442
+ * snapshot.
443
+ *
444
+ * On success returns true and `report_out` receives
445
+ * `{"dump_format_version", "persistent_format_version", "hawdb_version",
446
+ * "branch", "commit_epoch", "table_count", "table_row_count", "node_count",
447
+ * "relationship_count", "file_count", "total_bytes", "manifest_sha256"}`.
448
+ * On failure returns false and `err_out` receives `{"kind", "message"}`:
449
+ * `semantic` when the database holds a kind of data the dump format cannot
450
+ * represent yet, `transaction_open` while the handle has an open
451
+ * transaction, `invalid_argument` for a NULL or non-UTF-8 argument. Every
452
+ * kind except `publish_outcome_unknown` published nothing at `dest_path`.
453
+ * `publish_outcome_unknown` means the complete dump may already be at
454
+ * `dest_path` but its name is not yet known to be durable: keep it and
455
+ * reconcile with [`hawdb_confirm_dump_publication`] and
456
+ * [`hawdb_verify_dump`].
457
+ *
458
+ * # Safety
459
+ * `db` must be a live [`crate::hawdb_open`] handle or NULL; `dest_path` must
460
+ * be readable for `dest_len` bytes or NULL; `report_out` and `err_out` must
461
+ * be NULL or writable [`HawdbBuffer`] storage.
462
+ */
463
+ bool hawdb_export(struct HawdbDatabase *db,
464
+ const char *dest_path,
465
+ uintptr_t dest_len,
466
+ struct HawdbBuffer *report_out,
467
+ struct HawdbBuffer *err_out);
468
+
469
+ /**
470
+ * Build a new database at `dest_path` from the logical dump at `src_path`.
471
+ * `dest_path` must not exist; its parent must. The database is built in an
472
+ * unpublished directory beside the destination, every file is verified
473
+ * against the dump's SHA-256 and record counts, and the result is renamed
474
+ * onto `dest_path` only on complete success, never replacing an existing or
475
+ * concurrently created `dest_path`: a failed or interrupted import never
476
+ * leaves a database at `dest_path`. Needs no open handle; open the result
477
+ * with [`crate::hawdb_open`].
478
+ *
479
+ * On success returns true and `report_out` receives
480
+ * `{"dump_format_version", "source_hawdb_version",
481
+ * "source_persistent_format_version", "persistent_format_version",
482
+ * "table_count", "table_row_count", "node_count", "relationship_count",
483
+ * "file_count", "total_bytes", "manifest_sha256"}`. A dump written by a
484
+ * newer HawDB fails with `unsupported_storage_format`; a damaged or
485
+ * incomplete dump fails with `storage_integrity`. As for [`hawdb_export`],
486
+ * only `publish_outcome_unknown` may leave the complete database at
487
+ * `dest_path`: keep it, reconcile with [`hawdb_confirm_dump_publication`],
488
+ * then open it.
489
+ *
490
+ * # Safety
491
+ * `src_path` and `dest_path` must be readable for `src_len` / `dest_len`
492
+ * bytes or NULL; `report_out` and `err_out` must be NULL or writable
493
+ * [`HawdbBuffer`] storage.
494
+ */
495
+ bool hawdb_import(const char *src_path,
496
+ uintptr_t src_len,
497
+ const char *dest_path,
498
+ uintptr_t dest_len,
499
+ struct HawdbBuffer *report_out,
500
+ struct HawdbBuffer *err_out);
501
+
502
+ /**
503
+ * Verify the logical dump at `path` (`path_len` UTF-8 bytes) without
504
+ * writing anything: every file must match its manifest length, SHA-256 and
505
+ * record count. On success returns true and `report_out` receives
506
+ * `{"dump_format_version", "source_hawdb_version",
507
+ * "source_persistent_format_version", "branch", "commit_epoch",
508
+ * "table_count", "table_row_count", "node_count", "relationship_count",
509
+ * "file_count", "total_bytes", "manifest_sha256"}`; `manifest_sha256`
510
+ * equals the export report's for the dump that export wrote. A damaged or
511
+ * incomplete dump fails with `storage_integrity`, a newer one with
512
+ * `unsupported_storage_format`.
513
+ *
514
+ * # Safety
515
+ * `path` must be readable for `path_len` bytes or NULL; `report_out` and
516
+ * `err_out` must be NULL or writable [`HawdbBuffer`] storage.
517
+ */
518
+ bool hawdb_verify_dump(const char *path,
519
+ uintptr_t path_len,
520
+ struct HawdbBuffer *report_out,
521
+ struct HawdbBuffer *err_out);
522
+
523
+ /**
524
+ * Reconcile an export or import that failed with `publish_outcome_unknown`:
525
+ * check that `dest_path` is a directory and synchronize it and its parent,
526
+ * so the published name survives a crash once this returns true.
527
+ * Idempotent; it never changes or removes content. It does not judge the
528
+ * content: verify an export with [`hawdb_verify_dump`], open an import. If
529
+ * `dest_path` is missing, the publication did not survive and the call can
530
+ * be run again. On failure returns false and fills `err_out`.
531
+ *
532
+ * # Safety
533
+ * `dest_path` must be readable for `dest_len` bytes or NULL; `err_out` must
534
+ * be NULL or writable [`HawdbBuffer`] storage.
535
+ */
536
+ bool hawdb_confirm_dump_publication(const char *dest_path,
537
+ uintptr_t dest_len,
538
+ struct HawdbBuffer *err_out);
539
+
540
+ /**
541
+ * Write a consistent, self-verifying backup of an open database to
542
+ * `dest_path`, a directory that must not exist yet (its parent must).
543
+ *
544
+ * The database first checkpoints, so the backup holds every transaction
545
+ * committed before the call; the handle stays open and usable. Writes are
546
+ * paused for the duration of the call. Requires a writable persistent
547
+ * handle: a read-only or in-memory handle, an open transaction
548
+ * (`transaction_open`) or an existing destination fail without writing a
549
+ * backup.
550
+ *
551
+ * On success returns true and `report_out` receives
552
+ * `{"generation", "checkpoint_commit_epoch", "file_count", "total_bytes",
553
+ * "manifest_checksum"}` (unsigned 64-bit integers; preserve their
554
+ * precision). On failure returns false and fills `err_out`.
555
+ *
556
+ * # Safety
557
+ * `db` must be a live [`super::hawdb_open`] handle; `dest_path` must be
558
+ * readable for `dest_len` bytes or NULL; `report_out` and `err_out` must be
559
+ * NULL or writable [`HawdbBuffer`] storage.
560
+ */
561
+ bool hawdb_backup(struct HawdbDatabase *db,
562
+ const char *dest_path,
563
+ uintptr_t dest_len,
564
+ struct HawdbBuffer *report_out,
565
+ struct HawdbBuffer *err_out);
566
+
567
+ /**
568
+ * Restore the backup directory at `src_path` into `dest_path`, a new
569
+ * directory that must not exist yet. Every backup file is verified against
570
+ * the backup manifest (length, CRC32C and SHA-256) before anything is
571
+ * written; the result is an ordinary database to open with
572
+ * [`super::hawdb_open`]. No database handle is needed, and the backup is
573
+ * never modified.
574
+ *
575
+ * On success returns true and `report_out` receives
576
+ * `{"generation", "checkpoint_commit_epoch", "file_count", "total_bytes",
577
+ * "manifest_checksum"}`, matching the [`hawdb_backup`] report of the same
578
+ * backup. A damaged or incomplete backup fails without creating
579
+ * `dest_path`.
580
+ *
581
+ * # Safety
582
+ * `src_path` and `dest_path` must be readable for `src_len` / `dest_len`
583
+ * bytes or NULL; `report_out` and `err_out` must be NULL or writable
584
+ * [`HawdbBuffer`] storage.
585
+ */
586
+ bool hawdb_restore(const char *src_path,
587
+ uintptr_t src_len,
588
+ const char *dest_path,
589
+ uintptr_t dest_len,
590
+ struct HawdbBuffer *report_out,
591
+ struct HawdbBuffer *err_out);
592
+
593
+ /**
594
+ * Verify every durable file of the open database's published generation
595
+ * and its WAL against their recorded checksums (CRC32C, and SHA-256 where
596
+ * recorded), streaming without loading the database.
597
+ *
598
+ * On success returns true and `report_out` receives
599
+ * `{"generation", "checked_file_count", "checked_bytes",
600
+ * "sha256_verified_file_count", "wal_record_count", "wal_bytes"}`.
601
+ * Damage fails with the engine's storage error kind and a message naming
602
+ * the mismatch; the handle is then poisoned so that later statements fail
603
+ * until it is closed and the database reopened (or restored from a
604
+ * backup). An in-memory handle or an open transaction (`transaction_open`)
605
+ * fails without scrubbing. Read-only handles can be scrubbed.
606
+ *
607
+ * # Safety
608
+ * `db` must be a live [`super::hawdb_open`] handle; `report_out` and
609
+ * `err_out` must be NULL or writable [`HawdbBuffer`] storage.
610
+ */
611
+ bool hawdb_scrub(struct HawdbDatabase *db,
612
+ struct HawdbBuffer *report_out,
613
+ struct HawdbBuffer *err_out);
614
+
615
+ /**
616
+ * Return the additive experimental retained descriptor ABI version.
617
+ */
618
+ uint32_t hawdb_retained_abi_version(void);
619
+
620
+ /**
621
+ * Create an eligible experimental cursor. There is no copying fallback or JSON
622
+ * result encoding. Parameter JSON remains an input format.
623
+ *
624
+ * # Safety
625
+ * db must remain live for this call. request must be aligned/readable for
626
+ * request_size bytes, with valid pointed-to input ranges. out must be aligned
627
+ * and writable for out_size bytes. Keep the library loaded until final release.
628
+ */
629
+ uint32_t hawdb_retained_query(struct HawdbDatabase *db,
630
+ const struct HawdbRetainedQueryV1 *request,
631
+ uint32_t request_size,
632
+ struct HawdbRetainedCursorV1 *out,
633
+ uint32_t out_size);
634
+
635
+ /**
636
+ * Pull serially with no prefetch. Backpressure precedes source advancement and
637
+ * EOF carries an empty output. Earlier batches remain provisional until EOF.
638
+ *
639
+ * # Safety
640
+ * out must be aligned/writable for out_size bytes. Do not release a handle
641
+ * concurrently with access to its borrowed payload pointers.
642
+ */
643
+ uint32_t hawdb_retained_next(uint64_t owner_namespace,
644
+ uint64_t owner_id,
645
+ struct HawdbRetainedBatchV1 *out,
646
+ uint32_t out_size);
647
+
648
+ /**
649
+ * Return borrowed schema, including before the first pull or after empty EOF.
650
+ *
651
+ * # Safety
652
+ * out must be aligned/writable for out_size bytes. Schema names expire when
653
+ * the supplied owner is released; retain its owner during all reads.
654
+ */
655
+ uint32_t hawdb_retained_schema(uint64_t owner_namespace,
656
+ uint64_t owner_id,
657
+ uint64_t column,
658
+ struct HawdbRetainedSchemaV1 *out,
659
+ uint32_t out_size);
660
+
661
+ /**
662
+ * Create an independent immutable column owner without copying payload.
663
+ *
664
+ * # Safety
665
+ * out must be aligned/writable for out_size bytes. Pointers remain readable
666
+ * until this returned column owner is released, including after parent close.
667
+ */
668
+ uint32_t hawdb_retained_column(uint64_t owner_namespace,
669
+ uint64_t owner_id,
670
+ uint64_t column,
671
+ struct HawdbRetainedColumnV1 *out,
672
+ uint32_t out_size);
673
+
674
+ /**
675
+ * Borrow a column from a batch without allocating or admitting another owner.
676
+ * Its descriptor capacity was prepaid during the pull. This permits consuming
677
+ * a held batch even when no additional independently owned view can be admitted.
678
+ *
679
+ * # Safety
680
+ * out must be aligned/writable for out_size bytes. The supplied batch must
681
+ * remain live throughout every pointer read. A BORROWED descriptor must not be
682
+ * released independently; its owner_id is zero, a non-owning sentinel.
683
+ */
684
+ uint32_t hawdb_retained_column_borrow(uint64_t owner_namespace,
685
+ uint64_t owner_id,
686
+ uint64_t column,
687
+ struct HawdbRetainedColumnV1 *out,
688
+ uint32_t out_size);
689
+
690
+ /**
691
+ * Retain an independent batch owner. Cursor and column handles refuse; columns
692
+ * have their own export function and release lifetime.
693
+ *
694
+ * # Safety
695
+ * out must be aligned/writable for out_size bytes. Do not release its returned
696
+ * owner until all reads through the descriptor have finished.
697
+ */
698
+ uint32_t hawdb_retained_batch_retain(uint64_t owner_namespace,
699
+ uint64_t owner_id,
700
+ struct HawdbRetainedBatchV1 *out,
701
+ uint32_t out_size);
702
+
703
+ /**
704
+ * Retain an independent column owner, preserving all allocation identities and
705
+ * ranges. Admission failure leaves the original column readable.
706
+ *
707
+ * # Safety
708
+ * out must be aligned/writable for out_size bytes. Release this new owner after
709
+ * all reads, independently of the original column's owner.
710
+ */
711
+ uint32_t hawdb_retained_column_retain(uint64_t owner_namespace,
712
+ uint64_t owner_id,
713
+ struct HawdbRetainedColumnV1 *out,
714
+ uint32_t out_size);
715
+
716
+ /**
717
+ * Read current terminal state. A prior descriptor's scalar status must not be
718
+ * treated as final; this function observes late failures through retained views.
719
+ *
720
+ * # Safety
721
+ * out must be aligned/writable for out_size bytes.
722
+ */
723
+ uint32_t hawdb_retained_state(uint64_t owner_namespace,
724
+ uint64_t owner_id,
725
+ struct HawdbRetainedStateV1 *out,
726
+ uint32_t out_size);
727
+
728
+ /**
729
+ * Close a cursor and its source without revoking previously exported payload.
730
+ * Release the closed cursor handle separately. Repeated close is harmless.
731
+ */
732
+ uint32_t hawdb_retained_cursor_close(uint64_t owner_namespace, uint64_t owner_id);
733
+
734
+ /**
735
+ * Release exactly one owner. Stale, foreign-module and unknown handles return
736
+ * InvalidHandle without dereferencing caller-provided addresses.
737
+ */
738
+ uint32_t hawdb_retained_release(uint64_t owner_namespace, uint64_t owner_id);
739
+
740
+ /**
741
+ * Open a strict single-match indexed node cursor. Input parameters use JSON;
742
+ * results never do. All layout refusals are inherited from the native planner.
743
+ *
744
+ * # Safety
745
+ * db/request must be valid for this call. out must be aligned and writable for
746
+ * out_size bytes. The library mapping must outlive every returned owner.
747
+ */
748
+ uint32_t hawdb_retained_node_query(struct HawdbDatabase *db,
749
+ const struct HawdbRetainedQueryV1 *request,
750
+ uint32_t request_size,
751
+ struct HawdbRetainedCursorV1 *out,
752
+ uint32_t out_size);
753
+
754
+ /**
755
+ * Pull one independently owned node. EOF completes provisional values. A failed
756
+ * registration aborts delivery rather than allowing a later successful EOF.
757
+ *
758
+ * # Safety
759
+ * out must be aligned/writable for out_size bytes. Returned pointers remain
760
+ * readable until their owner is released; synchronize release with all reads.
761
+ */
762
+ uint32_t hawdb_retained_node_next(uint64_t owner_namespace,
763
+ uint64_t owner_id,
764
+ struct HawdbRetainedNodeV1 *out,
765
+ uint32_t out_size);
766
+
767
+ /**
768
+ * Create an independent child owner. Node ordering is _id, labels, then native
769
+ * sorted properties. Lists use index order; maps use native sorted key order.
770
+ *
771
+ * # Safety
772
+ * out must be aligned/writable for out_size bytes. Synchronize pointer reads
773
+ * with release. A child survives release of all its ancestors and database.
774
+ */
775
+ uint32_t hawdb_retained_node_child(uint64_t owner_namespace,
776
+ uint64_t owner_id,
777
+ uint64_t index,
778
+ struct HawdbRetainedNodeV1 *out,
779
+ uint32_t out_size);
780
+
781
+ /**
782
+ * Look up a node/map field without cloning its key or payload. Missing fields
783
+ * return InvalidColumn and an empty output; other payload kinds refuse.
784
+ *
785
+ * # Safety
786
+ * name must be readable UTF-8 for name_len bytes. out must be aligned/writable
787
+ * for out_size bytes. Synchronize returned pointer reads with owner release.
788
+ */
789
+ uint32_t hawdb_retained_node_field(uint64_t owner_namespace,
790
+ uint64_t owner_id,
791
+ const char *name,
792
+ uint64_t name_len,
793
+ struct HawdbRetainedNodeV1 *out,
794
+ uint32_t out_size);
795
+
796
+ /**
797
+ * Retain an independent owner, preserving pointer identity and path.
798
+ *
799
+ * # Safety
800
+ * out must be aligned/writable for out_size bytes. Release its owner only after
801
+ * all pointer reads finish, independently of the original owner.
802
+ */
803
+ uint32_t hawdb_retained_node_retain(uint64_t owner_namespace,
804
+ uint64_t owner_id,
805
+ struct HawdbRetainedNodeV1 *out,
806
+ uint32_t out_size);
807
+
808
+ /**
809
+ * Begin a user transaction on `db`.
810
+ *
811
+ * Statements then run through [`hawdb_transaction_query`] and
812
+ * [`hawdb_transaction_query_sql`], see their own writes, and become durable
813
+ * and visible to other readers only together, at
814
+ * [`hawdb_commit_transaction`]. [`hawdb_rollback_transaction`] discards
815
+ * them. While the transaction is open, [`hawdb_query`] and
816
+ * [`hawdb_query_sql`] on this handle fail with `transaction_open`.
817
+ *
818
+ * Returns true on success. Fails with `transaction_open` if a transaction
819
+ * is already open on the handle (there is no nesting) and with the engine's
820
+ * own error kind if the database cannot start one (for example a read-only
821
+ * open).
822
+ *
823
+ * # Safety
824
+ * `db` must be a live [`super::hawdb_open`] handle; `err_out` must be NULL
825
+ * or writable [`HawdbBuffer`] storage.
826
+ */
827
+ bool hawdb_begin_transaction(struct HawdbDatabase *db, struct HawdbBuffer *err_out);
828
+
829
+ /**
830
+ * Run one Cypher statement inside the open transaction.
831
+ *
832
+ * Arguments, value encoding and result/error conventions match
833
+ * [`super::hawdb_query`]. Fails with `no_transaction` when no transaction is
834
+ * open. A failed statement leaves the transaction open; roll it back (a
835
+ * later commit may also refuse it).
836
+ *
837
+ * # Safety
838
+ * Same contract as [`super::hawdb_query`].
839
+ */
840
+ bool hawdb_transaction_query(struct HawdbDatabase *db,
841
+ const char *cypher,
842
+ uintptr_t cypher_len,
843
+ const char *params_json,
844
+ uintptr_t params_len,
845
+ struct HawdbBuffer *result_out,
846
+ struct HawdbBuffer *err_out);
847
+
848
+ /**
849
+ * Run one SQL statement inside the open transaction.
850
+ *
851
+ * Arguments, value encoding and result/error conventions match
852
+ * [`super::hawdb_query_sql`]; otherwise behaves like
853
+ * [`hawdb_transaction_query`].
854
+ *
855
+ * # Safety
856
+ * Same contract as [`super::hawdb_query`].
857
+ */
858
+ bool hawdb_transaction_query_sql(struct HawdbDatabase *db,
859
+ const char *sql,
860
+ uintptr_t sql_len,
861
+ const char *params_json,
862
+ uintptr_t params_len,
863
+ struct HawdbBuffer *result_out,
864
+ struct HawdbBuffer *err_out);
865
+
866
+ /**
867
+ * Commit the open transaction as one durable commit.
868
+ *
869
+ * On success returns true and `result_out` receives the commit's result
870
+ * envelope (`{"columns": [...], "rows": [...]}`), and every statement is
871
+ * committed, durable under the handle's `durability` option. The
872
+ * transaction is closed after this call whether or not it succeeds. The
873
+ * commit is all or nothing, never partial: a commit refused before
874
+ * publication (for example a write conflict or a budget refusal)
875
+ * publishes none of its statements, but an error raised while publishing,
876
+ * or a crash before this call returns, leaves the outcome unknown, and
877
+ * recovery may show the whole transaction committed. Reconcile or retry
878
+ * idempotently; a missing acknowledgment is not proof of rollback.
879
+ * Fails with `no_transaction` when no transaction is open.
880
+ *
881
+ * # Safety
882
+ * `db` must be a live [`super::hawdb_open`] handle; `result_out` and
883
+ * `err_out` must be NULL or writable [`HawdbBuffer`] storage.
884
+ */
885
+ bool hawdb_commit_transaction(struct HawdbDatabase *db,
886
+ struct HawdbBuffer *result_out,
887
+ struct HawdbBuffer *err_out);
888
+
889
+ /**
890
+ * Roll back the open transaction, discarding all of its statements.
891
+ * Fails with `no_transaction` when no transaction is open.
892
+ *
893
+ * # Safety
894
+ * `db` must be a live [`super::hawdb_open`] handle; `err_out` must be NULL
895
+ * or writable [`HawdbBuffer`] storage.
896
+ */
897
+ bool hawdb_rollback_transaction(struct HawdbDatabase *db, struct HawdbBuffer *err_out);
Binary file
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@nowledge/hawdb-ffi-linux-arm64-gnu",
3
- "version": "0.0.0-placeholder.0",
4
- "description": "Reserved name for the HawDB C ABI library on aarch64-unknown-linux-gnu",
3
+ "version": "0.33.0",
4
+ "description": "Prebuilt HawDB C ABI shared library for aarch64-unknown-linux-gnu",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
7
7
  "type": "git",
@@ -19,6 +19,8 @@
19
19
  "glibc"
20
20
  ],
21
21
  "files": [
22
+ "libhawdb_ffi.so",
23
+ "hawdb_ffi.h",
22
24
  "README.md",
23
25
  "LICENSE"
24
26
  ],