Context
Discovered while implementing #4759 (PR #4821) — deliberately not bundled into that PR to keep it
scoped to exactly the 3 files #4759 named. Non-urgent, mechanical follow-up.
The problem
review-enrichment/src/analyzers/undocumented-export.ts, unused-export.ts, and caller-impact.ts
each still hand-roll their own private "fetch a repo file's content at a ref, bounded/streamed read
capped at 1MB" helper (readBoundedText + a fetchFileAtHead-style wrapper) — the same pattern
doc-comment-drift.ts, exhaustiveness-drift.ts, and complexity-delta.ts had before #4759/PR #4821
migrated them onto the shared boundedFetchText utility (review-enrichment/src/external-fetch.ts).
undocumented-export.ts additionally hand-builds its own GitHub auth headers inline
(Authorization: Bearer ${githubToken} etc.) instead of using the shared githubHeaders() helper
(review-enrichment/src/github-headers.ts) — the same inconsistency doc-comment-drift.ts had before
#4759. unused-export.ts and caller-impact.ts already use githubHeaders(), just not
boundedFetchText yet.
Fix
Follow the exact same playbook #4759/PR #4821 used:
- Read
review-enrichment/src/analyzers/duplication-delta.ts first — its fetchFileAtHead is the
reference implementation for calling boundedFetchText (including the options.analysis?.fetchText
vs. direct boundedFetchText fallback and the endpointCategory/phase/subcall conventions).
- Delete each of the 3 files' own private
readBoundedText entirely (not relocate it) and replace their
fetch-helper with a fetchFileAtHead-style wrapper that calls boundedFetchText /
options.analysis.fetchText.
- Switch
undocumented-export.ts to the shared githubHeaders() helper.
- Verify byte-identical behavior for all three via their existing test suites in
review-enrichment/test/
— continuing to pass unchanged (mechanical mocking updates allowed if needed to match
boundedFetchText's calling convention, mirroring duplication-delta.test.ts's own mocking style).
No new shared module — this is a pure migration onto infrastructure that already exists.
Acceptance criteria
Context
Discovered while implementing #4759 (PR #4821) — deliberately not bundled into that PR to keep it
scoped to exactly the 3 files #4759 named. Non-urgent, mechanical follow-up.
The problem
review-enrichment/src/analyzers/undocumented-export.ts,unused-export.ts, andcaller-impact.tseach still hand-roll their own private "fetch a repo file's content at a ref, bounded/streamed read
capped at 1MB" helper (
readBoundedText+ afetchFileAtHead-style wrapper) — the same patterndoc-comment-drift.ts,exhaustiveness-drift.ts, andcomplexity-delta.tshad before #4759/PR #4821migrated them onto the shared
boundedFetchTextutility (review-enrichment/src/external-fetch.ts).undocumented-export.tsadditionally hand-builds its own GitHub auth headers inline(
Authorization: Bearer ${githubToken}etc.) instead of using the sharedgithubHeaders()helper(
review-enrichment/src/github-headers.ts) — the same inconsistencydoc-comment-drift.tshad before#4759.
unused-export.tsandcaller-impact.tsalready usegithubHeaders(), just notboundedFetchTextyet.Fix
Follow the exact same playbook #4759/PR #4821 used:
review-enrichment/src/analyzers/duplication-delta.tsfirst — itsfetchFileAtHeadis thereference implementation for calling
boundedFetchText(including theoptions.analysis?.fetchTextvs. direct
boundedFetchTextfallback and theendpointCategory/phase/subcallconventions).readBoundedTextentirely (not relocate it) and replace theirfetch-helper with a
fetchFileAtHead-style wrapper that callsboundedFetchText/options.analysis.fetchText.undocumented-export.tsto the sharedgithubHeaders()helper.review-enrichment/test/— continuing to pass unchanged (mechanical mocking updates allowed if needed to match
boundedFetchText's calling convention, mirroringduplication-delta.test.ts's own mocking style).No new shared module — this is a pure migration onto infrastructure that already exists.
Acceptance criteria
undocumented-export.ts,unused-export.ts, andcaller-impact.tsall callboundedFetchText(or
options.analysis.fetchText) instead of their own private bounded-read logic.undocumented-export.tsuses the sharedgithubHeaders()helper instead of hand-built auth headers.