Overview of the AI Reporting DSL
The reporting DSL enables AI models to answer bounded analytics questions by emitting a typed query AST. This AST is validated by the server and executed against curated, read-only Postgres views. To ensure security and performance, the following invariants are enforced:
- No raw SQL: Only Zod-validated ASTs are converted to parameterized SQL.
- Row Limits: Maximum limit of 100 rows; queries exceeding this are rejected.
- Mandatory Date Range: Every query must include
dateFromanddateTo. - Workspace Isolation: Every view includes
workspace_id, and the executor binds the current$workspaceId. - Timeouts: A 5-second statement timeout is applied to the executor connection.
- PII Protection: Views exclude sensitive data (email/phone) unless explicitly allowlisted.