feat(calibration): pure counterfactual fixture assembler per the replay contract#8247
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 #8247 +/- ##
==========================================
- Coverage 92.12% 92.12% -0.01%
==========================================
Files 782 783 +1
Lines 78531 78551 +20
Branches 23720 23725 +5
==========================================
+ Hits 72347 72363 +16
Misses 5062 5062
- Partials 1122 1126 +4
Flags with carried forward coverage won't be shown. Click here to find out more.
|
|
Warning ⏸️ LoopOver review result - manual review recommendedReview updated: 2026-07-23 14:54:29 UTC
Review summary Nits — 4 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/counterfactual-fixtures.ts(Epic: AI counterfactual backtesting — prompt/model changes earn the same evidence gate as rule changes #8218 sub-epic phase 2):assembleCounterfactualFixtures(cases, contract)— pure selection, no AI calls, no IO — implementing the counterfactual: design the offline judge-replay contract — sampling, spend budget, scoring mapping #8219 contract's shapes verbatim (CounterfactualFixture,CounterfactualSamplingContract,CounterfactualSkipReason, and the contract's ownisReplayableCasenarrowing helper; nothing re-invented).metadata.diff, non-empty) + label; every exclusion is accounted in the returnedskipped: Record<CounterfactualSkipReason, number>(the Extend the backtest check to logic/regex changes via a dedicated CI job, using captured raw context #8139 skipped-case discipline) —fixtures + skipsalways sums to the input corpus, pinned by an invariant test.metadata.rawContextProvenance, the live calibration: capture bounded raw context (issueText/prTitle/prBody/diff) in linked_issue_scope_mismatch's fired-event metadata #8129/calibration: capture bounded raw context for the remaining isConfiguredGateBlocker codes, excluding secret_leak #8130 writers never set it — presence of the key ⇒raw_context_refetch, otherwiselive_capture, so results segment by capture era.maxFixtures, via thesplitBacktestCorpuscontent-hash discipline (sha256(${seed}:${targetKey}), first-8-hex rank, lowest ranks win) — never "the first N"; corpus order preserved within the sample; a same-target rank tie breaks toward the earlier case, deterministically.Closes #8220
Test plan
test/unit/counterfactual-fixtures-engine.test.ts(vitest, importing the engine source — the root mirror suite): eligibility arms (missing diff, empty diff, replayable) with skip accounting + the sum invariant; era segmentation both ways; under-budget no-sampling vs over-budget seeded sampling with preserved corpus order; same-seed byte-determinism, cross-seed divergence, and the not-first-N pin; the forced two-element same-target tie-break; empty corpuspackages/loopover-engine/test/counterfactual-fixtures.test.ts(node:test vs dist): barrel re-export + eligibility/provenance/skip round-trip + sampling determinismnpm run typecheckclean