[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).totalCount → 10 (issues only)
- GraphQL
pullRequests(states: OPEN).totalCount → 3
- 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
- Register a repo with 10 open issues and 3 open PRs (GraphQL totals as above).
- Run
refreshRepoGithubTotals with PR-subtraction logic (or compare to REST issue-only crawl).
- 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.
[Bug]:
openIssuesTotalunder-counts when open PRs are subtracted from GraphQL issue totalsSummary
For repositories with any open pull requests, persisting
openIssuesTotalasrepository.issues(states: OPEN).totalCount - repository.openPullRequests(states: OPEN).totalCountrecords too few open issues.GitHub GraphQL
repository.issuesis anIssueConnectionfor issues; open pull requests are already exposed separately throughrepository.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:
issues(states: OPEN).totalCount→ 10 (issues only)pullRequests(states: OPEN).totalCount→ 310 - 3→ persistsopenIssuesTotal: **7**Downstream effects:
expectedForRequiredSegment("open_issues", …)insrc/signals/data-quality.tsuses the depressed total.supplementUnderCountIfNeededinsrc/github/backfill.tsmay 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
refreshRepoGithubTotalswith PR-subtraction logic (or compare to REST issue-only crawl).openIssuesTotal: 7inrepo_github_totals_snapshots.Expected behavior
openIssuesTotalequals open issues only, e.g. queryissues(states: OPEN, filter: {issueTypes: ISSUE})without subtractingpullRequests.Actual behavior
Subtracting open PR count from the issues connection total under-counts open issues and breaks supplement/complete logic.
Suggested fix
issues(states: OPEN, filter: {issueTypes: ISSUE})for totals and GraphQL supplement.openPullRequests.totalCountfromissues.totalCount.PullRequestnodes if they appear in supplement pagination.