HomePlaygroundExpressionsDocsDriversBlogStatusRoadmapChangelog GitHub

๐ŸŽฏ Vision

"If it compiles, the query is correct."

The Evolution

Era 1 SQL Strings "Trust me, this string is safe"
Era 2 ORMs "Safe, but locked to one language"
Era 3 Query Builders "Safe, but still generates strings"
Era 4 SQLx "Compile-time checked SQL โ€” the breakthrough"
Era 5 QAIL "Pure AST that compiles directly to wire protocol"
Acknowledgment: SQLx pioneered compile-time SQL validation in Rust and remains the gold standard for SQL-based database access. QAIL builds on this foundation by eliminating strings entirely โ€” a natural evolution, not a replacement.

โœ… Completed

Done 1. First-Class Relations v0.16.0

Phase 1 ยท Runtime Registry
  • โœ“ ref: syntax in schema.qail
  • โœ“ RelationRegistry for runtime lookup
  • โœ“ Qail::join_on("table") โ€” string-based API
Phase 2 ยท Fully Typed Codegen
  • โœ“ build.rs generates schema_gen.rs with typed structs
  • โœ“ TypedColumn<T> with Rust type mapping (SQLโ†’Rust)
  • โœ“ Table structs implement Table trait
Phase 3 ยท Logic-Safe Relations
  • โœ“ RelatedTo<T> trait with bidirectional impls from ref:
  • โœ“ TypedQail<T> + join_related() โ€” compile error if unrelated
Phase 4 ยท Compile-Time Data Governance
  • โœ“ protected keyword in schema.qail
  • โœ“ TypedColumn<T, P> with Public / Protected markers
  • โœ“ Compile-time policy enforcement via type system

Done 2. SaaS Multi-Tenant Isolation (RLS) v0.15.6

Phase 1 ยท Driver-Level Context
  • โœ“ RlsContext struct โ€” operator_id, agent_id, is_super_admin
  • โœ“ PgDriver.set_rls_context(ctx) โ€” calls set_config()
Phase 2 ยท Pool-Level RLS Acquisition
  • โœ“ PgPool.acquire_with_rls(ctx) โ€” acquire + set in one call
  • โœ“ PooledConnection auto-clears RLS on Drop โ€” no stale tenant leaks
Phase 3 ยท Policy Definition API
  • โœ“ RlsPolicy builder + AlterOp::ForceRowLevelSecurity
  • โœ“ SQL transpiler for ENABLE + FORCE + CREATE POLICY
Phase 4 ยท AST-Level Query Injection
  • โœ“ TenantRegistry auto-detects tables with operator_id
  • โœ“ Qail::with_rls(ctx) โ€” GETโ†’filter, ADDโ†’payload injection
  • โœ“ Super admins + unregistered tables bypass automatically

Done 3. Schema DDL โ€” Full PostgreSQL Coverage v0.18.5

Phase 1 ยท Core Objects
  • โœ“ CREATE/DROP EXTENSION, ENUM, SEQUENCE
  • โœ“ CREATE/ALTER/DROP TABLE with all column properties
  • โœ“ Multi-column foreign keys, expression indexes
Phase 2 ยท Programmable Objects
  • โœ“ Views + Materialized Views
  • โœ“ Functions (PL/pgSQL) + Triggers
  • โœ“ GRANT/REVOKE, COMMENT ON, enable_rls / force_rls
Phase 3 ยท RLS Policy Definition
  • โœ“ Policy syntax in .qail โ€” permissive + restrictive
  • โœ“ Per-command scope: ALL, SELECT, INSERT, UPDATE, DELETE
  • โœ“ Role targeting: to app_user

Done 4. Database Introspection โ€” Fully AST-Native v0.18.5

Phase 1 ยท Core Introspection
  • โœ“ qail pull --url postgres://... โ†’ schema.qail
  • โœ“ Tables, columns, types, defaults, constraints, indexes
  • โœ“ FKs with actions (CASCADE, SET NULL, RESTRICT, etc.)
Phase 2 ยท Programmable Objects
  • โœ“ Views, materialized views, functions, triggers
  • โœ“ Grants, sequences, enums, extensions
Phase 3 ยท Zero Raw SQL
  • โœ“ RLS policies via Qail::get("pg_policies")
  • โœ“ policy_parser module for SQLโ†’Expr conversion
  • โœ“ Zero raw SQL in introspection โ€” every query is AST-native

Done 5. Migration Engine v0.15.9

Phase 1 ยท Schema Diffing
  • โœ“ diff_schemas() โ€” old vs new comparison
  • โœ“ AlterOp enum with intent-aware hints: rename, transform, drop confirm
  • โœ“ FK-ordered table creation (parent before child)
Phase 2 ยท CLI Commands
  • โœ“ qail migrate apply, create, status, reset, up, down
  • โœ“ qail diff --live โ€” schema drift detection
Phase 3 ยท Enterprise Features
  • โœ“ Shadow migrations โ€” COPY streaming, safe promote
  • โœ“ MigrationClass: Reversible, DataLosing, Irreversible
  • โœ“ qail migrate analyze โ€” scans codebase for affected queries

Done 6. Multi-Driver Unified AST v0.14.13

5,000 q/s
Prepared Statements
1.3M q/s
10-conn Pool
13%
Faster than Qdrant SDK
  • โœ“ PostgreSQL โ€” zero-copy wire protocol, SCRAM-SHA-256, TLS, COPY streaming
  • โœ“ Qdrant โ€” zero-copy gRPC, HTTP/2 batch pipelining, connection pool
  • โœ“ Redis โ€” native RESP3 protocol, Qail::redis_get() / redis_set()

Done 7. CLI Toolchain v0.15.7

  • โœ“ qail init โ€” project scaffold (supports --url, --deployment)
  • โœ“ qail pull โ€” live DB โ†’ schema.qail (fully AST-native)
  • โœ“ qail exec โ€” type-safe execution (--json, --tx)
  • โœ“ qail diff โ€” schema comparison + drift detection
  • โœ“ qail types โ€” schema.qail โ†’ Rust typed schema module
  • โœ“ qail check โ€” validate .qail syntax
  • โœ“ qail worker โ€” hybrid outbox daemon (PG โ†’ Qdrant sync)
  • โœ“ LSP server (qail-lsp) for editor integration

๐Ÿ”ฎ Future

Next 8. Schema-as-Proof System

"The schema becomes a type parameter. The compiler becomes the theorem prover."
Phase 1 ยท Column Existence Proof
  • โ—‹ schema.qail โ†’ codegen โ†’ Schema trait with associated types
  • โ—‹ Qail<S: Schema> carries schema as phantom type parameter
  • โ—‹ Column selection proven at compile time โ€” no proc macros, no external provers
Phase 2 ยท Type-Safe Filters
  • โ—‹ Filter comparisons proven against column types
  • โ—‹ TypedFilter<S> ensures operand type matches column type
Phase 3 ยท Join Validity Graph
  • โ—‹ FK relationship graph encoded at type level
  • โ—‹ N-way joins proven valid via RelatedTo<T> chain
Phase 4 ยท RLS Proof Witness
  • โ—‹ RLS-protected tables get marker trait
  • โ—‹ Queries without .with_rls() on protected tables = compile error
  • โ—‹ RlsProof<T> witness type provided by middleware
"Data leakage becomes a type error, not a security incident."

Planned 9. Native Versioning (Data Virtualization)

"GitHub for Databases" โ€” branching at the application layer.
  • โ—‹ Gateway middleware with X-Branch-ID header
  • โ—‹ Row-level branching (WHERE _branch_id = ?)
  • โ—‹ Copy-on-Write strategy for writes
  • โ—‹ CLI: qail branch create, qail checkout

Planned 10. Infrastructure-Aware Compiler

Verify external resources at compile time.
  • โ—‹ schema.qail extensions: bucket, queue, topic
  • โ—‹ build.rs validates resources exist in Terraform/AWS/GCP
  • โ—‹ Compile error if referencing non-existent infra

๐Ÿ“Š Current Status

Section Status Version
1. First-Class Relations โœ… Complete (4/4) v0.16.0
2. SaaS RLS Isolation โœ… Complete (4/4) v0.15.6
3. Schema DDL Coverage โœ… Complete (3/3) v0.18.5
4. Database Introspection โœ… Complete (3/3) v0.18.5
5. Migration Engine โœ… Complete (3/3) v0.15.9
6. Multi-Driver AST โœ… Complete v0.14.13
7. CLI Toolchain โœ… Complete v0.15.7
8. Schema-as-Proof โณ Planned โ€”
9. Data Virtualization โณ Planned โ€”
10. Infra-Aware Compiler โณ Planned โ€”

๐Ÿ’ก Philosophy

"QAIL eliminates SQL strings entirely. The builder API (Qail::get(), Qail::add()) is the ONLY way to construct queries. No parsing at runtime, no strings anywhere."