Add read-only SQL tool with Postgres access to basketball + contracts DBs #27
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Type
Feature
Lineage
Standalone — evolved from api_get (#23). SQL access is more powerful than API endpoints for arbitrary data questions.
Repo
forgejo_admin/westside-ai-assistantUser Story
As Marcus (admin)
I want to ask Nemo any question about program data and get an answer
So that I don't need custom API endpoints for every possible query
Context
The generic api_get tool (#23) gives Nemo access to basketball-api REST endpoints. But contract data lives in westside-contracts (separate Postgres DB, no REST API). And many questions require JOINs or aggregations that no single endpoint serves. A read-only SQL tool lets Claude generate queries from natural language against the actual database schema.
Safety: a dedicated Postgres role with SELECT-only permissions, statement_timeout, and REVOKE on sensitive columns (password hashes, tokens, secrets). Claude writes the SQL, Nemo executes it read-only.
File Targets
Files to create:
app/database.py— async Postgres client (asyncpg or psycopg), read-only connection, statement_timeout enforcementapp/ai.py—db_querytool with read metadataFiles to modify:
app/ai.py— adddb_querytool to TOOLS list, add schema description to SYSTEM_PROMPTapp/config.py— add DATABASE_URL env vars (basketball DB + contracts DB)Files NOT to touch:
app/confirmation.py— no write confirmation needed (queries are read-only at DB level)Infrastructure:
Acceptance Criteria
db_querytool executes SELECT queries against basketball-api databasedb_querytool executes SELECT queries against westside-contracts databaseTest Expectations
pytest tests/ -k test_db_queryConstraints
Checklist
Related
project-westside-basketballScope Review: NEEDS_REFINEMENT
Review note:
review-729-2026-03-30Well-structured feature issue with all template sections present, but has cross-repo scope that exceeds the single-ticket threshold.
Issues found:
story:WS-S5maps to CNPG infra (superadmin) or dashboard stats (admin), not AI data queries. Needs a new story ID.arch-westside-ai-assistantnote exists in pal-e-docs.requirements.txt(asyncpg dependency) andpal-e-deployments/.../deployment-patch.yaml(DATABASE_URL env vars) not listed.Action: Route to
skill-decompose-ticketfor sub-board creation (5 suggested sub-tickets across infra, deploy, and app work streams).