Repository navigation
test(token-health): pin the real terminal-skip boundary, not the pre-exemption one - #11592
Merged
diegosouzapw merged 2 commits intoAug 26, 2026
Conversation
…exemption one
`Unit Tests fast-path` is red on every branch:
✖ checkConnection still skips a GitHub Copilot connection expired for a
non-no_refresh_token reason (cheaper-inference#8182 boundary)
actual: 'github_access_token_invalid', expected: 'invalid_grant'
cheaper-inference#8182 skipped every "expired" connection so a sweep would not waste a probe on rows
that can never self-heal. That proved too wide — a transient OAuth failure parks a
healthy connection at "expired" and it could then never come back — so
`tokenHealthCheck.ts` grew `isRecoverableExpiredWithRetryBudget`, which un-terminals an
expired connection while it still has retry budget and is not `account_deactivated`.
The assertion still described the pre-exemption policy: that ANY non-`no_refresh_token`
expired GitHub connection is skipped. Its fixture has retry count 0 and no
`lastErrorType`, so under the current guard it is deliberately probed.
Replaced with the two halves of the boundary that exists now:
- retry budget remaining → probed, so a transient failure can self-heal;
- `lastErrorType: "account_deactivated"` → still skipped, row untouched.
The second case keeps cheaper-inference#8182's wasted-probe protection covered where it still applies —
deleting the old case outright would have left that unguarded. The probe case stubs
`globalThis.fetch` with a 401, matching the sibling tests, so it stays hermetic.
diegosouzapw
merged commit Aug 26, 2026
b9fd4aa
into
cheaper-inference:release/v3.8.51
10 of 16 checks passed
This was referenced Aug 26, 2026
diegosouzapw
added a commit
to HouMinXi/OmniRoute
that referenced
this pull request
Aug 29, 2026
…obe pin after merge Merging origin/release/v3.8.51 showed the skip assertion from cheaper-inference#11611 no longer matches production: GitHub access-token-only expired connections with remaining retry budget are probed via refreshCopilotToken (fetch is called; lastHealthCheckAt is set). That boundary was pinned by cheaper-inference#11592 after the cheaper-inference#11608 carve-out. Keep the probe assertion. Refs cheaper-inference#11611 cheaper-inference#11592 Co-authored-by: diegosouzapw <[email protected]>
muhamadgalihsaputra
pushed a commit
to niyatna/NiyatnaRoute
that referenced
this pull request
Sep 27, 2026
…exemption one (cheaper-inference#11592) Merged via /merge-batch (lote 2026-08-26, v3.8.51). Boarded no worktree combinado junto com outras ~30 PRs; validação única: typecheck/complexity/cognitive-complexity/changelog-integrity verdes, file-size rebaseado onde necessário (crescimento legítimo), lint com os mesmos 228 achados pré-existentes confirmados via sonda contra o tip puro (não introduzidos por este lote), e ~370 testes focados (unit + vitest) passando. Obrigado pela contribuição.
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.
Part of the "every gate is red on every branch" cleanup — one of six independent unit-test failures on
release/v3.8.51.The red test
The row was written, so
checkConnectiondid not return early — the terminal skip theassertion describes no longer applies to that fixture.
The policy moved on purpose
#8182 skipped every
"expired"connection so a sweep would not waste a probe per cycleon rows that can never self-heal. That turned out too wide: a transient OAuth failure
parks a healthy connection at
"expired"and it could then never come back.tokenHealthCheck.tstherefore grew a third exemption alongside the GitHub-Copilot andCursor ones:
with the intent stated inline: "allow expired connections with retry budget remaining
to pass through so transient OAuth failures can self-heal instead of being permanently
skipped. Exhausted retries stay terminal."
The test's fixture has retry count 0 and no
lastErrorType, so under the current guardit is deliberately probed. The assertion described the pre-exemption policy.
What changed
Deleting the case would have left #8182's wasted-probe protection unguarded, so it is
replaced by the two halves of the boundary that exists now:
lastHealthCheckAtgets written, so a transientfailure can self-heal.
lastErrorType: "account_deactivated"→ still skipped. Status staysexpired,errorCodeuntouched,lastHealthCheckAtstill null —checkConnectionreturnsearly without touching the row, which is the property fix(resilience): credits_exhausted providers still consume CPU despite cooldown config #8182 was protecting.
The probe case stubs
globalThis.fetchwith a 401, matching how the sibling tests inthis file isolate themselves, so it stays hermetic and does not reach the network.
Verification
Test-only; no production code touched.
One thing I did not cover and would rather flag than guess at: the third terminal
path,
getExpiredRetryCount(conn) >= EXPIRED_RETRY_MAX. Seeding a connection at theretry ceiling means writing
providerSpecificData.expiredRetry.count, and I could nottell from the code whether that shape is a supported fixture or an internal detail I
would be freezing by asserting on it. Happy to add the case if you confirm which.