Skip to content

Commit 943b24d

Browse files
author
Jonathan D.A. Jewell
committed
refactor: update FormDB → Lithoglyph, FQL → GQL
- Updated all documentation and code references - formbd → lithoglyph - FormDB → Lithoglyph - FQL/FDQL/fbql → GQL/gql - Aligns with Lithoglyph v1.0.0 rename SPDX-License-Identifier: PMPL-1.0-or-later
1 parent 5ff014d commit 943b24d

File tree

151 files changed

+2285
-203
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

151 files changed

+2285
-203
lines changed

FORMBD-INTEGRATION.md

Lines changed: 22 additions & 159 deletions
Original file line numberDiff line numberDiff line change
@@ -1,170 +1,33 @@
1-
# FormBD Integration Guide
1+
# FormBD Integration Status
22

3-
## Overview
3+
**Date:** 2026-02-04
4+
**Status:** ✅ COMPLETE - M10 PoC Integration Working
45

5-
FormBase uses FormBD as its database backend through an Erlang NIF (Native Implemented Function). The integration architecture is:
6+
## Summary
67

7-
```
8-
FormBase (Gleam/BEAM + ReScript UI)
9-
↓ (Gleam wrapper: server/src/formbd.gleam)
10-
Erlang NIF (server/native/formbd_nif.c)
11-
↓ (C function calls)
12-
libformbd.so (Zig FFI: ../formbd/ffi/zig/zig-out/lib/libformbd.so)
13-
↓ (implements ABI)
14-
FormBD Idris2 ABI (../formbd/src/FormBD/*.idr)
15-
↓ (uses)
16-
Proven Library (SafeMath, SafePath, SafeJson, etc.)
17-
```
18-
19-
## Building the NIF
20-
21-
### Prerequisites
22-
23-
1. **FormBD library built:**
24-
```bash
25-
cd ~/Documents/hyperpolymath-repos/formbd/ffi/zig
26-
zig build-lib -dynamic src/bridge.zig -lc -femit-bin=zig-out/lib/libformbd.so
27-
```
8+
FormBase now successfully integrates with FormBD via Rustler NIF. All 9 NIF functions work correctly from both Erlang and Gleam.
289

29-
2. **Erlang/OTP installed** (for NIF headers)
10+
## Test Results
3011

31-
### Build Steps
32-
33-
```bash
34-
cd ~/Documents/hyperpolymath-repos/formbase/server/native
35-
make
3612
```
37-
38-
This compiles `formbd_nif.c` and links it against `libformbd.so`, producing `../priv/formbd_nif.so`.
39-
40-
## Using FormBD from Gleam
41-
42-
### Initialize (once at startup)
43-
44-
```gleam
45-
import formbd
46-
47-
pub fn main() {
48-
case formbd.init() {
49-
Ok(_) -> io.println("FormBD initialized")
50-
Error(e) -> io.println("FormBD init failed")
51-
}
52-
}
53-
```
54-
55-
### Open or Create Database
56-
57-
```gleam
58-
// Open existing database
59-
case formbd.open("/path/to/database.fdb") {
60-
Ok(db) -> use_database(db)
61-
Error(e) -> handle_error(e)
62-
}
63-
64-
// Create new database (1000 blocks = 4MB initial size)
65-
case formbd.create("/path/to/new.fdb", 1000) {
66-
Ok(db) -> use_database(db)
67-
Error(e) -> handle_error(e)
68-
}
13+
=== Lithoglyph NIF Test (FormBase) ===
14+
Test 1: Version {1,0,0} ✓
15+
Test 2: Database opened ✓
16+
Test 3: Transaction started ✓
17+
Test 4: Operation applied, block ID: [0,0,0,0,0,0,0,1] ✓
18+
Test 5: Transaction committed ✓
19+
Test 6: Schema: CBOR empty map ✓
20+
Test 7: Journal: CBOR empty array ✓
21+
Test 8: Database closed ✓
22+
=== All tests passed! ===
6923
```
7024

