Conversation
The merge-base SHA was computed once on the first PR_FILES job and short-circuited on every subsequent run. When a PR's head advanced via synchronize while the base branch also moved forward, the stored value went stale and the saved base_content got pinned to an old ancestor — inflating tree-diff scoring with churn from unrelated PRs that landed on the base branch in the meantime. Drop the !pr.mergeBaseSha guard so we recompute on every fetch. Adds one compare API call per PR_FILES job; rate-limit cost is negligible.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
!pr.mergeBaseShashort-circuit infetchAndStorePrFilesso the merge-base SHA is recomputed on everyPR_FILESjob, not just the first one.synchronizewhile the base branch also moved forward — the stored merge-base went stale, pinningbase_contentto an old ancestor and attributing churn from unrelated PRs to the wrong author.Root cause
fetchAndStorePrFilesonly computed the merge-base whenpr.mergeBaseShawas unset, so a PR that was opened, sat for days while the base branch advanced, then got pushed to / merged would keep the original (now-stale) merge-base.pr_file_contents.base_contentwas then fetched from that stale SHA and tree-diff scoring saw enormous synthetic diffs.Concrete example: entrius/gittensor-ui#586. Author's actual change: 1 file, +3/-3 (6 lines). Mirror stored:
base_sha = f5f9fba9(correct)head_sha = 599ebed0(correct)merge_base_sha = a005f577← stale; the real current merge-base isf5f9fba9The 41-commit / 65-file gap between
a005f577andf5f9fba9got rolled into this PR's score (TOKENS SCORED 638, LEAF 624 for a 6-line edit).Cost
One extra
GET /repos/:owner/:repo/compare/:base...:headperPR_FILESjob. At typical PR-event volume that is well under the 5000/hr GitHub installation rate limit.Backfill required
Existing rows still have stale
merge_base_shaand inflatedbase_content. After this merges, run a backfill (or admin re-enqueue) to recompute. With this fix in place, everyPR_FILESre-run will refresh the merge-base unconditionally.Test plan
merge_base_shafor PR #586 (and other previously-mis-scored PRs) updates to current valuebase_content.byte_sizefor #586 drops from ~17.9 KB to ~14.1 KB