fix: prevent scoring data loss and fix fragile test in stale PR refresh - #992
Merged
Conversation
wdeveloper16
force-pushed
the
fix/stale-pr-gaps
branch
from
May 5, 2026 01:01
a5f1e49 to
9df5104
Compare
wdeveloper16
force-pushed
the
fix/stale-pr-gaps
branch
2 times, most recently
from
May 5, 2026 19:01
0ace2e9 to
5ffc817
Compare
Contributor
Author
|
Hi, @anderdc |
wdeveloper16
force-pushed
the
fix/stale-pr-gaps
branch
from
May 5, 2026 19:56
5ffc817 to
31c0fe3
Compare
Contributor
Author
This PR replaces the full UPSERT for the stale bucket with a dedicated |
wdeveloper16
force-pushed
the
fix/stale-pr-gaps
branch
11 times, most recently
from
May 9, 2026 00:17
a8946ba to
bccaf29
Compare
wdeveloper16
force-pushed
the
fix/stale-pr-gaps
branch
from
May 9, 2026 17:58
bccaf29 to
7d456b0
Compare
anderdc
approved these changes
May 9, 2026
alpurkan17
pushed a commit
to alpurkan17/gittensor
that referenced
this pull request
May 10, 2026
…sh (entrius#992) Co-authored-by: Ander <61125407+anderdc@users.noreply.github.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.
Description
Two gaps left unaddressed by #769.
Gap 1 — Stale UPSERT silently zeroes previously-scored rows
store_pull_requests_bulkingittensor/validator/utils/storage.py:74-76routes stale PRs throughBULK_UPSERT_PULL_REQUESTS, which usesON CONFLICT DO UPDATE SETwithEXCLUDED.*— overwriting every column on conflict.PullRequest.from_graphql_response()leaves all scoring fields at dataclass defaults (base_score = 0.0,earned_score = 0.0,credibility_multiplier = 1.0, etc.). Any PR that was previously scored — for example, one that was OPEN with collateral before the window shifted — has those computed values silently replaced with zeros on every subsequent scan.Gap 2 — Fragile positional assertion in
test_stale_closed_prs_are_stored_separatelytests/validator/utils/test_storage_mirror.py:176asserts stale storage correctness viacall_args_list[3]. If the call order insidestore_evaluationever changes, the assertion silently targets the wrong call and the test continues to pass.Changes
REFRESH_STALE_PR_STATEStoqueries.py— a targetedUPDATEthat touches onlypr_stateandupdated_at, leaving all scoring columns on existing rows untouchedRepository.refresh_stale_pr_states()backed by the new querystore_evaluationto callrefresh_stale_pr_statesinstead ofstore_pull_requests_bulkfor the stale bucketcall_args_list[3]withrefresh_stale_pr_states.assert_called_once()and add a leak guard asserting stale PRs do not reachstore_pull_requests_bulkNo schema changes required.
Closes #991