feat(miner): add a ledger metrics command that renders event-ledger Prometheus text (#4841) - #5486
Conversation
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5486 +/- ##
=======================================
Coverage 94.73% 94.74%
=======================================
Files 561 561
Lines 44794 44815 +21
Branches 14667 14667
=======================================
+ Hits 42437 42458 +21
Misses 1622 1622
Partials 735 735
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
|
Tip 🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩 ✅ Gittensory review result - approve/merge recommendedReview updated: 2026-07-12 23:13:50 UTC
✅ Suggested Action - Approve/Merge
Review summary Nits — 5 non-blocking
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 Gittensory, a quiet PR intelligence layer for OSS maintainers.
|
Summary
The event ledger is a structured audit trail, but the only way to consume it is
gittensory-miner ledger list --json— there is no scrape surface a self-hoster's own Grafana/Prometheus/alerting can ingest without polling that command and re-parsing its output (#4841).This adds a
gittensory-miner ledger metricssubcommand that renders the event ledger as Prometheus text-exposition counters:One
gittensory_miner_events_total{type}series per event type, so a new ledger entry is observable on the next scrape without pollingledger list. A scrape wrapper or cron job runs the command and serves/redirects its stdout.The renderer mirrors the metric-naming and HELP/TYPE/label conventions of the engine's existing
renderMinerPredictionMetrics(packages/gittensory-engine/src/miner-prediction-metrics.ts) — the same pattern themetricscommand already uses for prediction-calibration counters. It is pure and side-effect-free (the caller supplies the rows and prints the result), deterministic (series sorted by type), and always emits HELP/TYPE so an empty ledger is still a well-formed document. Likeledger list, the command is strictly local and offline: it reads only the local event ledger and makes no network calls.Scope
type(scope): short summaryConventional Commit format, for examplefix(api): restore profile access checks.CONTRIBUTING.mdand does not reintroduce GitHub Pages, VitePress,site/, orCNAME.Closes #123) — a linked open issue is required for every contributor PR.Validation
git diff --checknpm run actionlintnpm run typechecknpm run test:coveragelocally;codecov/patchrequires ≥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. Every changed line and branch here is covered (verified viacoverage/lcov.infoBRDA intersected withgit diff -U0).npm run test:workersnpm run build:mcpnpm run test:mcp-packnpm run ui:openapi:checknpm run ui:lintnpm run ui:typechecknpm run ui:buildnpm audit --audit-level=moderateIf any required check was skipped, explain why:
packages/gittensory-miner/libchange (the event-ledger CLI plus its--helpline) with no worker, MCP, OpenAPI, or UI surface. The checks that actually exercise it were run locally and are green:git diff --check,npm run actionlint,npm run typecheck,npm run test:coverage(changed lines and branches at 100%),npm run build:miner(node --checkover the miner lib),npm run miner:env-reference:check(confirms the change adds no newenv.*read, so the env-reference doc is unchanged), andnpm audit --audit-level=moderate. Thetest:workers,build:mcp,test:mcp-pack, andui:*jobs do not touch this package and are covered by this PR's CI.Safety
UI Evidencesection 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.Notes
runLedgerMetrics(render + exit 0, its own default-ledger open/close path, the unexpected-argument usage error, and both theErrorand non-Errorcatch arms), therunLedgerCli metricsdispatch, and the new--helpline.Closes #4841