freshcrate
Skin:/
Home > Uncategorized > typedqliser

typedqliser

Add formal type safety (10 levels, dependent/linear/session types) to any query language โ€” SQL, GraphQL, Cypher, SPARQL, VQL

Why this rank:Recent releaseHealthy release cadenceStrong adoption

Description

Add formal type safety (10 levels, dependent/linear/session types) to any query language โ€” SQL, GraphQL, Cypher, SPARQL, VQL

README

TypedQLiser

What Is This?

TypedQLiser adds formal type safety to any query language โ€” SQL, GraphQL, Cypher, SPARQL, KQL, VCL, or anything else โ€” without modifying the database.

It sits in front of your database as a compile-time type checker. Queries go in, TypedQLiser proves properties about them (no nulls where you donโ€™t expect them, no injection, no type mismatches, resources consumed correctly, transaction protocols followed), and then passes the original query through unchanged. The database never knows itโ€™s there.

This is the highest priority project in the -iser family.

The Problem

Every database has a query language. None of them have deep type safety:

  • SQL: Runtime type errors, null surprises, injection, no resource tracking

  • GraphQL: Schema types exist but no dependent types, no linearity, no effects

  • Cypher: Pattern matching with no formal verification

  • SPARQL: RDF types are stringly-typed at best

  • VCL: VeriSimDBโ€™s query language has VCL-DT/VCL-total extensions, but theyโ€™re VCL-specific

TypedQLiser makes the type safety portable across all query languages.

The 10 Type Safety Levels

Derived from TypeLL's type theory and VCL-total's 10-level hierarchy:

Established (Levels 1-6)

Level Name What It Proves

1

Parse-time safety

Query is syntactically valid before reaching the database

2

Schema-binding safety

All referenced tables/fields/types exist in the schema

3

Type-compatible operations

No comparing strings to integers, no invalid casts

4

Null-safety

Every nullable path is explicitly handled; no surprise nulls

5

Injection-proof safety

No user input can alter query structure (proven, not escaped)

6

Result-type safety

Return type is known at compile time; no any or unknown

Research (Levels 7-10)

Level Name What It Proves

7

Cardinality safety

Query returns exactly N rows, at-most-one, or non-empty (proven)

8

Effect-tracking safety

Know exactly what side-effects a query produces (reads, writes, deletes)

9

Temporal safety

Time-dependent queries are valid at the point of execution

10

Linearity safety

Resources (connections, cursors, transactions) consumed exactly once

How It Works

Your application
      โ”‚
      โ–ผ
  typedqliser.toml  โ”€โ”€โ–บ TypedQLiser CLI
      โ”‚                      โ”‚
      โ”‚         โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
      โ”‚         โ”‚            โ”‚            โ”‚
      โ–ผ         โ–ผ            โ–ผ            โ–ผ
  Query      Schema      Idris2        Target
  Parser     Loader      Type Kernel   Language
  (per-lang) (introspect)  (proofs)     Plugin
      โ”‚         โ”‚            โ”‚            โ”‚
      โ””โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”˜            โ”‚            โ”‚
           โ–ผ                 โ–ผ            โ”‚
      Annotated AST โ”€โ”€โ–บ Type Check โ—„โ”€โ”€โ”€โ”€โ”€โ”˜
           โ”‚                 โ”‚
           โ”‚            โ”Œโ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”
           โ”‚            โ”‚         โ”‚
           โ–ผ            โ–ผ         โ–ผ
      Original      Proof      Error
      Query         Certificate Report
      (unchanged)   (.proof)   (if fails)

Key insight: the original query passes through to the database unchanged. TypedQLiser is a compile-time tool, not a query rewriter. The database sees exactly what it would have seen without TypedQLiser. This means:

  • No performance overhead at runtime

  • No compatibility issues with database versions

  • No risk of query transformation bugs

  • Works with any database that speaks the target query language

Supported Query Languages

TypedQLiser uses a plugin architecture. Each query language gets a parser plugin:

Language Databases Max Level Today Plugin Status

SQL

PostgreSQL, MySQL, SQLite, MSSQL, Oracle

6

Priority

GraphQL

Any GraphQL API

6

Priority

Cypher

Neo4j, Memgraph, AGE

4

Planned

SPARQL

Any RDF triplestore

4

Planned

VCL

VeriSimDB

10

Planned (via VCL-total)

KQL

Azure Data Explorer, Kusto

4

Planned

GQL

ISO GQL databases

4

Planned

FQLDT

Lithoglyph

10

Planned (dependent types native)

Custom

User-defined grammar

varies

Plugin API

The Manifest

[typedql]
name = "my-api-queries"
# Which query language to type-check
language = "sql"
# Maximum type safety level to enforce (1-10)
level = 6
# How to load the database schema
schema-source = "introspect"   # introspect | file | inline

[database]
# Target database for schema introspection
target-db = "postgresql"
connection-string = "postgres://localhost/mydb"

[paths]
# Where to find queries to type-check
queries = ["src/**/*.sql", "src/**/*.rs"]
# How queries are embedded: standalone files, string literals, or tagged templates
embedding = "string-literal"   # standalone | string-literal | tagged-template

