Skip to content

fix(hub): leave the empty native-main slot out of /v1/hub-accounts - #10

Merged
dalsoop merged 1 commit into
mainfrom
hub/omit-empty-native-main
Nov 14, 2026
Merged

dalsoop merged 1 commit into
mainfrom
hub/omit-empty-native-main

Conversation

@dalsoop

@dalsoop dalsoop commented Nov 14, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • GET /v1/hub-accounts no 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: fetchCodexRows takes an opt-in mainCredential option. With it, the native-main row carries an optional hasCredential on AccountRow: true when the codex-auth DTO reports hasCredential: true, false only when the DTO reports hasCredential: false and reauthReason: "missing_credential", absent otherwise. The second condition matters because listCodexAuthAccountsSnapshot (src/codex/auth-api/account-list.ts) also sends hasCredential: false when it could not check (passive read, unavailable native-main claim, stale generation); it names missing_credential only when mainSnapshotLive && credentialChecked && !hasCredential.
  • src/server/hub-accounts.ts: the Codex read uses fetchCodexRows(..., false, true, { mainCredential: true }) (the same request fetchRows(..., "codex", {}) made before, plus the option) and drops a native-main row only on hasCredential === 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.
  • No other account list changes: ocx account commands, the dashboard and the management API do not request the option, so their rows and JSON are unchanged.
  • structure/cli-management.md (owner of src/cli/) describes the opt-in field.

The hub's account read goes over loopback HTTP to /api/codex-auth/accounts, a new request outside any runPassiveRead scope, so it is a non-passive (checking) read; the missing_credential requirement still protects against the unchecked fallbacks inside that read.

Verification

On m5m1 (macOS, Bun 1.4.4), head 3aaeeaa40:

Command Exit
bun install 0
bun test tests/server/hub-accounts.test.ts (10 pass: 6 existing + 4 new) 0
bun run typecheck 0
bun run privacy:scan 0
bun run structure:check 0
bun test tests/cli/cli-account.test.ts tests/ci-workflows/file-size-ratchet.test.ts tests/test-layout.test.ts (164 pass, TMPDIR on a real non-symlink path outside ~/.claude) 0
bun run test (same TMPDIR, 712 s) 1

bun run test on this Mac reports 139 (fail) lines, all in host-environment areas: Codex CLI private-prefix/POSIX apply and update job store (unsafe_store on the external build volume), PATH-Bun fixture trust and launcher PATH fallback, bun-install-frozen.sh retry 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 of src/cli/account-api.ts and src/server/hub-accounts.ts) is the suite proof.

New cases in tests/server/hub-accounts.test.ts map real codex-auth DTO shapes through fetchCodexRows and the endpoint: checked missing login → omitted; credentialed main needing reauth → kept (and no hasCredential in 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 carries hasCredential.

CI on head 3aaeeaa40: required ci pass and gates pass (run 43616705479; also test changed, structure gate, docker smoke, storage policy, api usage, npm-global ubuntu-latest pass), gitleaks pass, Catalog async contracts pass. 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_credential is set only for mainSnapshotLive && 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 the fetchCodexRows call equals the old fetchRows(..., "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 invalid auth.json, or a keyring-mode Codex reporting chatgpt auth without tokens, is also reported as missing_credential, so the slot is omitted there too — this follows the spec (the server's own hasCredential decides) and matches what the dashboard shows as missing_credential; (2) one test bypasses the 30 s cache with an earlier now instead of resetHubAccountsCacheForTest(); (3) the slotKind and id checks in isEmptyNativeMain are redundant by design (defensive).

Checklist

  • Scope stays focused and avoids unrelated cleanup.
  • Docs or release notes were updated when needed.
  • Security-sensitive changes were reviewed for secrets, auth, and unsafe defaults.

🤖 Generated with Claude Code

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>
@dalsoop
dalsoop merged commit 6f1933e into main Nov 14, 2026
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants