Skip to content

test: injectable quota-call pacing; smaller profile rotation test - #387

Merged
ualtinok merged 1 commit into
mainfrom
test/injectable-quota-pacing
Oct 17, 2026
Merged

ualtinok merged 1 commit into
mainfrom
test/injectable-quota-pacing

Conversation

@antauth-alfonso

@antauth-alfonso antauth-alfonso Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

Lets tests replace the real wait between quota usage calls, and fixes a test that couldn't fit its time limit under load. Production timing is unchanged.

  • Quota-call pacing: QuotaManager spaces physical usage GETs by about a second with a real, unref'd timer. A new pauseBetweenQuotaCalls option replaces that wait; it's called only when the remaining gap is positive and defaults to the same timer as before, returned without an async wrapper so it takes the same turns. Production passes nothing. OpenCode test fixtures pass it through a runtime override and Pi tests through a test-only setter; 7 OpenCode and several Pi rate-limit tests now assert the requested gap instead of spending real time. The existing real-clock spacing test runs unchanged, and a new mutation row proves the default wait is still exercised.
  • Profile rotation test: completed profile hydration does not refetch later token generations ran 66 dependent token generations, a count left from when attempts were keyed by access-token fingerprint. It now covers the boundary generations that prove the property, with the same assertions.

No global timers are mocked, no deadline changed.


Summary by cubic

Makes the wait between quota usage polls injectable so rate-limit tests record the requested pause instead of spending real time on it, and shrinks a profile rotation test that ran far more generations than needed. Production timing is unchanged.

  • QuotaManager gains a pauseBetweenQuotaCalls option that replaces the real unref'd timer only when set; production passes nothing and keeps the same one-second gap.
  • OpenCode and Pi tests pass a recording pause and assert each requested gap is between 0 and 1,000 ms.
  • The profile rotation test now runs 3 token generations instead of 66; the higher count was left over from an older token-keyed attempt map, and the assertions are unchanged.

Written for commit 3385caf. Summary will update on new commits.

View guided diff Turn on auto-fix

…ion test

QuotaManager gains an optional pauseBetweenQuotaCalls(ms). Unset, it uses
pauseOnRealTimer, the same unreferenced native setTimeout promise that was
inline before, returned directly so awaiting it takes the same turns.
OpenCode (runtime override quotaCallPause) and Pi (__setPiQuotaCallPauseForTest)
pass it only from test fixtures; production passes undefined.

OpenCode and Pi provider-error rate-limit tests now record the requested
wait instead of sleeping ~1 s, and assert each requested gap is in (0, 1000].
A new Core test asserts the second GET requests exactly the remaining gap.

"completed profile hydration does not refetch later token generations"
runs 3 rotations instead of 66. Same assertion (one profile call). The 66
came from an older token-keyed attempt map; today attempts and completed
checks are keyed by route ID and account identity, a fresh stored profile
skips the account first, and nothing in that path counts or caps rotations.

mutations.toml: two Core rows (default pause skips the wait; gap set to 0),
both proved CAUGHT with ckdev-mutate prove.
@ualtinok
ualtinok merged commit 3385caf into main Oct 17, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant