Skip to content

feat(miner): persist coding-agent provider + real cost on the attempt log - #5637

Merged
JSONbored merged 1 commit into
mainfrom
miner-attempt-log-provider-cost
Jul 13, 2026
Merged

feat(miner): persist coding-agent provider + real cost on the attempt log#5637
JSONbored merged 1 commit into
mainfrom
miner-attempt-log-provider-cost

Conversation

@JSONbored

Copy link
Copy Markdown
Owner

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.

  • New attempt_outcome_summary attempt-log event type, written once per completed attempt from attempt-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-iteration attempt_started/attempt_tool_edit/... trail iterate-loop.ts already writes (deliberately not touched — that orchestration chokepoint is maintainer-tagged).
  • tokens_used stays NULL, never a fabricated 0: 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).
  • Miner-side SQLite schema gets three new nullable columns (provider, cost_usd, tokens_used) via the same per-column ALTER TABLE migration idiom governor-state.js's ensurePauseColumns already established, so an existing on-disk attempt-log.sqlite3 upgrades 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 the reason/payload_json columns that export already drops.
  • packages/gittensory-miner/docs/observability.md documents the new columns.

A logging failure on the new event never fails an otherwise-successful attempt (mirrors iterate-loop.ts's own safeAppendAttemptLogEvent non-fatal handling).

Test plan

  • npm run typecheck
  • npm run build:miner, npm run test:miner-pack
  • Engine node:test suite (531 tests) + the root vitest mirror (test/unit/coding-agent-miner.test.ts) for Codecov visibility into the engine-level normalization
  • Miner-level SQLite tests (append/read round-trip, migration of a pre-existing file, re-opening an already-migrated file is a no-op)
  • attempt-cli.js wiring tests: submitted outcome, non-submitted outcome, and a broken appendAttemptLogEvent never failing an otherwise-successful attempt
  • Export-script tests: new columns pass through unchanged, NULL when unset
  • shellcheck scripts/export-ams-reporting-db.sh clean
  • Branch coverage: 100% of every new line/branch in this diff (verified via lcov branch-map inspection; a couple of pre-existing gaps elsewhere in attempt-log.js/attempt-cli.js are untouched by this PR)

Advances #5185

… 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-security

Copy link
Copy Markdown
Contributor

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

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

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

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.02%. Comparing base (dbcb7a3) to head (ba2152f).

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           
Flag Coverage Δ
shard-1 43.82% <0.00%> (-0.02%) ⬇️
shard-2 35.71% <93.75%> (+0.02%) ⬆️
shard-3 32.28% <0.00%> (-0.02%) ⬇️
shard-4 32.73% <81.25%> (+0.01%) ⬆️
shard-5 31.73% <31.25%> (-0.01%) ⬇️
shard-6 44.39% <56.25%> (+<0.01%) ⬆️

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

Files with missing lines Coverage Δ
...ackages/gittensory-engine/src/miner/attempt-log.ts 100.00% <100.00%> (ø)
packages/gittensory-miner/lib/attempt-cli.js 96.96% <100.00%> (+0.03%) ⬆️
packages/gittensory-miner/lib/attempt-log.js 95.31% <100.00%> (+0.76%) ⬆️
🚀 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:bug Gittensor-scored bug fix — scores a 0.05x 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 18:46:26 UTC

11 files · 1 AI reviewer · 2 blockers · readiness 93/100 · CI green · clean

⏸️ Suggested Action - Manual Review

Review summary
This PR adds a new `attempt_outcome_summary` event type carrying the real coding-agent provider and cost to the attempt log, with matching SQLite schema/migration, reporting-export passthrough, and docs. The implementation follows existing conventions (per-column ALTER TABLE migration mirroring `ensurePauseColumns`, non-fatal try/catch mirroring `iterate-loop.ts`'s `safeAppendAttemptLogEvent`), correctly distinguishes absent-vs-zero for cost/tokens, and is exercised by thorough round-trip, migration-idempotency, and resilience tests. The change is narrow, well-targeted at its stated prerequisite (#5185), and all CI checks passed.

Nits — 5 non-blocking
  • packages/gittensory-miner/lib/attempt-cli.js: the new block mixes `finalResult.outcome` (actionClass) with `result.outcome` (reason string) — worth using one consistent source for both fields to avoid confusion for future readers.
  • packages/gittensory-miner/lib/attempt-cli.js: the swallowed `catch {}` around `appendAttemptLogEvent` drops the error entirely with no logging — consider at least a `console.error` (debug-only) so a persistently failing disk isn't invisible forever, even though failing the attempt itself would be wrong.
  • packages/gittensory-miner/lib/attempt-cli.js is now ~504 lines per the size-smell check; consider whether the new outcome-summary block belongs in a small helper if the file keeps growing.
  • Consider logging (not throwing) inside the catch block in attempt-cli.js so operators can detect a systematically broken attempt-log write path.
  • If `result` and `finalResult` are expected to always carry the same outcome, collapse the reason string to reference `finalResult.outcome` for consistency.

Concerns raised — review before merging

  • No linked issue detected — If this PR is intended to solve an issue, link it explicitly in the PR body.
  • Maintainer requires a linked issue — Link the relevant issue (for example Closes #123) before opening the PR.
📋 Copy for AI agents — paste into your coding agent
Fix the following blocker(s) from this PR review:

1. No linked issue detected — If this PR is intended to solve an issue, link it explicitly in the PR body.

2. Maintainer requires a linked issue — Link the relevant issue (for example `Closes #123`) before opening the PR.
Signal Result Evidence
Code review ❌ 2 blockers 1 reviewer
Linked issue ⚠️ Missing No linked issue or no-issue rationale found.
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 (no linked issue context).
Validation posture ✅ 25/25 PR body includes validation/test evidence.
Contributor workload ✅ 10/10 Author activity: 44 registered-repo PR(s), 36 merged, 321 issue(s).
Contributor context ✅ Confirmed Gittensor contributor JSONbored; Gittensor profile; 44 PR(s), 321 issue(s).
Gate result ❌ Blocking Repo-configured hard blocker found.
Improvement ✅ Minor risk: clean · value: minor — Code changes are accompanied by test evidence.
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), 321 issue(s).
  • PR-specific overlap: none found.
Contributor next steps
  • Treat this as maintainer-lane context rather than normal contributor-lane activity.
  • Explain no-issue PR.
  • Link the issue being solved, or explicitly explain why this is a no-issue PR.
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 941c300 into main Jul 13, 2026
20 checks passed
@JSONbored
JSONbored deleted the miner-attempt-log-provider-cost branch July 13, 2026 18:48
JSONbored added a commit that referenced this pull request Jul 14, 2026
…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. manual-review Gittensor contributor context

Development

Successfully merging this pull request may close these issues.

1 participant