feat(miner): persist coding-agent provider + real cost on the attempt log - #5637
Conversation
… log Adds a new attempt_outcome_summary event type, written once per completed attempt from attempt-cli.js, carrying the real configured provider and the real accumulated cost -- the two signals a per-provider usage dashboard needs that the existing per-iteration attempt-log events don't carry. tokensUsed stays null (never fabricated): no coding-agent driver reports real token usage yet. Extends the redacted AMS reporting export and its datasource docs so the new columns reach Grafana without ever exposing the live ledger. Prerequisite for the per-provider usage dashboard.
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
loopover-ui | ba2152f | Commit Preview URL Branch Preview URL |
Jul 13 2026, 05:54 PM |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5637 +/- ##
=======================================
Coverage 95.02% 95.02%
=======================================
Files 576 576
Lines 45797 45813 +16
Branches 14661 14664 +3
=======================================
+ Hits 43518 43534 +16
Misses 1528 1528
Partials 751 751
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
|
Warning 🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨 ⏸️ LoopOver review result - manual review recommendedReview updated: 2026-07-13 18:46:26 UTC
⏸️ Suggested Action - Manual Review Review summary Nits — 5 non-blocking
Concerns raised — review before merging
📋 Copy for AI agents — paste into your coding agent
Review context
Contributor next steps
Signal definitions
[BETA] Chat with GittensoryAsk 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.
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.
|
…serve-last-good (#5757) An instance whose ams-attempt-log source has never existed (an engine-only deployment with no co-located miner) creates its one-and-only export under whichever DDL was current at that moment, then export_ledger's "source missing, output already exists" fail-open path preserves it forever -- the fingerprint/SCRIPT_VERSION rebuild check is unreachable while the source stays absent, so a later DDL widening (PR #5637 added provider/cost_usd/tokens_used to attempt_log_events a day after PR #5471 first shipped this script) was previously invisible to such an instance permanently. Every miner-usage.json panel selecting those columns then hard-fails with "no such column" instead of just showing empty. Fixed by reconciling the preserved output's schema against the current DDL's declared columns (ALTER TABLE ADD COLUMN, mirroring packages/gittensory-miner/lib/attempt-log.js's own ensureOutcomeColumns pattern) whenever a preserve-last-good path fires -- additive only, so existing rows and their data are never touched.
Summary
Prerequisite for #5185 (per-provider Grafana usage dashboard). The two AMS ledgers Grafana can already read (
attempt_log_events,predictions) carry no provider/cost dimension at all — this adds it.attempt_outcome_summaryattempt-log event type, written once per completed attempt fromattempt-cli.js(submitted/abandon/stale/blocked/governed — any terminal outcome), carrying the real configured coding-agent provider (resolveFirstConfiguredCodingAgentDriverName) and the real accumulated cost (finalResult.totalCostUsd) — distinct from the per-iterationattempt_started/attempt_tool_edit/... trailiterate-loop.tsalready writes (deliberately not touched — that orchestration chokepoint is maintainer-tagged).tokens_usedstaysNULL, never a fabricated0: no coding-agent driver reports real token usage today (Decide fate of attempt-metering.ts: wire real per-attempt budget enforcement, or remove it #5395's own documented gap).provider,cost_usd,tokens_used) via the same per-columnALTER TABLEmigration idiomgovernor-state.js'sensurePauseColumnsalready established, so an existing on-diskattempt-log.sqlite3upgrades in place.scripts/export-ams-reporting-db.sh's redacted reporting export (the only thing Grafana ever reads) passes the three new columns through unchanged — they're bounded/structured values, never free text like thereason/payload_jsoncolumns that export already drops.packages/gittensory-miner/docs/observability.mddocuments the new columns.A logging failure on the new event never fails an otherwise-successful attempt (mirrors
iterate-loop.ts's ownsafeAppendAttemptLogEventnon-fatal handling).Test plan
npm run typechecknpm run build:miner,npm run test:miner-packnode:testsuite (531 tests) + the root vitest mirror (test/unit/coding-agent-miner.test.ts) for Codecov visibility into the engine-level normalizationattempt-cli.jswiring tests: submitted outcome, non-submitted outcome, and a brokenappendAttemptLogEventnever failing an otherwise-successful attemptNULLwhen unsetshellcheck scripts/export-ams-reporting-db.shcleanattempt-log.js/attempt-cli.jsare untouched by this PR)Advances #5185