Commit f6370bf
feat(lithoglyph/gql-dt): implement FFI stubs — wire db_open, db_close, parse, execute
Replace all TODO/placeholder stub functions in the GQL-DT Zig FFI layer
with working implementations that allocate and manage opaque handle state
(DbState, QueryState, SchemaState, ResultState) on the heap.
Zig FFI (ffi/zig/src/main.zig):
- gqldt_db_open: validates path, allocates DbState, returns opaque handle
- gqldt_db_close: frees DbState backing memory
- gqldt_parse / gqldt_parse_inferred: store query text in QueryState
- gqldt_typecheck: marks query as type-checked (precondition for execute)
- gqldt_execute: verifies typecheck precondition, allocates ResultState
- gqldt_serialize_cbor: encodes query as CBOR text string (RFC 8949)
- gqldt_serialize_json: produces {"query":"..."} wrapper
- gqldt_deserialize_cbor: decodes CBOR text string back to QueryState
- gqldt_get_schema: allocates SchemaState for collection
- gqldt_validate_permissions: validates user_id, delegates to Idris2
- gqldt_query_free / gqldt_schema_free / gqldt_result_free: proper cleanup
- gqldt_version: returns "0.1.0"
- Slot allocation helpers (alloc_slot/read_slot/free_slot/bits64_to_ptr)
for Idris2 pointer marshalling
Idris2 ABI (src/GQLdt/ABI/Foreign.idr):
- Replace all ?impl_pending holes (dbOpen, dbClose, parse, parseInferred,
typecheck, execute, dbOpenSafe, parseSafe) with implementations using
allocSlot/readSlot/freeSlot + Data.So.choose pattern (zero believe_me)
- Add validateDbPath and validateQueryStr inline validators
- Add handle pointer extractors (extractDbPtr, extractQueryPtr, extractSchemaPtr)
Build (build.zig):
- Migrate to Zig 0.15.2 API (addLibrary/createModule)
- Build both static and shared library artifacts
Tests:
- Replace template placeholders in integration_test.zig with real GQL-DT
function signatures
- All 21 unit tests pass, both libraries compile clean
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent 45cd49d commit f6370bf
File tree
4 files changed
+1009
-289
lines changed- lithoglyph/gql-dt
- ffi/zig
- src
- test
- src/GQLdt/ABI
4 files changed
+1009
-289
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
3 | 3 | | |
4 | | - | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
5 | 7 | | |
6 | 8 | | |
7 | 9 | | |
8 | 10 | | |
9 | 11 | | |
10 | 12 | | |
11 | 13 | | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
17 | 23 | | |
| 24 | + | |
18 | 25 | | |
19 | | - | |
20 | | - | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
21 | 46 | | |
22 | | - | |
23 | 47 | | |
24 | | - | |
| 48 | + | |
25 | 49 | | |
26 | | - | |
| 50 | + | |
27 | 51 | | |
0 commit comments