Repository navigation
[Spec 1647] tower-collapse-the-four-per-wo - #2004
Draft
waleedkadous wants to merge 70 commits into
Draft
waleedkadous wants to merge 70 commits into
waleedkadous wants to merge 70 commits into
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.
….md and forge skills
…bined doctor causes)
# Conflicts: # packages/codev/src/agent-farm/servers/overview.ts
… last-page cursor, fake gh lock)
…ce-only plan resolution; pin the rate-limit pattern
…-prone text (found on native Windows)
… two cold lessons
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.
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 all four forge-backed sections of Tower's overview (open PRs, open issues, issues closed and PRs merged in the last 24 h) from one invocation. On GitHub its script sends onegh api graphqlrequest 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.Refs #1647. The close keyword is left out on purpose: the architect asked to handle closing #1647 and its deliberate copy #1995 themselves. Swap in
Closes #1647if the merge should close it.Per watched workspace, per idle hour, on GitHub:
ghprocesses (more than 100 open issues / 100 or fewer)Live on this repository: one refresh is one invocation and 2
ghprocesses, costing 5 points where the four calls cost 7.Changes
overview-bundleis inKNOWN_CONCEPTS, andOverviewBundleResultinforge-contracts.tsdocuments the input (CODEV_SINCE_DATE) and four 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 — 20 forge calls/h idle, 60 under constant invalidation.OverviewCacheholds one bundle entry per workspace at the 180 s list TTL, through the unchanged 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, so single-flight, debounced invalidation, the negative cache and suspension all carry over. The bundle is split back into the four section outcomesgetOverviewalready reads, so/api/overviewis unchanged. Its 24 h lists now refresh every 180 s instead of 600 s.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
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