Repository navigation
A minor release. The stable API (the guard, the violation codes, the policy schema, the CLI and HTTP protocol v1) only gains optional fields and options; everything new below is experimental and may change in a minor release (STABILITY). The one default that changed is under Changed.
Changed
--max-costor--max-plan-rowson an engine whose plan has no such number (SQLite, DuckDB) is now an error at startup instead of being ignored with a warning (#292). Backends with no plan reader (Oracle, MariaDB) still warn and ignore.
Deprecated
- The
limit_reachedfield of the MCPqueryresult is true wheneverrow_countequals the limit, even when nothing was cut. Usetruncated. It stays through 1.x and is not removed before 2.0 (#295).
Fixed
- The
explain_querytool description promised the rewritten SQL, which it never returns (#296), and several docs still called released features unreleased (#297).
Added
- Cross-query aggregate differencing check (experimental, #220).
cohortsin the MCP row-budget file compares the row ids behind each whole-cohort aggregate with those already served to the same session and refuses near-duplicates withdifferencing, orcohort_unavailablewhen it cannot check. - Verified queries (#287, guide, experimental): a git-managed catalog (YAML or JSON) of approved, read-only business queries with a version, stable ids,
:nameSQL templates, typed parameters (string,integer,number,boolean,date) and allowed roles.sqlguardllm mcp --catalog FILEaddslist_verified_queriesandrun_verified_query; the server owns the SQL and the values are bound, never written into it. A verified query gets no extra privileges: it goes through the same policy, masks, row filters, row limit, read-only transaction, timeout, taint tracking, row budgets and plan checks asquery, which does not change. The catalog is checked at startup against the policy and the guard's rewrite; audit events carrycatalog_queryandcatalog_versionand never a value or a row.sqlguardllm catalog check FILE --policy ...does the same check for CI. Examples with fixtures and expected business results are inexamples/catalog/. - Plan checks (#292, guide, experimental):
sqlguardllm.plan.PlanGuardjudges the database's own plan for a query the guard allowed (it only accepts aCheckResult, so the rewritten SQL is what is explained, neverANALYZE) againstmax_cost,max_rowsandfull_scan_tables, withon_exceeddenyorwarn;sqlalchemy_runnerruns the statements. Plans are read for PostgreSQL, MySQL, SQL Server (SHOWPLAN_XML), DuckDB and SQLite, with SQLite and MySQL aliases resolved through the SQL.sqlguardllm mcpgains--plan-full-scan TABLEand--plan-on-exceed, and a warn-mode query runs withstatus: "warned"and the reasons inwarnings. Changed:--max-costor--max-plan-rowson an engine whose plan has no such number (SQLite, DuckDB) is now an error at startup instead of being ignored with a warning; backends with no plan reader (Oracle, MariaDB) still warn and ignore. classify --sample N, value checks and Spanish names (#294):sqlguardllm classify --sample Nalso looks at up to N values per column (off by default, at most 1000 values and 500 columns, read-only, never printed) and checks them with an email shape, Luhn, CURP, RFC, SSN, CLABE and IBAN checks; each proposal says whether name, values or both support it. Spanish and Mexican names (tarjeta,numero_cuenta,pasaporte,imss) are recognised, and a descriptive first word (tipo_tarjeta,fecha_curp) is not a match. 130 corpus cases pin each class action in five dialects, per-role overrides in policy sets are documented and tested, and the threat model lists what classes do not cover.- Advice per table, and
advice/data_classesin the Node.js and .NET clients (#291, #294):Advice.tablesgives the columns used per physical table and clause, resolved through aliases, subqueries and the policyschema. The protocol schema lists both optional fields, a conformance test checks that in-process, stdio and HTTP explanations agree,Explanation(Node.js) andExplainResult.Advice/.DataClasses(.NET) are typed, and the Node.js generated types now include the policy fields added since 1.0 (advice,data_classes,column_classes,not_sensitive), which were missing. sqlguardllm diff(#293, guide, experimental): runs authored cases under a base and a candidate policy (or policy set) and reports the decision, codes, rewritten-SQL diff, row filters, masks, limit and advice score, plus the changes between the policies themselves.--fail-ongates (newly-allowed,newly-denied,filter-removed,mask-removed,hidden-removed,limit-raised,any-change) make the exit code 1 for CI; output as text, JSON (versioned schema) or Markdown for a PR summary;--redactreplaces literals. An example workflow and fixtures are inexamples/policy-diff/.- Sensitive data classes (#294, guide, experimental):
Policy.data_classes,column_classesandnot_sensitivesay once what a kind of data is (hideormask) and which columns are of it. They compile intohidden_columnsandmasked_columns, so enforcement is unchanged and an explicit entry wins.Guard.explain()andexplain_queryreport the classes a query reads,lintskips columns markednot_sensitive, andsqlguardllm classify --db URLproposes the mapping from column names only (never a row). - MCP results that say what the guard did (#295):
querynow returnsstatus(allowed,rewritten,warned), an exacttruncated(the server runs the query with one more row allowed to tell a cut result from a full one),applied_limit,rewrites(tables with row filters and masked columns, never their values) andwarnings, plusadvicewhen the policy has it.list_tables,describe_table,explain_queryandqueryadvertise a typedoutputSchema, andsqlguardllm proxyadvertises mapped SQL tools as read-only.limit_reachedstays and is deprecated. - Query advice (#291, guide, experimental), off by default: a
Policy.advicesection turns onExplanation.advicewith stable findings (select-star,no-filter,no-row-bound,leading-wildcard,function-on-filtered-column,or-chain,unlinked-join,deep-nesting,order-without-limit), a 1-100 score, and the columns by clause.sqlguardllm check --adviceprints it,explain_queryreturns it, andmin_scorecan reject low scores with the new experimental codelow_query_score. The decision never changes withoutmin_score. sqlguardllm redteam(#219, guide, experimental):setupprepares a disposable PostgreSQL or SQLite database with canary tables and a marker,mcpsends the benchmark attacks of that dialect to your MCP server's SQL tool, andreportrenders the result. Each case is first run directly on the database and rolled back, so "blocked" only counts attacks that would have worked; it refuses to run without the marker.- Experimental optional per-session row budgets for MCP result delivery, configurable in Python and via
mcp --row-budgets budgets.json(#220). - Structured error codes for stdio proxy session privacy checks (#220).
- MCP and the stdio proxy refuse reads before execution when their row budget is exhausted (#220).
- MCP refuses budgeted reads before connecting to the database when session accounting is unavailable (#220).
- Optional stdio proxy row budgets for mapped SQL tools that return structured rows (#220).
- Optional offset pagination restriction for budgeted MCP and proxy sources (#220).
- Optional restriction for simple keyset pagination on configured, budgeted MCP and proxy sources (#220).
- Optional per-session allowance for requests matching the configured keyset restriction (#220).
- Resolve direct column aliases and projection positions in keyset pagination sort orders (#220).
- Composite keyset cursors with literal bounds use the same per-session allowance as single-column cursors (#220).
- Optional fixed-cohort restriction for aggregates on budgeted MCP and proxy sources (#220).
- Experimental cohort comparison for Python applications with trusted row membership snapshots (#220).
- Optional English and Spanish remediation hints for selected guard violations, including context validation, controlled write restrictions and invalid procedure parameters. Hints on
CheckResultare also available in MCP, HTTP, stdio, and the Node.js and .NET clients (#217). - MCP
queryincludes available localized hints in its read-policy refusal messages.explain_querycontinues to expose each hint as structuredfixdata (#217). - Shadow mode (#222, shadow, experimental), off by default:
sqlguardllm.shadow.ShadowGuard(active, candidate=...)returns the active guard's decision untouched and records what a candidate policy would have decided (would_allow,would_rewrite,would_deny,error, with violation codes). The report keeps only counters, codes and SQL shape fingerprints: no SQL, literals, context or names. Alsosqlguardllm shadow --policy A --candidate B queries.sqlandexamples/shadow_demo.py. No stable API changed and nothing was added tosqlguardllm.__all__.