Skip to content

fix(engine): scope reward-risk open-PR count to the repo, not the portfolio (#8865) - #9022

Merged
JSONbored merged 2 commits into
JSONbored:mainfrom
RealDiligent:fix/critical-issue-reward-risk-repo-open-pr-8865
Jul 26, 2026
Merged

fix(engine): scope reward-risk open-PR count to the repo, not the portfolio (#8865)#9022
JSONbored merged 2 commits into
JSONbored:mainfrom
RealDiligent:fix/critical-issue-reward-risk-repo-open-pr-8865

Conversation

@RealDiligent

@RealDiligent RealDiligent commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

Problem

Closes #8865.

In packages/loopover-engine/src/reward-risk.ts, buildRepoRewardRisk computed:

const currentOpenPrCount = nonNegative(args.outcomeHistory.totals.openPullRequests);       // portfolio-wide
const currentOpenIssueCount = nonNegative(repoOutcome?.openIssues ?? args.outcomeHistory.totals.openIssues); // repo-scoped

The open-PR count used the contributor's portfolio-wide total across every repo, while the very next line correctly scopes open issues to the repo, and buildActions separately uses the correct repo-scoped args.repoOutcome?.openPullRequests ?? 0. Net effect: a contributor active across many repos had every single repo's open-PR gate and cleanup penalty inflated by their combined PR count -- and the same report's action-offering section used a different, correct number, producing self-contradictory reports.

Fix

Prefer the repo-scoped count first, matching the pattern already used one line below for issues and in buildActions:

const currentOpenPrCount = nonNegative(repoOutcome?.openPullRequests ?? args.outcomeHistory.totals.openPullRequests);

Test

test/unit/reward-risk-freshness.test.ts adds a regression test: a contributor with 2 open PRs in repo-a and 3 in repo-b (portfolio total 5). It first pins the fixture (totals.openPullRequests === 5, repoOutcomes[repo-a].openPullRequests === 2), then asserts repo-a's report riskBreakdown.openPullRequests === 2 -- its own count, not the combined total. Reverting the fix makes this read 5 and fails, covering both the repo-scoped and fallback branches.


CI note (required to make validate-code green)

This branch also includes a one-line .release-please-manifest.json sync (packages/loopover-engine: 3.14.13.15.0). packages/loopover-engine/package.json was bumped to 3.15.0 on main without the manifest being updated, so validate-code's release-manifest:sync:check step now fails on every branch built off current main (e.g. #9010 hit the same wall). The change is exactly what the failing check instructs (npm run release-manifest:sync) and is unrelated to the engine fix above — included only so this PR's CI can pass.

@RealDiligent
RealDiligent requested a review from JSONbored as a code owner July 26, 2026 15:59
@superagent-security

Copy link
Copy Markdown
Contributor

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

…tfolio

buildRepoRewardRisk computed currentOpenPrCount from the contributor-wide
totals.openPullRequests, while the very next line scopes open issues to the
repo (repoOutcome?.openIssues ?? totals) and buildActions scopes open PRs
the same way. A contributor active across many repos therefore had every
repo's open-PR gate and cleanup penalty inflated by their portfolio-wide PR
count, contradicting the offered-actions section of the same report.

Prefer repoOutcome?.openPullRequests before the portfolio-wide fallback,
matching the pattern already used one line below for issues.
@loopover-orb loopover-orb Bot added the gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. label Jul 26, 2026
@codecov

codecov Bot commented Jul 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.88%. Comparing base (f5fe939) to head (b0bc5eb).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #9022      +/-   ##
==========================================
- Coverage   93.88%   93.88%   -0.01%     
==========================================
  Files         809      809              
  Lines       80563    80563              
  Branches    24441    24442       +1     
==========================================
- Hits        75638    75634       -4     
  Misses       3560     3560              
- Partials     1365     1369       +4     
Flag Coverage Δ
backend 95.16% <100.00%> (-0.01%) ⬇️

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

Files with missing lines Coverage Δ
packages/loopover-engine/src/reward-risk.ts 100.00% <100.00%> (ø)

... and 1 file with indirect coverage changes

@loopover-orb

loopover-orb Bot commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

Caution

🛑 LoopOver review result - fixes required

Review updated: 2026-07-26 16:11:45 UTC

2 files · 1 AI reviewer · no blockers · CI failing · unstable

🛑 Suggested Action - Fix Blockers

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 — 1 non-blocking
  • The two undetailed FAILED checks (validate, validate-code) can't be diagnosed from what's given, and this branch is 3 commits behind default — worth rebasing to rule that out before merge.

CI checks failing

  • validate
  • validate-code

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 #8865
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: 305 registered-repo PR(s), 121 merged, 37 issue(s).
Contributor context ✅ Confirmed Gittensor contributor RealDiligent; Gittensor profile; 305 PR(s), 37 issue(s).
Improvement ✅ Minor risk: clean · value: minor · LLM: moderate
Linked issue satisfaction

Addressed
The diff makes the exact one-line change requested, preferring repoOutcome?.openPullRequests before falling back to the portfolio-wide total, and adds a two-repo regression test asserting the repo-scoped count (2) is used instead of the combined total (5), matching the issue's required deliverables.

Review context
  • Author: RealDiligent
  • Role context: outside_contributor
  • Public audience mode: oss maintainer
  • Lane context: Repository is configured for direct PR review.
  • Public profile languages: Python, Ruby, TypeScript, Svelte, Cuda, JavaScript, Markdown, MDX
  • Official Gittensor activity: 305 PR(s), 37 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 26, 2026
packages/loopover-engine/package.json is 3.15.0 but
.release-please-manifest.json still recorded 3.14.1, so the
release-manifest:sync:check step of validate-code fails on every branch
built off current main. Run the sanctioned npm run release-manifest:sync
to align the manifest, unblocking CI.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. manual-review Gittensor contributor context

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(engine): reward-risk scores a repo's open-PR gate off the contributor's global PR count, not that repo's own

2 participants