fix: sync pr_state for stale-merged PRs excluded from scoring - #1071
Closed
Crystora wants to merge 2 commits into
Closed
fix: sync pr_state for stale-merged PRs excluded from scoring#1071Crystora wants to merge 2 commits into
Crystora wants to merge 2 commits into
Conversation
Crystora
force-pushed
the
fix/sync-stale-merged-pr-state
branch
from
May 7, 2026 18:03
f0ef0d6 to
f9617bb
Compare
Crystora
force-pushed
the
fix/sync-stale-merged-pr-state
branch
from
May 10, 2026 00:07
96ba694 to
c6d61ee
Compare
Collaborator
|
Stale-merged only fires when a single miner's scanning has a >35-day gap (PAT lapse, identity change, etc.) and the impact is dashboard-only — no scoring effect. The stale-CLOSED variant in #769 covered the substantially more common case where any user can close a PR at any time. Not pursuing this edge case. Closing. |
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
A PR stored as
OPENstays stuck asOPENinpull_requestsif it gets merged on GitHub after the 35-day lookback window has already passed. The miner API and dashboard then keep showing it as open with a stalecollateral_score.Close: #1070
Root cause
should_skip_merged_prreturnsTrueoncemerged_atis older than the lookback window, and the loop justcontinues. The PR never enters any bucket, so the old OPEN row never gets refreshed.#769 fixed the same shape for stale-CLOSED PRs. This adds the MERGED counterpart.
Fix
New
stale_merged_pull_requestsbucket onMinerEvaluation, paired with a targetedUPDATE(not the bulk upsert) so existing rows get their status synced without touching scoring fields.gittensor/classes.pystale_merged_pull_requests+add_stale_merged_pull_request.gittensor/utils/github_api_tools.py_maybe_add_stale_merged_pr, called from the merged-PR skip branch.gittensor/validator/storage/queries.pyREFRESH_STALE_MERGED_PR_STATE— UPDATE-only, status fields only, guarded bypr_state != 'MERGED'.gittensor/validator/storage/repository.pyrefresh_stale_merged_pr_states.gittensor/validator/utils/storage.pyWhy UPDATE instead of the bulk upsert #769 used
A stale-MERGED row may already have real scoring fields from an earlier round. The bulk upsert would overwrite them with dataclass defaults. The targeted UPDATE only touches
pr_state,merged_at,collateral_score,updated_at, never inserts, and skips rows already atpr_state = 'MERGED'.No scoring impact
Stale-merged PRs never enter
merged_pull_requests, so totals, eligibility, credibility, token score, pioneer math, and emissions are all unchanged.Test plan
uv run python -m pytest tests/— 1418 passed (7 new)uv run python -m pyright— 0 errorsuv run pre-commit run— all hooks passNew tests:
tests/validator/test_unscored_stale_prs.py— stale-merged routes to the storage-only bucket, doesn't inflate totals; fresh merged PR is not captured; missingmergedAtis skipped safely.tests/validator/utils/test_storage_mirror.py— stale-merged list goes throughrefresh_stale_merged_pr_states, not the bulk upsert path.Related
Follow-up to #769.