Skip to content

codex: self-check unpinned CLI versions instead of refusing them - #251

Merged
IngTian merged 4 commits into
mainfrom
worktree-codex-self-verify
Nov 25, 2026
Merged

IngTian merged 4 commits into
mainfrom
worktree-codex-self-verify

Conversation

@IngTian

@IngTian IngTian commented Nov 25, 2026

Copy link
Copy Markdown
Owner

Why

The Codex runner admitted only exact pinned CLI versions. Codex shipped 11 stable releases in 28 days, and each one turned the daily contract check red (#244, #250). Each also refused every user on the new CLI until a witness release shipped the pin, even though in both cases the wire contract passed unchanged. Today 0.172.0 is out, and v0.15.1 only admits up to 0.171.0.

What changes

  • Self-check for unpinned versions (internal/platform/codex/selfcheck.go). Before an unpinned (version, model) pair gets a transcript, witness runs the real codex exec with the exact argv Run builds (now shared through execArgs) against a loopback fake Responses endpoint. It uses a scratch CODEX_HOME, a random key and no proxy variables, so the user's key and witness's login are never involved.
    • It requires checkWireRequest to pass: no tools, only developer instructions and one user corpus. That function moved here from the contract test.
    • Sensitivity check: dropping the catalog override must make the checker fail, or the CLI is refused because the check can't see tools on it.
    • Passes are recorded in <runtime>/codex/verified.json; failures are never recorded.
  • Gate: validate (Open and doctor) and Run call ensureToolFree after the catalog is fetched. Pinned versions skip the check, so a bug in it can only affect versions that were refused before this change.
  • Login and wire readiness no longer gate on the version. They send no transcript, and a plan login's catalog, which the check needs, only exists after login. TestLoginAndReadinessRejectUnverifiedCLI is replaced by TestLoginAndReadinessAcceptUnpinnedCLI.
  • CI: the latest leg drops the "not pinned" assertion and also runs TestContractSelfCheck, the production self-check on the real CLI for gpt-6.1-sol and gpt-5.5. Red now means users on latest are refused.

Pins stay as a CI-verified fast path. Bump them when convenient, not on every Codex release.

Verification

  • make fmt vet test green; go vet -tags codexcontract clean.
  • New unit tests use the re-exec fake Codex, extended with a probe mode that POSTs to openai_base_url:
    • The check passes.
    • It refuses offered tools.
    • It refuses when it can't see tools.
    • It runs once and is remembered, including after a corrupt record.
    • Pinned versions skip it.
    • A failed check refuses, is not remembered, and starts no generation call.
  • Each of those was mutation-checked (6 mutations, 5 caught). The surviving one is equivalent: os/exec keeps the last duplicate env key.
  • Locally against the real Codex CLI 0.172.0 (unpinned): TestContractToolFreeWire and TestContractSelfCheck pass. The self-check took ~14.5 s per model, once.

Known limits (unchanged from pins)

  • The ChatGPT-login request path is not observed.
  • Import and usage-limit text are not gated by version.

Closes #250.

🤖 Generated with Claude Code

IngTian and others added 4 commits November 24, 2026 21:38
selfCheck sends the exact argv Run builds (now shared via execArgs) to a loopback Responses endpoint with a scratch home and a random key, applies the contract test's checkWireRequest (moved into the product), and fails closed unless dropping the catalog override visibly offers tools. Not wired into the gate yet.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
validate (Open/doctor) and Run now gate each (version, model) on ensureToolFree after the catalog is fetched: pinned versions pass as before, any other pair must be recorded in <runtime>/codex/verified.json or pass selfCheck now. Only passes are recorded. Login and wire readiness no longer gate on the version: they send no transcript, and a plan login's catalog only exists after login. The contract test drops its not-pinned assertion and lets the self-check's own calls through untouched.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ing on every unpinned release

TestContractSelfCheck runs the production self-check on the real CLI for gpt-6.1-sol and gpt-5.5; the latest leg goes red only when the self-check or the wire contract rejects the CLI, which is exactly when users on it are refused. Docs and AGENTS.md describe the self-check. Verified locally against Codex CLI 0.172.0 (unpinned): wire contract and self-check pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- The sensitivity run now requires visibly offered tools (top-level tools or a non-message input item), not any contract failure: a CLI whose uncatalogued request only changes its instructions text no longer counts as having shown its tools.

- A record vouches for the checked binary (version, size, mtime), not for every binary printing that version.

- A verified.json of null no longer panics; it is re-checked like any corrupt record.

Re-verified against the real Codex CLI 0.172.0: wire contract and self-check pass on gpt-6.1-sol and gpt-5.5.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@IngTian
IngTian marked this pull request as ready for review November 25, 2026 03:29
@IngTian
IngTian merged commit f399890 into main Nov 25, 2026
15 checks passed
@IngTian
IngTian deleted the worktree-codex-self-verify branch November 25, 2026 03:29
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.

Codex contract: daily check against latest failed

1 participant