feat(calibration): pure per-repo corpus slicing + density stats - #8233
Conversation
Closes JSONbored#8215. Adds packages/loopover-engine/src/calibration/repo-corpus-slice.ts with sliceCorpusByRepo (group a BacktestCase[] by owner/repo parsed from targetKey's last '#', dropping unparseable keys, order-preserving) and computeRepoCorpusDensity (per-repo cases/confirmed/reversed plus an eligible flag that applies the same splitBacktestCorpus split + sample-minimum floors on each repo's own slice). Pure, aggregate-only. Barrel export + node:test (engine gate) + root vitest mirror (codecov coverage).
|
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 #8233 +/- ##
==========================================
- Coverage 92.10% 92.10% -0.01%
==========================================
Files 776 777 +1
Lines 78328 78350 +22
Branches 23668 23673 +5
==========================================
+ Hits 72147 72165 +18
Misses 5062 5062
- Partials 1119 1123 +4
Flags with carried forward coverage won't be shown. Click here to find out more.
|
|
Tip ✅ LoopOver review result - approve/merge recommendedReview updated: 2026-07-23 13:43:23 UTC
Review summary Nits — 3 non-blocking
Decision drivers
Context & advisory signals — never blocks the verdict
Linked issue satisfactionAddressed Review context
Contributor next steps
Signal definitions
🧪 Chat with LoopOverAsk LoopOver 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://loopover.ai/docs/loopover-commands 🧪 Experimental — new and may change. 🟩 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.
|
Summary
packages/loopover-engine/src/calibration/repo-corpus-slice.ts— the pure per-repo building block per-repo autonomy needs, besidebuildBacktestCorpus, same storage-agnostic 100%-covered discipline as calibration: pure BacktestCase corpus builder from RuleFiredEvent/HumanOverrideEvent pairs #8083–calibration: deterministic seeded held-out/visible split of the backtest corpus #8087.sliceCorpusByRepo(cases)→Map<repoFullName, BacktestCase[]>: parsesowner/repofrom eachtargetKey's last#(so an issue-fragment hash can't truncate the repo early), drops unparseable keys (no#, or an empty repo prefix) rather than guessing, and preserves input order within each slice (and first-seen order across keys) — deterministic.computeRepoCorpusDensity(cases, minVisible, minHeldOut, heldOutFraction, splitSeed)→ per-repo{ cases, confirmed, reversed, eligible }:eligibleapplies the samesplitBacktestCorpussplit + sample-minimum discipline the knob evaluators use, computed on each repo's own slice — so a large global corpus can't lend density to a sparse repo. Aggregate-only output (repo names + counts + a boolean; never a targetKey or metadata).backtest-corpus.js). Pure — no IO, store reads, or registry access. No behavior change to any existing consumer (additive).Tests
Two suites, per the epic's "engine blind-spot rule":
packages/loopover-engine/test/repo-corpus-slice.test.ts— thenode:testsuite gating the engine workspace's ownnpm run test(all 671 engine tests pass). It runs againstdistand is invisible to Codecov.test/unit/repo-corpus-slice-engine.test.ts— the root vitest mirror importing the enginesrcpath directly, which providescodecov/patchcoverage (the engine'snode:testoutput isn't harvested to Codecov). Covers multi-repo slicing, unparseable-key drops, last-#parsing, the confirmed/reversed split, both&&branches of the eligibility floors (visible-floor fail, held-out-floor fail, both-pass), the own-slice-floors invariant, split determinism, and the empty corpus — 100% of the diff's lines and branches, verified locally (21/21 lines, 0 missed branches).Scope
type(scope): short summaryConventional Commit format.CONTRIBUTING.mdand does not reintroduce GitHub Pages, VitePress,site/, orCNAME.Closes #8215).Validation
git diff --checknpm run typechecknpm run test:coveragelocally (100% patch coverage on the new file, verified via lcov)@loopover/enginebuild + its 671-testnode:testsuitenpm run test:engine-parity,npm run engine-parity:drift-check,npm run docs:drift-checkIf any required check was skipped, explain why:
test:cisteps (workers, mcp/miner packs, ui:build, db/drift checks) cannot be affected by it. Engine build + node:test, whole-repo typecheck, engine-parity, drift checks, and the unsharded coverage run were all executed and pass.Safety
UI Evidence
Not applicable — a pure calibration-engine function with no visible UI, frontend, docs, or extension change.
Notes