Skip to content

ams-calibration: pure corpus adapter pairing prediction-ledger predictions with realized pr_outcome events #8183

Description

@JSONbored

Problem

Epic #8172's foundation: the miner already records every predicted gate verdict (prediction-ledger.sqlite3's predictions table — target, head_sha, conclusion, readiness_score, blocker codes, engine_version) and every realized result (pr_outcome events in miner_event_ledger — merged/closed + reason, via lib/pr-outcome.ts), but nothing pairs them into the BacktestCase shape the shared calibration primitives consume. Without that corpus, no AMS knob can ever be backtested.

Requirements

⚠️ Required pattern. The pairing transform is PURE and lives in @loopover/engine (the miner is a thin IO/SQLite shell — every calibration primitive already flows through that seam, e.g. lib/calibration-run.ts). The miner side contributes only ledger readers reusing the existing readPrOutcomes() / prediction-ledger read paths.

  • Pure adapter: prediction rows + realized outcomes (+ optional governor attempt_blocked/halt verdicts from governor_events) → BacktestCase[] compatible with buildBacktestCorpus/splitBacktestCorpus. Deterministic join key: repo + PR number, latest-prediction-per-head_sha semantics matching lib/calibration.ts's existing precision join.
  • Positive/negative class mapping documented in the module header: a closed outcome against a merge-shaped prediction is the miner's reversal analog; engine_version is carried so a corpus can be filtered to comparable engine builds.
  • Fully local: reads only the node's own ledgers. No network, no cross-node data.

Deliverables

  • Engine-pure adapter module with 100%-branch unit coverage (root vitest mirror test per the engine blind-spot rule)
  • Miner thin reader wiring (lib/) with pack-test coverage
  • Corpus stats read surfaced through the existing miner calibration CLI (buildCalibrationReport neighborhood)

Links & Resources

#8172 (epic), #8083 (the ORB analog), packages/loopover-engine/src/calibration/**, packages/loopover-miner/lib/prediction-ledger.ts, lib/pr-outcome.ts, lib/calibration.ts

Boundaries

No knob changes, no writes to any ledger — read-and-transform only. Corpus never leaves the node.

maintainer-only — epic decomposition of #8172.

Metadata

Metadata

Assignees

Labels

maintainer-onlyOwner-only work — yields no Gittensor points.roadmapOn the Wave-2 agent-layer roadmap board (project 9)

Projects

Status
In Progress

Relationships

None yet

Development

No branches or pull requests

Issue actions