GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(codex): stable Codex runtime selection for sync/clamp (#297) by Wibias · Pull Request #359 · lidge-jun/opencodex

Conversation

@Wibias

@Wibias Wibias commented Jul 23, 2026 •
edited by coderabbitai Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Summary

  • Introduce one canonical ResolvedCodexRuntime resolver (env → configured → shim → PATH → fallback) with --version validation and persistence in codex-runtime.json.
  • Make bundled-catalog probing, effort clamping, and ocx v2 features use that same runtime so sync cannot silently pick an older PATH binary and strip max/ultra.
  • Surface diagnostics in ocx status, ocx doctor (including optional --fix-codex-runtime), sync logs, and the Startup dashboard warning.

Test plan

  • bun test tests/codex-runtime.test.ts
  • bun test tests/cli-status-json.test.ts
  • bun test tests/doctor.test.ts
  • bun test tests/codex-catalog.test.ts -t reasoning-effort
  • bun run typecheck
  • Full bun test + bun run lint:gui / build on CI
  • Manual Windows dual-install: PATH 0.133.0 vs CODEX_CLI_PATH 0.145.0-alpha.30 (clamp warning vs preserve max/ultra; restart/sync keep runtime)

Closes / related: #297

Summary by CodeRabbit

  • New Features
    • Added Codex runtime discovery in settings, startup UI, and CLI diagnostics (including version/source, warnings, and “newer available”).
    • Added ocx doctor --fix-codex-runtime and expanded ocx doctor output with Codex runtime selection diagnostics.
    • Enhanced ocx status (including --json) to report Codex runtime and catalog clamp state.
    • Startup now shows localized runtime clamp warnings and offers a copy-to-clipboard fix command when applicable.
  • Improvements
    • Improved Windows/POSIX Codex command launching behavior and added i18n performance optimizations (memoized translations).

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@Wibias
fix(codex): stabilize Codex runtime selection across sync and clamp
73a3030
Keep catalog probing and effort clamping on one persisted runtime so PATH cannot silently downgrade away max/ultra.
@Wibias
Wibias requested review from Ingwannu and lidge-jun as code owners July 23, 2026 18:57
@github-actions github-actions Bot added the bug Something isn't working label Jul 23, 2026
@coderabbitai

This comment was marked as resolved.

Sign in to view
chatgpt-codex-connector[bot]

This comment was marked as resolved.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

coderabbitai[bot]

This comment was marked as resolved.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Wibias added 2 commits July 23, 2026 21:13
@Wibias
fix(codex): harden runtime resolver edge cases and keep sync stdout c…
4f49a95
…lean

Reject unparseable --version output, stop v2 from bypassing validation, avoid false replacedConfigured when env matches persisted, and keep settings probes off the hot PATH scan.
@Wibias
fix(codex): address runtime PR review feedback
3f3ea0c
Numeric prerelease compare, redact probe failures, mkdir before persist, safer doctor --fix when CODEX_CLI_PATH wins, and localized Startup runtime warnings with complete sync remediation.
@Wibias

Wibias commented Jul 23, 2026

Copy link
Copy Markdown
Contributor Author

Follow-up after CodeRabbit / Codex review

Pushed 4f49a950 and 3f3ea0c7 addressing the actionable findings:

  • Reject unparseable --version output
  • ocx v2 always goes through the canonical resolver
  • No false replacedConfigured when env path equals persisted
  • Numeric prerelease compare (alpha.9 < alpha.30)
  • Redact probe failure messages; mkdir before persist
  • ocx doctor --fix-codex-runtime refuses to claim success when CODEX_CLI_PATH still wins
  • Startup warning uses i18n + copyCommand; fix command is doctor --fix && sync / sync as appropriate
  • Settings hot path uses discoverAlternatives: false; sync logs stay on stderr so stdout JSON stays parseable

Skipped / deferred:

  • Reworking Windows .cmd shell launching in codexExecInvocation (pre-existing platform requirement for npm shims; out of scope for this runtime-selection fix)
  • Full locale-neutral API prose removal for CLI warning strings (dashboard now builds copy from structured fields + i18n; CLI status still uses English diagnostics like the rest of ocx status)
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

coderabbitai[bot]

This comment was marked as resolved.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Wibias
fix(codex): drop plan doc and address new CodeRabbit findings
02ecb7a
Remove the implementation plan from the PR, restore newerAvailable on /api/settings via memoized full resolve, correlate clamp diagnostics to the active runtime, and isolate v2 invocation test state.
@Wibias

Wibias commented Jul 23, 2026

Copy link
Copy Markdown
Contributor Author

Removed docs/superpowers/plans/... from the PR.

Addressed the latest unresolved CodeRabbit threads:

  • /api/settings now does memoized full alternative discovery so newerAvailable works
  • clamp warnings only apply when the persisted clamp matches the current runtime
  • unresolved fallback with probe failures now warns
  • routine runtime log line goes to stderr (not console.warn)
  • v2 invocation cases each use an isolated configDir
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

coderabbitai[bot]

This comment was marked as resolved.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Wibias
fix(codex): cover mkdir persist, surface persist errors, tighten SemV…
e3b1d5b
…er compare

Add first-write directory regression tests, return persistError from resolveAndPersistCodexRuntime, and compare hyphenated prerelease identifiers with deterministic code-unit ordering.
@Wibias

Wibias commented Jul 23, 2026

Copy link
Copy Markdown
Contributor Author

Dual review (security + bugs/edge cases)

Bot review threads are already cleared (0 unresolved). CI is green. Independent second look below — several earlier bot findings were fixed; a few concrete leftovers remain.

Security categories checked

No malware, backdoor, hidden C2, admission bypass, or classic XSS. Runtime selection persists under OPENCODEX_HOME (codex-runtime.json / clamp state). Paths in diagnostics go through redactUserPath / redactSecretString. Version probes require parseable Codex --version output (null versions rejected).

Blockers / should-fix

  1. Windows .cmd/.bat probes still use shell: true (High, security) — src/codex/exec-invocation.ts
    codexExecInvocation quotes the path and sets shell: true. On Windows, Node does not safely escape cmd metacharacters in that mode, so CODEX_CLI_PATH / shim / PATH .cmd values can inject via the --version probe and codex debug models --bundled. The repo already has the hardened helper: commandInvocation() in src/lib/win-exec.ts (ComSpec /d /s /c + cross-spawn escaping + windowsVerbatimArguments). Route Codex exec through that (as ocx v2 already does) and drop shell: true here.

  2. Bundled catalog / clamp resolve does not forward isolatable deps (Medium) — src/codex/catalog/bundled.ts, effort.ts
    resolveAndPersistCodexRuntime({ execFileSync }) drops configDir / env / platform / existsSync / readFileSync. Stubbing only execFileSync in tests (or unusual callers) can still resolve against and write the real OS config dir. Extend BundledCatalogDeps and forward those fields; remove the as never cast.

Non-blocking / already in good shape

  • SemVer prerelease numeric compare, null-version rejection, env-vs-configured dedup, doctor CODEX_CLI_PATH honesty, mkdir-on-persist, Startup i18n + complete fix commands, resolve memoization, clamp↔runtime correlation — look addressed.
  • English warning strings on /api/settings / ocx status are fine for CLI; the dashboard correctly localizes from structured fields.
  • mkdir + persistError coverage exists in tests/codex-runtime.test.ts.

Suggested fix order

  1. Rewrite codexExecInvocation (or its call sites in runtime.ts / bundled.ts) to use commandInvocation.
  2. Thread resolver deps through BundledCatalogDeps.
  3. Add a focused /api/settings codexRuntime shape regression near tests/settings-stream-mode.test.ts.
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Wibias
fix(codex): harden Windows Codex exec and isolate catalog resolve deps
29849bb
Route .cmd/.bat probes through commandInvocation instead of shell:true, forward BundledCatalogDeps into the runtime resolver, and cover /api/settings codexRuntime shape.
coderabbitai[bot]

This comment was marked as resolved.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Wibias
fix(codex): address remaining CodeRabbit comments on runtime PR
6879d15
Pass configDir into persistEffortClamp, expose catalogClamp.runtimeVersion
in status JSON, memoize i18n t to avoid Startup refresh loops, and harden
settings clamp-correlation coverage.
@Wibias

Wibias commented Jul 23, 2026

Copy link
Copy Markdown
Contributor Author

Addressed the latest CodeRabbit batch (2 inline + 2 outside-diff) in 6879d15:

  1. effort.ts — persistEffortClamp(..., { configDir: deps.configDir }) on all write/clear paths + nested configDir regression test
  2. settings-stream-mode.test.ts — real clamp correlation via resolvable fake Codex returning 0.133.0
  3. status.ts (outside diff) — catalogClamp.runtimeVersion aligned with /api/settings
  4. i18n/provider.tsx (outside diff) — memoize t / provider value so Startup refresh does not loop

Tests: bun test on the touched suites + bun run typecheck green.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

coderabbitai[bot]

This comment was marked as outdated.

Sign in to view

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Wibias

Wibias commented Jul 23, 2026

Copy link
Copy Markdown
Contributor Author

Dual review (security + bugs/edge cases) — re-review @ 6879d15

Prior High blockers from the last dual review look fixed (.cmd/.bat via commandInvocation, no shell: true; BundledCatalogDeps forwarded; CodeRabbit batch addressed). CI-facing suites for the touched paths are green. Second look on current head:

Security

Verdict: merge-ready for security (no blockers).

Checked:

  • Windows launcher path uses shared commandInvocation (ComSpec /d /s /c + escaping); comment-only mention of shell: true remains.
  • Diagnostics (/api/settings, ocx status --json, probe failures, persist errors) go through displayCodexRuntimePath / redactUserPath / redactSecretString.
  • Persist uses mkdirSync(..., 0o700) + atomicWriteFile; no request-body/API-key logging introduced.
  • doctor --fix-codex-runtime only rewrites runtime selection; does not sync itself. CODEX_CLI_PATH still correctly wins.

Non-blocking: bare / non-absolute CODEX_CLI_PATH values (e.g. codex / codex.cmd) can be validated and persisted as configured. Later resolves then depend on the ambient PATH. Prefer resolving to a canonical absolute path before persist (stability more than classic injection).

Bugs / #297 goal

Verdict: not fully merge-ready — one remaining should-fix for the in-process remediation path.

Should-fix

  1. Bundled catalog cache ignores selected runtime (P1) — src/codex/catalog/bundled.ts (~134–162)
    loadBundledCodexCatalog() memoizes for 60s whenever there are no injected deps. The cache key does not include the resolved Codex command/version or codex-runtime.json mtime.
    Failure mode: long-lived proxy caches an old debug models catalog (no max/ultra) → ocx doctor --fix-codex-runtime (other process) updates the persisted runtime → dashboard Sync hits POST /api/sync in the same proxy → loadCatalogForSync + codexSupportedReasoningEfforts reuse the stale catalog and keep clamping. Fresh ocx sync CLI (new process) is fine; GUI//api/sync is not.
    Same class of blind spot: resolveCodexRuntime’s 15s cache (runtime.ts ~344–373) keys on env only, not persisted runtime file — status/settings can lag after doctor fix.
    Fix: include runtime identity (or invalidate) in the bundled-catalog cache; clear both caches when persistCodexRuntime / doctor --fix writes (or on /api/sync).

Residual / follow-ups (non-blocking)

  • src/cli/doctor.ts (~511–514): clamp warning does not use effortClampAppliesToRuntime, so doctor can still complain after status/settings correctly clear catalogClamp.active.
  • gui/src/pages/Startup.tsx: when clamp is active and no newerAvailable, recommending only ocx sync can re-apply the same clamp on a genuinely old runtime.
  • Test gap: no warm-process coverage for doctor-fix → /api/sync without restart.

What looks solid

  • Priority order env → configured → shim → PATH → fallback, with stickiness to persisted configured when still valid.
  • Clamp correlation (effortClampAppliesToRuntime) on settings/status; catalogClamp.runtimeVersion aligned.
  • configDir isolation for runtime + clamp persist (including effort.ts).
  • i18n t memoization (Startup refresh loop addressed).
  • Focused regressions for Windows exec, settings clamp correlation, status JSON shape.

Bottom line: security OK to merge; for #297, fix (or deliberately document + invalidate on sync) the 60s bundled-catalog cache before calling the GUI remediation path done.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Wibias
fix(codex): key catalog cache by runtime and address CodeRabbit follo…
716f39c
…w-ups

Bust resolve/catalog memos when persisted selection changes so dashboard
/api/sync does not keep clamping after doctor --fix. Also track default
effort clamps, forward full resolver deps, and harden related tests.
@Wibias

Wibias commented Jul 23, 2026

Copy link
Copy Markdown
Contributor Author

Addressed the re-review P1 + latest CodeRabbit batch in 716f39c:

Cache / #297 remediation

  • Bundled catalog cache is now keyed by selected runtime (command + version)
  • Resolve memo includes on-disk codex-runtime.json stamp (cross-process doctor --fix)
  • persistCodexRuntime clears the process resolve memo
  • Regression: doctor-style persist → same-process loadBundledCodexCatalog picks up max/ultra

CodeRabbit

  • Active catalogClamp.runtimeVersion coverage in status --json
  • Probe-fail clamp test actually exercises execFileSync
  • Cross-platform username redaction assert in settings test
  • Clamp diagnostics include unsupported default_reasoning_level changes
  • Forward now / discoverAlternatives through catalog deps
  • Status replacedConfigured predicate matches catalog; resolver throw surfaces in warning

Tests + typecheck green on the touched suites.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Wibias
Wibias merged commit adb6615 into lidge-jun:dev Jul 23, 2026
12 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@lidge-jun lidge-jun mentioned this pull request Jul 24, 2026
fix(codex): auto-restore the codex shim after external npm updates (#320) #356
Merged
@coderabbitai coderabbitai Bot mentioned this pull request Jul 24, 2026
feat: ship packaged macOS menu bar companion #387
Closed
3 tasks done
@Wibias
Wibias deleted the fix/stable-codex-runtime-selection branch July 25, 2026 07:00
This was referenced Jul 26, 2026
feat(oauth): reliability, credential integrity, and diagnostics #479
Merged
feat(cli): add ocx opencode launcher #568
Merged
This was referenced Jul 28, 2026
fix(catalog): stop respawning the codex --version probe on every catalog read #610
Closed
perf(gui): progressive dashboard paint and Startup safety CLS #740
Merged
feat(codex-auth): add default_mode_request_user_input feature toggle #911
Merged
feat(codex): add encrypted native main profiles #863
Merged
This was referenced Aug 7, 2026
fix(codex): warn when codex-shim install cannot prove routing #1169
Closed
feat(codex): converge account picker catalogs #1212
Merged
fix(codex): stop reporting every history failure as a Codex DB lock #1202
Merged
fix(subagent): move per-role model fallback into opencodex config (#1190) #1210
Closed
fix(codex): warn when codex-shim install cannot prove routing (#1169) #1289
Merged
fix(codex): stop recursive dynamic-launcher shims #1441
Closed
refactor(cli): move CLI head dispatch into src/cli/root.ts #1444
Merged
This was referenced Aug 15, 2026
feat(storage): inspect Codex diagnostic logs safely - Part 1 #1727
Merged
[Bug][Windows]: synchronous PowerShell app-server enumeration blocks /healthz and proxy traffic on v2 requests #1852
Closed
@h-dot-seo h-dot-seo mentioned this pull request Sep 8, 2026
[Bug]: Codex App update invalidates the persisted codex-runtime.json pin — the dead hashed path is never re-resolved #4035
Closed
2 tasks done
agentHits pushed a commit to agentHits/opencodex that referenced this pull request Sep 17, 2026
@Wibias
Merge pull request lidge-jun#359 from Wibias/fix/stable-codex-runtime…
30d280f
…-selection

fix(codex): stable Codex runtime selection for sync/clamp (lidge-jun#297)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@coderabbitai coderabbitai[bot] coderabbitai[bot] left review comments
@chatgpt-codex-connector chatgpt-codex-connector[bot] chatgpt-codex-connector[bot] left review comments
@lidge-jun lidge-jun Awaiting requested review from lidge-jun lidge-jun is a code owner
@Ingwannu Ingwannu Awaiting requested review from Ingwannu Ingwannu is a code owner

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

bug Something isn't working

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@Wibias
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.