codexUpstreamOn wrote the relay's ledger row as Provider: call.Provider
("openai") with no account. The account card's window holds key rows by
codex + the sign-in's email (usage/window_holds.go), so every turn Codex
relayed on its own sign-in was left out: the reporter's 7-day window read
2.3M/$0.31 where its calls were 19.0M/$64.26.
codexServed (ggbdpq's patch) records such a relay as the codex account
signed in to, or the account compactOn signed it with. An API-key call
and a relay with no sign-in to name stay openai with no account. The
Routing view's seat stays OpenAI. loggedAnswers (#1367) still leaves the
relay out of a lead's answerers, as openai or as codex without a
"host as email". Rows already written are not rewritten.
On top of the patch: the relay goes out with the token Codex sent, which
is the sign-in magpie reads only when it is the same ChatGPT account. A
request whose chatgpt-account-id isn't the account auth.json here is
signed in to (a Codex in WSL, another CODEX_HOME) stays openai rather than
being put on this machine's account (provider.CodexSignedInAccount).
TestCodexServedNamesTheAccountThatSigned is back and covers it.
Run, go1.26.8 darwin/arm64, on 03eb0633a, -tags nogui -p 1:
- go test ./internal/gateway -run 'TestCodex|TestSealedTaskFromChatGPTLead|
TestLoggedAnswer|Lead': ok (48.8s). The four new tests -race -count=3: ok.
- go test ./internal/provider -run 'TestSessionIdentit|TestCodex': ok;
./internal/usage -run 'Window|Hold': ok.
- go vet ./internal/gateway ./internal/provider for darwin, GOOS=linux and
GOOS=windows: clean. gofmt -l: nothing.
Broken by hand, each red, then put back:
- codexServed always "openai": TestCodexOwnModelRecordedAsCodexAccount
(Provider:openai, no account) and TestCodexServedNamesTheAccountThatSigned.
- chatgpt-account-id check dropped: TestCodexServedNamesTheAccountThatSigned
("another account's token: codex me@example.com").
- loggedAnswers back to provider == "openai" only:
TestCodexOwnModelRecordedAsCodexAccount and TestCodexOwnRelayAnswersNoLead
("own sign-in answered a lead").
ggbdpq's own record (Windows, 38d25fe3/1d61458b on 01c41e8b): the same
tests red with codex_backend.go reverted, green after; -race -count=5;
vet/build for windows, linux, darwin.
Not run: the full suite, GUI, a real Codex sign-in.
Full suite: SUITE_LINE
Co-authored-by: ggbdpq <ggbdpq@gmail.com>