Guardrails are an AST walk, not a blocklist
Problem: the model writes SQL that then runs against my real database. Prompt instructions are not a security boundary.
Solution: parse with sqlglot and walk the tree. Exactly one statement.
Must be a Query node. Reject any Insert, Update,
Delete, Create, Drop, Attach,
Copy, Pragma, Set or raw Command
anywhere in the tree, and any function that reaches the filesystem —
read_csv, read_parquet, glob,
getenv. Un-limited selects get a LIMIT 500 appended. A
blocklist checks strings; a parser checks meaning.