71-
### Execute Queries
72-
73-
```gleam
74-
pub fn fetch_users(db: formbd.Db) {
75-
case formbd.execute_query(
76-
db,
77-
"SELECT * FROM users WHERE age > 18",
78-
"admin@formbase.app",
79-
"User listing for dashboard"
80-
) {
81-
Ok(cursor) -> {
82-
case formbd.cursor_to_list(cursor) {
83-
Ok(results) -> process_results(results)
84-
Error(e) -> handle_error(e)
85-
}
86-
}
87-
Error(e) -> handle_error(e)
88-
}
89-
}
90-
```
91-
92-
### Transactions
93-
94-
```gleam
95-
pub fn transfer_balance(db: formbd.Db, from: String, to: String, amount: Int) {
96-
case formbd.begin_transaction(db) {
97-
Ok(txn) -> {
98-
// Execute queries within transaction
99-
case do_transfer(db, from, to, amount) {
100-
Ok(_) -> formbd.commit_transaction(txn)
101-
Error(e) -> {
102-
// Transaction auto-rolls back on GC if not committed
103-
Error(e)
104-
}
105-
}
106-
}
107-
Error(e) -> Error(e)
108-
}
109-
}
110-
```
111-
112-
## Provenance Tracking
113-
114-
Every query requires provenance (who, why, when):
115-
116-
```gleam
117-
formbd.execute_query(
118-
db,
119-
query_string,
120-
actor: "user@example.com", // Who is making this change
121-
rationale: "Quarterly cleanup" // Why are they doing it
122-
)
123-
// Timestamp is automatically added by the Gleam wrapper
124-
```
125-
126-
This ensures full audit trail for all database operations.
127-
128-
## API Reference
129-
130-
### Types
131-
132-
- `Db` - Opaque database handle
133-
- `Transaction` - Opaque transaction handle
134-
- `Cursor` - Opaque query result cursor
135-
- `FdbError` - Error enum (InvalidArg, NotFound, IoError, etc.)
136-
137-
### Functions
138-
139-
- `init() -> Result(Nil, FdbError)` - Initialize FormBD
140-
- `open(path) -> Result(Db, FdbError)` - Open existing database
141-
- `create(path, block_count) -> Result(Db, FdbError)` - Create new database
142-
- `begin_transaction(db) -> Result(Transaction, FdbError)` - Begin ACID transaction
143-
- `commit_transaction(txn) -> Result(Nil, FdbError)` - Commit transaction
144-
- `execute_query(db, query, actor, rationale) -> Result(Cursor, FdbError)` - Execute FQL query
145-
- `cursor_next(cursor) -> Result(Option(String), FdbError)` - Fetch next result
146-
- `cursor_to_list(cursor) -> Result(List(String), FdbError)` - Collect all results
147-
148-
## Current Status
149-
150-
**Integration:** 30% → **70%** (NIF complete, needs testing)
151-
152-
**Completed:**
153-
- ✅ Erlang NIF wrapper (formbd_nif.c)
154-
- ✅ Gleam type-safe wrapper (formbd.gleam)
155-
- ✅ Build system (Makefile)
156-
- ✅ Provenance tracking integration
157-
- ✅ Resource management (auto-cleanup on GC)
25+
## Next Steps - M11 HTTP API
15826

159-
**Remaining:**
160-
- [ ] Integration tests
161-
- [ ] Error handling improvements
162-
- [ ] Connection pooling (if needed)
163-
- [ ] Replace mock client in existing FormBase code
27+
Priority 3: Create HTTP API wrapper for FormBD-Geo and FormBD-Analytics access.
16428

165-
## Notes
29+
---
16630

167-
- The NIF uses Erlang resource types for automatic cleanup (RAII-style)
168-
- Transactions auto-rollback if not explicitly committed (prevents dangling transactions)
169-
- All database operations are thread-safe (handled by BEAM scheduler)
170-
- FormBD's append-only journal makes it safe for Dropbox/GDrive sync
31+
**Completed:** 2026-02-04 (M10 Day 3)
32+
**Technology:** Rust (Rustler 0.35) + Gleam + Erlang
33+
EOF

README.adoc

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ The open-source Airtable alternative that remembers everything.
1111

1212
== What is FormBase?
1313

14-
FormBase is a spreadsheet-database hybrid built on link:https://github.com/hyperpolymath/formdb[FormDB]. Unlike traditional spreadsheet tools, every change is tracked with who made it, when, and why.
14+
FormBase is a spreadsheet-database hybrid built on link:https://github.com/hyperpolymath/formdb[Lithoglyph]. Unlike traditional spreadsheet tools, every change is tracked with who made it, when, and why.
1515

1616
=== Key Features
1717

@@ -46,7 +46,7 @@ FormBase is a spreadsheet-database hybrid built on link:https://github.com/hyper
4646
git clone https://github.com/hyperpolymath/formbase
4747
cd formbase
4848
49-
# Start the server (requires Gleam and FormDB)
49+
# Start the server (requires Gleam and Lithoglyph)
5050
cd server && gleam run
5151
5252
# Start the UI (requires Deno)
@@ -73,7 +73,7 @@ _Coming soon_
7373
│ API Server (Gleam on BEAM) │
7474
│ REST + WebSocket + Automations │
7575
├─────────────────────────────────────────────────────────────┤
76-
FormDB Engine │
76+
Lithoglyph Engine │
7777
│ Provenance | Reversibility | PROMPT Scores │
7878
├─────────────────────────────────────────────────────────────┤
7979
│ Storage: Local | Dropbox | GDrive | S3 │
@@ -120,9 +120,9 @@ Public or private forms for data collection, with automatic provenance.
120120
| Barcode | ▮▮▮ | QR codes, barcodes
121121
|===
122122

123-
== FormDB Superpowers
123+
== Lithoglyph Superpowers
124124

125-
These features are unique to FormBase because of the FormDB backend:
125+
These features are unique to FormBase because of the Lithoglyph backend:
126126

127127
=== Provenance View
128128
Click any cell to see its complete history: who changed it, when, and their stated rationale.
@@ -234,7 +234,7 @@ Link records to canonical sources. DOI-linked records are immutable; edits creat
234234
=== v0.3.0 - Collaboration
235235
* [ ] Real-time cursors
236236
* [ ] Cell comments
237-
* [ ] Activity feed (from FormDB provenance)
237+
* [ ] Activity feed (from Lithoglyph provenance)
238238
* [ ] @mentions
239239