[output]
# What to produce
proof-certificates = true      # .proof files alongside queries
error-format = "gcc"           # gcc | json | sarif | human
ci-mode = false                # true = exit code 1 on type errors

[levels]
# Fine-grained control over which levels to enforce vs warn
enforce = [1, 2, 3, 4, 5, 6]
warn = [7, 8]
skip = [9, 10]

Architecture

Idris2 Type Kernel (src/abi/)

The core of TypedQLiser is an Idris2 type kernel that encodes the 10 levels as dependent types. Each level is a proof obligation โ€” the kernel either constructs a proof term (query is safe at that level) or produces a counterexample (hereโ€™s how it could fail).

Key proofs: * ParseSafe: parse(q) = Right ast (total parser, no panics) * SchemaBound: โˆ€ ref โˆˆ ast. ref โˆˆ schema (all references resolve) * TypeCompat: โˆ€ op โˆˆ ast. types(op.lhs) โ‰ก types(op.rhs) (no type mismatches) * NullSafe: โˆ€ path โˆˆ ast. nullable(path) โ†’ handled(path) (null paths covered) * InjectionFree: โˆ€ param โˆˆ ast. param โˆˆ Parameters (no string interpolation) * ResultTyped: typeof(execute(q, schema)) = T (return type known) * CardinalitySafe: |execute(q)| โˆˆ {0..1, 1, 1..n, n} (row count bounded) * EffectTracked: effects(q) โІ declared_effects (no undeclared side-effects) * TemporalSafe: valid_at(q, now()) = True (time-dependent predicates hold) * LinearSafe: consumed(resources(q)) = exactly_once (no leaks, no double-use)

Zig FFI (ffi/zig/)

C-ABI bridge between the Idris2 type kernel and the Rust CLI. Handles proof serialisation and AST marshalling.

Plugin Architecture (src/plugins/)

Each query language is a plugin implementing the QueryLanguagePlugin trait:

pub trait QueryLanguagePlugin: Send + Sync {
    /// Parse a query string into a typed AST.
    fn parse(&self, query: &str) -> Result<QueryAst>;

    /// Load schema from the target database.
    fn load_schema(&self, config: &DatabaseConfig) -> Result<Schema>;

    /// Extract queries from source files (for embedded queries).
    fn extract_queries(&self, source: &str, embedding: Embedding) -> Result<Vec<LocatedQuery>>;

    /// Language-specific type rules (e.g., SQL's NULL semantics vs GraphQL's).
    fn type_rules(&self) -> &TypeRules;

    /// Reconstruct the original query from the AST (for pass-through).
    fn reconstruct(&self, ast: &QueryAst) -> Result<String>;
}

Quick Start

# Install
cargo install typedqliser

# In your project, create typedqliser.toml (see above)
typedqliser init --language sql --database postgresql

# Type-check all queries in your project
typedqliser check

# Type-check a single query
typedqliser check --query "SELECT * FROM users WHERE id = $1"

# Generate proof certificates
typedqliser check --proofs

# CI mode (exit 1 on errors)
typedqliser check --ci

# Show what level each query achieves
typedqliser info

Relationship to TypeLL, VCL-total, and the -iser Family

  • TypeLL provides the type theory (10 levels, type kernel, verification protocol)

  • VCL-total applies those levels specifically to VeriSimDBโ€™s VCL

  • TypedQLiser makes them portable to any query language

  • TypedQLiserโ€™s Idris2 kernel can use TypeLL as a shared dependency

  • VCL-total becomes the VCL plugin within TypedQLiser

Status

Pre-alpha. Architecture defined, plugin trait designed, Idris2 proof obligations specified. SQL and GraphQL plugins are priority implementations.

This is the #1 priority -iser project.

License

SPDX-License-Identifier: PMPL-1.0-or-later

Release History

VersionChangesUrgencyDate
main@2026-06-02Latest activity on main branchHigh6/2/2026
0.0.0No release found โ€” using repo HEADHigh4/11/2026

Dependencies & License Audit

Loading dependencies...

Similar Packages

ponyiserWrap concurrent code in Pony reference capabilities for data-race freedommain@2026-06-02
tlaiserExtract state machines from code and model-check with TLA+/PlusCalmain@2026-06-02
oblibeniserMake operations reversible and auditable via Oblรญbenรฝmain@2026-06-02
verisimiserAugment any database with VeriSimDB octad capabilities โ€” drift detection, provenance, temporal versioning, modality overlaysmain@2026-06-02
phronesiserAdd provably safe ethical constraints to AI agents via Phronesismain@2026-06-02

More from hyperpolymath

verisimiserAugment any database with VeriSimDB octad capabilities โ€” drift detection, provenance, temporal versioning, modality overlays
ponyiserWrap concurrent code in Pony reference capabilities for data-race freedom
phronesiserAdd provably safe ethical constraints to AI agents via Phronesis
otpiserGenerate OTP supervision trees and fault-tolerance scaffolding

More in Uncategorized

llama.cppLLM inference in C/C++
modal-clientSDK libraries for Modal
anolisaANOLISA - Agentic Nexus Operating Layer & Interface System Architecture