Skip to content

feat(miner): add a metrics command that renders prediction-calibration Prometheus text (#4838) - #5470

Merged
JSONbored merged 1 commit into
JSONbored:mainfrom
cleanjunc:feat-miner-metrics-command
Jul 12, 2026
Merged

feat(miner): add a metrics command that renders prediction-calibration Prometheus text (#4838)#5470
JSONbored merged 1 commit into
JSONbored:mainfrom
cleanjunc:feat-miner-metrics-command

Conversation

@cleanjunc

Copy link
Copy Markdown
Contributor

Summary

  • Adds a gittensory-miner metrics subcommand that prints the miner's prediction-calibration counters in Prometheus text-exposition format to stdout, suitable for a scrape wrapper or a cron redirect.
  • Wires the already-built-but-uncalled engine renderer renderMinerPredictionMetrics (packages/gittensory-engine/src/miner-prediction-metrics.ts, feat(miner-selfimprove): calibration metrics exporter — Prometheus-style counters for prediction accuracy #4264) into the CLI without touching the renderer itself, per the issue's boundary. The command only reads the local prediction ledger (prediction-ledger.js readPredictions) and feeds the rows in.
  • Predicted conclusion counts populate gittensory_miner_predictions_total{conclusion="…"}; the correct/incorrect counters stay zero until an outcome-join exists, exactly as the renderer is designed to degrade before outcome-pairing.
  • Strictly local and offline, like status/doctor: it is dispatched before the opportunistic npm-registry update check and makes no network calls and no writes.

Closes #4838.

Scope

  • The PR title follows type(scope): short summary Conventional Commit format, for example fix(api): restore profile access checks.
  • This PR is focused and does not mix unrelated backend, UI, MCP, docs, dependency, and deploy changes.
  • This follows CONTRIBUTING.md and does not reintroduce GitHub Pages, VitePress, site/, or CNAME.
  • I linked a currently open issue this PR resolves (e.g. Closes #123) — a linked open issue is required for every contributor PR.

Validation

  • git diff --check
  • npm run actionlint
  • npm run typecheck
  • npm run test:coverage locally; codecov/patch requires ≥99% coverage of the lines AND branches you changed (aim for 100% on your diff so CI variance does not fail near the threshold). Global coverage is a non-blocking trend with a loose 90% backstop, not the gate.
  • npm run test:workers
  • npm run build:mcp
  • npm run test:mcp-pack
  • npm run ui:openapi:check
  • npm run ui:lint
  • npm run ui:typecheck
  • npm run ui:build
  • npm audit --audit-level=moderate
  • New or changed behavior has unit/integration tests for new branches, fallback paths, and sanitizer boundaries

If any required check was skipped, explain why:

  • This is an isolated packages/gittensory-miner/lib change with no worker, MCP, UI, API/OpenAPI, DB, or Cloudflare surface. Ran locally and green: git diff --check, actionlint, typecheck, build:miner (which node --checks the new files), test:miner-pack, miner:env-reference:check, npm audit, and vitest coverage scoped to the changed files — metrics-cli.js reports 100% of changed lines and 100% of branches (9/9), and the only cli.js change is a covered help-text line.
  • New unit tests (test/unit/miner-metrics-cli.test.ts) cover the command's rendered happy path, the self-owned default-ledger open/close path, unexpected-argument rejection, and both the Error and non-Error throw paths; the existing test/unit/miner-cli.test.ts help assertion is extended for the new command line.
  • The test:workers / build:mcp / test:mcp-pack / ui:* checks exercise surfaces this PR does not touch; they are left to the required validate CI job, which runs the full npm run test:ci chain.

Safety

  • No secrets, wallet details, hotkeys, coldkeys, user PATs, private keys, raw trust scores, private rankings, or private maintainer evidence are exposed.
  • Public GitHub text stays sanitized, low-noise, and does not imply compensation guarantees or optimization tactics.
  • Auth, cookie, CORS, GitHub App, Cloudflare, or session changes include negative-path tests. — N/A: no auth/session/network surface; the command is local-only and offline.
  • API/OpenAPI/MCP behavior is updated and tested where needed. — N/A: no API/OpenAPI/MCP surface changes (the metric names/HELP/TYPE are produced by the unchanged engine renderer).
  • UI changes use live API data or real empty/error/loading states, not production mock/demo fallbacks. — N/A: no UI changes.
  • Visible UI changes include a UI Evidence section below with JPG/JPEG or PNG screenshots arranged as organized, captioned, clickable thumbnails. SVG screenshots are not used as review evidence. Review-only screenshots or recordings are not committed to the repository. — N/A: CLI-only change, no visible UI/frontend/extension surface.
  • Public docs/changelogs are updated where needed; changelogs are only edited for release-prep PRs. — the command is listed in gittensory-miner --help; no changelog edit.

Notes

  • The engine renderer already terminates its output with a trailing newline; the command trims it before console.log so exactly one trailing newline is emitted (no doubled blank line), keeping the output byte-clean for a scrape/cron consumer.

@cleanjunc
cleanjunc requested a review from JSONbored as a code owner July 12, 2026 21:47
@superagent-security

Copy link
Copy Markdown
Contributor

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

@codecov

codecov Bot commented Jul 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.71%. Comparing base (6a6426e) to head (b5b95e9).
⚠️ Report is 10 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5470   +/-   ##
=======================================
  Coverage   94.71%   94.71%           
=======================================
  Files         556      557    +1     
  Lines       44546    44562   +16     
  Branches    14664    14664           
=======================================
+ Hits        42192    42208   +16     
  Misses       1619     1619           
  Partials      735      735           
Flag Coverage Δ
shard-1 43.88% <100.00%> (-0.14%) ⬇️
shard-2 35.22% <0.00%> (-0.02%) ⬇️
shard-3 32.09% <0.00%> (+0.08%) ⬆️
shard-4 31.59% <0.00%> (-0.54%) ⬇️
shard-5 33.13% <0.00%> (+0.37%) ⬆️
shard-6 43.75% <0.00%> (+0.26%) ⬆️

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

Files with missing lines Coverage Δ
packages/gittensory-miner/lib/cli.js 100.00% <ø> (ø)
packages/gittensory-miner/lib/metrics-cli.js 100.00% <100.00%> (ø)
🚀 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 12, 2026
@loopover-orb

loopover-orb Bot commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

Tip

🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩

✅ Gittensory review result - approve/merge recommended

Review updated: 2026-07-12 21:56:29 UTC

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

✅ Suggested Action - Approve/Merge

  • safe to merge

Review summary
This PR wires the existing, previously-unused engine renderer `renderMinerPredictionMetrics` into a new `gittensory-miner metrics` CLI command that reads the local prediction ledger and prints Prometheus text to stdout. The wiring is correct and minimal: it dispatches before the update-check network call (matching status/doctor), owns/closes the ledger only when not injected, and trims the renderer's trailing newline to avoid double-newlining console.log's own terminator. Tests cover the happy path, default-ledger open/close, usage errors, and both Error/non-Error throw paths, and CI is green.

Nits — 5 non-blocking
  • The `console.log`/`console.error` calls flagged as 'debug leftovers' in the brief are the intended production output of this command (it's a stdout-emitting CLI), not leftover debugging — no action needed, but worth noting the brief's heuristic doesn't apply here.
  • packages/gittensory-miner/lib/metrics-cli.js: the JSDoc comment on `collectPredictionMetricRows` duplicates the module-header comment's explanation of the zero correct/incorrect counters; consider trimming one for conciseness.
  • The linked issue Wire the existing miner-prediction Prometheus renderer into a real command #4838 is only partially covered per the brief (issue asks to wire the renderer, which this does) — worth a one-line confirmation in the PR description that no further scope from Wire the existing miner-prediction Prometheus renderer into a real command #4838 remains.
  • Consider a brief mention in the CLI help text or README that the correct/incorrect counters are always zero until outcome-pairing ships, so operators scraping this early aren't confused by static zero series.
  • If a `--json` or scrape-loop mode is ever requested, keep the current single-shot stdout design as the default per its stated cron/scrape-wrapper use case.
Signal Result Evidence
Code review ✅ No blockers 1 reviewer
Linked issue ✅ Linked #4838
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: 66 registered-repo PR(s), 26 merged, 30 issue(s).
Contributor context ✅ Confirmed Gittensor contributor cleanjunc; Gittensor profile; 66 PR(s), 30 issue(s).
Gate result ✅ Passing No configured blocker found.
Improvement ✅ Minor risk: clean · value: minor — Code changes are accompanied by test evidence.
Review context
  • Author: cleanjunc
  • Role context: outside_contributor
  • Public audience mode: oss maintainer
  • Lane context: Repository is configured for direct PR review.
  • Public profile languages: not available
  • Official Gittensor activity: 66 PR(s), 30 issue(s).
  • PR-specific overlap: none found.
Contributor next steps
  • Keep the PR focused and include validation evidence before maintainer review.
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 Gittensory, a quiet PR intelligence layer for OSS maintainers.

  • Re-run Gittensory review

@loopover-orb loopover-orb Bot added the manual-review Gittensor contributor context label Jul 12, 2026
@JSONbored
JSONbored merged commit 29c18f2 into JSONbored:main Jul 12, 2026
16 checks passed
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Wire the existing miner-prediction Prometheus renderer into a real command

2 participants