Skip to content

feat(production): InsightIQ production layer (#52)#53

Merged
AttiR merged 4 commits into
mainfrom
feature/52-sql-agent-production-layer
Jun 24, 2026
Merged

feat(production): InsightIQ production layer (#52)#53
AttiR merged 4 commits into
mainfrom
feature/52-sql-agent-production-layer

Conversation

@AttiR

@AttiR AttiR commented Jun 24, 2026

Copy link
Copy Markdown
Owner

Closes #52

1 Observability  Langfuse trace per query: question -> SQL -> exec
                 time -> rows -> cost; flush on SIGTERM (scale-to-zero safe)
2 Evaluation     15 pairs graded by execution accuracy (run both, compare
                 result sets), CI-gated >= 90% + guardrail red-team must be 100%
3 Guardrails     sqlglot AST: single SELECT, table/column whitelist,
                 reject DDL/DML nodes, NL-injection scan
4 Data access    read-only Postgres role, statement_timeout, forced LIMIT,
                 PII column block, append-only query audit log
5 Cost           per-query token+exec cost on the trace, daily budget alert
6 Reliability    graceful degradation: timeout / unparseable / zero-rows
                 each a typed user message, never a 500
7 Caching        normalised-question result cache w/ TTL (optional)
ops              Container Apps scale-to-zero, health probe, warm-up notice
AttiR and others added 3 commits June 24, 2026 16:51
pytest-asyncio creates a new event loop per test; singleton asyncpg pools
from test_ci_gold_sql_smoke_execute were reused after that loop closed,
breaking test_ci_execution_accuracy_smoke with "Event loop is closed".
Reset pools and schema cache in require_postgres before/after each test.

Co-authored-by: Cursor <cursoragent@cursor.com>
LLM-generated SQL often returns id/plan/month alongside metrics; treat
gold row values as a subset of generated values. Aggregate top-5 MRR
gold SQL per customer to match the question intent.
@AttiR
AttiR merged commit 1b08da4 into main Jun 24, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(production): SQL-agent production layer — tracing, exec-accuracy evals, AST guardrails, read-only data access, cost, graceful degradation

1 participant