Skip to content

feat(engine): add the Pareto-floor comparator for backtest score reports - #8110

Closed
cleanjunc wants to merge 1 commit into
JSONbored:mainfrom
cleanjunc:feat/8086-backtest-compare
Closed

feat(engine): add the Pareto-floor comparator for backtest score reports#8110
cleanjunc wants to merge 1 commit into
JSONbored:mainfrom
cleanjunc:feat/8086-backtest-compare

Conversation

@cleanjunc

Copy link
Copy Markdown
Contributor

Summary

Closes #8086.

Adds packages/loopover-engine/src/calibration/backtest-compare.ts — the pure Pareto-floor comparator between two BacktestScoreReports (#8085): a candidate rule change that regresses on ANY axis is "regressed", even while improving the other, so a fix can never be gamed by trading precision for recall or vice versa (the no-regression scoring METHOD the issue cites; nothing imported or copied from the external project).

Spec-exact:

  • BacktestComparison type and compareBacktestScores(baseline, candidate) exactly as specified; throws on mismatched ruleIds with both IDs in the message.
  • Per axis: either side null ⇒ the axis is excluded from both lists — insufficient decided data is never treated as 0 or as "no change"; strictly-less ⇒ regressed, strictly-greater ⇒ improved, equal ⇒ neither.
  • verdict is "regressed" whenever regressedAxes.length > 0a regression on even a single axis wins regardless of the other axis (the Pareto-floor rule; no weighted/averaged score anywhere); else "improved" when anything improved, else "unchanged".
  • Barrel export added on its own line immediately after the backtest-score.js export in packages/loopover-engine/src/index.ts, exactly where the issue specifies.

Tests land in both suites — packages/loopover-engine/test/backtest-compare.test.ts (the issue's mandated file: both-improve, the mixed improve/regress Pareto-floor case the issue marks non-optional, null-exclusion both directions, mismatched-ruleId throw with both IDs, all-equal unchanged) plus test/unit/backtest-compare.test.ts, the root-side vitest coverage twin importing the engine src directly (the pattern this module's own merged #8083 root test established: the engine's node --test suite runs against dist/ outside root vitest's coverage instrumentation, so the twin is what makes the new file's coverage visible to codecov/patch).

Scope

  • The PR title follows type(scope): short summary Conventional Commit format, for example fix(api): restore profile access checks.
  • This PR is focused and does not mix unrelated backend, UI, MCP, docs, dependency, and deploy changes.
  • This follows CONTRIBUTING.md and does not reintroduce GitHub Pages, VitePress, site/, or CNAME.
  • I linked a currently open issue this PR resolves (e.g. Closes #123) — a linked open issue is required for every contributor PR.

Validation

  • git diff --check
  • npm run actionlint
  • npm run typecheck
  • npm run test:coverage locally; codecov/patch requires ≥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:workers
  • npm run build:mcp
  • npm run test:mcp-pack
  • npm run ui:openapi:check
  • npm run ui:lint
  • npm run ui:typecheck
  • npm run ui:build
  • npm audit --audit-level=moderate
  • New or changed behavior has unit/integration tests for new branches, fallback paths, and sanitizer boundaries

If any required check was skipped, explain why:

  • Ran the directly-affected gates instead of the 30+-min unsharded suite: npm run build --workspace @loopover/engine (green), the engine node --test on the new file (6/6), root vitest on the coverage twin (5/5), and npm run typecheck (0 errors, run on this exact module during pre-validation). Every conditional's both sides are exercised: null-exclusion per direction, less/greater/equal per axis, the mismatched-ruleId throw, and all three verdicts.
  • actionlint/workers/mcp/ui/audit: untouched surfaces — one new pure engine file, one barrel line, two test files; zero dependency changes.

Safety

  • No secrets, wallet details, hotkeys, coldkeys, user PATs, private keys, raw trust scores, private rankings, or private maintainer evidence are exposed.
  • Public GitHub text stays sanitized, low-noise, and does not imply compensation guarantees or optimization tactics.
  • Auth, cookie, CORS, GitHub App, Cloudflare, or session changes include negative-path tests.
  • API/OpenAPI/MCP behavior is updated and tested where needed.
  • UI changes use live API data or real empty/error/loading states, not production mock/demo fallbacks.
  • Visible UI changes include a UI Evidence section 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.
  • Public docs/changelogs are updated where needed; changelogs are only edited for release-prep PRs.

The three unchecked Safety boxes are N/A: no auth/session/UI change — a pure, additive engine module plus tests.

UI Evidence

N/A — no UI change (pure engine module).

Notes

@cleanjunc
cleanjunc requested a review from JSONbored as a code owner July 22, 2026 22:42
@superagent-security

Copy link
Copy Markdown
Contributor

Superagent didn't find any vulnerabilities or security issues in this PR.

@codecov

codecov Bot commented Jul 22, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.01%. Comparing base (d07b057) to head (657f430).
⚠️ Report is 5 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8110      +/-   ##
==========================================
- Coverage   92.01%   92.01%   -0.01%     
==========================================
  Files         757      758       +1     
  Lines       77228    77240      +12     
  Branches    23346    23350       +4     
==========================================
+ Hits        71061    71069       +8     
  Misses       5061     5061              
- Partials     1106     1110       +4     
Flag Coverage Δ
shard-1 59.56% <0.00%> (+4.47%) ⬆️
shard-2 51.08% <0.00%> (-0.08%) ⬇️
shard-3 50.45% <100.00%> (-5.73%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...oopover-engine/src/calibration/backtest-compare.ts 100.00% <100.00%> (ø)

... and 1 file with indirect coverage changes

@loopover-orb loopover-orb Bot added the gittensor:feature Gittensor-scored feature linked to a feature issue — scores a 0.25x multiplier. label Jul 22, 2026
@loopover-orb

loopover-orb Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Caution

🛑 LoopOver review result - reject/close recommended

Review updated: 2026-07-22 23:03:50 UTC

4 files · 1 AI reviewer · 1 blocker · CI green · dirty

🛑 Suggested Action - Reject/Close

Review summary
The AI review returned non-blocking notes for this change but did not include a separate narrative summary. Review the nits below before deciding this PR.

Nits — 3 non-blocking
  • The two test files (packages/loopover-engine/test/backtest-compare.test.ts and test/unit/backtest-compare.test.ts) are near-duplicates of each other; the PR description explains this is an established coverage-twin pattern for this module, but it's worth confirming that convention is still desired going forward rather than indefinitely duplicating every test file.
  • backtest-compare.ts has no test for the case where both baseline and candidate values are equal to null on the same axis together with a real difference on the other axis in the engine's own node:test suite (only the vitest twin covers bothNull) — minor coverage asymmetry between the two suites.
  • None needed beyond the two nits above — the implementation is small, pure, and spec-exact.

Why this is blocked

  • No linked issue detected: The PR cites an issue number, but it could not be verified as a currently open issue. — If this PR is intended to solve an issue, link it explicitly in the PR body.
📋 Copy for AI agents — paste into your coding agent
Fix the following blocker(s) from this PR review:

1. No linked issue detected: The PR cites an issue number, but it could not be verified as a currently open issue. — If this PR is intended to solve an issue, link it explicitly in the PR body.

Decision drivers

  • ❌ Code review — 1 blocker (1 reviewer)
  • ❌ Gate result — Blocking (Repo-configured hard blocker found.)
Context & advisory signals — never blocks the verdict
Signal Result Evidence
Linked issue ✅ Linked #8086
Related work ⚠️ 1 scoped overlap Top overlaps are listed below; lower-confidence bulk is hidden.
Change scope ❌ 8/20 High review scope from cached public metadata (1 linked issue).
Validation posture ✅ 25/25 PR body includes validation/test evidence.
Contributor workload ✅ 10/10 Author activity: 46 registered-repo PR(s), 15 merged, 33 issue(s).
Contributor context ✅ Confirmed Gittensor contributor cleanjunc; Gittensor profile; 46 PR(s), 33 issue(s).
Improvement ✅ Minor risk: clean · value: minor
Linked issue satisfaction

Addressed
The diff adds backtest-compare.ts with the exact BacktestComparison type and compareBacktestScores implementation matching the spec (ruleId mismatch throw with both IDs, null-exclusion per axis, strict comparison, Pareto-floor verdict logic), plus the barrel export placed correctly, and both test suites explicitly cover the mandated mixed improve/regress case along with null exclusion, mismatched

Review context
  • Author: cleanjunc
  • Role context: outside_contributor
  • Public audience mode: oss maintainer
  • Lane context: Repository is configured for direct PR review.
  • Public profile languages: Python, TypeScript, JavaScript, Scala
  • Official Gittensor activity: 46 PR(s), 33 issue(s).
  • Related work: Titles/paths share 5 meaningful terms. (PR #8116)
Contributor next steps
  • Start here: Review top overlaps.
  • Then work through the remaining 2 steps in the Signals table above.
Signal definitions
  • Related work = same linked issue, overlapping active PRs, or title/path similarity.
  • Change scope = cached public metadata such as size labels, draft state, and review-burden hints.
  • Validation posture = whether the PR provides enough public validation/test evidence for maintainer review.
  • Contributor workload = public contributor activity and cleanup pressure, not a repo-wide quality failure.
  • Contributor context = public GitHub/Gittensor identity context; non-Gittensor status is not a blocker.
🧪 Chat with LoopOver

Ask 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.

  • @loopover ask &lt;question&gt; answers contribution-quality Q&A with source citations and freshness.
  • @loopover chat &lt;question&gt; answers in natural prose from cached decision-pack facts via local inference (maintainer/collaborator; read-only).
  • A plain-language @loopover mention with a real question is routed to the closest matching read-only command automatically — no exact syntax required.

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.

  • Re-run LoopOver review

@loopover-orb

loopover-orb Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

LoopOver is closing this pull request on the maintainer's behalf (conflicts with the base branch — resolve and open a fresh PR; No linked issue detected). 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.

@loopover-orb loopover-orb Bot closed this Jul 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gittensor:feature Gittensor-scored feature linked to a feature issue — scores a 0.25x multiplier.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

calibration: Pareto-floor comparator between two BacktestScoreReports

1 participant