fix(primer): drop reset-alignment retry; keep Claude binary fix only

Live evidence shows the Codex 5h limit is a trailing rolling window whose
reported reset slides forward with continued usage (observed 18:00 → 18:33
over ~33 min). A timed primer therefore cannot pin the reset to a fixed clock
time, and the previous "retry at reported reset" logic was both based on a
wrong fixed-window model and buggy under sliding resets (stale reset target,
single-shot). Revert it.

Keep the verified Claude primer binary-path fix (resolve repo-root
node_modules) and document the real rolling-window behavior so the primer is
correctly framed as a best-effort warm-up + success/failure record.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
Codex
2026-06-09 13:40:35 +09:00
parent 2313d6cf3e
commit efc8c00380
2 changed files with 18 additions and 111 deletions

View File

@@ -12,13 +12,8 @@ const refreshActiveCodexUsage = vi.fn(async () => {
});
const runCodexWarmupCycle = vi.fn(async () => {
callOrder.push('warmup');
return { status: 'warmed', accountIndex: 0 } as {
status: string;
accountIndex?: number;
reason?: string;
};
return { status: 'warmed', accountIndex: 0 };
});
const getAllCodexAccounts = vi.fn<() => Array<{ resetAt?: string }>>(() => []);
vi.mock('./config.js', () => ({
CODEX_WARMUP_CONFIG: {
@@ -58,10 +53,6 @@ vi.mock('./codex-warmup.js', () => ({
runCodexWarmupCycle,
}));
vi.mock('./codex-token-rotation.js', () => ({
getAllCodexAccounts,
}));
describe('usage-primer', () => {
it('refreshes Codex usage before primer selection and fires regardless of usage level', async () => {
callOrder.length = 0;
@@ -83,31 +74,4 @@ describe('usage-primer', () => {
{ ignoreZeroUsageWindow: true },
);
});
it('reschedules a retry at the window reset when the slot is rate-limited', async () => {
vi.useFakeTimers();
vi.setSystemTime(new Date('2026-06-09T00:00:00.000Z'));
runCodexWarmupCycle.mockClear();
// First slot: the 5h window is still active/exhausted → command fails.
runCodexWarmupCycle.mockResolvedValueOnce({
status: 'failed',
accountIndex: 0,
reason: 'exit_1',
});
// The account's window resets 60s from now.
getAllCodexAccounts.mockReturnValue([
{ resetAt: '2026-06-09T00:01:00.000Z' },
]);
const { runCodexPrimerCycle } = await import('./usage-primer.js');
await runCodexPrimerCycle();
expect(runCodexWarmupCycle).toHaveBeenCalledTimes(1);
// Retry is scheduled at reset (+60s) plus a 30s buffer = +90s.
await vi.advanceTimersByTimeAsync(91_000);
expect(runCodexWarmupCycle).toHaveBeenCalledTimes(2);
getAllCodexAccounts.mockReturnValue([]);
vi.useRealTimers();
});
});