fix(codex): find trust tables Codex saved with single-quoted keys instead of adding duplicates #2034
All Vouch review confidence checks passed
Residual risk 0.20 = Change Risk (0.50) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.50 · 598 lines diff across 7 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.383
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #2034"
general
weight: 0.35
openrig-review
What a person gets
After this, a Codex seat launch finds the project and hook trust tables Codex already saved in
~/.codex/config.toml, whatever quoting they use, and updates them in place. It never appends a second table for the same key.Before, Codex saved its tables with TOML literal (single-quoted) keys, such as
[projects.'/home/me/app']or[hooks.state.'…/config.toml:session_start:0:0']. OpenRig looked only for the double-quoted spelling, missed them, and appended a duplicate table. Codex then refused to start ("failed to load bootstrap configuration … duplicate key"), and so did every other Codex session on the machine, until the duplicates were removed by hand.Reported by @borfast in #2029.
If Codex already refuses to start with "trying to redefine an already defined table", remove the extra double-quoted table it names, once. This change doesn't rewrite a person's other lines, so it won't remove that duplicate itself. It leaves a config Codex can't read exactly as it is, so that one removal is the whole repair.
What changed
All four of the adapter's trust writers, and the owned plugin's content-approval check, now find a table by its parsed key, read with
smol-toml, which the adapter already uses, rather than by its text:upsertCodexProjectTrust;upsertCodexHookTrust;upsertCodexHookDisabled;rekeyCodexHookStateText;planOwnedCodexContentApproval, so a plugin update renews OpenRig's own hook approvals in a config Codex saved.A bare, double-quoted or single-quoted key, spaces around the dots and a trailing comment all match.
A header-shaped line only counts when it really opens a table in the document: swapped for a probe header the document doesn't already have, the parsed document gains that table. A table example inside a multi-line string, such as a person's
developer_instructions, is left exactly as it is, and the real table is written.A config that doesn't parse is left exactly as it is. Appending can't make it readable, and would add another table on every launch.
The helpers live in
domain/toml-tables.ts, shared by the adapter and the owned-plugin check.When the document already defines the key some other way, such as an inline table or dotted keys, the writer leaves the file as it is rather than append a duplicate. Codex's own trust prompt stays the fallback there, as it was.
A person's other tables and values are unchanged. Only the value line OpenRig manages is rewritten, as before.
Tests
codex-hook-trust.test.ts:- a single-quoted hook-state table is updated in place, with one table and a parse that passes;
- an inline-table entry is left byte-identical;
- through
ensureCodexActivityHooks, four single-quoted trust tables saved by Codex are updated and none is duplicated.codex-runtime-adapter.test.ts: throughdeliverStartup, a single-quoted[projects.'/tmp/workspace']and an inline[projects]entry are reused for the project's trust, with no duplicate.developer_instructionsstays exact, and the real project or hook trust is written (codex-runtime-adapter.test.ts,codex-hook-trust.test.ts).codex-owned-hook-trust.test.ts:- with the six owned tables saved single-quoted, an owned plugin upgrade renews their content approval in place, with no duplicate;
- the existing multi-line-example control now also expects the renewal, since the examples are no longer mistaken for tables.
upsertCodexHookTrustwith an unrelated duplicate key, and through twodeliverStartupcalls with #2029's duplicate project table (codex-hook-trust.test.ts,codex-runtime-adapter.test.ts).codex-hook-trust.test.ts).codex-activity-hooks-json.test.ts: removing OpenRig'shooks.jsongroup moves a later hook's trust and disable when Codex saved them with literal-quoted keys. Before, the move was skipped.With main's adapter, the six round-0 cases fail, and the single-quoted ones fail on a duplicate key. With round 0's source, the three new round-1 cases fail. With round 1's source, the five new round-2 cases fail.
Not in this change
The repeated trust prompt in #17 has two parts.
[hooks.state]table inside OpenRig's marked hook block, and OpenRig's next launch replaces the block and the trust with it. That's #2035, stacked on this change.🤖 Generated with Claude Code