Repository navigation
test(kimi): stop drawing the refresh window inside the assertion - #11380
Conversation
`checkKimiWebConnectionIfNeeded` spreads its refresh over [60, 240) seconds before expiry so a fleet of connections cannot stampede the token endpoint. The test built a token expiring in 90 s and asserted a refresh happened — true only when the draw lands at 90 or above, i.e. 150 of the 180 possible values. So the test fails 1 run in 6 by construction: 16.67% computed, 4 of 20 measured locally. That is what the Node 26 nightly hit, and it was filed as a Node-compat break (cheaper-inference#11361). The spread is now `defaultKimiRefreshJitterSec()` and the window is injectable as `jitterSecFn`, so a caller can decide it instead of rolling for it. Production is unchanged: the only caller (`tokenHealthCheck.ts:611`) passes nothing and keeps the random spread. Cases added for a token outside the window, and for the default spread staying inside [60, 240). Refs cheaper-inference#11361
|
CI note, so the red is not left ambiguous.
The same assertion fails identically on #11374, #11376, #11377 and #11380, whose
I have not touched the coverage floor: rebaselining a gate I did not break is not |
|
CI update — all three reds are base-side; none are reachable from this diff.
Identical inputs cannot produce a different coverage number, so this PR cannot have moved it.
Nothing to change here. Happy to rebase if you want a fresh run. |
d5d730c
into
cheaper-inference:release/v3.8.50
…aper-inference#11380) Validado em lote combinado (batch-0824g, junto de cheaper-inference#11388/cheaper-inference#11397/cheaper-inference#11415/cheaper-inference#11418) contra o tip de release/v3.8.50: typecheck:core limpo, file-size/changelog/complexity/cognitive-complexity OK, 62/62 testes focados passando. Diagnóstico correto e bem documentado: a falha do nightly Node 26 era um teste que sorteia um número e depende do resultado, não uma quebra de compatibilidade. Comportamento de produção inalterado (a janela de jitter continua aleatória; só o teste ganhou controle sobre ela). Obrigado pela investigação detalhada!
Refs #11361 — the Node 26 nightly failure on
release/v3.8.51is not a Node-compatbreak. It is a test that draws a random number and then asserts the outcome.
release/v3.8.50is not green; the failures this PRinherits are the ones tracked there, not introduced here.
What the nightly actually reported
From the run linked in #11361 (
Node 26 Compat Tests (4/4)):One failure out of 8280, in a test whose own name contains the word "jittered".
Why it fails, on any Node
checkKimiWebConnectionIfNeededdecides the refresh window by drawing it:The test builds a token expiring in 90 s and asserts a refresh happened. That is
true only when the draw lands at 90 or above — 150 of the 180 possible values.
Nothing about Node 24/26 is involved; the nightly just rolled low. The same coin has
presumably been flipped on every run of this suite since the test was written.
Change
The spread becomes
defaultKimiRefreshJitterSec()and the window becomes injectableas
jitterSecFn, so a caller can decide it rather than roll for it.Production behaviour is unchanged. The only caller
(
src/lib/tokenHealthCheck.ts:611) passes nothing and keeps the random spread —which exists for a real reason (a fleet of connections must not stampede the token
endpoint at the same instant), so it is kept, not removed.
The test now passes
jitterSecFn: () => 120for the in-window case, and two casesare added: a token outside the window is left alone, and the default spread stays
inside
[60, 240)over 2000 draws.Verification
Changelog fragment:
changelog.d/maintenance/kimi-health-check-jitter-determinism.md.I would not close #11361 on this alone — it asks to triage "which Node version/shard
broke", and the answer is "none of them, on this run". If a later nightly shows a
genuine Node 24/26 break, it will now be visible instead of buried under a 1-in-6 coin.