Skip to content

P0: preserve Codex MCP tool availability across deployment restart and OAuth rebind #163

Description

@James3014

Status

G0_EVIDENCE_BOUND / READY_FOR_BOUNDED_DIAGNOSIS

Owner-authorized public Issue. This Issue does not authorize merge, deployment, service restart, release, or production claims. AUTO_CHAIN=false.

Problem

An existing Codex conversation can lose the Dev MCP tool surface during or after a normal DevSpace deployment restart even though the replacement backend and public route are healthy. The failure occurs before agent_start, so it must not be classified as a provider/model failure.

Observed behavior:

  • a normal server shutdown closes hundreds of active MCP sessions;
  • the service launcher adds a fixed startup delay, creating an avoidable restart blackout;
  • after replacement, codex-mcp-client can complete OAuth discovery but receive HTTP 400 from POST /token;
  • no corresponding agent_start reaches the server;
  • active session count grows quickly after restart, suggesting significant session churn;
  • frequent deployment of a fast-moving main repeatedly interrupts active MCP clients.

This is a regression or remaining gap after #15, #31, #99, and #159. Those issues respectively cover general reliability, multi-session cutover, token request parsing, and missing snapshot rebind, but do not close this observed end-to-end failure chain.

Required invariant

normal deploy/restart
  -> bounded drain or explicit reconnect state
  -> replacement becomes ready without a fixed blackout
  -> same authenticated Codex client can refresh/rebind
  -> tools/list becomes callable again in the existing conversation
  -> a subsequent tool call reaches the handler exactly once

Server restart, OAuth recovery, MCP session recovery, tool-catalog exposure, and provider dispatch are separate evidence layers.

Gate sequence

G1 — Deterministic reproducer and classification

  • Add a test/harness for server-generation restart followed by the Codex-client token/rebind request shape.
  • Emit a safe structured OAuth failure class without logging credentials.
  • Determine whether repeated initialize/list/call cycles reuse, close, or leak sessions.

G2 — Bounded restart behavior

  • Replace unconditional startup delay with bounded readiness/backoff behavior.
  • Deployment must drain, defer, or emit an explicit durable reconnect/rebind outcome instead of silently dropping active sessions.
  • A failed build must not schedule or perform a restart.

G3 — OAuth and MCP rebind recovery

  • The same authorized Codex client can recover after server replacement without creating a new conversation.
  • Supported JSON and form token requests remain compatible.
  • Stale, cross-client, replayed, or malformed credentials continue to fail closed.

G4 — Session lifecycle bound

  • Repeated client operations do not create unbounded active sessions.
  • Idle or abandoned sessions have a tested TTL or explicit close path.
  • Health telemetry distinguishes normal concurrency from churn.

G5 — Host-level acceptance

  • Run one controlled authenticated restart/rebind trial.
  • Verify fresh tools/list and at least 10 consecutive safe calls after recovery.
  • Verify one bounded agent_start obtains a durable dispatch receipt before making a provider-success claim.

Non-goals

Claim ceiling

REPRODUCED_HOST_RESTART_AND_OAUTH_REBIND_FAILURE / SOURCE_REPAIR_NOT_YET_ACCEPTED

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions