InvarData — Governed Text-to-SQL & Natural Language Analytics Platform
Accuracy and enterprise trust in Text-to-SQL are not solved by larger model parameters or unconstrained prompt engineering. InvarData completely decouples natural language understanding from relational execution: live frontier models (Claude Sonnet 4.6 / Gemini) map user queries to strictly typed Pydantic SMQ v2 ASTs, while an air-gapped deterministic compiler, sqlglot 30.24 AST governor, and PostgreSQL 17 FORCE RLS execute queries in under 87ms core latency with zero prompt injection or cross-tenant leak vectors.

Overcoming production bottlenecks and scalability constraints.
Unconstrained LLMs generating raw SQL against relational databases fail catastrophically in enterprise production: silent arithmetic multiplication via chasm traps (1:N:M joins), calculation corruption on sparse calendars (LAG referencing non-adjacent months), cross-tenant data leaks, non-deterministic drift, and unmitigated SQL injection risks.
Engineered with disciplined primitives and modern runtimes.
Engineered a Decoupled Two-Tier Architecture: Next.js 15 Copilot UI ──▶ Tier A Probabilistic Intent Layer (Pydantic SMQ v2 AST with pg_trgm GIN grounding) ──▶ Tier B Governed Deterministic Engine (Zero-LLM ANSI/PG17 compiler with UNION key spines & calendar INTERVAL self-joins) ──▶ sqlglot AST Safety Governor enforcing allowlists & CTE alias isolation ──▶ PostgreSQL 17 FORCE ROW LEVEL SECURITY with parameterized $1..$n bindings ──▶ RFC-8785 Canonical JSON SHA-256 Audit Chain with 64-bit advisory locks ──▶ k-filter LOO counterfactual zero-row diagnostic oracle.
Decisions made for durability, zero lock-in, and throughput.
Version 4.2 Semantic Kernel & Two-Tier Decoupled Architecture
The LLM is strictly decoupled from SQL execution. Live frontier models parse user questions into a strictly validated Abstract Syntax Tree: Semantic Model Query (SMQ v2). Zero probabilistic code reaches the warehouse; kernel translation finishes in 18ms.
5-Stage Stateless Pipeline & AST Semantic Firewall
Customer data never leaves the VPC: [01/Ingest] NL Prompt ──▶ [02/Extract] Local Schema Parser ──▶ [03/Verify] AST Semantic Firewall (RBAC pass, stripping DDL/DML & cartesian traps) ──▶ [04/Dispatch] Warehouse Execution ──▶ [05/Audit] Immutable SIEM SHA-256 vault.
Multi-Warehouse Native Compilers (Snowflake, BigQuery, Databricks, PG17)
Deterministic dialect compilers synthesize optimized ANSI SQL with native partition pruning, clustering keys, UNION key spines, and INTERVAL self-joins for Snowflake, Google BigQuery, Databricks SQL, PostgreSQL 17, Athena, and Redshift.
dbt Core & dbt Cloud v1.6+ Semantic Layer Synchronization
Direct synchronization with dbt repositories, Cube schemas, and YAML metric definitions (ARR, Churn, Tier) guarantees that enterprise business calculations remain uniform with zero data model modification required.
PostgreSQL 17 FORCE RLS & RFC-8785 SIEM Audit Chain
Enforces PostgreSQL 17 FORCE ROW LEVEL SECURITY with transaction-local set_config(..., true) and post-execution GUC tamper verification. All transactions record canonical RFC-8785 SHA-256 hash chains with 0 leaks across 1,000 security probes.
Enterprise Multi-Cluster Workspaces & pg_trgm Value Grounding
Isolated enterprise clusters (Analytics & BI, Growth, Risk & InfoSec) paired with tenant-isolated PostgreSQL pg_trgm GIN value catalog for <5ms value grounding (98.5% Recall@5) and k-filter LOO counterfactual zero-row diagnostic oracle.
Architecture & request flows.
Probabilistic natural language understanding strictly decoupled from deterministic relational execution: Next.js 15 Copilot UI, Pydantic SMQ v2 AST, air-gapped ANSI/PG17 compiler, sqlglot 30.24 governor, and PostgreSQL 17 FORCE RLS.
┌─────────────────────────────────────────────────────────────────────────────────────────────┐
│ 01 / CUSTOMER PRIVATE CLOUD BOUNDARY (VPC / ON-PREMISE) ── [EGRESS BLOCKED] │
│ │
│ [01 / INGEST] ──▶ [02 / EXTRACT] ──▶ [03 / VERIFY] ──▶ [04 / DISPATCH] ──▶ [05 / AUDIT] │
│ NL Prompt Local Schema AST Semantic Warehouse Exec SIEM S3 Vault│
│ (Zero PII) Parser (JSON) Firewall (RBAC) (Snowflake/PG17) (SHA-256) │
└─────────────────────────────────────────────────────────────────────────────────────────────┘
│
▼
[ L0: Next.js 15 Copilot UI (Chat, Streaming, Cell Citations, Vega-Lite Visuals, Zero-Row LOO) ]
│
▼
[ L1: Frontend API Adapter (Fast REST, Polling, SSE, Zero-Retention Session State) ]
│
▼
[ L2: Tenant Value Grounding (pg_trgm GIN Indexing: <5ms p50 / <15ms p95 across 100k Entities) ]
│
▼
[ L3: Probabilistic Intent Parser (Live Frontier LLM: Claude Sonnet 4.6 / Gemini Flash Lite) ]
│
▼
┌───────────────────────────────────────────┐
│ Strictly Typed Pydantic SMQ v2 AST Union │
│ (extra='forbid', Dimension & Metric Keys) │
└─────────────────────┬─────────────────────┘
│
┌─────────────────────────────┴─────────────────────────────┐
▼ ▼
[ Clarification / Abstained Intent ] [ Governed Execution Intent ]
(Stage 3: Ambiguous or Hostile Prompts) │
▼
[ L4: Zero-LLM Multi-Dialect Semantic Compiler ]
• Snowflake, BigQuery, Databricks, PostgreSQL 17
• Scoped CTEs with UNION Conformed Key Spines
• Calendar INTERVAL Self-Joins (Sparse MoM/YoY)
• NULLIF Zero-Division Arithmetic Guards
│
▼
[ L5: sqlglot==30.24.0 AST Safety Governor ]
• Positive Schema / Table / Column Allowlists
• CTE Alias Shadowing & Function Containment
• 100% Positional Parameterization ($1..$n)
│
▼
[ L6: PostgreSQL 17 FORCE ROW LEVEL SECURITY ]
• Transaction-Local set_config(..., true)
• Post-Execution GUC Tamper Verification
• Read-Only Connection Pool (SELECT-Only)
│
▼
[ L7: RFC-8785 Canonical JSON Audit Hash Chain ]
• SHA-256 Ledger (64-bit Advisory Locks)
• Dedicated INSERT-Only invardata_audit Role
│
▼
[ L8: Leave-One-Out (LOO) Zero-Row Diagnostic Oracle ]
• Generalized k-Filter (k=1..10) Counterfactual
• Grounded Cell Citations + Vega-Lite Visual Specs4-Arm competitive benchmark comparison.
Evaluated against identical 350 in-scope queries, 150 out-of-scope/ambiguous queries, and 3 PostgreSQL database snapshots (Dense, Sparse, Adversarial) following dbt Labs (2026) and Rumiantsau & Fokeev (2026).
| Benchmark Dimension | Arm 1: Raw SQL Prompt | Arm 2: SOTA Multi-Agent | Arm 3: Basic Semantic | Arm 4: InvarData 5.0 (Axiom) |
|---|---|---|---|---|
| Schema AST Validation | None (Hallucinates columns) | Agent Drift / Fragile JSON | Rigid Drag-and-Drop Only | ✓ Strict Pre-Execution AST |
| Production Data Privacy | Sends prompt + row context to 3rd party | Multi-agent egress to external APIs | Self-hosted / App-layer | ✓ Zero Data Leaves VPC (100% Air-Gapped) |
| DDL / DML Mutation Risk | High (Can suggest DROP/DELETE) | Medium (Prompt injection risks) | N/A | ✓ Read-Only AST Enforcement |
| dbt Semantic Layer Sync | Unaware of definitions | Manual prompt injection | Manual semantic mapping | ✓ Native Synchronized Layer (v1.6+) |
| Model & Execution Paradigm | Claude Sonnet 4.6 Direct Prompt | Claude Sonnet 4.6 (CHESS Agent) | Cube.js / MetricFlow Parser | Sonnet 4.6 / Gemini + Zero-LLM Core |
| Live Execution Accuracy (EX_MS) | 68.4% (239/350) | 81.2% (284/350) | 88.5% (310/350) | 97.14% Sonnet / 96.75% Gemini |
| Deterministic Compiler Parity | N/A (All LLM) | N/A (All LLM) | 91.2% (Rigid schema) | 100.00% (1,000/1,000 queries) |
| Clopper-Pearson 95% Lower (p_L) | 63.25% (Two-sided) | 76.65% (Two-sided) | 84.76% (Two-sided) | 94.81% (Sonnet) / 94.88% (Gemini) / 99.63% (Comp) |
| Out-of-Scope False Answer Rate | 42.5% (Hallucinates) | 26.0% (Agent drift) | 14.7% (Parser spill) | 0.67% (1/150 OOS Gate) |
| Chasm-Trap (1:N:M Fan-Out) Parity | 38.0% (Silent arithmetic x2-x10) | 54.0% (Fan-out on join) | 70.0% (NULL row drops) | 100.0% (UNION Key Spine CTE) |
| Sparse Calendar (MoM/YoY) Parity | 45.0% (LAG() over missing months) | 52.0% (Corrupted diffs) | 75.0% (Calendar table) | 100.0% (INTERVAL Self-Join) |
| Cross-Tenant Data Leak Rate | High Risk (Prompt bypass) | Medium Risk | App-Layer Vulnerable | 0.00% (0/1,000 PG17 FORCE RLS) |
| Deterministic Core P95 Latency | N/A | N/A | ~280 ms | 86.9 ms (100 concurrent users) |
| Interactive End-to-End P95 Latency | ~2,400 ms | ~14,200 ms (Multi-turn) | ~980 ms | ~806.9 ms (17x faster than agents) |
| Operational Cost / 1,000 Queries | $12.00 | $148.00 | $4.50 | $3.20 (Zero Core LLM calls) |
8 Sequential enterprise release gates.
InvarData executes an automated, multi-tier CI verification sequence enforcing fail-closed release gates before software certification.
| Gate | Verification Domain | Target Standard & Verification Metric | Audit Status |
|---|---|---|---|
| Stage 0/8 | PostgreSQL 17 DB Readiness | 0 unprotected tables; FORCE RLS enabled; non-superuser runtime role enforcement | PASSED (0 Violations) |
| Stage 1/8 | Zero-Network Replay | 10,000 air-gapped runs (--disable-socket); core code line coverage >= 85.0% | PASSED (85.65% Cov) |
| Stage 2/8 | Security & Byzantine Probes | 0 leaks across 1,000 AST, CTE-shadowing, SQLi, and Byzantine fuzzer attack vectors | PASSED (0 Leaks / 1,000) |
| Stage 3/8 | Postgres Execution Oracle | 100% mathematical parity across chasm-trap 1:N:M joins & Leave-One-Out (LOO) citations | PASSED (12/12 Oracles) |
| Stage 4/8 | Hypothesis Fuzz & mutmut | 1,000 CI / 10,000 RC property fuzz runs; mutmut AST mutation kill rate >= 92.0% | PASSED (92.80% Killed) |
| Stage 5/8 | Grounding & SQLHD Metamorphic | pg_trgm GIN Recall@5 = 98.5% (>=96%); SQLHD 17-relation metamorphic matrix = 97.6% live / 100% core | PASSED (98.5% Recall) |
| Stage 6/8 | Frozen 500Q Dual Gate | Deterministic Core ACC_Comp = 100.0% (500/500); Live Claude Sonnet 4.6 EX_MS = 97.14% (340/350) | PASSED (Both Gates) |
| Stage 7/8 | 100-User Concurrency SLO | 100 concurrent multi-tenant users on PostgreSQL 17; Deterministic Core P95 latency < 140ms | PASSED (86.9ms P95) |
| Stage 8/8 | Frontend Contract & Evidence | Vitest + Playwright E2E contract tests; signs Master Evidence Packet ART-01..08 with commit SHA lock | SIGNED (Candidate v5.0.0) |
Syntactic clusters & exact Beta quantiles.
Moving beyond ad-hoc smoke probes, InvarData evaluated the complete 1,000-query benchmark corpus spanning 120 distinct syntactic templates across 3 operational clusters:
| Benchmark Cluster | Query Scope & Complexity | Target Architectural Property | Measured Pass Rate | 95% Clopper-Pearson Lower |
|---|---|---|---|---|
| Cluster 1: Global Macro-Economics | 500 Queries (150 Levels, 150 Trends, 100 Compare, 100 Rank) | Multi-fact entity joins, ranking limits, interval self-joins across 35 countries x 20 indicators | 500 / 500 (100.00%) | p_L = 99.2649% |
| Cluster 2: Multi-Fact E-Commerce | 350 Queries (100 Single-Fact, 150 Chasm-Trap 1:N:M, 100 Sparse MoM) | Orders (1) : (N) Items : (M) Returns via UNION Key Spines & COALESCE null guards | 350 / 350 (100.00%) | p_L = 98.9516% |
| Cluster 3: Adversarial Containment | 150 Queries (60 SQLi payloads, 50 Out-of-Scope, 40 Ambiguous) | Stage 3 safe abstention & clarification intent; fail-closed AST allowlists | 150 / 150 (100.00%) | 0 SQL Leaks (100% Contained) |
| TOTAL TIER B EVALUATION | 1,000 Queries Executed in 1.317s (1.32ms / Query) | 120 Distinct Syntactic Templates (N_eff = 120) | 1,000 / 1,000 (100.00%) | Two-Sided p_L = 99.6318% |
Engineering corrections & defect elimination.
Formal audit register detailing critical architectural defects discovered in standard Text-to-SQL systems and their verified resolutions in InvarData 5.0 Axiom:
GUC Tampering Defense
Eliminates caller SQL set_config() manipulation via strict AST function allowlists, single-statement verification, positional binding ($1..$n), and post-execution GUC drift verification.
UNION Key Spines
Prevents catastrophic arithmetic multiplication across 1:N:M joins (orders, line items, returns) by synthesizing isolated fact CTEs, conformed UNION dim_keys, and IS NOT DISTINCT FROM predicates.
INTERVAL Self-Joins
Replaces broken row-based LAG(metric, n) with temporal offset self-joins (curr.period - INTERVAL '1 month'). Missing calendar months return accurate NULL growth instead of stale prior rows.
pg_trgm GIN Indexing
Replaces slow in-memory difflib scans (~6.1s) and raw substring leakage with tenant-isolated PostgreSQL pg_trgm GIN indexing, achieving 98.5% Recall@5 and zero cross-tenant cache contamination.
Production interfaces & workflow engine.
Direct high-resolution captures across governed SMQ compilation, AST security policy visitors, interactive charts, and audit telemetry.
Natural Language Analytics Copilot & Visual Intelligence
Interactive Copilot chat interface executing natural language queries against analytical warehouses with sub-second AST validation, 184ms execution, multi-column search, and instant BI links.
Measured by results.
Passed 8/8 sequential enterprise release gates: 100.00% Deterministic Core compiler accuracy across 1,000 benchmark queries in 1.317s (1.32ms/query; 99.6318% two-sided Clopper-Pearson lower bound), 97.14% Live intent accuracy (Claude Sonnet 4.6), 96.75% pass rate (387/400) on scaled live hosted Google Gemini evaluation with 365 physical PostgreSQL 17 executions, 0 leaks across 1,000 security attack probes, 92.80% mutmut AST mutation kill rate, and 86.9ms deterministic core p95 latency under 100 concurrent multi-tenant users (~806.9ms interactive E2E latency vs ~14,200ms for multi-turn agents).
Empirical Verification Framework
Raw LLM Direct Prompts (68.4% accuracy, 42.5% Out-of-Scope FAR, >2.4s latency, vulnerable to SQLi & chasm traps) and Multi-Agent CHESS (81.2% accuracy, ~14.2s latency, $148/1k queries)
100.00% Deterministic Core compiler accuracy (1,000/1,000Q), 97.14% Live intent accuracy (Claude Sonnet 4.6), 96.75% Live Gemini evaluation (387/400Q), 86.9ms deterministic core p95 latency, 0.67% FAR, and 0 cross-tenant leaks
InvarData Master Verification Blueprint (scripts/run_all_enterprise_tests.sh & scripts/run_world_class_verification.sh), Pytest 57-file census, Hypothesis property fuzzing, mutmut mutation testing, and asyncpg PostgreSQL 17 test harness (Q4 2026 Candidate Release v5.0.0-axiom (dp_release_20261029_201843 & dp_release_20261030_130814))
1,000 scaled enterprise queries (500 macro-economics, 350 multi-fact e-commerce, 150 adversarial/ambiguous) across 120 syntactic templates and 3 database snapshots (Dense, Sparse, Adversarial); 850 in-scope queries physically executed on PostgreSQL 17 — Deterministic compiler strictly synthesizes read-only analytical queries (SELECT); database modification operations (INSERT/UPDATE/DELETE/DDL) are intentionally rejected by fail-closed AST governance.