Governed decision
- One typed decision per request: answer, clarification or block
- Model-visible governed context, evaluator-only truth kept separate
- Authority and policy blocks that never reach the SQL runtime
A governed one-shot Text-to-SQL system and execution-based benchmark where the model proposes a single typed decision and deterministic software owns SQL admission and read-only execution.
The model proposes. Deterministic software decides what may execute.
A model can produce SQL that is syntactically fine and still unauthorized, unbounded or semantically wrong. DecisionSQL keeps the model’s proposal and the authority to execute separate, and evaluates governance apart from query execution because some requests should refuse SQL entirely.
Correctness is decided by running the query against changing database states, not by comparing it to a reference string. The benchmark measures first-pass behavior under a one-shot contract, so model decisions and server enforcement both stay visible.
DecisionSQL covers the path from a governed request to a bounded result: one typed decision, a deterministic admission chain, and execution-based scoring across counterfactual states.
Only an ANSWER + SQL submission enters the SQL runtime. The selected SQL then crosses each stage below before a restricted reader runs it, and the executor never accepts SQL directly from the model, the normalizer or the evaluator.
The model receives the question plus a governed context and emits exactly one decision. Runtime routing follows the parsed submission, not evaluator truth, so only ANSWER + SQL enters the SQL runtime.
sqlglot parses the selected SQL and the policy enforces one read-only statement, governed object access, function restrictions and complexity limits before anything else runs.
A GrainSafetyValidator detects parent-measure fanout, where a join to several child rows can silently multiply a SUM. Server-owned metadata, not the model, owns that contract.
For the supported additive-parent, declared 1:N shape a deterministic normalizer preaggregates on the child side. Normalized SQL is never trusted automatically; it re-passes parse, policy and post-grain validation with no raw unsafe fallback.
PostgreSQL EXPLAIN runs on a deterministically analyzed state, and a frozen cost gate rejects SQL above the benchmark's max rows or max cost before execution.
Execution requires an accepted immutable QueryPlan issued by the SQL safety service. A restricted reader runs it under a read-only transaction, reader role, statement timeout and bounded result rows.
The model owns the first-pass decision and, when it answers, the proposed SQL. It does not own authorization, physical schema truth, grain semantics or the right to execute. Deterministic software owns that half.
| The model owns | Deterministic software owns |
|---|---|
|
|
Runtime routing follows the parsed submission, not evaluator truth. An ANSWER + SQL runs even when the truth is AMBIGUOUS; the harness records that runtime outcome separately instead of skipping the branch.
A governed context feeds one typed decision. Only ANSWER + SQL enters the admission chain — parse, policy, grain safety, narrow normalization, EXPLAIN, a cost gate and an accepted QueryPlan — before restricted read-only execution. A separate evaluator scores the outcome off the request path against counterfactual states.
Runtime routing is driven by the parsed model submission, not by evaluator truth; only ANSWER + SQL reaches the SQL runtime.
Analytics Request with governed context Model-Visible Governed Context. Model-Visible Governed Context one-shot generation One-Shot LLM Decision. One-Shot LLM Decision enters SQL runtime ANSWER + SQL. One-Shot LLM Decision governance outcome NEEDS_CLARIFICATION. One-Shot LLM Decision governance outcome BLOCKED_AUTHORITY. One-Shot LLM Decision governance outcome BLOCKED_POLICY.
The executor never accepts SQL directly from the model, the normalizer or the evaluator; execution requires an accepted immutable QueryPlan.
Selected SQL parses sqlglot Parse. sqlglot Parse policy SQL / Object / Function Policy. SQL / Object / Function Policy checks grain GrainSafetyValidator. GrainSafetyValidator normalizes Grain-Safe Normalizer. Grain-Safe Normalizer re-validates Re-Parse + Re-Policy + Post-Grain. Re-Parse + Re-Policy + Post-Grain plans PostgreSQL EXPLAIN. PostgreSQL EXPLAIN cost gate Query Cost Gate. Query Cost Gate accepts Accepted QueryPlan. Accepted QueryPlan executes Restricted Read-Only Executor. Restricted Read-Only Executor returns Bounded Result.
Truth decides whether the governed decision is correct and whether result-contract evaluation applies; it does not decide whether SQL enters runtime.
Runtime + Governance Outcome scored against Execution-Based Evaluator. Execution-Based Evaluator uses Witnesses + Counterfactual Fixtures. Witnesses + Counterfactual Fixtures yields Governed Task Success.
Architecture notes
Runtime routing is decided by the parsed model submission, not by evaluator truth. An ANSWER + SQL receives the full parse, policy, semantic, cost, QueryPlan and execution treatment even when the truth is AMBIGUOUS, and the harness records the runtime outcome separately instead of crashing on a wrong governed decision.
Joining a parent to several child rows can triple a parent measure. The model is not trusted to own that contract. Server-owned metadata describes entity and grain keys, relationship cardinality and aggregation behavior, and the normalizer stays fail-closed outside its frozen additive-parent, declared 1:N shape.
Candidate SQL is not judged by exact text or AST equality. Two independent reference witnesses, a typed ResultContract and counterfactual fixtures that change distributions decide correctness, so SQL that accidentally returns the right rows on one state fails when the semantics actually diverge.
One benchmark case yields one semantic attempt with no retry, repair, judge, selector or reflection, which keeps model decision errors and server enforcement observable. The corpus was assembled with 0 retries and 0 duplicate attempts under a frozen prompt and planner-statistics contract, with request-hash compatibility verified.
Joining one parent row to several child rows can silently multiply a parent measure. The model is not trusted to own this contract; server-owned metadata and a narrow deterministic normalizer are.
SUM(order.amount) = 300counted 3×SUM(order.amount) = 100counted onceAdditive parent measure, a declared 1:N relationship and a supported LEFT JOIN fanout shape resolve to deterministic child-side preaggregation. Outside that shape the normalizer stays fail-closed, and normalized SQL still re-passes parse, policy, EXPLAIN and the cost gate before it can run.
The benchmark includes cases where producing SQL is the wrong behavior, so refusing is a measured outcome, not a failure. The four behaviors are scored separately rather than merged into one accuracy number.
| Behavior | Cases | Expected decision | Result |
|---|---|---|---|
| ANSWERABLE | 60 | ANSWER + one read-only SELECT | 51 / 60 delivered correct |
| AUTHORITY_BLOCKED | 15 | BLOCKED_AUTHORITY | 15 / 15 · 0 unauthorized answers |
| AMBIGUOUS | 9 | NEEDS_CLARIFICATION | 6 / 9 |
| POLICY_BLOCKED | 6 | BLOCKED_POLICY | 6 / 6 |
The three governance residuals are all in the ambiguity category; authority held at 15 / 15 with no unauthorized answers. These are frozen synthetic benchmark results, not production accuracy.
Governed decisions, runtime admission, grain safety and semantic discrimination describe different failure surfaces. They stay separate instead of collapsing into one project score.
| Evidence slice | Current result | What it covers |
|---|---|---|
| Governed task success | 78 / 90 = 86.7% | One-shot governed decisions across all four behaviors on the frozen synthetic benchmark. Answerable end-to-end runtime task success accuracy was 51 / 60 = 85.0%. |
| Runtime admission | 0 rejections · 0 execution failures | Across the 53 answerable cases where the model chose ANSWER, every submission passed parse, policy, semantic admission, cost and execution. 2 result mismatches remained, giving 51 / 53 = 96.2% conditional runtime correctness. |
| Grain normalization | 4 / 4 · 100% precision | Every PARENT_MEASURE_FANOUT state was normalized with 0 regressions, 0 unauthorized relationships introduced and 0 unsafe raw fallback, inside the supported shape only. |
| Semantic discrimination | 190 / 190 mutants killed | 120 / 120 reference witnesses and 184 / 184 counterfactual fixture comparisons with 0 invalid and 0 surviving mutants, proving the fixtures actually separate semantic errors. |
| Branch-complete harness | 360 / 360 scenarios | 90 cases across 4 valid decisions exercised 90 ANSWER runtime routes and 270 non-ANSWER bypasses, verified before the remaining responses were generated. |
The repository is a governed one-shot benchmark and reference runtime. Its numbers belong to the frozen contracts, synthetic packs and one-shot conditions they were measured under.