[architect] converge hive-live + factory-stats fetchers onto shared lib/gh.js - #1257
Merged
castrojo merged 1 commit intoSep 13, 2026
Conversation
Fold the hand-rolled GitHub API plumbing out of the fetch layer and onto the single adr/0003-endorsed client in scripts/lib/gh.js (projectbluefin/ documentation#1232). - gh.js: export githubHeaders() as the one header contract (Accept + api-version + user-agent + Bearer) and forward an optional AbortSignal through ghFetch/ghPaginate so a caller can pin its own timeout without the shared client inventing a retry policy. - fetch-hive-live-data.js: drop its inline token + v3+json header object and its local GH_API; go through githubToken()/ghFetch(). - fetch-factory-stats.js: drop its inline token + v3+json header object and local GH_API; lane runs now come from ghPaginate() with the same per_page=100, maxPages=10, workflow_runs select and 20s timeout. Both migrations are behavior-neutral: same endpoints, same pagination, same timeout, same fail-soft wrappers — only the header/auth construction is deduplicated. The CJS request-queue.js side and the GraphQL/DI/Link- pagination fetchers are left for follow-up PRs. Signed-off-by: kylerankin <kylerankin@users.noreply.github.com>
castrojo
approved these changes
Sep 13, 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.
What
Fold two more hand-rolled GitHub API fetchers onto the single, adr/0003-endorsed client in
scripts/lib/gh.js(resolves architect issue #1232). This is the second incremental slice — a parallel PR (#1236) converges the other two ESM sites (lib/factory-monthly-metrics.mjs,lib/tap-promotions.mjs); each is independently reviewable as #1232 recommends.scripts/lib/gh.js:githubHeaders(token)as the one header contract —Accept: application/vnd.github+json, pinnedx-github-api-version: 2022-11-28, project user-agent, optionalAuthorization. Previously an internal-only helper; now the shared contract every ESM fetcher builds through.AbortSignalthroughghFetch/ghPaginateso a caller can pin its own timeout. The shared client keeps no retry of its own — a wedged endpoint fails fast instead of hanging the build (the hang [architect] GitHub API plumbing forked 3 ways: lib/request-queue.js (CJS), lib/gh.js (ESM), and 8 hand-rolled token+header sites in fetch-*.js #1232 calls out infetch-feeds.js).scripts/fetch-hive-live-data.js:GITHUB_TOKENread, its localGH_API, and its hand-rolledv3+jsonheader object; go throughgithubToken()/ghFetch().scripts/fetch-factory-stats.js:v3+jsonheader object and localGH_API. Lane runs now come fromghPaginate()with the sameper_page=100,maxPages=10,workflow_runsselect and 20s timeout.Behaviour
Neutral. Same endpoints, same pagination, same timeout, same fail-soft wrappers — only the token acquisition and header/auth construction is deduplicated. GitHub treats
application/vnd.github.v3+jsonandapplication/vnd.github+jsonidentically, so the header convergence changes no returned data.Verified:
node --test "scripts/**/*.test.js"(1079 tests) passes;eslintandprettier --checkclean on the changed files.Left for later
The remaining hand-rolled sites — the CJS fetchers behind
lib/request-queue.js, the GraphQLlib/tap-promotions.mjs, the DI-basedlib/factory-monthly-metrics.mjs, and the Link-pagination sites (fetch-feeds.js,fetch-hive-history.js,lib/sbom/api.js,fetch-pin-state.js) — converge onto the shared client in their own follow-up PRs.— hive: backend=pi model=lemonade/Ornith-1.5-35B-A3B-GGUF-Q6_K