Skip to content

[Bug]: openIssuesTotal under-counts when open PRs are subtracted from GraphQL issues #159

Description

@dearsishs

[Bug]: openIssuesTotal under-counts when open PRs are subtracted from GraphQL issue totals

Summary

For repositories with any open pull requests, persisting openIssuesTotal as repository.issues(states: OPEN).totalCount - repository.openPullRequests(states: OPEN).totalCount records too few open issues.

GitHub GraphQL repository.issues is an IssueConnection for issues; open pull requests are already exposed separately through repository.pullRequests. Subtracting PR totals double-excludes PRs and depresses the authoritative expected count used by the open-issue backfill pipeline.

Failure mode (concrete example)

A repo with 10 open issues and 3 open PRs:

  • GraphQL issues(states: OPEN).totalCount10 (issues only)
  • GraphQL pullRequests(states: OPEN).totalCount3
  • Incorrect formula 10 - 3 → persists openIssuesTotal: **7**

Downstream effects:

  • Repo summaries and decision packs show too few open issues.
  • expectedForRequiredSegment("open_issues", …) in src/signals/data-quality.ts uses the depressed total.
  • supplementUnderCountIfNeeded in src/github/backfill.ts may not run when REST already fetched ≥7 real issues but <10, so missing issues are never supplemented.

This is analogous to bounty validators needing authoritative closure data in issue_competitions/forward.py — here the sync forward pass must not corrupt the expected open-issue count.

Steps to reproduce

  1. Register a repo with 10 open issues and 3 open PRs (GraphQL totals as above).
  2. Run refreshRepoGithubTotals with PR-subtraction logic (or compare to REST issue-only crawl).
  3. Observe openIssuesTotal: 7 in repo_github_totals_snapshots.

Expected behavior

openIssuesTotal equals open issues only, e.g. query issues(states: OPEN, filter: {issueTypes: ISSUE}) without subtracting pullRequests.

Actual behavior

Subtracting open PR count from the issues connection total under-counts open issues and breaks supplement/complete logic.

Suggested fix

  • Query issues(states: OPEN, filter: {issueTypes: ISSUE}) for totals and GraphQL supplement.
  • Do not subtract openPullRequests.totalCount from issues.totalCount.
  • Skip any PullRequest nodes if they appear in supplement pagination.

Metadata

Metadata

Assignees

No one assigned

    Labels

    gittensor:bugGittensor-scored bug fix — scores a 0.05x multiplier.

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions