Skip to content

tower: collapse the four per-workspace overview forge calls into one GraphQL query #1995

Not planned

Description

@waleedkadous

Context

#1645 fixed the runaway: Tower no longer re-spawns forge commands on every 2.5 s dashboard
poll, and it now suspends on a rate limit. Steady state came down from ≈9,090 gh
spawns/hour to 52 per watched workspace per hour.

What #1645 deliberately did not do is item 4 of its prescribed fix — collapse the
per-workspace overview fetch into a single GraphQL request. It was left out because it
does not fit BUGFIX: it is a change to the forge abstraction shipped to adopters, not a
localized fix.

What is left to do

OverviewCache makes four GitHub-API-backed calls per workspace per refresh window:

concept command cost
pr-list gh pr list --json … 1 GraphQL request
issue-list gh issue list --limit 200 --json … 2 pages
recently-closed gh issue list --state closed --search 'closed:>…' --limit 1000 multi-page search
recently-merged gh pr list --state merged --search 'merged:>…' --limit 1000 multi-page search

All four ask the same repo for overlapping data. One gh api graphql query can return
open PRs, open issues, and both 24 h search windows in a single request, taking the
per-workspace cost from ~4 calls (and well over 4 points) to 1.

Why it needs AIR rather than BUGFIX

It is not a one-file change:

  • a new forge concept (overview-bundle or similar) added to KNOWN_CONCEPTS;
  • a GitHub script issuing the combined query, plus the response-shape mapping;
  • a contract type in forge-contracts.ts, since the concept returns a composite
    rather than one of the existing list shapes;
  • fallback behaviour for gitlab/gitea/linear and for any project that overrides or
    disables the concept — OverviewCache must still work by making the four calls;
  • codev doctor concept reporting and the spend projection in
    servers/overview-budget.ts both need updating;
  • tests on both the bundle path and the fallback path.

Correction to carry forward

#1645's text suggested moving the two --search calls to REST gh api search/issues for
"a separate 5,000 budget". That is wrong and should not be done — the GitHub search
resource is 30 requests per minute, not 5,000 per hour (measured on this account:
{"limit":30,"remaining":30}). Collapsing into one GraphQL query is the right direction.

Acceptance

  • One forge call per workspace per refresh window on GitHub.
  • Non-GitHub forges, and any project that disables the concept, keep working via the
    existing four calls.
  • projectHourlyForgeCalls reflects the new call count, and codev doctor reports it.

Follow-up to #1645. Refs #1641, #1629.

Activity

  1. added
    area/tower
    on Nov 26, 2026
  2. waleedkadous commented on Nov 29, 2026

    @waleedkadous
    ContributorAuthor

    Closing: this was a deliberate copy of the one-call Tower overview issue (#1647), which PR #2004 has now delivered (merged as 75a2ed4). PR #2005, built against this copy, is closed unmerged.

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

    area/tower

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions