Skip to content

fix(validator): cache issue-discovery state for zero-PR miners#1324

Open
dripsmvcp wants to merge 3 commits into
entrius:testfrom
dripsmvcp:fix/1323-cache-issue-only-miners
Open

fix(validator): cache issue-discovery state for zero-PR miners#1324
dripsmvcp wants to merge 3 commits into
entrius:testfrom
dripsmvcp:fix/1323-cache-issue-only-miners

Conversation

@dripsmvcp
Copy link
Copy Markdown
Contributor

@dripsmvcp dripsmvcp commented May 20, 2026

  • Always cache successful OSS-phase evaluations so issue-discovery-only miners get a cache anchor; previously the total_prs > 0 gate left them unrecoverable on transient mirror failures.
  • Add a cached_eval.total_prs > 0 guard in the OSS-failure fallback so an issue-only entry can never masquerade as authoritative PR state.

Root Cause

Validator.store_or_use_cached_evaluation at neurons/validator.py:170-171 gated the cache write on miner_eval.total_prs > 0. Combined with MinerEvaluationCache.update_issue_discovery being a no-op when no entry exists (gittensor/classes.py:620-630), an issue-only miner (no PRs surviving load-time filtering) never got a cache entry. A later MirrorRequestError during issue discovery had nothing to restore, and the miner was scored zero — asymmetric with PR+issue miners. This disproportionately affects entrius/allways (issue_discovery_share == 1.0), where PR rewards are skipped entirely and issue discovery is the sole earning surface.

Fix

  • Drop the total_prs > 0 gate at neurons/validator.py:170-171store() runs for every successful OSS fetch, including zero-PR miners.
  • In the fallback branch, additionally check cached_eval.total_prs > 0 before swapping the cached eval in; an issue-only entry stays in the cache for update_issue_discovery / _restore_issue_discovery_from_cache but is never used as PR fallback. Uses the existing total_prs derived property rather than a new flag — the PR lists are already preserved in _build_cache_entry, so no new state to keep in sync.
  • Update update_issue_discovery docstring to reflect the new invariant (entries now exist for zero-PR miners too).

Test Plan

  • Regression tests added: tests/validator/test_store_or_use_cached_evaluation.py
    • TestZeroPrCaching::test_zero_pr_miner_is_cached_after_successful_oss_fetch
    • TestZeroPrCaching::test_update_issue_discovery_now_refreshes_zero_pr_entry
    • TestOssFallbackGuard::test_oss_failure_does_not_restore_issue_only_entry_as_pr_state
    • TestOssFallbackGuard::test_oss_failure_still_restores_entry_with_pr_data
  • test_zero_pr_miner_is_cached_after_successful_oss_fetch fails on test without the validator change (verified by stashing the fix and re-running).
  • All tests pass: pytest tests/validator/test_store_or_use_cached_evaluation.py tests/validator/issue_discovery/test_scan.py
  • Output:

Fixes #1323

…us#1323)

Always cache successful OSS-phase evaluations so issue-discovery-only
miners get a cache anchor. The previous `total_prs > 0` gate left
miners with no PRs (e.g. pure issue-discovery miners, or those whose
PRs were all maintainer-filtered) unrecoverable on transient mirror
failures, while PR+issue miners were protected — an asymmetry that
disproportionately hurt entrius/allways (issue_discovery_share == 1.0).

In the OSS-failure fallback, also require `cached_eval.total_prs > 0`
before swapping the cached eval in, so an issue-only entry can never
masquerade as authoritative PR state. Uses the existing total_prs
derived property rather than a new flag; PR lists are already
preserved in _build_cache_entry.
@xiao-xiao-mao xiao-xiao-mao Bot added the bug Something isn't working label May 20, 2026
@dripsmvcp dripsmvcp changed the title fix(validator): cache issue-discovery state for zero-PR miners (#1323) fix(validator): cache issue-discovery state for zero-PR miners May 20, 2026
Comment thread neurons/validator.py Outdated
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(validator): cache issue-discovery state even when miner has zero PRs

2 participants