Skip to content

STA-1598: Prevent duplicate TOML project keys from breaking Codex startup - #8138

Merged
Jinwoo-H merged 1 commit into
mainfrom
fix/STA-1598-codex-project-toml-dedupe
Jul 10, 2026
Merged

Jinwoo-H merged 1 commit into
mainfrom
fix/STA-1598-codex-project-toml-dedupe

Conversation

@Jinwoo-H

Copy link
Copy Markdown
Contributor

Summary

  • match [projects.*] headers by decoded TOML key value instead of their raw quote representation
  • normalize Windows project identities across drive-letter/UNC casing and / vs \ separators, including already-canonical SSH paths
  • deduplicate semantic project tables during mirror preparation and merge so existing corrupted runtime configs self-heal; untrusted wins every conflict

Root cause

Orca wrote project trust as a TOML basic-string key while Codex/toml_edit can write the same Windows path as a literal-string key. buildProjectHeaderPattern only recognized double-quoted headers, and the mirror compared raw trimmed header text. The representation mismatch let both tables survive even though TOML decodes them to the same project key, causing Codex startup to fail with a duplicate-table parse error.

This predates and is unrelated to #7896 and #7960; those changes touch neighboring hook-trust/settings write-back paths but did not create the duplicate project key.

Self-heal and hooks

Every managed-config mirror pass now collapses semantically equivalent project sections from either input. Runtime project trust remains authoritative unless the system config marks the same normalized project untrusted; among already-duplicated sections, any untrusted entry survives.

[hooks.state.*] is intentionally not path-normalized by this deduper. The current hook upsert path already parses basic and literal keys and removes all quote-equivalent blocks before writing, while its paired Windows slash variants are required for Codex 0.140 raw native-path matching. This preserves the #6318 compatibility behavior and cannot recreate the reporter's quote-only hook duplication.

Test evidence

  • pnpm vitest run src/main/codex/config-toml-trust.test.ts src/main/codex/codex-config-mirror.test.ts — 114 passed
  • pnpm vitest run src/main/codex src/main/codex-accounts — 396 passed, 7 skipped
  • pnpm typecheck — passed
  • pnpm check:max-lines-ratchet — passed
  • targeted oxlint on all changed files — passed
  • Windows live check in disposable USERPROFILE / ORCA_USER_DATA_PATH: real Codex rejected the seeded duplicate config, the real mirror healed it to one project table, and codex features list then parsed successfully with sandboxed CODEX_HOME

References

@coderabbitai

coderabbitai Bot commented Jul 10, 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: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 0c691317-d3d5-496f-b184-c79e78715779

📥 Commits

Reviewing files that changed from the base of the PR and between 1afec6c and 0b32730.

📒 Files selected for processing (4)
  • src/main/codex/codex-config-mirror.test.ts
  • src/main/codex/codex-config-mirror.ts
  • src/main/codex/config-toml-trust.test.ts
  • src/main/codex/config-toml-trust.ts

📝 Walkthrough

Walkthrough

Codex trust updates now parse project headers with TOML-aware scanning and normalize Windows, UNC, WSL, and POSIX paths for matching. Configuration mirroring deduplicates equivalent project sections and preserves untrusted trust entries when duplicates conflict. New tests cover canonical and literal-string headers, path representation variants, duplicate runtime and system tables, trust revocation precedence, and paths containing quotes or backslashes.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description covers summary and test evidence, but it omits required template sections like Screenshots, AI Review Report, Security Audit, and Notes. Add the missing template sections, especially Screenshots, a testing checklist, AI Review Report with cross-platform checks, Security Audit, and Notes.
Docstring Coverage ⚠️ Warning Docstring coverage is 15.79% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly matches the main change: deduplicating TOML project keys to prevent Codex startup failures.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@Jinwoo-H
Jinwoo-H merged commit 629b575 into main Jul 10, 2026
3 checks passed
@Jinwoo-H
Jinwoo-H deleted the fix/STA-1598-codex-project-toml-dedupe branch July 10, 2026 19:32
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
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