Skip to content

fix(dup-winner): order open-sibling query by number so the cap keeps the winner - #1236

Merged
JSONbored merged 1 commit into
mainfrom
fix/duplicate-winner-ordering
Jun 24, 2026
Merged

fix(dup-winner): order open-sibling query by number so the cap keeps the winner#1236
JSONbored merged 1 commit into
mainfrom
fix/duplicate-winner-ordering

Conversation

@JSONbored

Copy link
Copy Markdown
Owner

Summary

Closes audit finding 3.9. listOtherOpenPullRequests applied LIMIT(100) with no ORDER BY. The duplicate-winner adjudication (isDuplicateClusterWinner) elects the minimum open PR number as the cluster winner — but on a repo with >100 open PRs, an unordered LIMIT (rows in unspecified/insertion order) could drop the true lowest-numbered sibling, mis-electing a higher-numbered PR as winner (sparing it and closing the real winner). Now ordered by ascending number so the 100-row window always retains the lowest open siblings.

Finding 3.10 (number-based election with no quality check) is the documented, owner-flag-gated design per the audit — out of scope here.

Scope

  • Backend only (src/db/repositories.ts); no schema change; no migration
  • Gated behind owner-only GITTENSORY_DUPLICATE_WINNER (default off); a latent-correctness fix regardless

Validation

Safety

  • No secrets / wallets / hotkeys / trust scores / reward values
  • No site/ / CNAME / lovable

…the winner

listOtherOpenPullRequests applied LIMIT(100) with no ORDER BY. The
duplicate-winner adjudication elects the minimum open PR number as the
cluster winner, but on a repo with >100 open PRs an unordered LIMIT could
drop the true lowest-numbered sibling and mis-elect a higher-numbered PR as
the winner (sparing it and closing the real winner). Order by ascending
number so the 100-row window always retains the lowest open siblings.
@dosubot dosubot Bot added the size:XS label Jun 24, 2026
@superagent-security

Copy link
Copy Markdown
Contributor

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

@codecov

codecov Bot commented Jun 24, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.96%. Comparing base (a50678e) to head (a7907ff).
⚠️ Report is 2 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1236   +/-   ##
=======================================
  Coverage   94.96%   94.96%           
=======================================
  Files         177      177           
  Lines       19772    19772           
  Branches     7110     7110           
=======================================
  Hits        18776    18776           
  Misses        397      397           
  Partials      599      599           
Files with missing lines Coverage Δ
src/db/repositories.ts 96.03% <ø> (ø)
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@JSONbored
JSONbored merged commit e3edf74 into main Jun 24, 2026
17 checks passed
@JSONbored
JSONbored deleted the fix/duplicate-winner-ordering branch June 24, 2026 12:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant