Skip to content

refactor: share GitHub pagination helper between collect scripts - #1373

Merged
mrbobbytables merged 1 commit into
mainfrom
arch/refactor-github-pagination
Oct 13, 2026
Merged

mrbobbytables merged 1 commit into
mainfrom
arch/refactor-github-pagination

Conversation

@hivecommons-hive

Copy link
Copy Markdown
Contributor

Refactor

scripts/collect-metrics.mjs and scripts/collect-launch-metrics.mjs each
defined their own githubAll()/sameOriginNext() pair for following Link
rel="next" pagination and guarding the Authorization header against a
cross-origin redirect target. collect-launch-metrics.mjs also rebuilt the
request headers inline instead of calling the existing makeGitHubHeaders().
scripts/lib/github.mjs exists precisely to centralize this kind of
auth/header logic in one place, so the duplication worked against its own
stated purpose.

This PR moves the pagination + same-origin guard into
scripts/lib/github.mjs as githubAllPages(url, headers), alongside the
existing makeGitHubHeaders/githubFetch. Both scripts now build headers
via makeGitHubHeaders() and call the one shared pagination helper; their
private copies of githubAll/sameOriginNext are removed.

No behavioral change: tests/collect-metrics.test.mjs and
tests/collect-launch-metrics.test.mjs assert on script output (stdout,
stderr, written files), not internals, and both suites (38 tests) pass
unmodified. Full coverage-gated suite (npm run test:unit:coverage:check)
also passes with src files at 100/100.

Fixes #1372


Filed by architect agent (ACMM L5 — hold-gated mode). Hold-gated: human review required.

— hive: agent=architect backend=copilot model=claude-opus-4-6 copilot=1.0.88

scripts/collect-metrics.mjs and scripts/collect-launch-metrics.mjs each
defined their own githubAll()/sameOriginNext() pair for following Link
rel="next" pagination and guarding the Authorization header against a
cross-origin redirect target. collect-launch-metrics.mjs also rebuilt
the request headers inline instead of calling the existing
makeGitHubHeaders().

Move the pagination + same-origin guard into scripts/lib/github.mjs as
githubAllPages(url, headers), alongside the existing makeGitHubHeaders
and githubFetch it was meant to share. Both scripts now build headers
with makeGitHubHeaders() and call the one shared pagination helper.

No behavior change: tests/collect-metrics.test.mjs and
tests/collect-launch-metrics.test.mjs assert on script output, not
internals, and both suites pass unmodified.

Signed-off-by: architect <architect@hive.kubestellar.io>
@hivecommons-hive

Copy link
Copy Markdown
Contributor Author

Important

Held for human review by the hive's ACMM level gate.

This PR was opened by the "architect" agent while Hive policy required a human checkpoint for that agent. Non-outreach agents are held at ACMM L3–L5; the outreach agent is always held because it publishes project-facing communication.

Hive will keep the hold label until a human removes it. Operators can make a deliberate one-off release during an ACMM level change with release_level_holds=true, but level changes never release this hold automatically.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[architect] Duplicated GitHub pagination/same-origin-guard logic across collect-metrics.mjs and collect-launch-metrics.mjs

1 participant