|
| 1 | +// SPDX-License-Identifier: PMPL-1.0-or-later |
| 2 | += Nextgen Databases — Query Languages & Integration Status |
| 3 | +:toc: |
| 4 | +:toclevels: 2 |
| 5 | + |
| 6 | +Last verified: 2026-03-21 |
| 7 | + |
| 8 | +== Overview |
| 9 | + |
| 10 | +This monorepo contains 5 database engines, each with its own query language. |
| 11 | +Three are registered in the BoJ Server `database-mcp` cartridge with connection |
| 12 | +management, query execution, and PanLL dashboard panels. |
| 13 | + |
| 14 | +== Database & Query Language Matrix |
| 15 | + |
| 16 | +[cols="<2,<2,^1,^1,<3", options="header"] |
| 17 | +|=== |
| 18 | +| Database | Query Language | BoJ ID | Status | Key Components |
| 19 | + |
| 20 | +| **VeriSimDB** |
| 21 | +| VQL (Verified Query Language) |
| 22 | +| 1 |
| 23 | +| Mature |
| 24 | +| 10 ReScript modules: Parser, TypeChecker, BiDir, Subtyping, ProofObligation, Circuit, Explain, Context, Error, Types |
| 25 | + |
| 26 | +| **LithoGlyph** |
| 27 | +| GQL (Graph Query Language) |
| 28 | +| 6 |
| 29 | +| Beta |
| 30 | +| Graph algebra in `src/Lith/`, GQL execution via database-mcp |
| 31 | + |
| 32 | +| **QuandleDB** |
| 33 | +| KQL (Knot Query Language) |
| 34 | +| 5 |
| 35 | +| Early |
| 36 | +| Connector-based architecture, minimal source |
| 37 | + |
| 38 | +| **NQC** |
| 39 | +| NQC (Nested Query Calculus) |
| 40 | +| — |
| 41 | +| Alpha |
| 42 | +| Pure Gleam implementation with Erlang FFI, not yet in database-mcp |
| 43 | + |
| 44 | +| **TypeQL-Exp.** |
| 45 | +| TypeQL (Type-Safe QL) |
| 46 | +| — |
| 47 | +| Stub |
| 48 | +| Parser skeleton, Idris2 ABI definitions, spec only |
| 49 | +|=== |
| 50 | + |
| 51 | +== BoJ Server Integration |
| 52 | + |
| 53 | +=== database-mcp Cartridge |
| 54 | + |
| 55 | +Located at `boj-server/cartridges/database-mcp/`: |
| 56 | + |
| 57 | +**Adapter:** `adapter/database_adapter.v` (V-lang) |
| 58 | + |
| 59 | +**FFI functions (C ABI via Zig):** |
| 60 | + |
| 61 | +* `db_connect(backend_id) → slot` |
| 62 | +* `db_connect_verisimdb(url) → slot` |
| 63 | +* `db_connect_quandledb(url) → slot` |
| 64 | +* `db_connect_lithoglyph(url) → slot` |
| 65 | +* `db_connect_sqlite(path) → slot` |
| 66 | +* `db_disconnect(slot) → result` |
| 67 | +* `db_execute_sql(slot, query) → result` — PostgreSQL, SQLite |
| 68 | +* `db_execute_vql(slot, query) → result` — VeriSimDB |
| 69 | +* `db_execute_kql(slot, query) → result` — QuandleDB |
| 70 | +* `db_execute_gql(slot, query) → result` — LithoGlyph |
| 71 | +* `db_begin_query(slot) / db_end_query(slot)` — Transaction boundaries |
| 72 | +* `db_state(slot)` — Connection state (disconnected/connected/querying/error) |
| 73 | + |
| 74 | +=== PanLL Dashboard Panels |
| 75 | + |
| 76 | +[cols="<3,<5", options="header"] |
| 77 | +|=== |
| 78 | +| Panel | Purpose |
| 79 | + |
| 80 | +| `db-status` | Connection pool health across all backends |
| 81 | +| `db-connections` | Active connections, QPS metrics |
| 82 | +| `db-verisimdb` | Octad counts, proof counts, modality status |
| 83 | +| `vql-ut-safety-dashboard` | 10-level safety pipeline visualisation |
| 84 | +| `vql-ut-query-editor` | Live type-checking with Idris2 kernel (TypeLL) |
| 85 | +| `vql-ut-proof-explorer` | Obligation tracking and proof certificates |
| 86 | +| `vql-ut-horror-stories` | Interactive education — what each safety level prevents |
| 87 | +|=== |
| 88 | + |
| 89 | +== VQL Safety Levels (VQL-UT) |
| 90 | + |
| 91 | +VeriSimDB's query language has a 10-level type-safe query pipeline: |
| 92 | + |
| 93 | +[cols="^1,<3,<5", options="header"] |
| 94 | +|=== |
| 95 | +| Level | Name | What It Prevents |
| 96 | + |
| 97 | +| L1 | Construction Safety | SQL/query injection |
| 98 | +| L2 | Schema Pinning | Schema drift between query and database |
| 99 | +| L3 | Resource Linearity | Connection/cursor leaks |
| 100 | +| L4 | Session Protocols | State machine violations (query before connect) |
| 101 | +| L5 | Effect Tracking | Unaudited side effects |
| 102 | +| L6 | Scope Isolation | Namespace boundary violations |
| 103 | +| L7 | Information Flow | Data lineage tracking failures |
| 104 | +| L8 | Quantitative Bounds | Resource exhaustion (unbounded queries) |
| 105 | +| L9 | Proof Attachment | Missing evidence for sensitive operations |
| 106 | +| L10 | Cross-Cutting | Composition bugs across query boundaries |
| 107 | +|=== |
| 108 | + |
| 109 | +== Not Yet Integrated |
| 110 | + |
| 111 | +* **NQC** — Gleam-based Nested Query Calculus. Working implementation in `nqc/src/nqc.gleam` |
| 112 | + with Erlang FFI. Needs a `db_execute_nqc()` FFI function and database-mcp registration. |
| 113 | +* **TypeQL-Experimental** — Idris2 ABI definitions exist at `typeql-experimental/src/abi/`. |
| 114 | + Parser is stub-phase. Needs compiler work before integration. |
0 commit comments