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 global policy enforces one read-only statement, governed object access, function restrictions and complexity limits before anything else runs.
Global policy answers whether an object is queryable by the service; request-scoped authority answers whether this request may use it. An immutable relation-level ExecutionAuthority, derived from the same governed SchemaContext, rejects an unauthorized relation before any database connection, EXPLAIN or execution.
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 Global SQL / Object Policy. Global SQL / Object Policy authorizes Request-Scoped Relation Authority. Request-Scoped Relation Authority 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 pass@K, which keeps model decision errors and server enforcement observable instead of letting a repair loop smooth them over. Responses are admitted under exact provider-request fingerprinting and deterministic replay.
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 | 122 | ANSWER + one read-only SELECT | 108 / 122 runtime TSA correct |
| AUTHORITY_BLOCKED | 30 | BLOCKED_AUTHORITY | 28 / 30, runtime blocks the unauthorized relation |
| AMBIGUOUS | 16 | NEEDS_CLARIFICATION | 12 / 16 |
| POLICY_BLOCKED | 12 | BLOCKED_POLICY | 12 / 12 |
The three governance residuals are all in the ambiguity category; authority held at 15 / 15 with no unauthorized answers.
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 | 160 / 180 = 88.89% | One-shot governed decisions across four behavior classes on one 180-case benchmark spanning 12 synthetic domains. 20 governed misses overall. |
| Answerable runtime TSA | 108 / 122 = 88.52% | Answerable queries that survived the real runtime and satisfied the result contract on BASE and every required counterfactual state. healthcare_10 passes BASE but fails a counterfactual. |
| Authority | 28 / 30 = 93.33% | Model authority decisioning. telecom_15 is the known case where the model wrongly chose ANSWER; request-scoped relation authority rejected the unauthorized relation with zero database connection, EXPLAIN or execution. |
| Governance blocks | policy 12 / 12, ambiguity 12 / 16 | Policy blocking is exact at 100%; ambiguity recognition is the weaker axis at 75.00%. Refusing SQL is a measured, expected outcome on these cases. |
| Execution boundary | QueryPlan-gated, no raw unsafe fallback | Accepted execution requires an immutable QueryPlan issued by the SQL safety service; raw SQL or copied plan objects cannot bypass planning, and the reader runs under a read-only transaction, reader role, statement timeout and bounded rows. |