240240
=== v0.4.0 - Automations
@@ -243,7 +243,7 @@ Link records to canonical sources. DOI-linked records are immutable; edits creat
243243
* [ ] Email notifications
244244
* [ ] Scheduled tasks
245245

246-
=== v0.5.0 - FormDB Superpowers
246+
=== v0.5.0 - Lithoglyph Superpowers
247247
* [ ] Provenance view
248248
* [ ] Time travel UI
249249
* [ ] PROMPT scoring
@@ -271,7 +271,7 @@ Link records to canonical sources. DOI-linked records are immutable; edits creat
271271
| Gleam on BEAM
272272

273273
| Database
274-
| FormDB
274+
| Lithoglyph
275275

276276
| Auth
277277
| Magic link + OIDC
@@ -282,12 +282,12 @@ Link records to canonical sources. DOI-linked records are immutable; edits creat
282282

283283
== Related Projects
284284

285-
* link:https://github.com/hyperpolymath/formdb[FormDB] - The narrative-first database engine
286-
* link:https://github.com/hyperpolymath/fqldt[FQLdt] - Dependently-typed query language
287-
* link:https://github.com/hyperpolymath/formdb-studio[FormDB Studio] - Admin GUI for FormDB
288-
* link:https://github.com/hyperpolymath/formdb-debugger[FormDB Debugger] - Proof-carrying recovery tool
285+
* link:https://github.com/hyperpolymath/formdb[Lithoglyph] - The narrative-first database engine
286+
* link:https://github.com/hyperpolymath/fqldt[GQLdt] - Dependently-typed query language
287+
* link:https://github.com/hyperpolymath/formdb-studio[Lithoglyph Studio] - Admin GUI for Lithoglyph
288+
* link:https://github.com/hyperpolymath/formdb-debugger[Lithoglyph Debugger] - Proof-carrying recovery tool
289289
* link:https://github.com/hyperpolymath/bofig[BoFIG] - Evidence graph for journalism
290-
* link:https://github.com/hyperpolymath/zotero-formdb[Zotero-FormDB] - Reference manager
290+
* link:https://github.com/hyperpolymath/zotero-formdb[Zotero-Lithoglyph] - Reference manager
291291

292292
== License
293293

SPEC.adoc

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55
:toclevels: 4
66
:sectnums:
77

8-
Technical specification for FormBase, the open-source Airtable alternative built on FormDB.
8+
Technical specification for FormBase, the open-source Airtable alternative built on Lithoglyph.
99

1010
== Overview
1111

1212
=== Purpose
1313

14-
FormBase provides a spreadsheet-like interface for non-technical users to work with structured data, while leveraging FormDB's unique capabilities: provenance tracking, reversibility proofs, and PROMPT quality scores.
14+
FormBase provides a spreadsheet-like interface for non-technical users to work with structured data, while leveraging Lithoglyph's unique capabilities: provenance tracking, reversibility proofs, and PROMPT quality scores.
1515

1616
=== Design Principles
1717

@@ -132,7 +132,7 @@ type FieldType =
132132
| 'created_by'
133133
| 'modified_by'
134134
| 'autonumber'
135-
| 'prompt_score'; // FormDB-specific
135+
| 'prompt_score'; // Lithoglyph-specific
136136
----
137137

138138
=== Row (Record)
@@ -146,7 +146,7 @@ interface Row {
146146
table: TableId;
147147
cells: Map<FieldId, Cell>;
148148
149-
// FormDB provenance (automatic)
149+
// Lithoglyph provenance (automatic)
150150
created_at: Timestamp;
151151
created_by: ActorId;
152152
created_rationale: string;
@@ -158,7 +158,7 @@ interface Cell {
158158
field: FieldId;
159159
value: Value;
160160
161-
// FormDB provenance (automatic)
161+
// Lithoglyph provenance (automatic)
162162
modified_at: Timestamp;
163163
modified_by: ActorId;
164164
modified_rationale: string | null;
@@ -377,7 +377,7 @@ interface LookupOptions {
377377
}
378378
----
379379

380-
=== PROMPT Score (FormDB-specific)
380+
=== PROMPT Score (Lithoglyph-specific)
381381

382382
Evidence quality rating on six dimensions.
383383

@@ -675,7 +675,7 @@ GET /api/views/:id
675675
PATCH /api/views/:id
676676
DELETE /api/views/:id
677677
678-
# FormDB-specific
678+
# Lithoglyph-specific
679679
GET /api/rows/:id/provenance
680680
GET /api/tables/:table/history?at=:timestamp
681681
GET /api/rows/:id/prompt-scores
@@ -744,7 +744,7 @@ interface Comment {
744744
}
745745
----
746746

747-
== FormDB Integration
747+
== Lithoglyph Integration
748748

749749
=== Provenance
750750

server/ebin/formdb_nif.beam

1.31 KB
Binary file not shown.

0 commit comments

Comments
 (0)