Skip to content

feat(miner): add a Grafana dashboard for coding-agent-driver usage, cost, and attempt outcomes - #5646

Merged
JSONbored merged 1 commit into
mainfrom
miner-usage-grafana-dashboard
Jul 13, 2026
Merged

feat(miner): add a Grafana dashboard for coding-agent-driver usage, cost, and attempt outcomes#5646
JSONbored merged 1 commit into
mainfrom
miner-usage-grafana-dashboard

Conversation

@JSONbored

Copy link
Copy Markdown
Owner

Summary

Depends on #5637 (merged) for the provider/cost_usd/tokens_used columns this dashboard reads.

  • grafana/dashboards/miner-usage.json: per-provider (claude-cli/codex-cli/agent-sdk) attempt success/fail counts, total cost, and total tokens, all in one dashboard behind a $provider template variable — not one dashboard per provider, per the issue's own reasoning (AMS's local ledger has far lower data volume than ORB's three cloud reviewers).
  • Every panel queries the AMS Attempt Log SQLite datasource's attempt_outcome_summary rows only (event_type = 'attempt_outcome_summary') — never Prometheus, never the live ledger.
  • Cross-references ai-usage.json (ORB) in both directions via a top-level links entry — the only existing dashboard-to-dashboard link convention already in this repo (resource-hub.json's own links array). ai-usage.json's other panels/variables/datasources are untouched.
  • tokens_used reads 0/NULL honestly today (documented on the panel itself) — no coding-agent driver reports real token usage yet (Decide fate of attempt-metering.ts: wire real per-attempt budget enforcement, or remove it #5395); the dashboard needs no changes once one does.

Test plan

  • npm run selfhost:validate-observability (repo's own dashboard-JSON structural validator)
  • New test/unit/selfhost-grafana-miner-usage-dashboard.test.ts (9 cases), mirroring selfhost-grafana-ai-usage-dashboard.test.ts's real-sqlite3-execution rigor: structural checks (uid/title/tags, single $provider variable, SQLite-only datasource, cross-reference links both directions, additive-only ai-usage.json diff), an invariant test asserting no panel ever mixes AMS's attempt_log_events table with ORB's ai_usage_events/Prometheus metric names, and a seeded-database test that runs every panel's actual query and verifies $provider narrows correctly (including that a non-attempt_outcome_summary row on the same attempt_id, with provider IS NULL, never leaks into any aggregate or the recent-outcomes table)
  • npm run typecheck
  • Full observability + AMS test sweep (132 tests across 14 files) green
  • git diff --check

Closes #5185

…ost, and attempt outcomes

Adds grafana/dashboards/miner-usage.json: a single dashboard (a
$provider template variable, not one dashboard per provider) showing
per-provider attempt success/fail counts, total cost, and total
tokens, reading only the redacted attempt_outcome_summary rows the
AMS reporting export exposes via the AMS Attempt Log SQLite
datasource -- no Prometheus scraping.

Cross-references ai-usage.json (ORB) in both directions via a
top-level `links` entry, matching the only existing dashboard-to-
dashboard link convention in this repo (resource-hub.json's own
links array). ai-usage.json's other panels/variables are untouched.
@superagent-security

Copy link
Copy Markdown
Contributor

Superagent didn't find any vulnerabilities or security issues in this PR.

@JSONbored JSONbored self-assigned this Jul 13, 2026
@codecov

codecov Bot commented Jul 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.03%. Comparing base (941c300) to head (9ed1ea3).
⚠️ Report is 2 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5646   +/-   ##
=======================================
  Coverage   95.03%   95.03%           
=======================================
  Files         577      577           
  Lines       45920    45920           
  Branches    14695    14695           
=======================================
  Hits        43640    43640           
  Misses       1528     1528           
  Partials      752      752           
Flag Coverage Δ
shard-1 43.49% <ø> (-0.43%) ⬇️
shard-2 35.81% <ø> (+0.13%) ⬆️
shard-3 32.13% <ø> (-0.06%) ⬇️
shard-4 30.81% <ø> (-1.77%) ⬇️
shard-5 32.53% <ø> (+0.75%) ⬆️
shard-6 44.84% <ø> (+0.37%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@loopover-orb loopover-orb Bot added the gittensor:feature Gittensor-scored feature linked to a feature issue — scores a 0.25x multiplier. label Jul 13, 2026
@loopover-orb

loopover-orb Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Warning

🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨

⏸️ LoopOver review result - manual review recommended

Review updated: 2026-07-13 19:28:55 UTC

3 files · 1 AI reviewer · no blockers · readiness 100/100 · CI green · clean

⏸️ Suggested Action - Manual Review

  • AI review could not be completed: The dual-model AI review did not return a usable verdict for this change.

Review summary
This PR adds a new Grafana dashboard (miner-usage.json) for AMS coding-agent-driver usage/cost/outcome metrics, wires a bidirectional links cross-reference into the existing ai-usage.json (ORB) dashboard, and ships a thorough unit test suite that runs the panel queries against a real seeded sqlite3 database. The queries consistently scope by event_type='attempt_outcome_summary', the $provider template variable, and the selected time window, and the tests explicitly verify that a non-outcome-summary row with a NULL provider on the same attempt_id never leaks into any aggregate — a real edge case, not a fabricated one. The change is additive-only to ai-usage.json (only a links entry added) and depends on the already-merged #5637 for the provider/cost_usd/tokens_used columns it reads.

Nits — 6 non-blocking
  • Panel 3's 'Succeeded' definition treats every action_class other than 'attempt_submitted' as failure, including 'attempt_governed', which may not always represent a true failure outcome — worth a sentence in the panel description clarifying that classification choice is intentional and not just a placeholder.
  • grafana/dashboards/miner-usage.json panel 7's sortBy ('total', desc) doesn't provide a secondary tiebreaker, so provider rows with equal totals (e.g. codex-cli and agent-sdk in the test fixture) have no guaranteed stable order — low-impact for a dashboard table but worth noting for reproducible screenshots/docs.
  • Consider adding a brief comment/description on the $provider template variable itself noting that its 'All' sentinel ('$__all') is compared literally against the query's ${provider:sqlstring} filter, mirroring whatever convention ai-usage.json already established, so future contributors don't accidentally break the All-selection path when editing either dashboard.
  • If a future migration adds more action_class values (e.g. a new terminal state), the binary succeeded/failed split in panels 3 and 7 will need re-auditing — worth a short code comment pointing at the AMS ledger's action_class enum as the source of truth.
  • PR author also opened the linked issue — Link an issue that was opened by a different contributor, or provide a rationale for why this self-authored issue represents genuine discovery work.
  • AI review could not be completed — The gate is held for a human reviewer rather than passed automatically; it re-evaluates on the next update.
Signal Result Evidence
Code review ✅ No blockers 1 reviewer
Linked issue ✅ Linked #5185
Related work ✅ No active overlap found No same-issue or scoped active PR overlap found.
Change scope ✅ 20/20 Low review scope from cached public metadata (1 linked issue).
Validation posture ✅ 25/25 PR body includes validation/test evidence.
Contributor workload ✅ 10/10 Author activity: 44 registered-repo PR(s), 36 merged, 320 issue(s).
Contributor context ✅ Confirmed Gittensor contributor JSONbored; Gittensor profile; 44 PR(s), 320 issue(s).
Gate result ⚠️ Not blocking Advisory; not blocking this PR.
Improvement ⚠️ ℹ️ Insufficient signal risk: clean · value: insufficient-signal — Nothing measurable for the structural-improvement analyzers on this PR (e.g. no code files changed). LLM value judgment: moderate — The PR is a well-scoped, thoroughly tested observability addition that directly implements open issue #5185's dashboard requirement without touching any review/gate logic, so its value is real but confined to operator tooling rather than the core engine.
Linked issue satisfaction

Addressed
The PR adds grafana/dashboards/miner-usage.json with a single $provider template variable covering all three coding-agent providers, panels for success/fail counts, cost, and tokens queried directly from the AMS SQLite datasource, plus bidirectional cross-reference links matching ORB's convention and an additive-only change to ai-usage.json.

Review context
  • Author: JSONbored
  • Role context: owner (maintainer lane)
  • Public audience mode: oss maintainer
  • Lane context: Repository is configured for direct PR review.
  • Public profile languages: not available
  • Official Gittensor activity: 44 PR(s), 320 issue(s).
  • PR-specific overlap: none found.
Contributor next steps
  • Treat this as maintainer-lane context rather than normal contributor-lane activity.
Signal definitions
  • Related work = same linked issue, overlapping active PRs, or title/path similarity.
  • Change scope = cached public metadata such as size labels, draft state, and review-burden hints.
  • Validation posture = whether the PR provides enough public validation/test evidence for maintainer review.
  • Contributor workload = public contributor activity and cleanup pressure, not a repo-wide quality failure.
  • Contributor context = public GitHub/Gittensor identity context; non-Gittensor status is not a blocker.
[BETA] Chat with Gittensory

Ask Gittensory a question about this PR directly in a comment — grounded only in the same cached, public-safe facts shown above, never a new claim.

  • @gittensory ask &lt;question&gt; answers contribution-quality Q&A with source citations and freshness.
  • @gittensory chat &lt;question&gt; answers in natural prose from cached decision-pack facts via local inference (maintainer/collaborator; read-only).
  • A plain-language @gittensory mention with a real question is routed to the closest matching read-only command automatically -- no exact syntax required.

Full command reference: https://gittensory.aethereal.dev/docs/gittensory-commands

🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed


💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →.

Checked by LoopOver, a quiet PR intelligence layer for OSS maintainers.

  • Re-run LoopOver review

@loopover-orb loopover-orb Bot added the manual-review Gittensor contributor context label Jul 13, 2026
@JSONbored
JSONbored merged commit 313342d into main Jul 13, 2026
18 checks passed
@JSONbored
JSONbored deleted the miner-usage-grafana-dashboard branch July 13, 2026 19:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gittensor:feature Gittensor-scored feature linked to a feature issue — scores a 0.25x multiplier. manual-review Gittensor contributor context

Development

Successfully merging this pull request may close these issues.

Add a Grafana dashboard for coding-agent-driver usage, cost, and attempt outcomes

1 participant