Skip to content

fix: clear stale issue_discovery_score when fresh mirror data makes cached miner ineligible#1245

Open
bitloi wants to merge 1 commit into
entrius:testfrom
bitloi:fix/1244-stale-issue-discovery-score-ineligible
Open

fix: clear stale issue_discovery_score when fresh mirror data makes cached miner ineligible#1245
bitloi wants to merge 1 commit into
entrius:testfrom
bitloi:fix/1244-stale-issue-discovery-score-ineligible

Conversation

@bitloi
Copy link
Copy Markdown
Contributor

@bitloi bitloi commented May 13, 2026

Summary

When _score_miner_issues() determines a miner is ineligible after a successful mirror fetch, it returned early without zeroing evaluation.issue_discovery_score. A MinerEvaluation restored from a prior cycle kept its old positive score even though the current authoritative data showed ineligibility. normalize_issue_discovery_rewards() then read that stale score and awarded an undeserved emission share.

Fix: add evaluation.issue_discovery_score = 0.0 in the ineligible early-return branch. All other diagnostic fields (total_solved_issues, issue_credibility, is_issue_eligible, counts) are already written from fresh data before this branch and are intentionally preserved for operator diagnostics.

The cache-failure restore path (_restore_issue_discovery_from_cache) is unaffected — it runs only on MirrorRequestError, not on a successful-but-ineligible result.

Related Issues

Closes #1244

Type of Change

  • Bug fix

Testing

  • Tests added/updated
  • Manually tested

Regression test TestStaleScoreClearedOnIneligible (3 cases):

  • Primary: stale 8.12 score zeroed to 0.0 when fresh fetch is ineligible — FAIL before fix, PASS after
  • Normalizer: normalize_issue_discovery_rewards returns 0.0 instead of 1.0FAIL before fix, PASS after
  • Control: mirror fetch failure still restores cached score unchanged — PASS both

Full suite: 728/728 passed.

Checklist

  • Code follows project style guidelines
  • Self-review completed
  • Changes are documented (if applicable)

@xiao-xiao-mao xiao-xiao-mao Bot added the bug Something isn't working label May 13, 2026
…ached miner ineligible

When _score_miner_issues() determines is_eligible=False after a successful
mirror issue fetch, it returned immediately without zeroing the evaluation's
issue_discovery_score.  A miner restored from cache could therefore keep a
positive score from a prior eligible cycle even though the current authoritative
data shows it is below the valid-solved gate.

Fix: set evaluation.issue_discovery_score = 0.0 in the ineligible early-return
branch, matching the field that normalize_issue_discovery_rewards() reads when
building reward shares.

All other diagnostic fields (total_solved_issues, total_valid_solved_issues,
issue_credibility, is_issue_eligible, etc.) are already written from fresh data
before this branch, so only the aggregate score field needs clearing here.

The cache-failure restore path (_restore_issue_discovery_from_cache) is
unaffected: that path runs before _score_miner_issues and only when the fetch
itself raises MirrorRequestError, not when it succeeds with ineligible data.

Tests: add TestStaleScoreClearedOnIneligible with three cases:
- fresh ineligible fetch zeroes issue_discovery_score while preserving counts
- normalizer returns 0.0 for the formerly-stale miner after zeroing
- control: mirror-fetch failure still restores the cached score unchanged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: stale issue_discovery_score survives fresh ineligible mirror scan when miner is restored from cache

1 participant