Skip to content

[Spec 1995] tower-collapse-the-four-per-wo - #2005

Closed
waleedkadous wants to merge 48 commits into
mainfrom
builder/spir-1995
Closed

waleedkadous wants to merge 48 commits into
mainfrom
builder/spir-1995

Conversation

@waleedkadous

@waleedkadous waleedkadous commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Summary

On GitHub, Tower's overview now fetches a workspace's lists with one overview-bundle forge
call per open-list refresh
. Before, it made four calls: pr-list, issue-list,
recently-closed and recently-merged. The 24 h windows travel in the same GraphQL query,
only when they are due (age ≥ 420 s), and they never make a call of their own.

per watched workspace, idle before after
overview forge calls/h 52 20
gh processes/h (codev: 424 open issues → 2 pages) 52 40
GraphQL points/h, small repo 72 ≈47
GraphQL points/h, codev 112 ≈87

The point costs were measured with rateLimit { cost } on the exact shipped request text
before the cache work started: 2 points open-only, 3 with the windows. Both are at the spec's
ceilings.

Every non-GitHub preset (gitlab, gitea, linear, jira) and any project that overrides or
disables a constituent concept or overview-bundle keeps the four calls, with behaviour
unchanged. A failed bundle never falls back to the four calls at runtime.

Closes #1995

Refs #1645, #1641, #1629

Changes

  • New forge concept overview-bundle (scripts/forge/github/overview-bundle.sh,
    contract OverviewBundle in forge-contracts.ts, KNOWN_CONCEPTS 20 → 21).
    • One GraphQL request carries every section. Extra pages are per-connection follow-up
      requests; --paginate is not used because it re-costs the whole query.
    • The caps match today's: 30 PRs, 200 issues, 1000 per window.
    • The exit status stays honest. The call has a 60 s / 40 MB budget, and output is printed
      once, after the last page.
    • A GraphQL error confined to the window searches comes back as windowsError and fails
      only the windows. Any other error, a rate limit included, fails the whole call.
    • The output reproduces gh's --json rendering: app/ for a deleted author, and user-only
      reviewers (Copilot and team reviewers dropped). Parity was checked by item set and field
      on six real repos.
    • Every non-GitHub preset disables overview-bundle explicitly.
  • OverviewCache bundle path (servers/overview.ts, resolveOverviewPath in
    lib/forge.ts).
    • The cache keeps two positive-only groups: open lists (180 s, invalidated) and windows
      (600 s maximum age, never invalidated).
    • The calls are single-flight. A whole-call failure gets the escalating failure window, and
      the windows get their own. Dispatch is gated read-only by isFailureWindowOpen.
    • The four-call path's code is unchanged; it moved into fourCallLists.
  • servers/overview-budget.ts (new, no imports) owns the overview TTLs and
    projectHourlyForgeCalls (20 bundled / 52 four-call). OverviewCache imports the TTLs from
    it.
  • codev doctor prints one informational row after the forge concepts:
    overview path bundled: ~20 forge calls/h per watched workspace (idle steady state, a floor that invalidation can raise).
    On the four-call path it prints four calls (<reason>): ~52 … instead.
  • Docs: forge.md "Tower Overview" section, arch.md, and codev.md plus its skeleton
    mirror.

Fixed in place: forge concept disables lost across config layers (pre-existing bug)

loadConfig layered config files through deepMerge, which deletes null. A documented
"<concept>": null disable was therefore lost whenever a lower layer (~/.codev/config.json,
the framework cache) or config.local.json also held a forge object. The fallback rule
depends on "overview-bundle": null holding, so this is fixed here. The forge section now
merges key by key (mergeConfigLayer), keeping null as "disabled". deepMerge itself is
unchanged because commands/update.ts also uses it. The bug was reproduced first: five cases
fail on the old code and pass with the fix.

Owner ruling worth knowing when reviewing

On the bundle path, a failed invalidation-driven refresh keeps serving the still-fresh
open lists with forgeStatus: 'ok'. The four-call path blanks them instead. This was decided
at plan approval (question (a)) and is pinned by its own test.

Adjacent doc fix

forge.md's "Validation" example showed a doctor output format that no longer exists. It is
replaced with real output.

Testing

Verify phase (after merge)

These need the merged build in Tower, so they wait for a human go-ahead to restart Tower:

  • a read-only Playwright render of the Work view against main;
  • the doctor line on the installed build;
  • a 1 h look at gh spawns.

Spec

codev/specs/1995-tower-collapse-the-four-per-wo.md

Review

codev/reviews/1995-tower-collapse-the-four-per-wo.md

…ge concept

One GraphQL query returns the open PRs, the open issues and, on request,
the two 24 h windows. Follow-up pages ask for one connection only, up to
its cap (issues 200, each window 1000). The output reproduces gh's --json
rendering, including bot and deleted authors and user-only reviewers. An
error confined to the window searches is salvaged as windowsError; any
other error fails the whole call, and gh's stderr is passed through.

- forge.ts: overview-bundle is the 21st concept. It is disabled on the
  gitlab, gitea, linear and jira presets, and it counts as an issue
  concept for resolveIssueIdKind.
- forge-contracts.ts: OverviewBundleResult and its conformance rule.
- github.ts: fetchForOverview('overview-bundle', cwd, {includeWindows})
  with its own 60 s / 40 MB budgets, and per-contract validation.

Measured cost (Step 0): 2 points open-only, 3 with the windows.
Not called by OverviewCache yet; Phase 3 wires it in.
… notes

- Drop a just-reopened issue (closedAt null) from the closed window, as
  recently-closed's 24 h filter does, instead of failing the call.
- Always pass CODEV_INCLUDE_WINDOWS, so the open-only path cannot inherit
  a stray value from Tower's environment.
- Salvage a window error with empty messages under a named reason.
…t disables across config layers

deepMerge deletes a null, so a project's "<concept>": null in forge was lost
whenever a lower layer (global, framework cache) or config.local.json carried
a forge object, and the concept ran its default. loadConfig now merges each
layer through mergeConfigLayer, which keeps nulls inside forge as "disabled"
(key-wise, higher layer wins). deepMerge itself is unchanged.
…per open-list refresh, 24 h windows ride along

resolveOverviewPath picks the bundle only when it resolves and no constituent
concept is overridden or disabled; OverviewCache gains the bundle path with two
positive-only freshness groups, the 420 s ride-along rule, read-only failure
gates, a separate windows failure window and single-flight. The four-call path
is unchanged. Existing overview, rate-limit and #1645 tests run on both paths.
… the project, in four-call reasons

An override or disable can come from any config layer after the key-wise
forge merge, and the reason reaches users through the doctor line.
@waleedkadous
waleedkadous marked this pull request as draft November 27, 2026 06:47
waleedkadous added a commit that referenced this pull request Nov 29, 2026
deepMerge treats null as delete, so a project's "overview-bundle": null was
dropped whenever a lower layer (framework cache, ~/.codev/config.json) also
had a forge section, and the bundle ran anyway. mergeConfigLayer merges the
flat forge section key-wise, so a higher layer's string or null wins and a
whole-section "forge": null still deletes it. Ported from PR #2005 on the
owner's ruling, with tests across the global, project and local layers.
@waleedkadous

Copy link
Copy Markdown
Contributor Author

Closing unmerged. This was one of two independent implementations of the one-call Tower overview (issue #1647); the owner chose the other, PR #2004 (merged as 75a2ed4), which took this PR's config-layering fix in its fix round. The branch is kept.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant