Skip to content

Commit d3c440c

Browse files
hyperpolymathclaude
andcommitted
feat: add typeql-experimental (VQL-dt++) — 6 type-theoretic extensions to VQL
Implement experimental exploration of linear types, session types, effect systems, modal types, proof-carrying code, and quantitative type theory as extensions to VQL (VeriSim Query Language). Idris2 kernel: 9 modules type-check clean with %default total and zero banned patterns (no believe_me/assert_total/assert_smaller). Zig FFI bridge: 5 tests pass on Zig 0.15.2. ReScript parser written following VeriSimDB combinator patterns. 7 annotated .vqlpp example files. Also updates parent README.adoc with revised project descriptions and priority notes for VeriSimDB, LithoGlyph, and QuandleDB. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent e565e98 commit d3c440c

41 files changed

Lines changed: 4819 additions & 19 deletions

Some content is hidden

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

.machine_readable/STATE.scm

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
;; SPDX-License-Identifier: PMPL-1.0-or-later
2-
(state (metadata (version "0.1.0") (last-updated "2026-02-13") (status active))
3-
(project-context (name "nextgen-databases") (purpose "Parent repo tracking database application portfolio") (completion-percentage 30))
2+
(state (metadata (version "0.3.0") (last-updated "2026-03-01") (status active))
3+
(project-context (name "nextgen-databases") (purpose "Parent repo tracking database application portfolio") (completion-percentage 35))
44
(components
55
(component "quandledb" (status "active") (description "Knot-theory database wrapping Skein.jl"))
66
(component "verisimdb" (status "active") (description "Multimodal verification database"))
77
(component "lithoglyphdb" (status "active") (description "Glyph and inscription database"))
8-
(component "glyphbase" (status "planned") (description "Web frontend for LithoglyphDB"))))
8+
(component "glyphbase" (status "planned") (description "Web frontend for LithoglyphDB"))
9+
(component "typeql-experimental" (status "active") (description "VQL-dt++ experimental type-theoretic extensions — 9/9 Idris2 modules type-check, 5/5 Zig FFI tests pass, ReScript parser written"))))

README.adoc

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,32 +24,39 @@ This repository serves as the central tracking hub for the Next-Gen Databases in
2424
|===
2525
| Database | Description | Technology | Query Language | Status
2626

27+
| *VeriSimDB*
28+
| Cross-system entity consistency engine — 8 modalities (octad), drift detection, self-normalisation, formally verified queries. **Primary database project.** Operates as standalone database OR federation coordinator over existing databases (PostgreSQL, ArangoDB, Elasticsearch).
29+
| Rust (core) + ReScript (VQL parser) + Elixir (orchestration)
30+
| VQL (VeriSim Query Language) + VQL-DT (dependent types)
31+
| Active — beta
32+
2733
| *QuandleDB*
28-
| Knot-theory database — stores knots as Gauss codes, computes invariants (Jones polynomial, genus, Seifert circles), queries by topological properties
34+
| Knot-theory database — stores knots as Gauss codes, computes invariants (Jones polynomial, genus, Seifert circles), queries by topological properties. **Exploratory/research project**: a thought experiment in applying knot theory to database design, not yet intended as a production tool.
2935
| Julia (Skein.jl engine) + ReScript frontend
3036
| KQL (Knot Query Language) — in development
31-
| Active
37+
| Exploratory
3238

33-
| *VeriSimDB*
34-
| Multimodal verification database — 6 modalities (Graph, Vector, Tensor, Semantic, Document, Temporal) for security analysis and software verification
35-
| Rust (core) + ReScript (VQL parser) + Elixir (executor)
36-
| VQL (Verification Query Language)
37-
| Active
38-
39-
| *LithoglyphDB*
40-
| Glyph and inscription database — catalogues lithographic specimens, inscriptions, and symbol systems with provenance tracking
41-
| Rust + Julia
42-
| (planned)
43-
| Active
39+
| *LithoGlyph*
40+
| Narrative-first, reversible, audit-grade database core for journalism, narrative arts, and media/comms. Working towards production but **secondary priority** to VeriSimDB. Long-term vision: intimate integration with portfolio tools (bofig, etc.) for journalism and PR applications.
41+
| Forth (storage) + Zig (bridge) + Factor (FQL) + Idris2 (proofs) + Lean 4 (normalizer)
42+
| GQL (Glyph Query Language) — planned
43+
| Active — on backburner
4444

