Skip to content

feat(mcp): expose the miner-local calibration report as a read-only MCP tool (loopover_miner_get_calibration_report) #5821

Description

@JSONbored

Context

packages/loopover-miner/lib/calibration-cli.js (loopover-miner calibration [--json], #4849) already builds a read-only report that joins the miner's own local prediction ledger (prediction-ledger.js) with its locally-observed PR outcomes (event-ledger.js's pr_outcome events) via the pure buildCalibrationReport composer, producing per-project merge/close precision. It is strictly local and offline — no network call, no mutation.

This is distinct from the ORB-side loopover_get_outcome_calibration MCP tool already registered in src/mcp/server.ts (line ~1660): that tool is maintainer-authenticated and reads slop-band/recommendation calibration from the hosted review database (D1) for a {owner, repo} the caller has access to. The miner-local calibration report reads a different data source (the miner's own on-disk SQLite ledgers) and needs no maintainer auth or network round-trip at all — a contributor running a self-hosted AMS miner has no way to ask "how accurate have my own gate predictions been?" via MCP today, only via the CLI.

The AMS miner's own stdio MCP server, packages/loopover-miner/bin/loopover-miner-mcp.js, already exposes exactly this shape of capability for sibling local stores — e.g. loopover_miner_get_governor_decisions (read-only projection over governor-ledger.js) and loopover_miner_status (wraps status.js's collectStatus/runDoctorChecks). Calibration has no equivalent tool despite following the identical "thin read-only wrapper around an existing pure aggregator" pattern (see the header comment in calibration-cli.js itself, and the file's own doc comment cross-referencing event-ledger-cli.js's runLedgerMetrics and queue-cli.js's runQueueMetrics as siblings).

Requirements

  • Add a new tool loopover_miner_get_calibration_report to packages/loopover-miner/bin/loopover-miner-mcp.js, registered via server.registerTool(...) alongside the existing nine tools (loopover_miner_ping, loopover_miner_get_portfolio_dashboard, loopover_miner_list_claims, loopover_miner_get_audit_feed, loopover_miner_get_run_state, loopover_miner_list_plans, loopover_miner_get_plan, loopover_miner_get_governor_decisions, loopover_miner_status).
  • Input schema: no arguments (mirrors loopover_miner_get_portfolio_dashboard and loopover_miner_status, which also take {} — the underlying CLI command takes no positional/filter args either).
  • Implementation: open the prediction ledger and event ledger (respecting the existing options.initPredictionLedger / options.initEventLedger injection seams already used by the other tools for testability), call the SAME toPredictionRecords / toOutcomeRecords mapping helpers and buildCalibrationReport composer that calibration-cli.js already uses — do not reimplement the join. Close whichever store(s) this tool itself opened, exactly like the existing tools' finally blocks.
  • Description text must state plainly that this is local-only, read-only, and reuses the existing CLI's report builder with no new join/scoring logic — follow the phrasing convention already used by the other 9 tool descriptions (e.g. loopover_miner_get_governor_decisions's "no new logic, no mutation").
  • Output: the same JSON shape buildCalibrationReport already returns (an object with hasSignal and, when true, per-project rows), passed through unchanged — do not reshape it.

Deliverables

  • loopover_miner_get_calibration_report tool registration in packages/loopover-miner/bin/loopover-miner-mcp.js, with an options.initPredictionLedger / options.initEventLedger injection seam matching the file's existing convention
  • Unit test(s) covering: the has-signal case (at least one decided prediction with a matching pr_outcome), the no-signal case (hasSignal: false, matching calibration-cli.js's own "no decided predictions yet" branch), and that the tool opens/closes only the stores it itself opened (mirroring the existing tests for loopover_miner_get_governor_decisions)
  • Add the new tool to the file's own header-comment tool list (the block above createMinerMcpServer that currently documents all 9 tools with their issue numbers)

Test Coverage Requirements

99%+ Codecov patch coverage on every changed line and branch in packages/loopover-miner/bin/loopover-miner-mcp.js — both the has-signal and no-signal branches of the underlying buildCalibrationReport result must be exercised by the new test(s), plus the store-ownership (opens-and-closes-only-what-it-opened) invariant the sibling tools already test for.

Expected Outcome

An MCP client connected to the gittensory-miner stdio server (e.g. npx @loopover/miner mcp or the packaged loopover-miner-mcp bin) can call loopover_miner_get_calibration_report and get the same per-project merge/close prediction-accuracy report that loopover-miner calibration --json prints today, without shelling out to the CLI.

Links & Resources

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    gittensor:featureGittensor-scored feature linked to a feature issue — scores a 0.25x multiplier.help wantedExtra attention is needed

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions