Skip to content

refactor: remove unreachable legacy partial-pagination cache-fallback branch in store_or_use_cached_evaluation #1295

Description

@sxxtony

name: Bug Report
about: Report a bug or unexpected behavior
labels: bug

Title

refactor: remove unreachable legacy partial-pagination cache-fallback branch in store_or_use_cached_evaluation

Description

neurons/validator.py:store_or_use_cached_evaluation still contains a legacy branch intended for a pre-mirror partial-pagination failure mode:

if not miner_eval.should_use_cache_fallback and not miner_eval.mirror_pr_fetch_failed:
    bt.logging.warning(
        f'UID {uid}: GitHub fetch failed after partial PR load; skipping cache store/fallback this round'
    )
    continue

After the mirror-only scoring refactor, that state is no longer constructible by current writers of github_pr_fetch_failed.

This leaves stale dead logic and a misleading inline comment in active validator code.

Steps to Reproduce

  1. Inspect the stale branch in neurons/validator.py.
  2. Check all writers of github_pr_fetch_failed = True:
  3. Verify control flow:
    • identity transient path returns early in reward.py before PR load
    • mirror fetch failure sets both mirror/github failure flags and returns before PR append
  4. Verify should_use_cache_fallback definition in gittensor/classes.py:
    • github_pr_fetch_failed and total_prs == 0

Expected Behavior

Validator cache-fallback code should not contain legacy branches that are unreachable under the current mirror-only execution model.

Actual Behavior

The legacy partial-pagination branch remains in neurons/validator.py even though:

  • only two current writers can set github_pr_fetch_failed = True
  • both paths produce total_prs == 0
  • one of them also forces mirror_pr_fetch_failed == True

So the guarded condition is unreachable.

Environment

  • OS: Ubuntu (VM)
  • Python version: N/A (static flow analysis)
  • Commit/Version: test branch @ 5291948abe3fd040771c31800b316906e1e92c95 (verified equal across local HEAD, origin/test, and upstream/test)

Additional Context

Unreachable state proof

The stale branch executes only when all are true:

  1. github_pr_fetch_failed == True
  2. not should_use_cache_fallback == True => total_prs > 0 (given property definition)
  3. mirror_pr_fetch_failed == False

But in current code:

  • writer A (inspections.py) sets github_pr_fetch_failed only for transient identity failure, and reward.py returns before PR loading -> total_prs == 0
  • writer B (mirror/load.py) sets both github_pr_fetch_failed=True and mirror_pr_fetch_failed=True, and returns before PR loading -> total_prs == 0

No third writer exists in gittensor/ or neurons/.

Why this likely remained

Overlap check

  • No exact open/closed issue or PR currently targets this specific stale branch cleanup in store_or_use_cached_evaluation.
  • Open PR feat(validator): per-repository eligibility #1293 (feat/per-repository eligibility) touches neurons/validator.py but retains this branch.

Proposed fix

Remove only the unreachable block and stale comment in neurons/validator.py, leaving the normal cache-fallback path intact.

Optional follow-up test: assert invariant that any MinerEvaluation with github_pr_fetch_failed=True has total_prs==0 under current writers.

Metadata

Metadata

Assignees

No one assigned

    Labels

    refactorCode restructuring without behavior change

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions