Skip to content

feat(engine): aggregate REGRESSED-verdict track-record statistics from persisted backtest CI results - #8143

Merged
JSONbored merged 1 commit into
JSONbored:mainfrom
cleanjunc:feat/8140-regressed-track-record
Jul 23, 2026
Merged

feat(engine): aggregate REGRESSED-verdict track-record statistics from persisted backtest CI results#8143
JSONbored merged 1 commit into
JSONbored:mainfrom
cleanjunc:feat/8140-regressed-track-record

Conversation

@cleanjunc

Copy link
Copy Markdown
Contributor

Summary

Closes #8140.

Adds the aggregation #8105's Phase-2 merge-gating decision needs: computeRegressedVerdictTrackRecord (packages/loopover-engine/src/calibration/backtest-track-record.ts) — a pure function turning an array of historical BacktestComparison results (#8086) into the decision summary (total runs, REGRESSED count, a regressedRate that stays null for zero runs — the module's established never-coerce-unknown-to-0 discipline — and a per-ruleId Map breakdown of total/regressed/improved/unchanged), plus the thin CLI (scripts/backtest-track-record.ts) that reads the rows the advisory backtest CI check persists (#8138, calibration.threshold_backtest_run in audit_events, metadata.comparison) and prints the summary.

  • The event-type literal mirrors THRESHOLD_BACKTEST_EVENT_TYPE in src/services/threshold-backtest-run.ts with a keep-in-sync comment — that module is Worker-bound (D1 repository import graph) and deliberately not imported into a standalone script, the same posture the merged backtest-corpus-export.ts takes toward signal-tracking-wire's private helpers.
  • The CLI mirrors export-d1-data.ts's parseArgs/d1Query shell-out exactly (read-only, fail-loud) and contains no logic beyond the read, the JSON-parse (fail-open per-row, matching listAuditEventsByType's own posture), the pure-function call, and printing — per the epic's established pure-core/thin-IO exemption, no dedicated wrapper test.
  • Barrel export added after the backtest-report.js line, continuing the module's export order.

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:

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 engine module + read-only CLI.

UI Evidence

N/A — no UI change.

Notes

@cleanjunc
cleanjunc requested a review from JSONbored as a code owner July 23, 2026 03:18
@superagent-security

Copy link
Copy Markdown
Contributor

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

@codecov

codecov Bot commented Jul 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.03%. Comparing base (9258836) to head (d8b3dc6).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #8143   +/-   ##
=======================================
  Coverage   92.03%   92.03%           
=======================================
  Files         763      764    +1     
  Lines       77506    77520   +14     
  Branches    23425    23430    +5     
=======================================
+ Hits        71332    71346   +14     
  Misses       5062     5062           
  Partials     1112     1112           
Flag Coverage Δ
shard-1 57.65% <100.00%> (+3.95%) ⬆️
shard-2 50.89% <0.00%> (-3.84%) ⬇️
shard-3 54.47% <0.00%> (+0.36%) ⬆️

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

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

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

loopover-orb Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Tip

✅ LoopOver review result - approve/merge recommended

Review updated: 2026-07-23 03:33:17 UTC

5 files · 1 AI reviewer · no blockers · readiness 100/100 · CI green · clean

✅ Suggested Action - Approve/Merge

  • safe to merge

Review summary
This PR adds a pure aggregation function `computeRegressedVerdictTrackRecord` that folds an array of `BacktestComparison` results into total/regressed counts, a null-safe `regressedRate`, and a per-ruleId breakdown, plus a thin read-only CLI (`scripts/backtest-track-record.ts`) that pulls persisted rows from `audit_events` via `wrangler d1 execute` and prints the summary. The aggregation logic is straightforward and correctly exhaustive over the three verdict states, the zero-runs null-rate case is explicitly tested, and the barrel export is added in the right place. The CLI's SQL interpolates only a hardcoded constant (not user input) so there's no injection risk, and the fail-open per-row JSON parse mirrors the existing `listAuditEventsByType` posture as claimed.

Nits — 5 non-blocking
  • scripts/backtest-track-record.ts:36 hardcodes the 256*1024*1024 maxBuffer and other magic numbers (500-char stderr slice) without a named constant — minor, matches export-d1-data.ts's existing style per the PR description but worth a quick check for consistency.
  • packages/loopover-engine/src/calibration/backtest-track-record.ts has no branch test for a comparison with an unrecognized/malformed ruleId feeding into the CLI's `typeof comparison.ruleId === 'string'` guard — worth a one-line CLI-level sanity test even under the pure-core/thin-IO exemption.
  • The CLI's `d1Query` error message truncates stderr/stdout to 500 chars — reasonable, but consider noting in a comment why 500 was chosen if it's arbitrary.
  • Consider extracting the `256 * 1024 * 1024` maxBuffer literal in scripts/backtest-track-record.ts:36 into a named constant like export-d1-data.ts likely already does, for consistency.
  • The per-rule Map iteration order in the CLI's print loop (scripts/backtest-track-record.ts:69) is insertion order — fine for now, but if stable alphabetical output is ever needed for snapshotting CI comments, sort ruleIds first.

Decision drivers

  • ✅ Code review — No blockers (1 reviewer)
  • ✅ Gate result — Passing (No configured blocker found.)
Context & advisory signals — never blocks the verdict
Signal Result Evidence
Linked issue ✅ Linked #8140
Related work ✅ No active overlap found No same-issue or scoped active PR overlap found.
Change scope ✅ 20/20 Low 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: 52 registered-repo PR(s), 18 merged, 33 issue(s).
Contributor context ✅ Confirmed Gittensor contributor cleanjunc; Gittensor profile; 52 PR(s), 33 issue(s).
Improvement ✅ Minor risk: clean · value: minor · LLM: moderate
Linked issue satisfaction

Addressed
The PR adds the pure computeRegressedVerdictTrackRecord function in packages/loopover-engine/src/calibration/ with the requested total/regressed rate and per-ruleId Map breakdown, includes tests covering zero runs, all-clean, some-regressed, and multi-ruleId cases, and adds a thin CLI wrapper that reads audit_events rows and prints the summary.

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: 52 PR(s), 33 issue(s).
  • PR-specific overlap: none found.
Contributor next steps
  • Keep the PR focused and include validation evidence before maintainer review.
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 added the manual-review Gittensor contributor context label Jul 23, 2026
@JSONbored
JSONbored merged commit 4578fef into JSONbored:main Jul 23, 2026
12 checks passed
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. manual-review Gittensor contributor context

Projects

None yet

Development

Successfully merging this pull request may close these issues.

calibration: compute REGRESSED-verdict track-record statistics from ORB's persisted backtest results

2 participants