perf(primer): drop pre-fire usage refresh so the Codex primer fires exactly on the slot
The Codex primer awaited refreshAllCodexAccountUsage + refreshActiveCodexUsage before firing, purely to feed the old usage-based warm-up gating. With forceAttempt the primer fires regardless of usage, so those pre-call refreshes only added variable latency (the few-hundred-ms jitter that pushed the call off the exact slot) and a needless dependency on the usage API. Fire first at the slot; refresh once afterwards for observability (never delaying the call). The hourly usage collector keeps cached usage current. Verified: typecheck, build, bundle-smoke; usage-primer + codex-warmup suites pass (primer now fires before any refresh; refreshAll no longer called). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -54,7 +54,7 @@ vi.mock('./codex-warmup.js', () => ({
|
||||
}));
|
||||
|
||||
describe('usage-primer', () => {
|
||||
it('refreshes Codex usage before primer selection and fires regardless of usage level', async () => {
|
||||
it('fires the Codex primer first with forceAttempt and refreshes usage only afterwards', async () => {
|
||||
callOrder.length = 0;
|
||||
refreshAllCodexAccountUsage.mockClear();
|
||||
refreshActiveCodexUsage.mockClear();
|
||||
@@ -63,7 +63,10 @@ describe('usage-primer', () => {
|
||||
const { runCodexPrimerCycle } = await import('./usage-primer.js');
|
||||
await runCodexPrimerCycle();
|
||||
|
||||
expect(callOrder).toEqual(['refreshAll', 'refreshActive', 'warmup']);
|
||||
// No pre-call usage refresh (that was the off-slot latency source); the
|
||||
// command fires immediately, then usage is refreshed for observability.
|
||||
expect(callOrder).toEqual(['warmup', 'refreshActive']);
|
||||
expect(refreshAllCodexAccountUsage).not.toHaveBeenCalled();
|
||||
expect(runCodexWarmupCycle).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
enabled: true,
|
||||
|
||||
Reference in New Issue
Block a user