Skip to content

fix(codex): honor tri-state fastMode in Codex config injection - #1022

Merged
lidge-jun merged 2 commits into
lidge-jun:devfrom
harryzhou2000:fix/codex-fast-mode-tri-state
Aug 5, 2026
Merged

fix(codex): honor tri-state fastMode in Codex config injection#1022
lidge-jun merged 2 commits into
lidge-jun:devfrom
harryzhou2000:fix/codex-fast-mode-tri-state

Conversation

@harryzhou2000

@harryzhou2000 harryzhou2000 commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Summary

injectCodexConfig() unconditionally forced [features] fast_mode = true into ~/.codex/config.toml on every ocx init / ocx start / ocx sync, even when the user's fastMode setting said otherwise. This made the client-side injection contradict the wire path (which already honors the tri-state fastMode: true injects service_tier: priority, false strips it, unset is passthrough).

The injection now follows the same tri-state semantics:

  • fastMode: true → writes fast_mode = true (unchanged behavior)
  • fastMode: false → writes fast_mode = false, consistent with the wire strip
  • fastMode unset → preserves the user's existing fast_mode and no longer creates a [features] table in configs that never had one (fast becomes opt-in)

The fallback profile (opencodex.config.toml) mirrors the flag, and omits fast_mode entirely when unset.

Verification

  • bun run typecheck — clean
  • bun test --isolate tests/codex-inject.test.ts tests/codex-inject-integration.test.ts tests/service-tier-capability.test.ts tests/codex-v2-gate.test.ts — 143 pass, 0 fail
  • New unit + integration regression tests cover all three states (fastMode true / false / unset), including configs with and without an existing [features] table.

Note: the full local suite has unrelated environment-dependent failures in this workspace (server port binding under the sandbox, load flakes); the touched files and all injection tests pass.

Checklist

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

Closes #1021

Summary by CodeRabbit

  • New Features

    • Codex fast mode now supports explicitly enabled, disabled, or unset states.
    • Unset fast mode preserves existing settings and avoids creating unnecessary configuration sections.
    • Explicit settings are consistently applied across generated profiles.
    • Existing quoted or commented configuration formats are handled without creating duplicate settings.
  • Documentation

    • Updated Codex integration guidance in English, Japanese, Korean, Russian, and Simplified Chinese.
  • Tests

    • Added coverage for enabled, disabled, unset, and fallback profile scenarios.

@github-actions github-actions Bot added the bug Something isn't working label Aug 4, 2026
@coderabbitai

coderabbitai Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 2cf327c4-fd00-4656-a3dd-1483dc6a6f82

📥 Commits

Reviewing files that changed from the base of the PR and between 5d960a0 and f742a3f.

📒 Files selected for processing (8)
  • docs-site/src/content/docs/guides/codex-integration.md
  • docs-site/src/content/docs/ja/guides/codex-integration.md
  • docs-site/src/content/docs/ko/guides/codex-integration.md
  • docs-site/src/content/docs/ru/guides/codex-integration.md
  • docs-site/src/content/docs/zh-cn/guides/codex-integration.md
  • src/codex/inject.ts
  • tests/codex-inject-integration.test.ts
  • tests/codex-inject.test.ts

📝 Walkthrough

Walkthrough

Codex configuration injection now treats fastMode as tri-state. Explicit values write features.fast_mode to configuration and generated profiles. An unset value preserves existing configuration and does not create a [features] table. Tests and localized guides cover the behavior.

Changes

Codex fast mode injection

