Repository navigation
Description
Parent epic: #214
Priority: P1
Problem
A rejection tells the model what went wrong (hidden_column, table_not_allowed…) but not what it may do instead, so agents give up or retry blindly. The most common objection to a guard is "my agent will answer fewer questions", and there is no measurement that answers it.
Proposal
- Fix hints. Every violation gets an optional structured
fix:hidden_column→ the visible columns of that table.table_not_allowed→ the allowed tables whose names are closest to the one requested.aggregate_only→ "aggregate, with groups of at least k".required_filters→ the columns one of which must be filtered.row_limit,max_joinsand similar → the limit.
Hints name only what the policy allows. They never reveal a hidden column, a table outside the allowlist or a filter value.
- Accuracy benchmark. On the BIRD or Spider dev set, compare execution accuracy for the same model and prompt: no guard, guard with plain messages, guard with fix hints and one retry. Publish the numbers, the cost and the script in
docs/BENCHMARK.md.
Security impact
Hints are computed from the policy only. A test asserts that no hint contains a hidden column, a non-allowed table or a context value.
Acceptance criteria
-
fixon every violation code where a safe alternative exists, translated EN / ES, stable schema inCheckResultand in the MCP tool output. - Leak test over the whole adversarial corpus: no hidden name or context value in any hint.
- Reproducible accuracy run (pinned model, dataset version and seed) with results in
docs/BENCHMARK.md. - Clients (Node.js, .NET) expose
fix, and the conformance suite covers it.
Files
src/sqlguardllm/violations.py·messages.py·mcp_server.py·research/accuracy/(new) ·docs/BENCHMARK.md
Size
L
PR #255 merged after all ten workflows passed. It adds localized, context-independent hints to Python violations and MCP explain_query for selected codes. Client support, full corpus evidence and accuracy measurement remain pending.
PR #257 merged after 13 successful workflows, including Node.js, .NET and shared conformance. It adds the optional hint to the wire protocol and both clients. Full corpus leak evidence and the pinned accuracy measurement remain open.
PR #259 verifies that serialized hints depend only on the violation code and language across the 169 existing conformance cases in English and Spanish. All eight reported workflows passed. The pinned model accuracy measurement remains open.
PR #271 adds bilingual guidance for write operations, row locks, denied functions and aggregate-only policies. All ten workflows passed. The pinned model accuracy study remains open.
PR #279 merged after eight successful PR workflows. It adds an offline scorer for paired execution outcomes and records model revision, dataset revision and seed. The synthetic fixture checks scoring only. The experiment still needs recorded outcomes from a pinned model and dataset across all three arms.
PR #284 merged after eight successful PR workflows. The offline scorer now accepts recorded result rows, compares them with their references, and outputs aggregate accuracy without echoing the rows. Synthetic tests cover ordering, duplicates and missing results. The pinned model measurement remains open.
PR #288 merged after ten successful PR workflows. Native MCP query now presents available localized guidance. The pinned 20-question SQLite pilot produced 1/20 correct outcomes without the policy and 7/20 with either type of guarded feedback. Only two cases triggered retries. The benchmark was repeated with identical aggregate output and no paid inference. The full local suite passed (1,604 tests).
Activity
Add remediation hints for context and controlled operations (#275)
Score recorded remediation accuracy outcomes offline (#279)
Score recorded SQL result rows against their references (#284)