Skip to content

fix: isolate mirror PR cache entries - #928

Closed
Helios531 wants to merge 1 commit into
entrius:testfrom
Helios531:fix/mirror-cache-fill-gap-824
Closed

fix: isolate mirror PR cache entries#928
Helios531 wants to merge 1 commit into
entrius:testfrom
Helios531:fix/mirror-cache-fill-gap-824

Conversation

@Helios531

@Helios531 Helios531 commented May 1, 2026

Copy link
Copy Markdown

Summary

Fixes a cache isolation gap where mirror PR objects returned from MinerEvaluationCache.get() could share ScoredMirrorPR instances with the cached snapshot.

When cache fallback is used, finalize_miner_scores() mutates top-level PR scoring fields such as earned_score, collateral_score, open_pr_spam_multiplier, credibility_multiplier, pioneer_rank, and pioneer_dividend. Legacy PRs were already protected by fresh top-level PullRequest copies, but mirror PR buckets were not.

Changes

  • Add top-level copy isolation for:
    • mirror_merged_prs
    • mirror_open_prs
    • mirror_closed_prs
  • Keep nested mirror metadata shared because the fallback path reads it but does not mutate it
  • Preserve the existing cache-store behavior that strips ScoredMirrorPR.files
  • Add regression coverage for:
    • mirror merged PR scoring-field mutations
    • mirror open PR collateral-score mutations
    • legacy PR top-level isolation
    • mirror file stripping at store time

Validation

uv run --with pytest pytest tests/validator/test_validator_cache_fallback.py](fix: isolate mirror PR cache entries)

Fixes #927

@xiao-xiao-mao xiao-xiao-mao Bot added the bug Something isn't working label May 1, 2026
@Helios531
Helios531 force-pushed the fix/mirror-cache-fill-gap-824 branch from 7d537ae to b8c0445 Compare May 1, 2026 20:29
@Helios531 Helios531 changed the title Fix/mirror cache fill gap 824 MinerEvaluationCache.get() does not isolate mirror PRs from finalize_miner_scores mutations May 2, 2026
@Helios531
Helios531 force-pushed the fix/mirror-cache-fill-gap-824 branch from aee33e8 to 6ee9513 Compare May 2, 2026 14:08
@Helios531 Helios531 changed the title MinerEvaluationCache.get() does not isolate mirror PRs from finalize_miner_scores mutations fix: isolate mirror PR cache entries May 2, 2026
@anderdc anderdc added enhancement New feature or request and removed bug Something isn't working labels May 6, 2026
@anderdc

anderdc commented May 6, 2026

Copy link
Copy Markdown
Collaborator

Verified the claimed leakage doesn't manifest — every field listed in the issue is fresh-assigned in Phase 1 of finalize_miner_scores (scoring.py:319, 344-348) before Phase 2/3 read it. calculate_final_earned_score (scored_pr.py:94) recomputes earned_score from base × multipliers, so stale cached values get overwritten before observation. The cache also lives entirely in the GitHub-PR-fetch fallback path that's being decommissioned with the move to mirror-only scoring (classes.py:715). Closing as defensive isolation in a path on the way out.

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

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MinerEvaluationCache.get() does not isolate mirror PRs from finalize_miner_scores mutations

2 participants