Skip to content

[EPIC] ClawMetry Dives — AI SQL→chart over local DuckDB #999

Description

@vivekchand

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)

  1. User types in /dives tab input box
  2. Backend prompt: schema descriptor (table names, column types, no row values) + question → LLM returns {sql, chart_type, x, y, title}
  3. SQL safety validator rejects anything that's not a SELECT against the allowlisted 9 tables
  4. Run query against local DuckDB
  5. Render with Chart.js
  6. 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

  • User types "Show me total cost per agent today" → bar chart in <5s, labeled openclaw/claude_code/etc.
  • All 9 multi-agent schema tables queryable
  • SQL injection ('; DROP TABLE events;--) rejected with clear error
  • Saved Dive re-runs on tab open with current data
  • No-key state shows clear banner, no silent failures

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions