Skip to content

fix(scoring): count merged PR repo attribution before mirror file-fetch#1617

Open
jaytbarimbao-collab wants to merge 1 commit into
entrius:testfrom
jaytbarimbao-collab:fix/unique-repos-contributed-to-mirror-early-return
Open

fix(scoring): count merged PR repo attribution before mirror file-fetch#1617
jaytbarimbao-collab wants to merge 1 commit into
entrius:testfrom
jaytbarimbao-collab:fix/unique-repos-contributed-to-mirror-early-return

Conversation

@jaytbarimbao-collab

Copy link
Copy Markdown

Summary

score_pr() only added a MERGED PR's repo to eval_.unique_repos_contributed_to at the very end of the function, after three early-return paths that fire whenever the mirror's file-diff data isn't available yet (scoring_data_stored=False, a transient MirrorRequestError, or an empty files result) — all explicitly normal transient states per the function's own comments.

Since a PR is already counted toward eligibility/total_merged_prs independent of file-fetch status, this let unique_repos_contributed_to (persisted as unique_repos_count, surfaced via gitt miner score) silently undercount based on mirror-fetch timing rather than any property of the PR itself.

Fix

Moved the if pr.state == 'MERGED': eval_.unique_repos_contributed_to.add(...) block earlier in score_pr(), before the early-return branches, so repo attribution no longer depends on this round's file-fetch outcome.

Same bug class was previously fixed in the pre-mirror scoring path (#65 / #71), but was reintroduced when scoring moved to the mirror-based flow and was never re-applied there.

Testing

Added TestUniqueReposContributedTo covering all three early-return paths plus a negative control (CLOSED PR never counted):

  • test_counts_when_scoring_data_not_stored
  • test_counts_when_mirror_fetch_fails
  • test_counts_when_no_files_returned
  • test_not_counted_for_closed_pr

Validation commands run

python -m pytest tests/validator/oss_contributions/mirror/test_scoring.py -v   # 71 passed
ruff check gittensor/validator/oss_contributions/mirror/scoring.py tests/validator/oss_contributions/mirror/test_scoring.py   # All checks passed
ruff format --check gittensor/validator/oss_contributions/mirror/scoring.py tests/validator/oss_contributions/mirror/test_scoring.py   # already formatted
pyright gittensor/validator/oss_contributions/mirror/scoring.py tests/validator/oss_contributions/mirror/test_scoring.py   # 0 errors, 0 warnings

Closes #1616

score_pr() only added a MERGED PR's repo to eval_.unique_repos_contributed_to
at the end of the function, after three early-return paths that fire whenever
the mirror's file-diff data isn't available yet (pending backfill, a
transient MirrorRequestError, or an empty files result) — all explicitly
normal transient states per the function's own comments.

Since a PR is already counted toward eligibility/total_merged_prs
independent of file-fetch status, this let unique_repos_contributed_to
(persisted as unique_repos_count, surfaced via `gitt miner score`) silently
undercount based on mirror-fetch timing rather than any property of the PR.

Move the MERGED repo-attribution above the early-return branches so it no
longer depends on this round's file-fetch outcome. Same bug class previously
fixed in the pre-mirror scoring path (entrius#65/entrius#71), reintroduced when scoring
moved to the mirror-based flow.

Closes entrius#1616
@xiao-xiao-mao xiao-xiao-mao Bot added the bug Something isn't working label Jul 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(scoring): unique_repos_contributed_to undercounts when mirror file-fetch is pending/fails for a MERGED PR

1 participant