Skip to content

[codex] Fix stale shared broker auth after account switch - #303

Draft
spnotold wants to merge 1 commit into
openai:mainfrom
spnotold:codex-fix-stale-broker-auth
Draft

spnotold wants to merge 1 commit into
openai:mainfrom
spnotold:codex-fix-stale-broker-auth

Conversation

@spnotold

@spnotold spnotold commented May 7, 2026

Copy link
Copy Markdown

Summary: Detect when a shared Codex broker is serving stale account state after Codex login switches accounts; compare broker auth against a freshly started app-server and discard stale broker sessions; ignore dead broker endpoints when reporting session runtime status; add regression coverage for stale broker auth and current login tracking. Root cause: the plugin reuses a long-lived codex app-server broker inside Claude Code, and that process can keep serving the previous account after Codex login changes the local account. Testing: npm test; npm run build.

fireblue added a commit to fireblue/codex-plugin-cc that referenced this pull request May 17, 2026
…ai#303, openai#315)

- Drop non-JSONL garbage on app-server stdout (openai#311)
- Fix broker shutdown hang on unresponsive socket (openai#300)
- Treat jobs as inactive when their PID is dead (openai#297)
- Fix stale shared broker auth after account switch (openai#303)
- Widen /codex:review wait threshold to ~5 files / 200 lines (openai#315)
- Update test fixtures to include pid for PID-alive checks

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
audichuang added a commit to audichuang/codex-plugin-cc that referenced this pull request Jun 7, 2026
…ision (1.0.9→1.0.12)

Implements the verified reliability gaps from docs/reliability-backlog.md, TDD
throughout, each batch adversarially verified by agent workflows. +56 tests
(290 total, all green); `npm run build` clean (tsc); version sites in lockstep
at 1.0.12; CHANGELOG documents every item.

Batch 1 — most-defensive, smallest, pure-backend (1.0.9):
- openai#2 robust stdout JSONL parsing: AppServerClientBase.handleLine strips ANSI and
  skips non-JSON noise instead of tearing down the connection (and killing the
  turn) on the first unparseable line. New lib/strings.mjs#stripAnsi.
- openai#5 hook stdin tolerates EAGAIN/EWOULDBLOCK pipe jitter (new lib/hook-input.mjs;
  both hooks share it; returns {} instead of crashing and dropping session_id).
- openai#1 captureTurn idle watchdog (CODEX_TURN_IDLE_TIMEOUT_MS, default 0/off because
  delta notifications are opted out; rejects with the thread/turn id).

Batch 2 — process / connection lifecycle (1.0.10):
- openai#3 terminateProcessTree POSIX descendant sweep (via ps) + ESRCH→direct-kill
  fallback; close() reaps the codex app-server subtree on every platform.
  Deliberately did NOT detach codex (would orphan its subtree on a watchdog
  broker-reap) — the tree-walk covers both the close and reap paths.
- openai#262 broker reuse gated on the recorded pid being alive (isSessionStale), not
  just the endpoint answering.
- openai#303 (stale broker after account switch) deferred — conflicts with the
  shared-broker safety rules and needs a fresh on-disk auth probe (account/read
  through the long-lived broker returns its own stale cached account).

Batch 3 — output & failure visibility (1.0.11):
- openai#4 adversarial-review prompt capped under the ~1 MB Codex input limit with
  UTF-8-safe truncation (truncateToByteBudget) + a truncation notice.
- main() failures also emit a {"status":"error",...} envelope on stdout so the
  codex-rescue subagent (stdout-only) sees the failure.
- non-retryable turn errors short-circuit to failed (authoritative willRetry===
  false signal; narrow permanent-auth regex fallback), gated to the root thread
  so a subagent-thread error does not fail the parent.

Batch 4 — UX / observability + the openai#355 design decision (1.0.12):
- Background jobs survive SessionEnd: background:true marking, cleanupSessionJobs
  skips+retains them, and the shared broker is kept alive while any background
  job is active (shouldTeardownBroker + hasActiveBackgroundJobs).
- /codex:attach: live log tail that exits at terminal status; bounded
  (maxConsecutiveNullStatus + finite maxPolls) and cross-workspace aware.
- openai#6 cross-workspace job lookup: findJobByIdAcrossWorkspaces as a read-only
  fallback for an explicit id; default (no id) stays workspace/session-scoped.
- dispatch sentinel [[codex-task status=dispatched id=...]]; and app-server type
  alignment (requestAttestation capability; drop removed experimentalRawEvents)
  for a clean tsc build.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
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.

1 participant