TL;DR
Plain-English question → SQL → chart, all against the local DuckDB store. No SaaS dep, no row values leave the machine.
Full design + trade-off analysis in PRD-clawmetry-dives.md (private repo).
Why now
What's missing is the glue: schema-aware prompting + SQL safety validator + chart-spec rendering.
Architecture (high-level)
- User types in
/dives tab input box
- Backend prompt: schema descriptor (table names, column types, no row values) + question → LLM returns
{sql, chart_type, x, y, title}
- SQL safety validator rejects anything that's not a
SELECT against the allowlisted 9 tables
- Run query against local DuckDB
- Render with Chart.js
- Optional save → JSON spec at
~/.clawmetry/dives/<slug>.json
Privacy promise
On each Dive run, the LLM call sends:
- The user's natural-language question
- A schema descriptor (table/column names, types)
- NEVER row values
For users wanting zero LLM contact, the existing Ollama integration is the path.
Sub-issues
- #DIVES-1 — SQL safety validator (allowlist, regex rejection, 30+ malicious-input tests)
- #DIVES-2 — Prompt template + schema descriptor builder
- #DIVES-3 —
/api/dives/* endpoints (query, save, list, get, delete)
- #DIVES-4 —
/dives tab UI (input box, chart area, saved Dives list, "show SQL" toggle)
- #DIVES-5 — Suggested-questions gallery (regression-tested fixed list)
- #DIVES-6 — Telemetry: log
dive_run events into the local store for prompt improvement
Out of scope (Phase 2+)
- Evidence.dev
/reports sidecar (Phase 2 — power users authoring markdown+SQL by hand)
- Sharing Dives across team via cloud (Phase 3)
- Scheduled Dive re-runs + threshold notifications (Phase 4)
- Self-Evolve feedback loop (Phase 5)
Effort
~3-4 days for Phase 1 MVP. Phase 2 (Evidence.dev) ~2-3 days, opt-in via pip install clawmetry[reports].
Acceptance
TL;DR
Plain-English question → SQL → chart, all against the local DuckDB store. No SaaS dep, no row values leave the machine.
Full design + trade-off analysis in PRD-clawmetry-dives.md (private repo).
Why now
agent_type./claude-apialready routes prompts through user's BYO key.What's missing is the glue: schema-aware prompting + SQL safety validator + chart-spec rendering.
Architecture (high-level)
/divestab input box{sql, chart_type, x, y, title}SELECTagainst the allowlisted 9 tables~/.clawmetry/dives/<slug>.jsonPrivacy promise
On each Dive run, the LLM call sends:
For users wanting zero LLM contact, the existing Ollama integration is the path.
Sub-issues
/api/dives/*endpoints (query, save, list, get, delete)/divestab UI (input box, chart area, saved Dives list, "show SQL" toggle)dive_runevents into the local store for prompt improvementOut of scope (Phase 2+)
/reportssidecar (Phase 2 — power users authoring markdown+SQL by hand)Effort
~3-4 days for Phase 1 MVP. Phase 2 (Evidence.dev) ~2-3 days, opt-in via
pip install clawmetry[reports].Acceptance
'; DROP TABLE events;--) rejected with clear error