Skip to content

fix(engine): surface linked-issue overflow in the predicted-gate preview - #9043

Merged
loopover-orb[bot] merged 1 commit into
JSONbored:mainfrom
nghetien:fix/issue-8868-a1-fix-engine-predicted
Jul 26, 2026
Merged

fix(engine): surface linked-issue overflow in the predicted-gate preview#9043
loopover-orb[bot] merged 1 commit into
JSONbored:mainfrom
nghetien:fix/issue-8868-a1-fix-engine-predicted

Conversation

@nghetien

Copy link
Copy Markdown
Contributor

The predicted-gate engine's local extractLinkedIssueNumbers silently truncated a PR body at MAX_LINKED_ISSUE_NUMBERS = 50 and returned the trimmed list with no other signal. The maintainer-side linked-issue hard rule (src/review/linked-issue-hard-rules.ts, via src/db/repositories.ts's extractLinkedIssueNumbersWithOverflow) hard-fails the same body with "PR body links more issues than LoopOver can safely verify automatically; please reduce linked closing references or request maintainer review." — so the local prediction told miners the PR was ready while the upstream gate would close it.

Mirror the maintainer helper's shape:

  • Add extractLinkedIssueNumbersWithOverflow(text, repoFullName): { numbers, overflow } next to the existing extractor (kept as a thin wrapper so unrelated callers don't move).
  • Have buildPreflightResult consume the overflow flag and push a linked_issue_overflow finding at severity: "critical" (the existing hasWarning check already lifts a critical finding to status: "needs_work"), carrying the maintainer gate's own reason string verbatim so miners see identical wording.
  • Expose the new helper on predictedGateEngineInternals for parity tests.

Added a regression test with 51 distinct closing references that asserts the finding, its critical severity, the exact detail string, status === "needs_work", and the direct extractor result. A second test pins the negative cases: a body at exactly 50 unique references, and a 100-line body that dedupes to 50 uniques, must NOT flag overflow (matching the maintainer helper's length > cap semantics).

Validation

  • npx turbo run build --filter=@loopover/engine && npx turbo run build --filter=@loopover/mcp && npx turbo run build:tsc build:verify --filter=@loopover/miner — green
  • npx vitest run --changed=upstream/main --passWithNoTests — 12421 pass / 16 skipped
  • npm test — full suite green after prerequisite npm run build --workspace @loopover/ui-kit (that test file's own name flags the build as an environment prereq; unrelated to this diff)
  • npx vitest run test/unit/predicted-gate-engine.test.ts — 36 pass, including the new fix(engine): predicted-gate's linked-issue extractor truncates instead of mirroring the maintainer gate's overflow hard-fail #8868 regression + at-cap negative test

Closes #8868

The predicted-gate engine's extractor silently truncated PR bodies with more
than MAX_LINKED_ISSUE_NUMBERS closing references, so the local preview looked
ready while the maintainer-side linked-issue hard rule (which reads the SAME
overflow signal via extractLinkedIssueNumbersWithOverflow in
src/review/linked-issue-hard-rules.ts) would close the PR outright.

Mirror the maintainer helper's shape: expose an overflow-aware extractor
alongside the existing one and have buildPreflightResult raise a critical
linked_issue_overflow finding carrying the maintainer gate's own message when
the cap is exceeded.
@nghetien
nghetien requested a review from JSONbored as a code owner July 26, 2026 16:12
@superagent-security

Copy link
Copy Markdown
Contributor

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

@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.87%. Comparing base (62e6d25) to head (80c0d22).
⚠️ Report is 12 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #9043      +/-   ##
==========================================
- Coverage   93.88%   93.87%   -0.01%     
==========================================
  Files         807      807              
  Lines       80496    80502       +6     
  Branches    24411    24413       +2     
==========================================
+ Hits        75572    75574       +2     
  Misses       3560     3560              
- Partials     1364     1368       +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 Δ
...opover-engine/src/signals/predicted-gate-engine.ts 100.00% <100.00%> (ø)

... and 1 file with indirect coverage changes

@loopover-orb loopover-orb Bot added the gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. label Jul 26, 2026
@loopover-orb

loopover-orb Bot commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

Tip

✅ LoopOver review result - approve/merge recommended

Review updated: 2026-07-26 16:29:55 UTC

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

✅ Suggested Action - Approve/Merge

  • safe to merge

Review summary
This PR adds an `extractLinkedIssueNumbersWithOverflow` wrapper that mirrors the maintainer-side hard rule's overflow detection, wiring a critical `linked_issue_overflow` finding into `buildPreflightResult` with the exact detail string from the upstream gate. The change is well-scoped: the old `extractLinkedIssueNumbers` becomes a thin wrapper delegating to the new function (preserving existing callers unchanged), and the overflow condition (`unique.length > MAX_LINKED_ISSUE_NUMBERS`) correctly matches the maintainer helper's `length > cap` semantics described in the PR body. Tests cover the boundary (51 overflow, 50 at-cap, 100-lines-deduping-to-50) and assert both the finding shape and the direct extractor's `overflow` flag.

Nits — 3 non-blocking

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 #8868
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: 4 registered-repo PR(s), 1 merged, 0 issue(s).
Contributor context ✅ Confirmed Gittensor contributor nghetien; Gittensor profile; 4 PR(s), 0 issue(s).
Improvement ✅ Minor risk: clean · value: minor · LLM: moderate
Linked issue satisfaction

Partially addressed
The PR adds the overflow-aware extractor and wires a critical `linked_issue_overflow` finding into `buildPreflightResult` with the maintainer gate's exact message, satisfying the first two deliverables, but the diff only adds tests in `predicted-gate-engine.test.ts` and never adds a 51+-reference fixture verified through the `engine-parity-fixtures.test.ts` harness as explicitly required by the th

Review context
  • Author: nghetien
  • Role context: outside_contributor
  • Public audience mode: oss maintainer
  • Lane context: Repository is configured for direct PR review.
  • Public profile languages: Dart, JavaScript, Python, CSS, C#, C++, TypeScript
  • Official Gittensor activity: 4 PR(s), 0 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 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LoopOver approves — the gate is satisfied and CI is green.

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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(engine): predicted-gate's linked-issue extractor truncates instead of mirroring the maintainer gate's overflow hard-fail

1 participant