refactor(github): consolidate githubHeaders cluster and CI-cache params (#4610) - #4681
Merged
Merged
Conversation
…uster (#4610) app.ts, scoring/model.ts, contributor-issue-draft.ts, and upstream/ruleset.ts each carried their own drifted githubHeaders copy (four different signatures, no shared GitHub HTTP header helper anywhere in src/). Extract one shared, options-object githubHeaders into github/client.ts and route all four call sites through it. Mechanical, no behavior change.
…ct (#4610) cachedFetchLiveCiAggregate, fetchLiveCiAggregateWithRequiredContexts, cachedLiveCiAggregate, and refreshLiveCiAggregate each took 9-10 positional params, including three consecutive same-shaped optional strings (headSha, baseRef, token) with no compiler protection against transposition. Convert all four to the single labeled options-object convention already used by neighboring large functions in this file. The 3-layer cache architecture (cachedLiveCiAggregate -> refreshLiveCiAggregate -> reuseOrRefreshLiveCiAggregate) is unchanged; only the parameter-passing convention changes. Mechanical, no behavior change -- the full existing queue.test.ts suite (807 tests) passes unmodified.
Contributor
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4681 +/- ##
=======================================
Coverage 94.14% 94.14%
=======================================
Files 435 435
Lines 38566 38567 +1
Branches 14060 14062 +2
=======================================
+ Hits 36308 36309 +1
Misses 1599 1599
Partials 659 659
🚀 New features to boost your workflow:
|
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
githubHeadersREST-header builder intosrc/github/client.tsand replaces four independently-drifted local copies (each with a different signature) insrc/github/app.ts,src/scoring/model.ts,src/services/contributor-issue-draft.ts, andsrc/upstream/ruleset.ts(14 call sites total). The new options-object signature ({ token?, accept?, json?, apiVersion? }) reconciles the four original shapes while producing byte-identical headers at every existing call site.processors.ts's live CI-aggregate cache cluster (cachedFetchLiveCiAggregate,fetchLiveCiAggregateWithRequiredContexts,cachedLiveCiAggregate,refreshLiveCiAggregate) from 9-10 positional params — including three consecutive same-shaped optional strings (headSha,baseRef,token) with no compiler protection against transposition — to the single labeled options-object convention already used by neighboring large functions in this file. The 3-layer cache architecture (cachedLiveCiAggregate→refreshLiveCiAggregate→reuseOrRefreshLiveCiAggregate) is unchanged; only the parameter-passing convention changes.review-enrichment/githubHeaderscluster (Consolidate review-enrichment's 17-file githubHeaders() duplication #4609, already merged separately as a self-contained change).Fixes #4610.
Scope
type(scope): short summaryConventional Commit format, for examplefix(api): restore profile access checks.CONTRIBUTING.mdand does not reintroduce GitHub Pages, VitePress,site/, orCNAME.Closes #123) — a linked open issue is required for every contributor PR.Validation
git diff --checknpm run actionlintnpm run typechecknpm run test:coverage(ran scopedvitest --coverageinstead — see note below)npm run test:workersnpm run build:mcpnpm run test:mcp-packnpm run ui:openapi:checknpm run ui:lintnpm run ui:typechecknpm run ui:buildnpm audit --audit-level=moderateIf any required check was skipped, explain why:
src/queue,src/github,src/scoring,src/services,src/upstream) with zero UI/MCP/workers-pool/OpenAPI/dependency surface, so those checks don't apply to this diff; CI runs them regardless. Locally:npm run typecheckis clean, and every changed file was verified with a targetedvitest --coveragepass (test/unit/github-client.test.ts— including 5 new tests exercising every branch of the new sharedgithubHeadershelper — plustest/unit/github-app.test.ts,test/unit/scoring.test.ts,test/unit/contributor-issue-draft.test.ts,test/unit/routes-contributor-issue-draft.test.ts,test/unit/upstream-ruleset.test.ts, and the fulltest/unit/queue.test.ts, 1124 tests total, all passing unmodified). Coverage was cross-checked line-by-line against the exact diff hunks: zero uncovered statements or branches on any changed line in either finding. The queue.test.ts suite needed no changes at all, confirming the CI-cache signature change is behavior-preserving.Safety
github-app.test.ts, e.g. JWT-rejection/eviction and installation-token-rejection cases, pass unmodified against the refactored call sites.)UI Evidence
Not applicable — backend-only refactor, no UI/frontend/visible changes.
Notes
mainimmediately before pushing (git fetch origin && git rebase origin/main); the only concurrentprocessors.tschange onmain(feat(review): instrument impact-map + add a public AI-reuse-rate trend (#4448) #4671, a 1-line edit ~6,000 lines away from this diff) rebased with no conflict.