Repository navigation
fix(hub): leave the empty native-main slot out of /v1/hub-accounts - #10
Merged
Merged
Conversation
A hub without a native Codex login listed the openai native-main slot (`__main__`) as an account. The Codex row mapping now carries the server's native-main credential presence as an optional `hasCredential` on AccountRow, only when the reader asks for it (`mainCredential`). `false` requires the server's checked `missing_credential` reason too, because the server also reports `hasCredential: false` for a read that could not check. `GET /v1/hub-accounts` is the only reader that asks, and it omits the slot only on that checked absence; a credentialed slot (also one needing reauth), an unknown presence, pool accounts and other providers stay listed. The response shape is unchanged, and `ocx account` listings neither request nor carry the field. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
GET /v1/hub-accountsno longer lists the openai native-main slot (slotKind: "native-main", id__main__) on a hub that has no native Codex login. The decision uses only the server's own credential observation, never label or email text.src/cli/account-api.ts:fetchCodexRowstakes an opt-inmainCredentialoption. With it, the native-main row carries an optionalhasCredentialonAccountRow:truewhen the codex-auth DTO reportshasCredential: true,falseonly when the DTO reportshasCredential: falseandreauthReason: "missing_credential", absent otherwise. The second condition matters becauselistCodexAuthAccountsSnapshot(src/codex/auth-api/account-list.ts) also sendshasCredential: falsewhen it could not check (passive read, unavailable native-main claim, stale generation); it namesmissing_credentialonly whenmainSnapshotLive && credentialChecked && !hasCredential.src/server/hub-accounts.ts: the Codex read usesfetchCodexRows(..., false, true, { mainCredential: true })(the same requestfetchRows(..., "codex", {})made before, plus the option) and drops a native-main row only onhasCredential === false. A credentialed slot (also one needing reauth), an unknown presence, pool accounts and the other providers stay listed. The response shape is unchanged: no new field, same masking and quota allow-list.ocx accountcommands, the dashboard and the management API do not request the option, so their rows and JSON are unchanged.structure/cli-management.md(owner ofsrc/cli/) describes the opt-in field.The hub's account read goes over loopback HTTP to
/api/codex-auth/accounts, a new request outside anyrunPassiveReadscope, so it is a non-passive (checking) read; themissing_credentialrequirement still protects against the unchecked fallbacks inside that read.Verification
On m5m1 (macOS, Bun 1.4.4), head
3aaeeaa40:bun installbun test tests/server/hub-accounts.test.ts(10 pass: 6 existing + 4 new)bun run typecheckbun run privacy:scanbun run structure:checkbun test tests/cli/cli-account.test.ts tests/ci-workflows/file-size-ratchet.test.ts tests/test-layout.test.ts(164 pass,TMPDIRon a real non-symlink path outside~/.claude)bun run test(sameTMPDIR, 712 s)bun run teston this Mac reports 139(fail)lines, all in host-environment areas: Codex CLI private-prefix/POSIX apply and update job store (unsafe_storeon the external build volume), PATH-Bun fixture trust and launcher PATH fallback,bun-install-frozen.shretry policy, owned-path removal, Codex launcher ACL/credential-destination fixtures, release version moves. None is in the account, hub-accounts or codex-auth tests; the same classes of host failures were recorded for the plain v2.100.2 tag in #9. The Linux CI below (test changed, which follows the import graph ofsrc/cli/account-api.tsandsrc/server/hub-accounts.ts) is the suite proof.New cases in
tests/server/hub-accounts.test.tsmap real codex-auth DTO shapes throughfetchCodexRowsand the endpoint: checked missing login → omitted; credentialed main needing reauth → kept (and nohasCredentialin the response); unknown presence (false without the checked reason, false with another reauth reason, not reported) → kept; pool rows, including one without a credential → kept; without the option no row carrieshasCredential.CI on head
3aaeeaa40: requiredcipass andgatespass (run 43616705479; alsotest changed,structure gate,docker smoke,storage policy,api usage,npm-global ubuntu-latestpass),gitleakspass,Catalog async contractspass. Full shards and macOS/Windows lanes are skipped on a PR by upstream policy. The upstream-oriented event gates (enforce-pr-target,react-doctor) did not run on this PR; they are not merge gates for the hub line (they failed on #9).Independent review (a reviewer agent that did not write the change, read-only): APPROVE, no blocking findings. It confirmed that
missing_credentialis set only formainSnapshotLive && credentialChecked && !hasMainCredential, that every unchecked path (passive read, unavailable claim, unobservable, stale prepared token, non-live generation) keeps the row, that the hub read is non-passive, that thefetchCodexRowscall equals the oldfetchRows(..., "codex", {})plus the option, and that no other listing or the response shape changes. Non-blocking notes: (1) the server's checked absence is wider than "never logged in": an unreadable or invalidauth.json, or a keyring-mode Codex reportingchatgptauth without tokens, is also reported asmissing_credential, so the slot is omitted there too — this follows the spec (the server's ownhasCredentialdecides) and matches what the dashboard shows asmissing_credential; (2) one test bypasses the 30 s cache with an earliernowinstead ofresetHubAccountsCacheForTest(); (3) theslotKindandidchecks inisEmptyNativeMainare redundant by design (defensive).Checklist
🤖 Generated with Claude Code