Repository navigation
[Spec 1647] tower-collapse-the-four-per-wo - #2004
Merged
Merged
Conversation
… and nested caps (review iter 2)
… gh 200+errors verified (review iter 3)
…script Register the overview-bundle forge concept with its OverviewBundleResult contract, disable it in the gitlab, gitea, linear and jira presets, and count it as an issue concept for id-kind detection. The GitHub script returns open PRs, open issues and both 24 h search windows from one gh api graphql request, paging only on overflow up to the sibling concepts' caps. Search-local GraphQL errors null their section; everything else fails the whole bundle with gh's status and stderr. gh runs in the background so the timeout's SIGTERM reaches the trap, and jq only ever reads staged files through redirection. Parity is proven against the four sibling scripts on a state recorded from real gh (grafana/grafana), with constructed team/bot reviewer and null-author cases.
waleedkadous
marked this pull request as draft
November 27, 2026 07:29
…t signals the script Debian and Ubuntu build dash without the exec-last-command optimization for sh -c (Debian patch 0004), so Node's exec timeout killed only the outer shell: overview-bundle.sh's traps never ran, gh outlived the limit and the temp directory stayed. Linux CI's Unit Tests check failed on this on every push. Also number the fake gh's calls by atomic mkdir claims instead of a locked count file, which lost a call under load on Linux CI.
The e2e tests still lose a call intermittently on Linux CI with mkdir numbering, so the counter was not the cause. A guard gh next on PATH records any call that falls through the fake (and keeps a real gh from running), and CODEV_DEBUG plus the cache's status in the assertion message capture what the lost call did.
…kdir The Linux runner is now ubuntu-26.04, whose uutils mkdir (rust-coreutils 0.8-0.10; fixed upstream in 0.11) reports success when it loses a race to create the same directory. The fake gh used mkdir for exclusion, so two concurrent calls could claim one number and a call went missing in about a third of CI runs. The invocation log showed two pids both claiming n=1. Claim by creating call.N under noclobber, which the shell opens with O_EXCL. A regression test puts an always-succeeding mkdir first on PATH. The temporary invocation log is removed.
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.
Conflict in codev/resources/lessons-learned.md: both sides appended lessons at the same place; kept both.
…n cadences
Reverses decision D2 on the owner's ruling (fix round). overview-bundle
takes a required CODEV_OVERVIEW_SECTIONS: open returns {prs, issues},
recent returns {recentlyClosed, recentlyMerged} and alone takes
CODEV_SINCE_DATE. Tower caches them as two plain cachedFetch entries:
open at the list TTL, invalidatable; recent at the search TTL, which
invalidate() never touches. The half is part of the single-flight key,
and the contract check requires exactly the half's two sections.
Measured with rateLimit { cost }: open 2 points, recent 1, the old
combined query 3. Bundled projection: 26 calls/h idle (46 points),
66 under churn (126), from 20/60 and 60/180.
The fake gh's route() now replaces every part of an earlier route.
Spec: D2' added, D2 kept and marked superseded, new spend table. Plan: amendment note. Review: the four fix-round items and their evidence. forge.md, arch.md, both forge skills and the codev.md doctor example describe the two halves and the 26/66 projection.
waleedkadous
marked this pull request as ready for review
November 29, 2026 15:11
waleedkadous
added a commit
that referenced
this pull request
Nov 29, 2026
waleedkadous
added a commit
that referenced
this pull request
Nov 29, 2026
This was referenced Nov 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A new forge concept,
overview-bundle, returns the four forge-backed sections of Tower's overview (open PRs, open issues, issues closed and PRs merged in the last 24 h) in two halves, selected by a requiredCODEV_OVERVIEW_SECTIONS:openfor the open lists, refreshed every 180 s and on invalidation, andrecentfor the two 24 h searches, refreshed every 600 s. On GitHub its script sends onegh api graphqlrequest per half and pages inside the same invocation up to today's caps (PRs 30, issues 200, searches 1,000).OverviewCacheuses it per workspace when configuration allows and otherwise makes the four existing calls, unchanged. A failed bundle is never retried as four calls.Closes #1647. The architect closes the deliberate copy #1995 separately.
Fix round (the owner's ruling, 2026-11-29)
Four items, nothing else:
mergeConfigLayerinconfig.tskeeps a forge concept'snullacross config layers. Before, a project's"overview-bundle": nullwas deleted bydeepMergewhenever a lower layer (framework cache,~/.codev/config.json) also had aforgesection, so the opt-out silently failed. 10 tests across the global, project and local layers; 7 fail against plaindeepMerge.overviewline in bothcodev.mdtrees.overview-bundletakes a requiredCODEV_OVERVIEW_SECTIONS:open→{prs, issues},recent→{recentlyClosed, recentlyMerged}(onlyrecenttakesCODEV_SINCE_DATE). Tower caches them as two plaincachedFetchentries:openat the list TTL, invalidatable;recentat the search TTL, whichinvalidate()never touches. The half is in the single-flight key, and the contract check requires exactly the half's two sections. Measured live withrateLimit { cost }:open2 points,recent1, the old combined query 3.overview.ts: +32/−26 lines. Recorded as D2′ in the spec, with notes in the plan and review.origin/mainmerged (02a8875), no rebase; thelessons-learned.mdconflict kept both sides.Per watched workspace, per idle hour, on GitHub:
ghprocesses (more than 100 open issues / 100 or fewer)Under constant invalidation: 66 invocations and 126 points per hour on a smaller repo (D2: 60 and 180).
Changes
overview-bundleis inKNOWN_CONCEPTS, andOverviewBundleResult(OverviewBundleOpen | OverviewBundleRecent) inforge-contracts.tsdocuments the inputs (CODEV_OVERVIEW_SECTIONS;CODEV_SINCE_DATEforrecent) and each half's two required keys, each an array ornull.scripts/forge/github/overview-bundle.sh:-Fonly whereghmust expand{owner}/{repo}, cursors through-f;gh's status and stderr;ghruns in the background withwait, so the dispatcher's timeout kills it promptly, and temp files are cleaned up by a trap.resolveOverviewPlan()inforge.tspicks the mode from configuration alone. The bundle is used when it resolves to a command and either the project overrides it, or no constituent is overridden or disabled. gitlab, gitea, linear and jira disable it; for the two hybrids that is a correctness requirement. The newsrc/lib/overview-budget.tsowns the overview TTLs, the debounce andprojectHourlyForgeCalls().codev doctorlists the concept and prints anoverviewline with the mode, reason and projected calls/hour, e.g.bundled — 26 forge calls/h idle, 66 under constant invalidation.OverviewCacheholds two bundle entries per workspace through the tower: overview cache burns the user's entire GitHub GraphQL quota (3 gh calls × N workspaces every 30s, failures uncached) — every gh command on the machine then fails #1645cachedFetch: theopenhalf at the 180 s list TTL, invalidatable, and therecenthalf at the 600 s search TTL, never invalidated. Single-flight (keyed by half), debounced invalidation, the negative cache and suspension all carry over. The halves are split back into the four section outcomesgetOverviewalready reads, so/api/overviewis unchanged.forge.mdgains a Tower Overview section and a GitLab override sketch.arch.mdand both forgeSKILL.mdfiles describe the concept, and the stale "18 concepts" counts are corrected to 21.Behaviour changes adopters can see (all approved at the spec gate):
forgeStatus: ok, instead of "could not fetch issues".PR-review hardening (43573c0):
ghreleases its lock if killed (since replaced; see below).PR-review round 2 (7864b9a, ea435ef):
jq, not on the platform).jq.exewrites CRLF, so with both searches failed,closed\rmatched no section and a search-local failure became a whole-bundle failure. Classification now goes byjq -eexit status, and cursors are read with-j. A CRLFjqshim pins it on POSIX.resolveOverviewPlan()no longer reads every concept script on each poll: the new source-only resolver does no file I/O.After review round 3: the PR's Linux CI (acd756a). The Unit Tests check (ubuntu) had failed on every push since this PR opened. I had been citing local macOS runs as "the full suite"; that is corrected below.
sh -c" optimization. Node'sexectimeout therefore SIGTERMed only the outer dash:overview-bundle.sh's traps never ran,ghoutlived the limit and the temp directory stayed. Reproduced on macOS by building dash 0.5.12 with that one patch. POSIXexecShellString/execShellStringSync(platform/posix/command-launch.ts) now run a bare absolute path to an existing.shasexec '<path>', the POSIX counterpart of Windows' existing bare-script case. Every other shell string is passed through unchanged. Pinned by a mocked string-form test,spec-1647-posix-script-exec.test.ts(a script path with a space and a quote; on timeout, the script's TERM trap runs and its child dies), and exit status 143 asserted in the script timeout test. All three new tests fail with the fix disabled.ghcall in about a third of Linux runs, a different call each time. The runner image had moved to ubuntu-26.04, whose uutilsmkdir(rust-coreutils0.8 to 0.10, fixed upstream in 0.11) reports success when it loses a race to create the same directory. The fake usedmkdirfor exclusion, first as a lock and then as a numbered claim. An invocation log in the failure message showed two pids both claimingn=1. The fake now claimscall.Nby creating it under noclobber (O_EXCL, done by the shell itself), and a regression test puts an always-succeedingmkdirfirst on PATH. Two diagnostics stay: a guardghafter the fake on PATH, which keeps a realghfrom ever running in these tests, andCODEV_DEBUGin the e2e file. No shipped script usesmkdirfor exclusion.Adjacent fixes in this PR:
mergedPRCachewas typedForgePR[]althoughrecently-mergedreturnsMergedPrItem[]. It is retyped, and a merged PR without aurlnow links nothing; the JSON payload is unchanged.forge.md'scodev doctorsample used a format doctor no longer prints. It is replaced with real current output.Testing
-f suites=true): 46275389517, all jobs green. Its codev unit tests: 487 files passed, 15 skipped; 10,870 tests passed, 449 skipped. Spec-1647 files that ran there: the script tests (40 of 61; the 21 skipped are gated off win32 by design: 15 direct/bin/shruns, which are the new input checks and one stderr read, plus the executable-bit check, the hostile strings, the signal-based timeout and the CRLF shim), the cache tests (25), the gh end-to-end tests (7, realOverviewCache→ dispatcher → Git Bash → script, both halves), the fetch tests (18) and the plan tests (33).config.test.ts(47, with the layering tests) and the tower: overview cache burns the user's entire GitHub GraphQL quota (3 gh calls × N workspaces every 30s, failures uncached) — every gh command on the machine then fails #1645 harness (3) passed. The run dispatched on 8192cde (46274866753) was cancelled when the head moved.main(windows: console window flashes while an agent works in a VS Code terminal (unhidden child-process spawns) #1919/Raise the Node.js floor to 22, drop Node 20, and standardise CI on Node 22 #1944):windows-console-spawn-guard.test.ts> "the import walk reaches Tower, the CLIs and the extension host" timed out at 5,141 ms against the 5 s default on 8192cde's Unit Tests (46274869142). Its sibling in that file was sized to 20 s by Raise the Node.js floor to 22, drop Node 20, and standardise CI on Node 22 #1944; this one was not. Left running, not skipped, not fixed here; named in the review's Flaky Tests.packages/codevsuite (macOS), full run on cd1d4f3 (the code of the final head except the fix below): 487 files passed, 14 skipped, 1 failed to parse (11,200 tests passed, 116 skipped). The failure wasbugfix-1645-gh-quota.test.ts: a test name I had broken with an apostrophe. Fixed in 8192cde, and that file was re-run alone (3 passed). The Linux CI run above is the full suite on the final head.deepMerge(7).mkdirflake).packages/codevsuite (macOS) on b455181: 466 files passed, 14 skipped; 10,153 tests passed, 116 skipped.spec-1647-overview-bundle-script.test.ts: parity with the four sibling scripts on a state recorded from real GitHub, process counts and paging, argument guards, classification, hostile strings, timeout.spec-1647-overview-plan.test.ts: mode resolution, the projection, doctor text.spec-1647-fetch-overview-bundle.test.ts: limits, contract checks, the 24 h filter.spec-1647-overview-bundle-cache.test.tsandspec-1647-overview-bundle-gh.test.ts: cache semantics, rate limit, timeout, mode selection, end-to-endOverviewDataparity between the two modes.overview.test.tsandoverview-rate-limit.test.tspin four-call mode in one block each, as the kept four-call variant.gh, in both modes: samependingPRs,backlogandrecentlyClosed, same key sets. Both search sections equal their sibling concepts' results.ghnumbering and 36 script tests;spec-1647-posix-script-exec.test.tsis POSIX-only and skips by design.-f filter=spec-1647. All 5 cache end-to-end tests (realOverviewCache→ dispatcher → Git Bash → script) and 36 script tests passed; 14 skipped by design. The skipped ones are the direct/bin/shruns, the hostile cursor (its route file name is illegal on NTFS), the signal-based timeout kill, and the CRLF shim, which Windows covers with the realjq.exe. Correction: the two earlier runs ran none of these tests (45952952774 was green, and 45954554101's unit-test job ended without finishing), because both files were gated off win32 until the second PR review caught it. The first real run then found the CRLF bug below.Consultation: two lanes (codex, claude) for the spec, the plan and each of the four phases. All four implementation phases came back APPROVE. Dispositions are in the review doc.
Spec
codev/specs/1647-tower-collapse-the-four-per-wo.md
Review
codev/reviews/1647-tower-collapse-the-four-per-wo.md