HeadlinesBriefing favicon HeadlinesBriefing.com

sqlsure: Deterministic Semantic Inspection for SQL

Hacker News •
×

sqlsure is a semantic inspector designed to catch logic errors that standard linters and databases miss, such as fan-out double-counting and additivity violations. Unlike LLM-based reviews, it uses deterministic dictionary lookups to validate queries against a semantic model in 0.1 ms. The tool identifies errors like FANOUT and CHASM joins, where one-to-many relationships multiply results, and ADDITIVITY errors, such as summing rates or averages.

The engine generates rulebooks by introspecting dbt manifest.json, SQLite PRAGMAs, or information_schema. It operates entirely offline without database connectivity or telemetry, parsing query text to ensure security. In audits of the BIRD and Spider benchmarks, sqlsure flagged 45 errors across 2,568 expert-written queries with zero false alarms, including a BIRD gold answer that was provably wrong by 8x.

Developers can integrate sqlsure as a CI gate, a library for text-to-SQL frameworks, or an MCP server for AI agents. This creates a self-repair loop where agents draft, check, and fix SQL verbatim. By treating semantic rules as enforceable constraints rather than suggestions, it prevents silent data corruption in AI-generated analytics.