fix(issue-discovery): honor per-repo min_token_score in solving-PR cache#1356
Open
galuis116 wants to merge 1 commit into
Open
fix(issue-discovery): honor per-repo min_token_score in solving-PR cache#1356galuis116 wants to merge 1 commit into
galuis116 wants to merge 1 commit into
Conversation
`_build_solving_pr_cache` filtered by the global `MIN_TOKEN_SCORE_FOR_BASE_SCORE`, dropping merged PRs that cleared their repo's per-repo override. The cache-MISS path (`_resolve_solving_pr_score`) and OSS scoring path already honor the per-repo threshold (PR entrius#1330); align the cache-population path so cache-HIT and cache-MISS yield the same scoring outcome. Falls back to the global default for repos missing from `mirror_repos` (defensive). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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 #1330 plumbed
min_token_score_for_base_scorethrough the OSS scoring path (mirror/scoring.py) and the issue-discovery solving-PR cache-MISS path (scan.py:676-680), but the solving-PR cache-population path atscan.py:409kept reading the globalMIN_TOKEN_SCORE_FOR_BASE_SCOREconstant — silent state asymmetry between the cache and the path that fills its misses.With a repo-level override set, OSS gives a merged PR with
token_score = 3a non-zerobase_score(post-#1330), but_build_solving_pr_cachedrops the entry because3 < 5. Every sibling discoverer's lookup for that PR then cache-MISSes and refetches viaMirrorClient.get_pr_files; on aMirrorRequestErrororscoring_data_stored = Falsethe per-repo accumulator setsfetch_failed = True, and the discoverer loses bothvalid_solvedcredit anddiscovery_earned_scorefor that issue — even though the data was already in memory on this validator round. No repo inmaster_repositories.jsoncurrently sets the override, so the bug is latent, but the moment an admin uses the field the cache and the cache-MISS path disagree about which PRs are scorable. Same forward-looking-consistency posture as #1330.The docs are explicit on the contract: every eligibility constant "is a global default that any repository can override in its config entry" (
docs.gittensor.io/oss-contributions.html§"Per-repo configs vary"), and the cross-miner cache is specified as a pure pass-through — "Miners' own PRs are pre-scored during OSS evaluation and reused for free" (docs.gittensor.io/issue-discovery.html§"Base Score Calculation"). The current cache filter breaks the "reused for free" promise whenever the override is in effect.Closes #1355.
Fix
_build_solving_pr_cachenow takesmirror_repos: Dict[str, RepositoryConfig]and resolves the per-PR threshold viaresolve_eligibility(repo_config.eligibility).min_token_score_for_base_score, falling back to the globalMIN_TOKEN_SCORE_FOR_BASE_SCOREwhen the repo isn't inmirror_repos(defensive — in practice everymerged_prsentry is from a tracked repo).run_issue_discovery(scan.py:165) now passesmirror_repos.Test plan
tests/validator/issue_discovery/test_scan.py::TestSolvingPrCache:test_per_repo_override_keeps_pr_above_repo_threshold— a repo withmin_token_score_for_base_score = 2keeps a PR whosetoken_score = 3(clears override, fails global default).test_untracked_repo_falls_back_to_global_threshold— defensive: a repo missing frommirror_reposstill gates on the global default, doesn't crash.TestSolvingPrCachetests (test_build_cache_from_multiple_miners,test_cache_first_occurrence_wins_on_duplicate,test_below_threshold_prs_excluded_from_cache) updated to passmirror_repos; behavior preserved when no override is configured.uv run pytest tests/validator/issue_discovery/test_scan.py -q— 66 passed.uv run pytest tests/validator/ -q— 519 passed.uv run ruff check gittensor/validator/issue_discovery/scan.py tests/validator/issue_discovery/test_scan.py— clean.uv run ruff format --check gittensor/validator/issue_discovery/scan.py tests/validator/issue_discovery/test_scan.py— clean.uv run pyright gittensor/validator/issue_discovery/scan.py tests/validator/issue_discovery/test_scan.py— 0 errors, 0 warnings.Files changed
gittensor/validator/issue_discovery/scan.py—_build_solving_pr_cacheaccepts and uses the resolved per-repo threshold; call site inrun_issue_discoveryupdated to passmirror_repos.tests/validator/issue_discovery/test_scan.py— 2 new regression tests; 3 existingTestSolvingPrCachetests updated to passmirror_repos;RepoEligibilityConfigadded to the existingload_weightsimport block.