Skip to content

fix(issue-discovery): clear stale per-repo issue fields on the scoring path#1611

Open
kevin8600 wants to merge 1 commit into
entrius:testfrom
kevin8600:fix/issue-discovery-stale-repo-fields
Open

fix(issue-discovery): clear stale per-repo issue fields on the scoring path#1611
kevin8600 wants to merge 1 commit into
entrius:testfrom
kevin8600:fix/issue-discovery-stale-repo-fields

Conversation

@kevin8600

Copy link
Copy Markdown

Summary

Issue discovery has two per-round reset paths that must clear a miner's per-repo issue fields identically, but they drifted:

  • _clear_issue_discovery_fields (no-issues path) zeroes the issue fields on every repo_evaluation.
  • _finalize_repo_issue_scores (scoring path) only rewrites the repos seen this round (sorted(set(repo_acc) | set(open_counts))), while _roll_up_issue_totals sums over all repo_evaluations.

So a repo scored in a prior round but absent this round keeps stale per-repo values that leak into the round-level totals.

Root cause. The only way a repo_evaluation carries prior-round issue data into a new round is the OSS cache-restore path: on github_pr_fetch_failed, store_or_use_cached_evaluation replaces the eval with the cached one (which carries repo_evaluations). Issue discovery is expected to recompute fresh fields on top (see the forward.py comment: "cached UIDs now have fresh issue-discovery fields"), but the scoring path never clears the repos it doesn't revisit, so _roll_up_issue_totals sums stale + fresh.

Impact. Inflated per-repo issue rows (persisted via bulk_store_evaluation) and round-level total_solved_issues / issue_discovery_score / is_issue_eligible, which also get re-written to the evaluation cache (update_issue_discovery) and compound across rounds. Consumed by CLI miner score and analytics. Current-round emission allocation reads the freshly-rebuilt issue_discovery_issues list, so this is a stored-data/reporting correctness bug, not an emissions change.

Fix. Extract the per-repo reset into a shared _reset_repo_issue_fields helper (removing the duplication that let the two paths drift) and call it at the top of _finalize_repo_issue_scores, mirroring _clear_issue_discovery_fields.

Related Issues

Fixes #1610

Type of Change

  • Bug fix
  • New feature
  • Refactor
  • Documentation
  • Other (describe below)

Testing

  • Tests added/updated
  • Manually tested

Added test_successful_scoring_clears_stale_issue_fields_for_repos_absent_this_round: pre-populates a repo_evaluation with prior-round issue data (simulating the OSS cache restore), returns mirror issues only for a different enabled repo, and asserts the stale repo and the round-level roll-up are both zeroed. The test fails on main (assert 7 == 0) and passes with the fix. Full issue-discovery suite green (73 passed); ruff, ruff format, and vulture clean.

Checklist

  • Code follows project style guidelines
  • Self-review completed
  • Changes are documented (if applicable)

…g path

_finalize_repo_issue_scores rewrote only the repos seen this round while
_roll_up_issue_totals sums over every repo_evaluation, so a repo scored in a
prior round but absent this round (e.g. on an OSS cache-restored evaluation)
kept stale issue values that leaked into the round-level totals. The no-issues
path already clears every repo via _clear_issue_discovery_fields; extract that
per-repo reset into a shared helper and apply it on the scoring path too.
@xiao-xiao-mao xiao-xiao-mao Bot added the bug Something isn't working label Jul 9, 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.

Stale per-repo issue-discovery fields survive a successful scoring round and inflate roll-up totals

1 participant