fix(validator): filter stale closed mirror PRs#1361
Open
JSONbored wants to merge 1 commit into
Open
Conversation
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
Defensively re-apply the repo lookback cutoff for CLOSED PRs returned by the mirror before they enter current credibility accounting.
What changed
since_by_repocutoff map used for the mirror request into_maybe_add_pr.created_atis older than that repo's cutoff.Why
load_miner_prs()already computes per-repo lookback cutoffs and sends them to the mirror, but the loader currently assumes every returned PR is in-window. Since CLOSED PRs feed current credibility accounting, keeping the local cutoff preserves the existing invariant that out-of-window CLOSED PRs do not count as current attempts.Proof
The new regression test builds a fake mirror response with:
Before this patch, the test fails because both CLOSED PRs are loaded:
With this patch, the stale PR is filtered and only the fresh CLOSED PR remains in
eval_.closed_prs.I also checked the end-to-end loader/finalizer behavior locally with one current merged PR and one stale CLOSED PR returned by the mirror:
Validation
uv run --extra dev pytest tests/validator/oss_contributions/mirror/test_load.py::TestLookbackWindow::test_stale_closed_pr_before_repo_lookback_is_dropped_defensively -quv run --extra dev pytest tests/validator/oss_contributions/mirror tests/validator/test_blend_emission_pools.py tests/validator/test_scoring_classes.py tests/validator/test_scoring_resolver.py -quv run --extra dev pytest -quv run --extra dev ruff check gittensor/validator/oss_contributions/mirror/load.py tests/validator/oss_contributions/mirror/test_load.pygit diff --check