Skip to content

fix: refresh stale repo weights on cached evaluations (#364)#365

Closed
jonathanchang31 wants to merge 2 commits intoentrius:testfrom
jonathanchang31:fix/364-stale-repo-weight-in-cache
Closed

fix: refresh stale repo weights on cached evaluations (#364)#365
jonathanchang31 wants to merge 2 commits intoentrius:testfrom
jonathanchang31:fix/364-stale-repo-weight-in-cache

Conversation

@jonathanchang31
Copy link
Copy Markdown

@jonathanchang31 jonathanchang31 commented Apr 10, 2026

Summary

  • Cached miner evaluations retained repo_weight_multiplier from the round they were originally scored. When master_repositories.json was updated between rounds, cached evaluations used stale weights for scoring, causing incorrect repository weights.
  • Added _refresh_cached_repo_weights() in reward.py that updates repo_weight_multiplier on all PRs in cached evaluations using the current master_repositories before finalize_miner_scores() runs.
  • DB storage still skips cached UIDs (to avoid overwriting file patches with NULL from lightweight cache copies) and self-corrects on the next successful evaluation.

Fixes #364

Test plan

  • 10 new unit tests covering: merged/open/closed PRs, multi-repo scenarios, rounding, fallback default for removed repos, non-cached UIDs untouched, mixed cached+fresh evaluations
  • Full test suite (282 tests) — all pass, no regressions
  • Ruff lint — all checks passed
  • Ruff format — all files formatted
  • Pyright type check — 0 errors, 0 warnings

Cached miner evaluations retained repo_weight_multiplier from the round
they were originally scored. When master_repositories.json was updated
between rounds, cached evaluations used stale weights for scoring and
persisted them to the DB, causing incorrect weights on PR pages.
…NULL

Cached evaluations have patch data stripped by create_lightweight_copy().
Re-storing them would overwrite existing DB patches with NULL via the
UPSERT query. Keep skip_uids for DB storage — the in-memory weight
refresh in reward.py is sufficient for correct scoring.
@anderdc
Copy link
Copy Markdown
Collaborator

anderdc commented Apr 12, 2026

if master repositories is updated mid round, it's from a push from test -> main, which causes the validator to restart and thus all cached evaluations are cleared/reset.

The only case this happens is if a validator is trying to make their own repository weights, which would then cause them to lose vtrust, so this scenario you're fixing doesn't happen in production.

@anderdc anderdc closed this Apr 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Incorrect repository weight shown for some PR pages

2 participants