Repository navigation
fix(codex): reconcile marketplace and plugin tables through the config mirror - #20150
Conversation
… baseline rows The block ran to the next table header, so that table's leading comment was copied into the canonical config detached from what it described. Adds the policy rows no test discriminated: canonical wins when enablement changed on both sides or has no mirrored ancestor, the v2 baseline upgrade path, and the baseline-loss resurrection as a characterization test.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Registration-table reconciliation —
planCodexRegistrationPromotion/applyCodexRegistrationPromotionsreconcile[marketplaces.*]and[plugins.*]tables across the destructive managed-home mirror via a baseline-aware three-way (runtime vs canonical vs mirrored baseline), with distinct rules for marketplace refresh metadata and the pluginenabledtoggle. - TOML table parsing —
config-toml-plugin-registration-tables.tskeys registrations by parsed-header identity (so[plugins."a@b"]and[plugins.'a@b']are one registration), captures whole blocks including[root.name.*]subtables, and trims trailing comments through the existing line-scan state rather than text heuristics. - Baseline v3 —
config-settings-baseline.tsgains an optionalregistrationsmap (version: 3); absent ≡ never-mirrored makes the v2→v3 upgrade lossless and downgrade a safe degrade. - Mirror integration —
config-settings-promotion.tsandcodex-config-mirror.tspromote registrations into canonical before the canonical→runtime copy and setmirroredRegistrations: trueonly after a successful mirror, so a bootstrap baseline never records tables Orca didn't mirror. - Extraction refactor — promoted-key constants and
readPromotedSettingValuesmove intoconfig-toml-promoted-setting-values.ts, and the EOL helpers intoconfig-toml-line-scan.ts, removing the duplicate definitions.
I read the full diff end-to-end and traced the mirror flow through codex-config-mirror.ts, config-settings-promotion.ts, config-settings-baseline.ts, and the runtime-owned-section merge. The three-way reconciliation is internally consistent, the EOL/CRLF handling is correct, and the tests carry exact (toBe) rather than loose assertions — including characterization tests for the documented baseline-loss residual risk and the #10489 metadata-only discriminator. The author's mutation analysis and real-file evidence align with what the code actually does.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (1)
Included review availability: Your plan provides up to 10 included reviews per hour; 4 remain after this review. 📝 WalkthroughWalkthroughThe change adds TOML readers for promoted settings and Codex registration tables. Baselines now persist normalized registration fields under schema version 3. Runtime marketplace metadata and plugin enablement changes are reconciled with canonical configuration. The mirror passes registration state through snapshot and promotion flows. Shared line-ending helpers preserve CRLF and trailing-newline behavior. New tests cover parsing, reconciliation, persistence, failures, formatting, and account isolation. Priority: ➖ Normal Merge Risk: 🟡 Moderate · up to A failed baseline write can cause a later sync to restore a registration that was intentionally removed from canonical configuration. Resolve the failure handling before merge to preserve removal semantics. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Linked Issues checkExplanation The PR implements the linked objectives in [ Resolution Require a non-multiline runtime
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 530b1c1a-d925-47c2-900c-882eefbb83f9
📒 Files selected for processing (13)
config/tsconfig.cli.jsonsrc/main/codex/codex-config-mirror.tssrc/main/codex/codex-config-settings-upsert.tssrc/main/codex/config-plugin-registration-promotion.test.tssrc/main/codex/config-plugin-registration-promotion.tssrc/main/codex/config-settings-baseline-upgrade.test.tssrc/main/codex/config-settings-baseline.tssrc/main/codex/config-settings-promotion.test.tssrc/main/codex/config-settings-promotion.tssrc/main/codex/config-toml-line-scan.tssrc/main/codex/config-toml-plugin-registration-tables.tssrc/main/codex/config-toml-promoted-setting-values.tssrc/main/codex/sta-4823-shared-state-survives-a-failed-read.test.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 5 remain after this review.
| registrations: options.mirroredRegistrations | ||
| ? readCodexRegistrationBaseline(runtimeConfig) | ||
| : new Map() |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
Do not report a successful mirror when the registration baseline write fails
snapshotCodexRuntimeSettingsBaseline catches writeCodexSettingsBaseline failures and returns void, so the mirror continues with the runtime registration reachable but absent from the durable baseline. If canonical configuration later removes that registration, planCodexRegistrationPromotion sees a runtime-only entry and promotes it again. Propagate the snapshot failure or persist a pending state, and block baseline-free registration promotion until the baseline write succeeds.
…airs Date.parse rolls `2025-02-30` forward to March 2 rather than rejecting it, so a malformed runtime timestamp read as NEWER and won against canonical. Promoting a newer timestamp while the runtime had no last_revision also cleared the canonical revision, publishing the mismatched pair the pairing rule exists to prevent. Co-authored-by: BsTiger <[email protected]> Co-authored-by: Rod Boev <[email protected]>
|
Both findings on this review were real and are fixed in ce2780e. Impossible calendar dates — confirmed and fixed. Incomplete Baseline write failure — I am not making the snapshot failure fatal, deliberately. You have correctly identified a real window, and it is the same residual risk the PR body documents under "Residual risk: baseline loss", reached by a different trigger (failed write rather than lost file). Two reasons not to take the suggested fix:
This is a pre-existing property of the baseline mechanism that this PR extends to registrations rather than introduces: a failed baseline write already causes scalar settings to be re-promoted the same way. It is characterised by a test ( |
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
This run re-reviewed the delta since the prior Pullfrog review at c78c394 — commit ce2780e, which tightens two edge cases in marketplace refresh promotion.
- Impossible-date rejection —
parseCodexRegistrationTimestampnow validates the day against the real length of the month before callingDate.parse, so values like2026-02-30(which V8 rolls forward to March 2 and would otherwise read as newer) become malformed and are skipped. Checked the adjacent cases too: non-leap2023-02-29is rejected the same way, while invalid time components and out-of-range offsets already yieldNaNfromDate.parse, so the date guard is the only gap. - Unpaired refresh guard —
planMarketplaceRefreshPromotionreturns early when the runtime supplies a newerlast_updatedbut nolast_revisionwhile canonical already carries one, so the refresh can no longer clear the canonical revision and publish a mismatched pair. - Regression tests — two exact-assertion tests cover both cases; the full file passes 36/36 locally (
pnpm test src/main/codex/config-plugin-registration-promotion.test.ts).
openrouter/deepseek/deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

What this fixes (plain language)
If you added a Codex plugin or plugin marketplace while working inside Orca, it kept disappearing. You would install it, it would work, and then the next time Orca started it was simply gone — you had to add it again. The same thing quietly happened to the bookkeeping Codex keeps about where a marketplace came from and when it last updated, so Codex could also lose track of having refreshed it.
The cause was that Orca keeps its own copy of your Codex settings and re-syncs it from your real config file on startup. That sync knew how to carry ordinary settings back and forth, but it did not know about plugins and marketplaces at all, so anything you installed from inside Orca was wiped out when the two copies were reconciled.
Now the sync understands them. Something you install inside Orca is copied back into your real config so it survives, while a marketplace or plugin you deliberately remove from your own config stays removed instead of coming back. Both copies end up agreeing, and repeated startups no longer change the file.
Scalar promotion omitted the marketplace and plugin tables, and the mirror rebuilt ordinary config from canonical while only trust sections survived. A new managed-account registration and refreshed provider metadata were therefore destroyed at the same boundary.
Fixes #10489
Fixes #11770
Policy
Identity key is
<root>:<parsed header segment>, so[plugins."a@b"]and[plugins.'a@b']are one registration. R = runtime tables, S = canonical, B = registration baseline.last_updatedvalid and strictly newerlast_revisionlast_revisionto pairenabledchanged only in R vs BenabledRegistrations are promoted into
~/.codex/config.tomlbefore the mirror runs, so they return through the ordinary canonical→runtime copy rather than needing a second preservation path.Baseline v3 migration
The baseline gains an optional
registrationsmap. Absent ≡ never mirrored, which is what makes the upgrade lossless: an existing v2 user's registrations read as additions on the first pass and heal into canonical, instead of reading as removals and being dropped.isStoredSettingsBaselineaccepts1 | 2 | 3, so no rewrite or migration step is needed.Downgrade is a safe degrade: an older build accepts only
version === 1 | 2, so it rejects a v3 file, treats it as absent, and bootstraps a fresh baseline. One pass of scalar promotion is skipped, exactly as on a fresh install. No corruption, no data loss.Residual risk: baseline loss
The baseline is the only guard against re-promoting a registration the user removed canonically. Reproduced on real files, three cases:
The damaging window requires the removal and the loss to coincide. The consequence is un-removal, not data loss, and it is recoverable — removing it again with the rebuilt baseline in place sticks. Covered by
re-promotes a canonically removed registration when the baseline is lost firstas a characterization test so the behavior cannot change silently.Real-file evidence
Run against real
config.tomlfiles under/tmpwith a real managed-account home and canonical system home, driving the actual mirror entry point (no test framework, no mocks).Registration survives and is idempotent. Runtime after Codex registers a marketplace and a quoted plugin, then after each of three mirrors — all four states
sha256:edef2f198aec692b, both files identical:Resulting baseline:
{ "version": 3, "settings": { "model": "\"gpt-5\"", "approval_policy": "\"on-request\"", ... }, "registrations": { "marketplaces:ponytail": {}, "plugins:ponytail@ponytail": { "enabled": "true" } } }#10489 discriminator. Canonical holds
[marketplaces.other]; the runtime-only[marketplaces.ponytail]has perfectly valid timestamps. A metadata-only policy (what #11770 proposed) only reconciles entries present on both sides, so it dropsponytailentirely. This implementation promotes it, and both marketplaces end up in canonical and runtime.Canonical removal honored. After the registration is promoted, the user deletes both tables from
~/.codexoutside Orca. Two further mirrors leave canonical and runtime atmodel = "gpt-5"\n— not resurrected.Refresh metadata. Seeded at
2026-01-05T10:00:00Z/aaaa111; runtime refresh to2026-02-01T09:30:00Z/bbbb222promotes the pair and leaves the user comment,ref_name,source, and[mcp_servers.docs]untouched. A subsequent stale (2020-01-01) and then malformed (not-a-timestamp) runtime value each leave canonical byte-identical atsha256:e49510fa49452136.Atomic-write failure.
~/.codexchmod0500produces a realEACCESon the temp write. Checksums before and after the failed pass: canonical85e4f46739de75eb, runtime2c73775d8fc457a9, baselinedbc5ebcc91ccf853— all three unchanged, runtime registration intact. Restoring permission lets the next pass complete.Account isolation. Two managed accounts sharing one canonical home, mirrored alternately: each promotes its own marketplace, both converge on the same canonical file, and neither baseline is polluted by the other's pending state.
v2 → v3. Baseline downgraded on disk to
{ "version": 2, "settings": {...} }with noregistrationskey; the runtime then holds the registration the old mirror was about to destroy. After two passes it is healed into canonical and the baseline is rewritten as v3 with both entries.Mutation discriminators
Against the 34 tests in
config-plugin-registration-promotion.test.ts:planCodexRegistrationPromotionreturns[])Review fixes in the second commit
entry.blockran to the next table header, so a comment introducing the following table was copied into canonical detached from what it described. Now trimmed using the existing TOML line-scan state, so a#inside a multiline string is never mistaken for a trailing comment.enabledbaseline three-way guard entirely passed all 27 original tests — the "both sides changed" test was actually discriminating ondisabled_reason, notenabled. Added the two rows that exercise it (enabledis three-valued in practice:true,false, absent), taking that mutation from 1 failure to 4.entry.rootinstead of re-deriving it withkey.startsWith('marketplaces:').End-to-end with a real Codex binary
The evidence below is not a simulation of Codex:
codex-cli 0.154.0wrote the registration and read the result, withCODEX_HOMEpointed at scratch homes throughout.Real Codex was launched against the managed runtime home (what Orca does), and ran
codex plugin marketplace add+codex plugin addagainst a real local marketplace. It wrote:Note this is real Codex choosing the quoted
[plugins."<plugin>@<marketplace>"]form the identity key is built to handle. Two mirror passes then ran, and real Codex was asked to list what it could see.Before (registration promotion disabled), canonical and runtime both collapse to:
After (this PR), both homes keep the full table shown above, and real Codex reports:
That
No marketplace plugins found.→installed, enabledtransition is the user-visible bug in #10489 and #11770, reproduced and fixed against the real tool.Why no screenshots
There is no Orca UI for this. Codex's marketplace and plugin registrations live only in
config.tomland are surfaced by thecodexCLI inside a terminal pane. Orca's own Settings → Plugins pane is a separate plugin host (src/main/plugins/,window.api.plugins) that never reads these tables, so a screenshot of it would show an unrelated feature that this PR does not change. The real before/after config bytes and real Codex CLI output above are the honest equivalent.Relationship to #10494 and #11861
Two open community PRs each solved one half of this, and both were on the right track. Both authors are credited as co-authors.
#10494 (@Bongseop-Kim) — the #10489 half. Reaches the same central conclusion this PR does: a runtime-only registration must be promoted, but a registration the canonical config removed must not be resurrected, and the baseline is what tells them apart. Their guard (
runtimeRaw !== baselineRaw && systemRaw === baselineRaw) is the same three-way as the baseline rows in the table above, and they reused the existing conflict machinery rather than adding a parallel path. Their real-binary sandboxed regression against Codex CLI 0.145 covered removal-without-resurrection too. It does not close #11770: it compares whole normalised table blocks, so a marketplace metadata refresh makes the entire block "changed" and there is no field-levellast_updated/last_revisionrule to merge it.Where they went further: for a baseline with no registration ancestry they anchor a conflict instead of promoting, which sidesteps the baseline-loss resurrection documented above. This PR deliberately promotes instead, so a v2 upgrade heals the user's install into canonical rather than parking it in a conflict — a real trade-off, chosen because the install reaching
~/.codexis the outcome #10489 asks for.#11861 (@rodboev) — the #11770 half. Implements substantively the same marketplace rule: identity match on the source fields, then promote only on a strictly newer timestamp, with stale and malformed values skipped. It handles more than the happy path, and its array-aware
sparse_pathscomparison is more precise than the raw-text comparison used here (this PR is merely conservative there — a formatting difference reads as an identity change and skips). It does not close #10489: it only rewriteslast_updated/last_revisioninside marketplaces that already exist on both sides, so a runtime-only registration is never promoted and still vanishes. That case is the discriminator test in this PR.Neither PR caught the
Date.parse('2025-02-30')rollover; #11861 shares it, since plainDate.parserolls the day forward instead of rejecting it.Verification
pnpm tcclean ·oxlintclean ·oxfmt --checkclean ·vitest run src/main/codex— 1853 passed, 10 skipped, 173 files.