4545
| *Glyphbase*
46-
| Web interface for LithoglyphDB — browser-based search, visualisation, and annotation of glyph specimens
47-
| ReScript frontend + LithoglyphDB API
48-
| (via LithoglyphDB)
46+
| Web interface for LithoGlyph — browser-based search, visualisation, and annotation of glyph specimens
47+
| ReScript frontend + LithoGlyph API
48+
| (via LithoGlyph)
4949
| Planned
5050

5151
|===
5252

53+
[NOTE]
54+
====
55+
**Project priorities:** VeriSimDB is the primary database engineering project, receiving active development focus. LithoGlyph is working towards production for specialist use in journalism and narrative arts, but is secondary priority while VeriSimDB matures. QuandleDB is a research exploration into knot theory's applications in database design — valuable for the mathematical insights but not positioned as a production tool at this stage.
56+
57+
Lessons learned from VeriSimDB development (drift detection, formal verification, federation) will directly improve LithoGlyph when development focus returns to it.
58+
====
59+
5360
== Architecture
5461

5562
Each database in the portfolio follows a layered architecture:

typeql-experimental/.gitignore

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Idris2 build artefacts
2+
build/
3+
4+
# Zig build artefacts
5+
ffi/zig/.zig-cache/
6+
ffi/zig/zig-out/
7+
8+
# ReScript build artefacts
9+
lib/
10+
node_modules/
11+
.merlin
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
;; SPDX-License-Identifier: PMPL-1.0-or-later
2+
(ecosystem
3+
(version "1.0.0")
4+
(last-updated "2026-03-01")
5+
6+
(name "typeql-experimental")
7+
(type "experimental-language-extension")
8+
(purpose "Explore advanced type-theoretic extensions to VQL")
9+
10+
(position-in-ecosystem
11+
(parent "nextgen-databases"
12+
(relationship "sub-project")
13+
(description "Lives within the nextgen-databases monorepo, no own .git"))
14+
(description "Experimental sister project to VQL-dt. While VQL-dt is the
15+
production dependent type system for VeriSimDB (~35% wired),
16+
typeql-experimental explores six advanced extensions that may
17+
eventually feed back into VQL-dt. All 9 Idris2 modules
18+
type-check clean with zero banned patterns."))
19+
20+
(related-projects
21+
(project "verisimdb"
22+
(relationship "sibling-dependency")
23+
(description "VQL v3.0 grammar (317 lines), VQL-dt type checker,
24+
AST types, parser combinator patterns. Primary reference.")
25+
(artefacts-used "vql-grammar.ebnf" "VQLParser.res" "VQLTypes.res"))
26+
27+
(project "lithoglyph"
28+
(relationship "sibling-pattern")
29+
(description "GQL-dt (FBQLdt) Idris2 ABI patterns. ipkg structure,
30+
module organisation, zero-believe_me invariant.")
31+
(artefacts-used "fbqldt.ipkg" "src/FormBD/*.idr"))
32+
33+
(project "proven"
34+
(relationship "potential-consumer")
35+
(description "Formal verification library. Proof-carrying code extension
36+
may integrate with proven's certificate format."))
37+
38+
(project "quandledb"
39+
(relationship "sibling-inspiration")
40+
(description "Knot-theory database. KQL query language may benefit from
41+
similar type extensions."))
42+
43+
(project "nqc"
44+
(relationship "sibling-tool")
45+
(description "NQC cross-database console. Web UI patterns (ReScript + Deno)
46+
informed the parser build setup.")))
47+
48+
(technologies
49+
(technology "Idris2" (role "type-system-kernel") (version "0.8.0"))
50+
(technology "ReScript" (role "parser") (version ">= 11.0"))
51+
(technology "Deno" (role "runtime") (version ">= 2.0"))
52+
(technology "Zig" (role "ffi-bridge") (version "0.15.2"))))
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
;; SPDX-License-Identifier: PMPL-1.0-or-later
2+
(meta
3+
(version "1.0.0")
4+
(last-updated "2026-03-01")
5+
6+
(architecture-decisions
7+
(decision "vql-not-sql"
8+
(status accepted)
9+
(date "2026-03-01")
10+
(context "Need a base query language for type extensions")
11+
(decision "Use VQL (VeriSim Query Language) as foundation, not SQL")
12+
(rationale "VQL's cross-modal semantics (HEXAD, 8 modalities, PROOF clauses)
13+
are the natural foundation. SQL's relational model is too flat
14+
for the properties we want to prove."))
15+
16+
(decision "idris2-qtt-native"
17+
(status accepted)
18+
(date "2026-03-01")
19+
(context "Need linear types for resource-counted connections")
20+
(decision "Use Idris2's native QTT (quantitative type theory) rather than encoding linearity")
21+
(rationale "Idris2 variables carry quantities (0, 1, omega). CONSUME AFTER 1 USE
22+
maps to (1 conn : Connection) — compiler enforces linearity for free."))
23+
24+
(decision "delta-grammar"
25+
(status accepted)
26+
(date "2026-03-01")
27+
(context "Need grammar for 6 new clause types")
28+
(decision "Extend VQL v3.0 EBNF with optional clauses appended after standard query")
29+
(rationale "No keyword conflicts. All new keywords disjoint from VQL's 60+ reserved words."))
30+
31+
(decision "dual-language-split"
32+
(status accepted)
33+
(date "2026-03-01")
34+
(context "Need both formal proofs and practical parsing")
35+
(decision "Idris2 for type kernel, ReScript for parser")
36+
(rationale "Idris2 proves properties. ReScript parses queries. Independent operation
37+
in experimental phase — no runtime interop needed."))
38+
39+
(decision "zero-believe-me"
40+
(status accepted)
41+
(date "2026-03-01")
42+
(context "Formal verification integrity")
43+
(decision "Absolute ban on believe_me, assert_total, assert_smaller")
44+
(rationale "These undermine formal verification. If a proof cannot be
45+
completed, the type definition must be restructured."))
46+
47+
(decision "zig-0-15-build-api"
48+
(status accepted)
49+
(date "2026-03-01")
50+
(context "Zig 0.15.2 removed addStaticLibrary from Build API")
51+
(decision "Use addModule + addTest(.root_module) pattern instead of addStaticLibrary")
52+
(rationale "Zig 0.15 restructured the build system. Module-based approach
53+
is the idiomatic pattern. build.zig.zon required for package metadata."))
54+
55+
(decision "subsumes-argument-order"
56+
(status accepted)
57+
(date "2026-03-01")
58+
(context "Effect subsumption direction was initially backwards")
59+
(decision "Subsumes declared actual = Subset actual declared (actual is subset of declared)")
60+
(rationale "A query's actual effects must be a subset of its declared effects.
61+
The original direction (Subset declared actual) was backwards,
62+
meaning 'every declared effect appears in actual' which is wrong."))
63+
64+
(decision "no-erased-pattern-match"
65+
(status accepted)
66+
(date "2026-03-01")
67+
(context "Idris2 quantity-0 implicits cannot be pattern-matched at runtime")
68+
(decision "Removed hasUses function; use type system to distinguish Available from Depleted")
69+
(rationale "Erased (quantity 0) implicits exist only at type level. Any function
70+
that needs to inspect the resource count must take it as a runtime argument.")))
71+
72+
(development-practices
73+
(practice "all-modules-total"
74+
(description "Every Idris2 module uses %default total"))
75+
(practice "structural-termination"
76+
(description "All recursive functions prove termination structurally"))
77+
(practice "parser-combinator-pattern"
78+
(description "ReScript parser follows VeriSimDB's combinator style"))
79+
(practice "ipkg-typecheck"
80+
(description "Use 'idris2 --typecheck file.ipkg' for packages, not --check"))
81+
(practice "explicit-nesting"
82+
(description "Non-associative helper functions (andCheck) require explicit nested calls,
83+
not backtick infix chaining"))))
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
;; SPDX-License-Identifier: PMPL-1.0-or-later
2+
(state
3+
(metadata
4+
(version "1.0.0")
5+
(last-updated "2026-03-01")
6+
(status active))
7+
8+
(project-context
9+
(name "typeql-experimental")
10+
(purpose "Experimental type-theoretic extensions to VQL (VQL-dt++)")
11+
(completion-percentage 85))
12+
13+
(current-position
14+
(phase "initial-implementation-complete")
15+
(summary "All 37 files implemented across 6 phases. Idris2 kernel (9 modules)
16+
type-checks clean with --total and zero banned patterns. Zig FFI
17+
bridge (5 tests) passes. ReScript parser and examples written.
18+
Six extensions: linear types, session types, effect systems,
19+
modal types, proof-carrying code, quantitative type theory."))
20+
21+
(components
22+
(component "idris2-kernel"
23+
(status "complete")
24+
(description "9 Idris2 modules: Core, Linear, Session, Effects, Modal,
25+
ProofCarrying, Quantitative, Checker, Proofs. All type-check
26+
with %default total. Zero believe_me/assert_total/assert_smaller.")
27+
(completion 100))
28+
(component "rescript-parser"
29+
(status "written")
30+
(description "Extended AST (TQLAst.res) and parser (TQLParser.res) for 6 new
31+
VQL++ clauses. Follows VeriSimDB combinator patterns. Not yet
32+
build-tested (requires rescript-legacy toolchain).")
33+
(completion 70))
34+
(component "grammar-spec"
35+
(status "complete")
36+
(description "Delta EBNF extending VQL v3.0 with 6 new clause types.
37+
Documented in docs/vql-dtpp-grammar.ebnf.")
38+
(completion 100))
39+
(component "zig-ffi"
40+
(status "complete")
41+
(description "C-compatible FFI bridge skeleton. build.zig targets Zig 0.15.2.
42+
5 tests pass: empty annotations, consume_after=0, usage<consume,
43+
full valid annotations, version string.")
44+
(completion 100))
45+
(component "examples"
46+
(status "complete")
47+
(description "7 annotated .vqlpp example files covering all 6 extensions
48+
individually plus a combined maximal query.")
49+
(completion 100))
50+
(component "idris2-tests"
51+
(status "complete")
52+
(description "3 compile-time test modules: TestLinear.idr, TestSession.idr,
53+
TestQuantitative.idr. Validated by Idris2 type-checker.")
54+
(completion 100))
55+
(component "documentation"
56+
(status "complete")
57+
(description "README.adoc, DESIGN doc, type-system-spec.adoc, examples.adoc,
58+
grammar EBNF, AI manifest, machine-readable SCM files.")
59+
(completion 100)))
60+
61+
(route-to-mvp
62+
(milestone "type-kernel-complete"
63+
(description "All 9 Idris2 modules type-check with --total, zero believe_me")
64+
(completion 100))
65+
(milestone "zig-ffi-tested"
66+
(description "Zig FFI bridge compiles and all 5 tests pass on Zig 0.15.2")
67+
(completion 100))
68+
(milestone "parser-written"
69+
(description "ReScript parser written with combinator pattern from VeriSimDB")
70+
(completion 70))
71+
(milestone "parser-build-tested"
72+
(description "ReScript parser compiles and accepts all 7 example .vqlpp files")
73+
(completion 0))
74+
(milestone "integration"
75+
(description "Idris2 proofs validated against ReScript-parsed ASTs")
76+
(completion 0)))
77+
78+
(verified-results
79+
(result "idris2-typecheck"
80+
(command "idris2 --typecheck typeql-experimental.ipkg")
81+
(outcome "9/9 modules compile clean")
82+
(date "2026-03-01"))
83+
(result "zig-tests"
84+
(command "cd ffi/zig && zig build test")
85+
(outcome "5/5 tests pass")
86+
(date "2026-03-01"))
87+
(result "banned-patterns"
88+
(command "grep -rn 'believe_me|assert_total|assert_smaller' src/abi/")
89+
(outcome "zero matches (comment-only reference in Proofs.idr)")
90+
(date "2026-03-01")))
91+
92+
(implementation-notes
93+
(note "idris2-version" "Idris2 0.8.0 — ipkg uses --typecheck not --check")
94+
(note "zig-version" "Zig 0.15.2 — addModule/addTest API, no addStaticLibrary")
95+
(note "effects-subsumption" "Subsumes declared actual = Subset actual declared (flipped)")
96+
(note "erased-implicit" "Cannot pattern-match on quantity-0 implicits (removed hasUses)")
97+
(note "andCheck-nesting" "Non-associative function requires explicit nested calls"))
98+
99+
(blockers-and-issues
100+
(blocker "rescript-build"
101+
(description "ReScript parser not yet build-tested — needs rescript-legacy or
102+
equivalent toolchain. Written code follows VeriSimDB patterns.")))
103+
104+
(critical-next-actions
105+
(action "Build-test ReScript parser with rescript-legacy toolchain")
106+
(action "Test all 7 example .vqlpp files parse correctly")
107+
(action "Wire Idris2 proof results to ReScript-parsed ASTs (integration phase)")))

0 commit comments

Comments
 (0)