Skip to content

fix: don't cache fabricated zero when mirror scoring_data_stored=False - #968

Merged
anderdc merged 5 commits into
entrius:testfrom
ai-mountain:fix/mirror-issue-discovery-cache-unavailable
May 8, 2026
Merged

fix: don't cache fabricated zero when mirror scoring_data_stored=False#968
anderdc merged 5 commits into
entrius:testfrom
ai-mountain:fix/mirror-issue-discovery-cache-unavailable

Conversation

@ai-mountain

@ai-mountain ai-mountain commented May 4, 2026

Copy link
Copy Markdown
Contributor

Summary

In _resolve_solving_pr_score (gittensor/validator/issue_discovery/mirror_scan.py), a mirror response with scoring_data_stored=False was treated as a successful fetch of an empty diff — mirror_files_to_legacy() returned no file changes, calculate_base_score_for_pr_files() returned base_score=0 / token_score=0, and that fabricated zero was committed to the cross-miner solving-PR cache. Sibling miners' lookups against the same (repo, pr_number) then served the cached zero with no in-cycle retry, even after the mirror finished its backfill mid-cycle.

This PR adds an explicit guard immediately after the MirrorRequestError branch: when files_response.scoring_data_stored is False, increment cache_stats.fetch_failures, log a warning that mentions data unavailability (not "below threshold"), and return None without writing to cache. Parity with the existing MirrorRequestError handling — same three actions, same callsite-visible semantics.

Scope: only gittensor/validator/issue_discovery/mirror_scan.py and its sibling test file. No change to mirror/scoring.py and no change to credibility/eligibility behavior

Related Issues

Closes #836

Type of Change

  • Bug fix
  • New feature
  • Refactor
  • Documentation
  • Other (describe below)

Testing

  • tests/validator/issue_discovery/test_mirror_scan.py::TestCacheStats — 2 new cases:
    • test_resolve_treats_unavailable_scoring_data_as_failure — single call: asserts result is None, fetch_failures == 1, empty cache.
    • test_unavailable_scoring_data_is_not_cached_across_sibling_lookups — the literal acceptance criterion from [Bug] Mirror issue-discovery caches a fabricated zero score when scoring_data_stored=False #836: two issues sharing one solving PR, scoring_data_stored=False returned both times → misses == 2, fetch_failures == 2, cache == {}, client.get_pr_files.call_count == 2.
  • Full validator test suite passes locally (728/728).
  • Ruff lint + format clean (uv run pre-commit run --all-files).
  • Pyright: 0 errors / 0 warnings (uv run pre-commit run --all-files --hook-stage pre-push).

Checklist

  • Code follows project style guidelines.
  • Self-review completed.
  • No change to mirror OSS scoring (oss_contributions/mirror/scoring.py).
  • No change to credibility/eligibility behavior; legacy parity preserved.
  • Cache mutation is gated: cache stays empty on availability failure, leaving the slot open for sibling miners' in-cycle retries.

@xiao-xiao-mao xiao-xiao-mao Bot added the bug Something isn't working label May 4, 2026
@ai-mountain
ai-mountain force-pushed the fix/mirror-issue-discovery-cache-unavailable branch from ef33390 to 3643e5e Compare May 4, 2026 16:48
@ai-mountain

Copy link
Copy Markdown
Contributor Author

@anderdc Could you please review this please? Thanks

@anderdc anderdc added enhancement New feature or request and removed bug Something isn't working labels May 8, 2026

@anderdc anderdc left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix tests

@ai-mountain

Copy link
Copy Markdown
Contributor Author

@anderdc I've fixed CI test failures.

@anderdc
anderdc merged commit 7502ff1 into entrius:test May 8, 2026
3 checks passed
@ai-mountain

Copy link
Copy Markdown
Contributor Author

@anderdc Thanks.

@ai-mountain
ai-mountain deleted the fix/mirror-issue-discovery-cache-unavailable branch May 8, 2026 22:22
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.

[Bug] Mirror issue-discovery caches a fabricated zero score when scoring_data_stored=False

2 participants