VQL-UT is the next-generation query language for VeriSimDB, designed to satisfy all 10 levels of type safety — the 6 established IO-covered forms and the 4 additional forms identified through our research.
The goal is production-worthy VQL that is provably correct at every layer, from parse to execution. At minimum, this repo serves as a research vehicle for exploring the boundaries of type-safe query languages.
|
Note
|
This project was briefly known as "vql" during early discussion. The canonical name is *VQL-UT* (Ultimate Type-Safe). All references to vql, vqlpp, or VQL Plus Plus should be read as VQL-UT. File extension: .vqlut.
|
The 10 type safety levels originate in TypeLL (the core type theory), flow into PanLL (panel framework type safety), and are now applied to database queries as VQL-UT.
TypeLL (type theory core — defines the 10 levels)
│
├──→ PanLL (panel framework type safety)
│
└──→ VQL-UT (database query language type safety)
│
└──→ VeriSimDB (6-modal execution engine)| Tier | What | How |
|---|---|---|
VQL |
The query language |
Parser (ReScript) → AST → execution. What users write. |
VQL-UT |
The safety pipeline |
10 progressive levels. Sits behind VQL, applies automatically. Simple queries
short-circuit at L1-L2. Proof-carrying queries (with |
|
Note
|
VQL-DT (Dependent Types) was the original name for the proof-carrying execution
mode (queries with PROOF clauses). It is not a separate product — it is now folded
into VQL-UT’s L9 (Proof Attachment) and L10 (Cross-Cutting) levels. All references to
"VQL-DT" in older documentation should be read as "VQL-UT L9-L10".
|
The 6 proof types (EXISTENCE, INTEGRITY, CONSISTENCY, PROVENANCE, FRESHNESS,
AUTHORIZATION) remain — they are activated by VQL’s PROOF clause and validated
by VQL-UT levels L9-L10.
The type safety story unfolds in three phases:
-
ReScript evangeliser proves the concept first — demonstrate the value of these type safety levels in ReScript itself, where the developer community can experience them firsthand
-
Once proven, VQL-UT and AffineScript become the two showcase languages for teaching people the 10 levels of type safety
-
VQL-UT handles the database query domain; AffineScript handles general-purpose programming
| Level | Name | Description |
|---|---|---|
1 |
Parse-time safety |
Query syntax verified at parse time — malformed queries rejected before processing |
2 |
Schema-binding safety |
Column names, table references, relationships validated against live schema |
3 |
Type-compatible operations |
Arithmetic, comparison, aggregation only on compatible types |
4 |
Null-safety |
Nullable vs non-nullable tracked through joins, subqueries, projections |
5 |
Injection-proof safety |
Parameterised queries enforced at type level — interpolation impossible by construction |
6 |
Result-type safety |
Query return types known at compile time — no runtime casting |
| Level | Name | Description |
|---|---|---|
7 |
Cardinality safety |
Return count guarantees (exactly-one, at-most-one, many) in the type system |
8 |
Effect-tracking safety |
Read vs write vs DDL distinguished at type level — pure queries cannot mutate |
9 |
Temporal safety |
Bi-temporal and system-time queries carry time bounds in types — prevents stale reads |
10 |
Linearity safety |
Connection and transaction handles are linear types — use-after-close impossible |
The typeql-experimental sub-project within nextgen-databases prototyped 6 mechanisms that map to levels 7-10:
| Mechanism | VQL-UT Syntax | Idris2 Encoding |
|---|---|---|
Linear types |
|
QTT quantity |
Session types |
|
|
Effect systems |
|
Effect set with subsumption proofs |
Modal types |
|
Box types indexed by world/scope |
Proof-carrying code |
|
|
Quantitative type theory |
|
Bounded resource tracking via QTT |
+---------------+
| VQL Source |
| (.vqlut) |
+-------+-------+
|
+-----------v-----------+
| Parser (Level 1) | ReScript — extends VeriSimDB VQL parser
+-----------+-----------+
|
+-----------v-----------+
| Schema Binder (2) | Idris2 — dependent types on schema
+-----------+-----------+
|
+-----------v-----------+
| Type Checker (3-6) | Idris2 — nullability, injection, results
+-----------+-----------+
|
+-----------v-----------+
| Effect Analyser | Idris2 — cardinality (7), effects (8),
| (7-10) | temporality (9), linearity (10)
+-----------+-----------+
|
+-----------v-----------+
| Zig FFI Codegen | Compiles to C-ABI query plan
+-----------+-----------+
|
+-----------v-----------+
| VeriSimDB Engine | 6-modal execution
+-----------------------+| Layer | Language | Purpose |
|---|---|---|
Core type system |
Idris2 |
Dependent types for all 10 safety levels. |
FFI bridge |
Zig |
C-ABI query plan compilation. Zero-copy result sets. |
Parser |
ReScript |
Surface syntax parsing, extending VeriSimDB’s VQL parser. |
API layer |
V-lang |
REST/gRPC/GraphQL endpoints for query submission. |
VeriSimDB integration |
Elixir |
6-modal storage engine connection via NIFs. |
-
❏ VQL-UT grammar specification (EBNF, extending VQL v3.0)
-
❏ Idris2 parser with totality proof
-
❏ Schema representation as dependent types
-
❏ Type-compatible operation checker
-
❏ Zig FFI for query plan emission
-
❏ Basic test suite against VeriSimDB
-
❏ Null-tracking through join algebra
-
❏ Injection-proof parameterisation (type-level enforcement)
-
❏ Result-type inference with compile-time guarantees
-
❏ Property-based tests (QuickCheck/Hedgehog)
-
❏ Cardinality annotations and inference
-
❏ Effect system (Read/Write/DDL monad stack)
-
❏ Temporal type annotations for bi-temporal queries
-
❏ Linear types for connections and transactions (Idris2 QTT)
| Project | Relationship |
|---|---|
Target database engine (6-modal octad storage) |
|
nextgen-databases/verisimdb/docs/VQL-SPEC.adoc |
Base VQL grammar specification (26KB, EBNF appendix) |
nextgen-databases/verisimdb/docs/vql-vs-vql-dt.adoc |
VQL-DT specification (to be superseded by VQL-UT) |
nextgen-databases/typeql-experimental |
6 extension mechanisms for levels 7-10 (Idris2 kernel + ReScript parser) |
Core type theory — the 10 levels originate here |
|
Panel framework — integrates TypeLL type safety for UI |
|
nextgen-languages/affinescript |
Sister showcase for type safety adoption (general-purpose programming) |
# Type-check the Idris2 core
cd src/interface/abi && idris2 --typecheck
# Build FFI
cd src/interface/ffi && zig build
# Run tests
just test