SQL query
Route: /query (sidebar: SQL query, under Account)
The SQL query page in Mushi Mushi answers questions about your project’s bug data. On the
Ask tab, pick Natural language to type a question in plain English, or Raw SQL
to write a SELECT yourself. Every run is read-only, sandboxed and logged.
The page has four tabs: Ask, History, Schema (the approved tables) and Overview.
How it works
- You type a question, for example “How many P0/P1 reports landed this week vs last week?” (press Enter to run). In Raw SQL mode you write the query and press ⌘/Ctrl+Enter.
- Graph questions go to the graph. Questions about blast radius or dependencies are answered by walking the knowledge graph directly, without writing SQL.
- Otherwise the model writes SQL from a schema description of the approved tables,
filtered by
project_id = $1and limited to 100 rows. - The SQL is checked before it runs: one statement only, no writes or DDL (
INSERT,UPDATE,DELETE,DROP, …), no system schemas (auth,storage,vault, …). A query withoutLIMITgetsLIMIT 100appended. A rejected query returnsINVALID_SQL. - The query runs as a read-only database role (
mushi_nl_reader) that can onlySELECTthe approved tables and only your project’s rows. That role, not the text checks, is the real boundary. - You get the result rows as a table, the SQL that ran (with Copy SQL), and, for natural-language questions, a short plain-English summary.
Runs are rate-limited to 60 an hour per user; past the limit the API returns RATE_LIMITED.
Approved tables
| Table | What’s in it |
|---|---|
reports | Every incoming report with its classification fields |
report_groups | Groups of similar reports |
classification_evaluations | Judge scores for classifications |
reporter_reputation | Reporter reputation scores |
reporter_devices | Devices tracked by Spam & abuse |
graph_nodes, graph_edges | The knowledge graph |
bug_ontology | Bug category tags |
fix_attempts, fix_verifications, fix_events | Fix runs, their verification and events |
llm_invocations | Every LLM call, with model, tokens and cost |
anti_gaming_events | Flag and unflag events |
In Raw SQL mode, a query that names a table outside this list is rejected before it reaches the database. The Schema tab shows the same list.
Example questions
"Which component has the most open critical reports in the last 30 days?"
"Show me the daily report volume trend for the past 3 months."
"How many fix attempts failed vs. succeeded last week?"
"Show reports where severity is critical and status is open, created this week."History and saved queries
Every run, successful or not, is stored with your user, the prompt, the generated SQL, the row count and the latency. The Library panel lists them in three groups:
- Saved: runs you pinned with Pin to Saved
- Recent: your latest runs
- Team: recent runs by other people on the projects you can see
You can remove a run from your history.
Results show as a table only. The page does not draw charts and has no CSV export; copy the SQL if you need the data elsewhere.
API
POST /v1/admin/query { "question": "..." } # natural language
POST /v1/admin/query/raw { "sql": "SELECT ..." } # raw SQL
GET /v1/admin/query/history?limit=25
PATCH /v1/admin/query/history/:id # pin / unpin
DELETE /v1/admin/query/history/:id
GET /v1/admin/query/team?limit=25
GET /v1/admin/query/statsSee also
- Admin → Intelligence reports: automated weekly digest built from the same data.
- Concepts → Knowledge graph: explore relationships visually instead of via SQL.