Repository navigation
chore(token-refresh): decompose services/tokenRefresh.ts into tokenRefresh/* leaves (999 → 724) - #8547
Conversation
|
Reviewed #8547 in an isolated worktree against the PR head (167af6e). Verification:
Diffed all 18 relocated functions against the pre-move file — they're byte-identical moves, and the re-export surface in One small nit, non-blocking: the new header comment in No blocking issues found from this review. |
…gic into tokenRefresh/* leaves
…d.ts cad2c72 moved isUnrecoverableRefreshError out of tokenRefresh.ts into tokenRefresh/shared.ts. This suite asserts on source *text* (it regex-matches the function body to prove the unrecoverable sentinel is returned), so the move made it fail to find the definition — the only red test across the 23 tokenRefresh-related suites. Repoint the read() at the file that now defines the body. The public surface is unchanged: tokenRefresh.ts still re-exports the symbol, verified by import.
…tokenRefresh header The header claimed credit for KooshaPari's diegosouzapw#7338 was "preserved via co-authorship on the extraction commits", but none of the commits carries a Co-authored-by trailer -- and adding one would be inaccurate, since this is an independent implementation against the current tip rather than a reuse of that diff. The by-name credit for proposing the split stays; only the false claim about the mechanism is removed.
c9bd671 to
4c3f5d0
Compare
|
The #7338 attribution nit is fixed — commit Also rebased onto Re-verified on the rebased head: |
|
Correction to my comment above: I measured it on pristine detached checkouts with an empty working tree: The gate is in |
|
Thanks @MumuTW — merged into |
…fresh/* leaves (999 → 724) (diegosouzapw#8547) * chore(token-refresh): extract rotation/cas/circuit-breaker refresh logic into tokenRefresh/* leaves * test(oauth): follow isUnrecoverableRefreshError to tokenRefresh/shared.ts cad2c72 moved isUnrecoverableRefreshError out of tokenRefresh.ts into tokenRefresh/shared.ts. This suite asserts on source *text* (it regex-matches the function body to prove the unrecoverable sentinel is returned), so the move made it fail to find the definition — the only red test across the 23 tokenRefresh-related suites. Repoint the read() at the file that now defines the body. The public surface is unchanged: tokenRefresh.ts still re-exports the symbol, verified by import. * docs(changelog): add fragment for this PR * docs(auth): correct the diegosouzapw#7338 attribution wording in the tokenRefresh header The header claimed credit for KooshaPari's diegosouzapw#7338 was "preserved via co-authorship on the extraction commits", but none of the commits carries a Co-authored-by trailer -- and adding one would be inaccurate, since this is an independent implementation against the current tip rather than a reuse of that diff. The by-name credit for proposing the split stays; only the false claim about the mechanism is removed.
…fresh/* leaves (999 → 724) (diegosouzapw#8547) * chore(token-refresh): extract rotation/cas/circuit-breaker refresh logic into tokenRefresh/* leaves * test(oauth): follow isUnrecoverableRefreshError to tokenRefresh/shared.ts cad2c72 moved isUnrecoverableRefreshError out of tokenRefresh.ts into tokenRefresh/shared.ts. This suite asserts on source *text* (it regex-matches the function body to prove the unrecoverable sentinel is returned), so the move made it fail to find the definition — the only red test across the 23 tokenRefresh-related suites. Repoint the read() at the file that now defines the body. The public surface is unchanged: tokenRefresh.ts still re-exports the symbol, verified by import. * docs(changelog): add fragment for this PR * docs(auth): correct the diegosouzapw#7338 attribution wording in the tokenRefresh header The header claimed credit for KooshaPari's diegosouzapw#7338 was "preserved via co-authorship on the extraction commits", but none of the commits carries a Co-authored-by trailer -- and adding one would be inaccurate, since this is an independent implementation against the current tip rather than a reuse of that diff. The by-name credit for proposing the split stays; only the false claim about the mechanism is removed.
Phase 1 god-file decomposition, 3 of 3. Independent of the sibling PRs — disjoint file sets, mergeable in any order.
This is the highest-risk of the three because it touches the OAuth refresh path, so it is deliberately the smallest extraction of the set:
tokenRefresh.ts999 → 724 lines, only the pieces with a clean seam.What
tokenRefresh/rotationMap.tstokenRefresh/casGuard.tstokenRefresh/circuitBreaker.tstokenRefresh/shared.tsisUnrecoverableRefreshError(file already existed)tokenRefresh.tsstill re-exports the moved symbols, so the ~8 call sites acrossopen-sse/executors,handlers/chatCore,tokenHealthCheck,codexAuthFile,claudeAuthFileand the OAuth import route are untouched. Verified by importing the module and asserting the symbol resolves.One real regression, caught and fixed
Moving
isUnrecoverableRefreshErrorout oftokenRefresh.tsbroketests/unit/oauth-providers-error-handling.test.ts. That suite makes text-based assertions on source files — it readstokenRefresh.tsand regex-matches the function body to prove the unrecoverable sentinel is returned:A re-export does not satisfy that, so the definition went missing and the test failed — the only red test across the 23 tokenRefresh-related suites. The second commit repoints the
read()attokenRefresh/shared.ts, which is where the body now lives. The assertion itself is unchanged, and the public surface is unchanged.Worth flagging for reviewers of future decomposition work: this repo has source-text structural tests that a pure move can break without any behavioral change.
Faithfulness
isUnrecoverableRefreshErroris a genuine move, not new logic — it lived at line 489 of the pre-movetokenRefresh.tsVerification
typecheck:corecheck:cyclescheck-file-sizeInherited base-red (not from this PR)
release/v3.8.49is red on two gates this branch does not touch: lint (stale suppression, fixed by #8544) and file-size (providers/page.tsx1990 > 1927,tokenHealthCheck.ts843 > 841 — fixed by #8532 / #8524). Both verified present on the base at branch point.