Skip to content

fix(github): run_gh paces gh pr checks, gh pr list and gh issue list as core REST though gh sends them as GraphQL #1415

Description

@dan-petty

Problem

_detect_resource (src/devops_cli/github/rate_limiter.py:475-494) counts a command as GraphQL only for project or when an argument contains graphql (_is_graphql_command, :450-452). On the release/v0.2.29 tip (05e9388), gh_request_resource (:497) returns core for pr checks, pr list and issue list (checked 2026-10-08). gh runs those porcelain commands over GraphQL: pr checks resolves the pull request and reads statusCheckRollup with GraphQL queries. So run_gh paces and reserves them against the core budget, never the GraphQL one, and every dry-run plan labels them 'REST read'.

devops pr checks, for example, calls fetch_pr_check_verdicts (src/devops_cli/github/check_verdict.py:450) for the pull request it checks (src/devops_cli/commands/pr.py:385-386). The Service's main failure today is the GraphQL budget (#1400), and these calls go uncounted there.

Proposed remedy

Class gh's GraphQL-backed porcelain commands as graphql in one constants-module table, which run_gh's pacing and planned_gh (src/devops_cli/roadmap/request_plan.py:68) both read. Alternatively, replace the porcelain calls on the roadmap paths with the REST endpoints they stand for, such as repos/{repo}/commits/{sha}/check-runs, which fetch_pr_check_verdicts already falls back to.

Acceptance criteria

  • gh_request_resource(['pr', 'checks', '1']) returns graphql, or fetch_pr_check_verdicts reads check runs over REST. The label in the dry-run plan of planned_gh matches.
  • Tests are offline, and uv run devops ci passes.

Found while delivering #1362. Related: #1400, #1361, #1125, #998, #983.

Activity

  1. added
    type/bug
    scope/github
    source/agent
    on Oct 8, 2026
  2. dan-petty commented on Oct 8, 2026

    @dan-petty
    OwnerAuthor

    Amendment from the 2026-10-08 client-library audit (checked offline with gh_request_resource at 05e9388):

    • False positives as well as the false negatives above. _is_graphql_command (github/rate_limiter.py:450-452) and _is_general_search_command (:470-472) look for substrings in every argument, titles, bodies and paths included:

      • issue create --title "Fix GraphQL quota" --body x gives graphql;
      • api -X POST repos/o/r/issues/1/comments -f "body=see search/issues for details" gives search;
      • api repos/o/r/contents/docs/graphql.md gives graphql.

      So an issue or comment that mentions GraphQL is paced and planned against the GraphQL budget. Since fix(roadmap): a GraphQL budget refusal pauses every Service worker until the reset, and each Service round ends with its spend line #1400, the roadmap store also sends a closing budget read and logs a spend line for a round whose only "GraphQL" call was such a REST write. The table this item proposes should key on the command words (gh_command_words) and, for gh api, on the parsed endpoint (parse_gh_api_args(...).endpoint), never on argument text.

    • More porcelain classed core today that gh may send as GraphQL. Confirm each with GH_DEBUG=api:

      • release list (github/release_notes.py:62-63);
      • label list (commands/gh.py:154, github/client.py:329);
      • issue create (github/issues.py:206);
      • pr view (commands/pr.py:374, github/check_verdict.py:428);
      • pr edit (commands/pr.py:776), pr ready (:1093) and pr close (:1166).

    Found by the 2026-10-08 client-library audit.

  3. dan-petty-bot commented on Oct 8, 2026

    @dan-petty-bot
    Collaborator

    Intake placed this item to the backlog: at intake only a critical fix goes into a release; a release start pulls Ready items in, P0 features first.

    • Priority: P2-Medium. The misclassification contributes to the project's main operational failure (GraphQL budget exhaustion per #1400) by leaving these calls uncounted against the GraphQL budget, but a REST fallback exists and it is one contributor among severa
    • Value: Medium. Accurate budget classification prevents premature GraphQL exhaustion and corrects misleading dry-run labels, directly improving reliability of the closure and roadmap workflows.
    • Effort: Low. The fix is adding a few command names to a constants table that both run_gh pacing and planned_gh already read, or swapping two porcelain calls for REST endpoints that already exist as fallbacks.
  4. dan-petty commented on Oct 18, 2026

    @dan-petty
    OwnerAuthor

    Amendment (2026-10-18): the same function also misclasses REST paths by substring

    _is_graphql_command, _is_code_search_command, _is_code_scanning_autofix_command and _is_general_search_command (src/devops_cli/github/rate_limiter.py:457-479 at release/v0.2.37 30b8fdd) test whether any argument contains graphql, search/code, code-scanning and autofix, or search/. A REST path that merely contains those letters is paced against the wrong budget. Checked with gh_request_resource at 30b8fdd:

    Call Resource returned Should be
    api repos/graphql/graphql-js/issues graphql core
    api repos/octo/research/issues search (30 a minute) core
    api repos/octo/app/contents/docs/search/index.md search core
    api graphql -f query=x graphql graphql

    A repository named research, or any file under a search/ directory, is throttled to the search budget's 30 requests a minute. The GitHub session from #983 (PR 1) reuses this function through gh_request_resource to pace its REST requests, so the defect now reaches both transports.

    AGENTS.md forbids matching against a subset of possible values. The remedy belongs with this item's table: classify by the parsed request, not by substrings. For gh api, the endpoint is the first positional argument after api; it is graphql exactly, or a REST path whose resource follows from its leading segments (search/code, search/..., repos/{owner}/{repo}/code-scanning/.../autofix, .../dependency-graph/sbom), which GitHub's REST reference defines. For porcelain commands, use the table this item already proposes.

    Extra acceptance criteria for this item:

    • gh_request_resource returns core for api repos/graphql/graphql-js/issues, api repos/octo/research/issues and api repos/octo/app/contents/docs/search/index.md, and the existing classes stay as they are for api graphql, api search/issues, api search/code, search issues x and search code x.
    • No in arg substring test remains in the resource predicates.
  5. dan-petty commented on Oct 18, 2026

    @dan-petty
    OwnerAuthor

    Amendment (2026-10-18): gh pr view and gh pr edit too

    #1345 PR 1's review found two more gh porcelain commands that run_gh paces against the wrong budget. gh_request_resource returns core for gh pr view <branch> --json number ..., and planned_gh renders it as "REST read" (gh pr edit as "REST write"). gh 2.102.0 resolves pr view <branch> with a GraphQL query, and requests reviewers with the requestReviewsByLogin mutation. So client-side pacing and dry-run labels draw on the core quota while GitHub charges GraphQL. Add both to this item's table of GraphQL-backed porcelain commands.

  6. added a commit that references this issue on Oct 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    scope/githubsource/agenttype/bug

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions