feat(engine): build a labeled backtest corpus from rule-fired and human-override history#8094
feat(engine): build a labeled backtest corpus from rule-fired and human-override history#8094cleanjunc wants to merge 1 commit into
Conversation
…an-override history (JSONbored#8083)
|
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 #8094 +/- ##
==========================================
- Coverage 92.01% 92.01% -0.01%
==========================================
Files 753 754 +1
Lines 77157 77181 +24
Branches 23330 23335 +5
==========================================
+ Hits 70998 71018 +20
Misses 5053 5053
- Partials 1106 1110 +4
Flags with carried forward coverage won't be shown. Click here to find out more.
|
|
Caution 🛑 LoopOver review result - reject/close recommendedReview updated: 2026-07-22 22:09:06 UTC
Review summary Nits — 6 non-blocking
Why this is blocked
📋 Copy for AI agents — paste into your coding agentDecision 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.
|
|
LoopOver is closing this pull request on the maintainer's behalf (Linked issue overlaps another open PR; duplicate of open PR #8093). This is an automated maintenance action — to pursue this change, please open a new pull request with the issues resolved. Closed PRs may be analyzed later to improve review accuracy, but they are not automatically reopened or re-reviewed. |
Summary
Closes #8083.
Adds
packages/loopover-engine/src/calibration/backtest-corpus.ts— the labeled backtest corpus builder the parent epic (#8082) needs: wherecomputeRulePrecision(signal-tracking.ts) aggregates fired/override pairs into one precision number,buildBacktestCorpus(ruleId, fired, overrides)keeps each paired firing as an individual replayableBacktestCase("this rule fired against this target, and a human later said it was right/wrong").Everything follows the issue's spec exactly:
signal-tracking.ts's existing event types.BacktestCaseexactly as specified;metadatais the fired event's metadata, omitted entirely (never set toundefined) when absent — the same optional-property disciplineRuleFiredEventuses.computeRulePrecision-style): a firing pairs with the override sharing the function'sruleIdand the sametargetKey, choosing the override closest in time strictly after that firing; when none strictly follows, the most recent override byoccurredAt. One case per fired event, never duplicates. Unmatched firings are excluded — mirrorscomputeRulePrecision's "only the decided ones count" discipline.overrideMatchesRule's one-line filter with a comment noting the mirror;signal-tracking.tsitself is untouched (additive-only, per the issue's boundary).signal-tracking.jsexport inpackages/loopover-engine/src/index.ts, exactly where the issue specifies.Tests land in both suites:
packages/loopover-engine/test/backtest-corpus.test.ts(the issue's mandated file, mirroringsignal-tracking.test.ts's fixture style) — all five specified cases plus the equal-instant boundary of "strictly follows".test/unit/backtest-corpus.test.ts— a root-side vitest twin importing the engine src directly (the same direct-src patterntest/contract/*-parity.test.tsandtest/integration/miner-*.test.tsalready use). The engine package's ownnode --testsuite runs againstdist/outside root vitest's coverage instrumentation, so this twin is what makes the new file's coverage visible to thecodecov/patchgate rather than reporting 0%.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.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:
test:coverage(30+ min on this machine), I ran the directly-affected suites:npm run build --workspace @loopover/engine(green) + the engine package'snode --teston the new test file (9/9) + root vitest on the new twin with coverage (7/7), and measured patch coverage empirically by intersectingcoverage/lcov.infoDA/BRDArecords withgit diff -U0againstupstream/main: 100% of changed lines and branches inbacktest-corpus.ts(both sides of every conditional: has-override vs no-override, single vs multiple overrides including the no-strictly-following fallback, matching vs non-matchingruleId, present vs absentmetadata).actionlint/test:workers/build:mcp/test:mcp-pack/ui:*/npm audit: untouched surfaces — the diff is one new engine src file, one barrel-export line, and two test files; no workflows, workers, mcp, UI, or dependency changes (audit's current moderate findings exist onupstream/mainitself).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.The three unchecked Safety boxes are N/A: no auth/session/UI change of any kind — a pure, additive engine module plus tests.
UI Evidence
N/A — no UI change (pure engine module).
Notes