Layer / File(s) Summary
Fast-mode configuration normalization
src/codex/inject.ts, tests/codex-inject-integration.test.ts
ensureFastModeFeature preserves configuration when fastMode is unset. It creates or updates features.fast_mode when the value is explicitly true or false. Tests cover commented headers and quoted TOML forms.
Profile fast-mode propagation
src/codex/inject.ts, tests/codex-inject.test.ts
buildProfileFile accepts fastMode. Fallback and standard profiles emit the supplied boolean only when it is defined. Tests cover loopback and legacy non-loopback profiles.
Tri-state documentation
docs-site/src/content/docs/guides/codex-integration.md, docs-site/src/content/docs/ja/guides/codex-integration.md, docs-site/src/content/docs/ko/guides/codex-integration.md, docs-site/src/content/docs/ru/guides/codex-integration.md, docs-site/src/content/docs/zh-cn/guides/codex-integration.md
The guides document explicit true, explicit false, and unset fastMode behavior.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Suggested reviewers: ingwannu, lidge-jun

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: fixing tri-state fastMode handling during Codex configuration injection.
Linked Issues check ✅ Passed The implementation and tests satisfy issue #1021 for true, false, and unset fastMode behavior in config injection and fallback profiles.
Out of Scope Changes check ✅ Passed The changes are limited to Codex injection logic, related tests, and localized documentation for the linked issue objectives.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 501642f7da

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/codex/inject.ts Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/codex/inject.ts`:
- Around line 406-417: Update ensureFastModeFeature to identify the features
table and fast_mode key using TOML-aware parsing, including inline table
comments, quoted table names such as ["features"], and quoted keys such as
"fast_mode". When fastMode is explicit, update the existing matching table/key
rather than appending duplicates, and add regression tests covering each
accepted spelling.

In `@tests/codex-inject-integration.test.ts`:
- Around line 120-154: Extend the fastMode tests around runInject to inspect the
generated opencodex.config.toml profile as well as config.toml. For the explicit
true case, assert the profile contains fast_mode = true; for the unset case,
assert it does not force fast_mode = true. Keep the existing config.toml
assertions unchanged.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 4bb1143f-54f6-4bfb-abb3-b5456cfacfdf

📥 Commits

Reviewing files that changed from the base of the PR and between 79fdaf9 and 501642f.

📒 Files selected for processing (8)
  • docs-site/src/content/docs/guides/codex-integration.md
  • docs-site/src/content/docs/ja/guides/codex-integration.md
  • docs-site/src/content/docs/ko/guides/codex-integration.md
  • docs-site/src/content/docs/ru/guides/codex-integration.md
  • docs-site/src/content/docs/zh-cn/guides/codex-integration.md
  • src/codex/inject.ts
  • tests/codex-inject-integration.test.ts
  • tests/codex-inject.test.ts

Comment thread src/codex/inject.ts Outdated
Comment thread tests/codex-inject-integration.test.ts
injectCodexConfig unconditionally wrote [features] fast_mode = true, even
when fastMode: false strips service_tier on the wire and when the user's
config opted out. Thread the tri-state fastMode through
ensureFastModeFeature and buildProfileFile:

- true -> fast_mode = true (unchanged)
- false -> fast_mode = false (consistent with the wire strip)
- unset -> preserve the user's fast_mode; do not add a [features] table

Adds unit and integration regression tests for all three states and
updates the integration guide (en/ja/ko/ru/zh-cn).
…L spellings

- buildProfileFile no longer defaults an unset fastMode to true: the fallback
  profile omits [features]/fast_mode when fastMode is unset, mirroring the
  config.toml passthrough instead of re-enabling priority mode.
- ensureFastModeFeature recognizes valid TOML spellings ([features] # comment,
  ["features"]/['features'], quoted "fast_mode" keys) so an explicit
  fastMode updates the existing table/key rather than appending duplicates.
- Integration tests assert the generated profile for all three states and cover
  the TOML spellings.
@lidge-jun
lidge-jun force-pushed the fix/codex-fast-mode-tri-state branch from 26cebc1 to f742a3f Compare August 5, 2026 05:09
@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@lidge-jun
lidge-jun merged commit ebcfff4 into lidge-jun:dev Aug 5, 2026
36 of 38 checks passed
lidge-jun added a commit that referenced this pull request Aug 5, 2026
PR #1022 made fast_mode opt-in and documented that unset adds no [features]
table. The config example two lines above still showed that table
unconditionally, so a reader following the example expected output they will
not get.

One comment line in each of the five locales, marking the block as conditional.
lidge-jun added a commit that referenced this pull request Aug 5, 2026
A second audit round caught a sentence claiming nothing inside the span may be
non-deterministic or IO-bearing. The span IS the IO - a journal write, two
atomic file replacements, and the marking that follows them. The real
constraint is narrower: nothing there may perform IO the journal does not
account for, because restore replays only what the journal recorded.

Also corrects the compatibility claim about PR #1022, now landed. Its two
changed call sites sit INSIDE the span, not outside as originally written.
The ordering decision survives with a different reason: land it first so the
lock is written against the function's final shape.

Line citations refreshed against dev at 4685876, with a note that the
anchors are the call names rather than the numbers.
lidge-jun added a commit that referenced this pull request Aug 5, 2026
Six conflicts, fifteen hunks, resolved once. A rebase was tried earlier and
stopped at commit 74 of 129 with the same files recurring; the branch is longer
now, and merging resolves each hunk a single time while preserving commit SHAs
and review anchors.

inject.ts took dev in all seven hunks. Every one of ours there was a formatter
reflow of the base while dev carried the real tri-state fastMode change from
#1022, so taking dev IS the semantic composition rather than a textual
keep-both. The write-lock pipeline lives elsewhere in the file and is
untouched - ensureFastModeFeature still runs before the candidate bytes are
final, and the witness still hashes those final bytes.

catalog/sync.ts is the one that needed judgement. Dev still wrote the catalog
with a raw atomicWriteFile; keeping that would bypass the catalog write lock
this branch added. The permit writer owns the write, and dev's account-bound
row count and its restoration helpers survive around it.

The rest compose: our permit-guarded cache invalidation beside dev's cooldown
worker, our tri-state service evidence beside dev's reworded accessor comment,
clientIntegrations beside dev's account-qualified subagentModels contract, and
our ownership-aware provider map beside dev's routed-slug replacement map.

Verified in a scratch worktree before landing: typecheck clean, 111 focused
tests passing, and the lock call edge still reachable from inject.ts.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants