shangyuan0818 on Discord (10-24): "Warm up on reset" on for the Codex
week. magpie spent a Codex reset card about to run out, the warm-up
after it started the week, nothing was used, then OpenAI reset
everyone's limits. No warm-up went for that second reset.
Cause: warmDue saw a reset only when the window's use fell (by 1 or
more) or its kept reset time passed. After the card and its warm-up
the window was running at 0% used, so the official reset had no use
to fall from, and the reset time kept (a week from the warm-up) was
still days off. The read after it shows the window not started (0%,
its reset a whole window from now), which nothing compared with what
was kept.
Fix: warmDue also counts a window as started over when it is not
started now (idle) and its reported reset is at least warmSlack later
than both the reset it was seen running to and the end of the window
magpie's last warm-up started (movedOn), or no reset is reported at
all. The second bound keeps a read that still carried an old reset
before showing the warm-up's own window from looking like a reset.
After the upgrade an account already in this state is warmed on the
next look: nothing for the user to do.
Siblings: the same warmDue runs for every ChatGPT account, the 5-hour
window ("all"), and Claude's warm-up (claude_warmup.go, same
codexWarmer), whose not-started windows Anthropic leaves out of the
read; each has a subtest. No other provider has a warm-up.
Tests: TestWarmAfterResetCardThenOfficialReset drives fake usage reads
through the reported sequence (card spent, warm-up, a third of the
window unused, official reset, then 12 more looks) for the Codex week,
the Codex 5 hours and a Claude week left out of the read, with a
second account running all along that must never be sent one.
TestWarmDue gets three cases. TestCodexWarmOncePerReset's last step
set two weeks warmed 10 and 35 minutes before to reset a full week
from now, which is what a not-started window reports; they now reset
a week from their warm-ups, as the backend reports a started window.
Broken by hand:
- old codex_warmup.go with the new tests: TestWarmDue "reset early,
nothing used before" and "... left out" due false, want true;
TestWarmAfterResetCardThenOfficialReset all three subtests "after
the official reset, sent [a@example.com]".
- movedOn's nil-reset branch returning false: the Claude subtest and
the "left out" case go red.
- movedOn without the warm-up bound: TestCodexWarmOncePerReset goes
red ("all: [a@example.com:5 hours b@example.com:7 days]").
Run at 4b9694c34 plus this change (rebased onto dcfda5f16, which
changes internal/gateway only):
- gofmt -l on both files: nothing.
- go vet ./internal/provider/, GOOS=linux go vet -tags nogui
./internal/provider/, GOOS=windows go vet ./internal/provider/: ok.
- go build ./..., GOOS=linux go build -tags nogui ./...,
GOOS=windows go build ./...: ok.
- go test -tags nogui -timeout 45m ./internal/provider/ in a sandbox
HOME: ok (113s), no reds.
Not run: the full go test ./... (other sessions' full suites are
queued on this machine, one suite per machine). Not tried with a real
account: an official OpenAI reset can't be made on demand, so the
backend's reads after it come from the report and from what an idle
window reports today (0% used, reset a whole window from now). If
OpenAI's reset instead keeps the old reset time with 0% used, the
read can't tell it from a running unused window, and this change
doesn't catch it.