Expand description
Per-agent SQL contracts + a contract validator with machine-readable repair hints.
An agent contract is a scoped grant: which SQL verbs and tables an agent
may touch, which predicates a query must carry (e.g. a tenant filter), and
whether reads must be bounded by a LIMIT. Queries are validated against
the contract BEFORE execution; a violation is returned as a structured
Violation — a violation class, the offending fragment, and a suggested
rewrite — so an LLM agent can read it and self-correct in one round trip
instead of flailing against an opaque error.
Validation is intentionally a lightweight static inspection (verb + table + predicate + LIMIT detection), the same altitude as a pg_hba / pgcat-style guard; it is a policy gate, not a full SQL parser.
Structs§
- Agent
Contract - A scoped grant for one agent identity.
- Predicate
Rule - A predicate an agent’s queries must carry when they touch
table. - Violation
- A contract violation, serialized to the agent as a machine-readable hint.
Functions§
- validate
- Validate
sqlagainstcontract.Ok(())admits the query;Errcarries a structured repair hint.