[architect] Converge ESM GitHub fetch sites onto lib/gh.js (#1232) - #1236
Open
kylerankin wants to merge 1 commit into
Open
[architect] Converge ESM GitHub fetch sites onto lib/gh.js (#1232)#1236kylerankin wants to merge 1 commit into
kylerankin wants to merge 1 commit into
Conversation
The GitHub API plumbing was forked three ways: lib/request-queue.js (CJS), lib/gh.js (ESM), and hand-rolled token+header sites in the fetch layer (architect issue projectbluefin#1232). This converges the ESM half onto lib/gh.js. lib/gh.js gains two exports so every ESM fetch site routes through one client instead of restating plumbing: * githubHeaders(token, {accept, apiVersion, userAgent}) — the single header contract (accept, pinned x-github-api-version, project user-agent, Bearer auth). Callers override only accept where an endpoint needs a different representation (Contents API .raw). * githubFetch(path, {headers, signal, fetchImpl, throwOnError}) — one request through the shared client; throws on non-2xx unless throwOnError:false, so fail-soft sites still get a null fallback. Migrated the two ESM hand-rolled sites: * lib/factory-monthly-metrics.mjs — token via githubToken(), headers via githubHeaders(), lane runs via githubFetch(). * lib/tap-promotions.mjs — PR files and package descriptions now build headers and fetch through the shared client, keeping their per-endpoint accept overrides (v3+json, v3.raw) and throw/return semantics. Behaviour is unchanged: all 1000 existing tests still pass, and the new githubHeaders/githubFetch contracts are covered by gh-lib.test.js. The CJS hand-rolled sites (fetch-feeds, fetch-pin-state, fetch-hive-*, fetch-factory-stats, lib/sbom/api) remain on lib/request-queue.js for a separate incremental migration. Signed-off-by: kylerankin <kylerankin@users.noreply.github.com>
kylerankin
force-pushed
the
fix/github-api-plumbing
branch
2 times, most recently
from
September 13, 2026 07:28
8222cf2 to
a032a05
Compare
castrojo
approved these changes
Sep 13, 2026
castrojo
enabled auto-merge
September 13, 2026 07:58
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.
Resolves architect issue #1232 (first incremental step): the GitHub API plumbing was forked three ways — lib/request-queue.js (CJS), lib/gh.js (ESM), and hand-rolled token+header sites across the fetch layer. This converges the ESM half onto lib/gh.js.
What changed
lib/gh.js gains two exports so every ESM fetch site routes through one client instead of restating plumbing:
githubHeaders(token, { accept, apiVersion, userAgent })— the single header contract (accept, pinnedx-github-api-version, project user-agent,Bearerauth). Callers override onlyacceptwhere an endpoint needs a different representation (e.g. the Contents API.raw).githubFetch(path, { headers, signal, fetchImpl, throwOnError })— one request through the shared client; throws on non-2xx unlessthrowOnError: false, so fail-soft sites still get a null fallback.Migrated the two ESM hand-rolled sites:
lib/factory-monthly-metrics.mjs— token viagithubToken(), headers viagithubHeaders(), lane runs viagithubFetch().lib/tap-promotions.mjs— PR files and package descriptions now build headers and fetch through the shared client, keeping their per-endpoint accept overrides (v3+json,v3.raw) and throw/return semantics.Behaviour
Neutral. Token acquisition, header shape, timeout signal,
fetchImplinjection, and throw-vs-return semantics are preserved per site. All 1000 existing tests still pass; the newgithubHeaders/githubFetchcontracts are covered by new cases ingh-lib.test.js(1008 tests total). Prettier + eslint clean.Follow-up
The CJS hand-rolled sites (
fetch-feeds,fetch-pin-state,fetch-hive-live-data,fetch-hive-history,fetch-factory-stats,lib/sbom/api) remain onlib/request-queue.jsfor a separate incremental migration of the CJS half.— hive: backend=pi model=lemonade/Ornith-1.5-35B-A3B-GGUF-Q6_K
🐝 Hive Agent:
contributor| SHA:a032a053