Repository navigation
fix(codex): stop rebuilding shared Codex state from a read that failed (STA-4823) - #15417
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (14)
🚧 Files skipped from review as they are similar to previous changes (13)
Included review availability: Your plan provides up to 10 included reviews per hour; 7 remain after this review. 📝 WalkthroughWalkthroughCodex shared-state readers now distinguish absent, malformed, and unreadable files. Write and reconciliation paths stop when existing state cannot be read. Settings baseline observation now has present, absent, and indeterminate states. Configuration sync reports unavailable or unreadable paths. Hook cleanup and mirroring preserve existing runtime state when source reads fail. Regression tests cover failed reads and recovery across hooks, ledgers, baselines, configuration, and pane registries. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 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: 3
🧹 Nitpick comments (1)
src/main/codex/config-settings-promotion.ts (1)
246-251: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winPreserve the original baseline read error.
The runtime-config arm at Line 242 throws
runtimeTomlObservation.error, so the errno reaches the log. This arm throws a newErrorand discards the underlying filesystem error. An operator cannot then tellEPERMfromEBUSYfor the baseline path.
CodexSettingsBaselineObservationdoes not carry the error today. Add it to theindeterminatevariant insrc/main/codex/config-settings-baseline.ts, then rethrow it here.♻️ Proposed change
In
src/main/codex/config-settings-baseline.ts:| { kind: 'absent' } - | { kind: 'indeterminate' } + | { kind: 'indeterminate'; error: unknown }Return the caught error from
readParsedCodexSettingsBaselineinstead of the'unreadable'sentinel, then here:if (baselineObservation.kind === 'indeterminate') { // Why: an empty plan here lets the mirror proceed and write the system value // back over an in-Codex edit this baseline would have identified. The caller // turns a throw into the existing stall-and-retry null. - throw new Error('Codex settings baseline could not be read') + throw baselineObservation.error }
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: f5883728-2239-47bb-a2a5-a543d1c0fc28
📒 Files selected for processing (8)
src/main/agent-hooks/hooks-json-read.tssrc/main/codex/codex-pane-account-registry.tssrc/main/codex/codex-trust-grant-ledger.tssrc/main/codex/config-settings-baseline.tssrc/main/codex/config-settings-promotion.tssrc/main/codex/config-sync-stall.tssrc/main/codex/config-toml-trust.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; 2 remain after this review.
80aba44 to
6e3aaf5
Compare
Review verdict: PASSI completed a source, call-site, test-rig, mutation, compatibility, and performance review and pushed the scoped fixes found during review. The final branch is clean: an indeterminate filesystem observation cannot authorize a rebuild, destructive write, cached erasure, or healthy sync status; genuine absence and known-invalid baseline state still recover. Issues found and fixed
Sweeps that were clean
Verification
Per-test mutation results (source restored immediately after each run):
|
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 128caa49-a0bf-440b-a0ff-84ea0d56c759
📒 Files selected for processing (4)
src/main/codex/config-settings-baseline.tssrc/main/codex/config-sync-stall.tssrc/main/codex/config-toml-trust.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; 9 remain after this review.
| describe('STA-4823 D15 — the sync status must not report synced while the mirror refuses', () => { | ||
| it('reports the managed home as unavailable when its config cannot be read', () => { | ||
| const runtimeConfigPath = join(runtimeHomePath, 'config.toml') | ||
| realFs.writeFileSync(runtimeConfigPath, 'model = "m"\n', 'utf-8') | ||
| realFs.writeFileSync(join(systemHome(), 'config.toml'), 'model = "s"\n', 'utf-8') | ||
| denials.deny(runtimeConfigPath) | ||
|
|
||
| const status = getCodexConfigSyncStatus({ runtimeHomePath, systemHomePath: systemHome() }) | ||
|
|
||
| // Before the fix existsSync reported the locked runtime config as absent | ||
| // and this returned `synced` — telling the user their edits had been | ||
| // applied while nothing had run. | ||
| expect(status).toMatchObject({ state: 'stalled', reason: 'managed-home-unavailable' }) | ||
| }) | ||
|
|
||
| it('reports the managed home as unavailable when only its content read is denied', () => { | ||
| const runtimeConfigPath = join(runtimeHomePath, 'config.toml') | ||
| realFs.writeFileSync(runtimeConfigPath, 'model = "m"\n', 'utf-8') | ||
| realFs.writeFileSync(join(systemHome(), 'config.toml'), 'model = "s"\n', 'utf-8') | ||
| denials.denyReads(runtimeConfigPath) | ||
|
|
||
| expect( | ||
| getCodexConfigSyncStatus({ runtimeHomePath, systemHomePath: systemHome() }) | ||
| ).toMatchObject({ state: 'stalled', reason: 'managed-home-unavailable' }) | ||
| }) | ||
|
|
||
| it('still reports synced when no runtime config exists yet', () => { | ||
| realFs.writeFileSync(join(systemHome(), 'config.toml'), 'model = "s"\n', 'utf-8') | ||
|
|
||
| // Why: with no managed config the mirror seeds one; there is nothing to | ||
| // have fallen behind, and warning here would fire on every fresh install. | ||
| expect( | ||
| getCodexConfigSyncStatus({ runtimeHomePath, systemHomePath: systemHome() }) | ||
| ).toMatchObject({ state: 'synced', reason: null }) | ||
| }) | ||
| }) |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Add a case for the unreadable-source reason.
getCodexConfigSyncStatus gained a new branch at config-sync-stall.ts Line 46 that returns unreadable-source when the system config read is indeterminate. This suite covers managed-home-unavailable and synced, but no test reaches the new source-side branch. A revert of that branch would not fail any test.
Add a case that keeps the runtime config readable and denies the system config.
💚 Proposed test
+ it('reports an unreadable source config rather than claiming a sync', () => {
+ const systemConfigPath = join(systemHome(), 'config.toml')
+ realFs.writeFileSync(join(runtimeHomePath, 'config.toml'), 'model = "m"\n', 'utf-8')
+ realFs.writeFileSync(systemConfigPath, 'model = "s"\n', 'utf-8')
+ denials.denyReads(systemConfigPath)
+
+ expect(
+ getCodexConfigSyncStatus({ runtimeHomePath, systemHomePath: systemHome() })
+ ).toMatchObject({ state: 'stalled', reason: 'unreadable-source' })
+ })📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| describe('STA-4823 D15 — the sync status must not report synced while the mirror refuses', () => { | |
| it('reports the managed home as unavailable when its config cannot be read', () => { | |
| const runtimeConfigPath = join(runtimeHomePath, 'config.toml') | |
| realFs.writeFileSync(runtimeConfigPath, 'model = "m"\n', 'utf-8') | |
| realFs.writeFileSync(join(systemHome(), 'config.toml'), 'model = "s"\n', 'utf-8') | |
| denials.deny(runtimeConfigPath) | |
| const status = getCodexConfigSyncStatus({ runtimeHomePath, systemHomePath: systemHome() }) | |
| // Before the fix existsSync reported the locked runtime config as absent | |
| // and this returned `synced` — telling the user their edits had been | |
| // applied while nothing had run. | |
| expect(status).toMatchObject({ state: 'stalled', reason: 'managed-home-unavailable' }) | |
| }) | |
| it('reports the managed home as unavailable when only its content read is denied', () => { | |
| const runtimeConfigPath = join(runtimeHomePath, 'config.toml') | |
| realFs.writeFileSync(runtimeConfigPath, 'model = "m"\n', 'utf-8') | |
| realFs.writeFileSync(join(systemHome(), 'config.toml'), 'model = "s"\n', 'utf-8') | |
| denials.denyReads(runtimeConfigPath) | |
| expect( | |
| getCodexConfigSyncStatus({ runtimeHomePath, systemHomePath: systemHome() }) | |
| ).toMatchObject({ state: 'stalled', reason: 'managed-home-unavailable' }) | |
| }) | |
| it('still reports synced when no runtime config exists yet', () => { | |
| realFs.writeFileSync(join(systemHome(), 'config.toml'), 'model = "s"\n', 'utf-8') | |
| // Why: with no managed config the mirror seeds one; there is nothing to | |
| // have fallen behind, and warning here would fire on every fresh install. | |
| expect( | |
| getCodexConfigSyncStatus({ runtimeHomePath, systemHomePath: systemHome() }) | |
| ).toMatchObject({ state: 'synced', reason: null }) | |
| }) | |
| }) | |
| describe('STA-4823 D15 — the sync status must not report synced while the mirror refuses', () => { | |
| it('reports the managed home as unavailable when its config cannot be read', () => { | |
| const runtimeConfigPath = join(runtimeHomePath, 'config.toml') | |
| realFs.writeFileSync(runtimeConfigPath, 'model = "m"\n', 'utf-8') | |
| realFs.writeFileSync(join(systemHome(), 'config.toml'), 'model = "s"\n', 'utf-8') | |
| denials.deny(runtimeConfigPath) | |
| // Before the fix existsSync reported the locked runtime config as absent | |
| // and this returned `synced` — telling the user their edits had been | |
| // applied while nothing had run. | |
| const status = getCodexConfigSyncStatus({ runtimeHomePath, systemHomePath: systemHome() }) | |
| expect(status).toMatchObject({ state: 'stalled', reason: 'managed-home-unavailable' }) | |
| }) | |
| it('reports the managed home as unavailable when only its content read is denied', () => { | |
| const runtimeConfigPath = join(runtimeHomePath, 'config.toml') | |
| realFs.writeFileSync(runtimeConfigPath, 'model = "m"\n', 'utf-8') | |
| realFs.writeFileSync(join(systemHome(), 'config.toml'), 'model = "s"\n', 'utf-8') | |
| denials.denyReads(runtimeConfigPath) | |
| expect( | |
| getCodexConfigSyncStatus({ runtimeHomePath, systemHomePath: systemHome() }) | |
| ).toMatchObject({ state: 'stalled', reason: 'managed-home-unavailable' }) | |
| }) | |
| it('reports an unreadable source config rather than claiming a sync', () => { | |
| const systemConfigPath = join(systemHome(), 'config.toml') | |
| realFs.writeFileSync(join(runtimeHomePath, 'config.toml'), 'model = "m"\n', 'utf-8') | |
| realFs.writeFileSync(systemConfigPath, 'model = "s"\n', 'utf-8') | |
| denials.denyReads(systemConfigPath) | |
| expect( | |
| getCodexConfigSyncStatus({ runtimeHomePath, systemHomePath: systemHome() }) | |
| ).toMatchObject({ state: 'stalled', reason: 'unreadable-source' }) | |
| }) | |
| it('still reports synced when no runtime config exists yet', () => { | |
| realFs.writeFileSync(join(systemHome(), 'config.toml'), 'model = "s"\n', 'utf-8') | |
| // Why: with no managed config the mirror seeds one; there is nothing to | |
| // have fallen behind, and warning here would fire on every fresh install. | |
| expect( | |
| getCodexConfigSyncStatus({ runtimeHomePath, systemHomePath: systemHome() }) | |
| ).toMatchObject({ state: 'synced', reason: null }) | |
| }) | |
| }) |
7f51841 to
7d90e51
Compare
Main validation evidence — origin/main on Windows high spec (not PR validation)Isolated origin/main worktree
Host measurement (before any app flow)
FileShare.None on files: metadata Results
Screenshots (local; upload blocked)
CleanupAll ACL denials restored (inherited |
Main validation evidence — origin/main on Windows high spec (not PR validation)Isolated origin/main worktree Prior comment without images: #15417 (comment) Host measurement (before any app flow)
Results
Screenshots#15046 before quota poll #15046 during marker deny + poll (alpha still Active) #15046 after ACL restore #15279 gap: Add Account blocked (custom provider) #15279 gap: toast names #15093 isolated app after refused resume #15289 after denied runtime auth poll (alpha still Active) |
|
Windows high-spec validation of PR 15417 at 7d90e51. Isolated Orca Accounts pane after icacls deny (R) on the managed runtime config.toml. Visible text: Orca could not read this account's Codex files just now, so settings may not be syncing. Uncropped renderer screenshot. No API keys, tokens, cookies, or emails in the image. |
7d90e51 to
b58b788
Compare
|
Windows HIGH SPEC (STA-4823 / PR 15417): Accounts pane shows managed-home-unavailable after icacls deny of the isolated managed config.toml. |
…d (STA-4823) Six shared files were rebuilt, erased or reported healthy after a read that had only failed. Batch A of the STA-4606 split: every one of these is reachable and testable on the host lane, so none of them wait on the WSL work. - `config-toml-trust.ts` upsertHookTrustEntries: `existsSync` reported a locked config.toml as absent, so the base content became '' and the upsert rewrote the file from the trust entries alone — a trust-only stub, with the user's model, provider, MCP servers, approvals and comments gone. It refuses now; every hook-service caller already turns that into "trust entries could not be written. Run /hooks in Codex to approve." - `codex-trust-grant-ledger.ts`: an unreadable ledger degraded to empty and the next write persisted a file holding only the home being written, dropping every other home's grants. The write paths refuse; the read path still degrades, and a corrupt ledger is still rebuilt. - `codex-pane-account-registry.ts`: an unreadable registry erased every pane's attribution AND cached that erasure, so it survived the file recovering. The failure is no longer cached, and both write sites refuse rather than persist a registry derived from an empty stand-in. - `hooks-json-read.ts`: the read arm already separated "no hooks" from "could not read", but the `existsSync` arm in front of it returned a valid empty config for a file that could not be opened. One read now classifies both. - `config-settings-baseline.ts`: absent, unparseable and unreadable all collapsed into `null`, so the snapshot rebuilt a baseline it could not read — recording an in-Codex edit as Orca's own write, after which promotion skips it forever. - `config-sync-stall.ts`: an unreadable runtime config read as absent and the status reported `synced` while the mirror was refusing. It reports `managed-home-unavailable`, the existing reason for exactly this, rather than borrowing a source-side one and blaming the wrong path. Absent and malformed still rebuild throughout — resetting corrupt state is the intent, and conflating it with unreadable would wedge a user on a broken file.
MEASURED on both platforms: a file-permission denial leaves existsSync TRUE and fails only the content read — chmod 000 gives EACCES on macOS, icacls /deny (R) gives EPERM errno -4048 on Windows, with stat/lstat succeeding in both. The rig's docblock claimed this mode modelled that denial. It does not. What it models is the UNC / \\wsl$ transport, where an unreachable distro reports errno UNKNOWN at every level and existsSync folds it to false. The distinction decides what the D29 guard is worth: under a permission denial the pre-fix code already failed safe, because existsSync was true so it took the read branch and threw. Only a transport that lies about existence reaches the rebuild-from-empty path. No behaviour change; the comment was wrong, not the code.
8b7964b to
572b2fa
Compare
|
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. |
Review verdict: PASS — ready to landSecond-loop review is complete at Honest trigger map
An ordinary permission denial cannot reach D29’s rebuild-from-empty path. On macOS, Mutation and review resultsI reran the mutation matrix rather than relying on the prior PR table. Reverting the D15/D26/D30/D31 guards makes their live content-denial cases red; reverting D29/D33 makes their The review also found and fixed two scoped gaps. Pending pane-attribution mutations are retained and merged after registry recovery with bounded capacity/retry timing, and a final mutation check caught the reconciliation-only write path canceling its own retry. The closing readiness audit then found that an unreadable D26 baseline safely stopped mirroring but could still report Validation
Final-head Electron startup was validated at No additional WSL or SSH runtime leg was needed: this PR does not change SSH execution, wire contracts, or remote publishing, and the indeterminate transport case modeled by D29 remains part of the WSL-lane follow-up. The final Windows CI packaging job passed, alongside the direct macOS/Windows permission measurements above. |
…d trust
`cleanupLegacySystemManagedHooks` reads `~/.codex/hooks.json` and, when it finds
no hooks, removes Orca's managed trust entries from the system config.toml and
deletes that home's grant-ledger record.
Since the STA-4823 read classification landed, `readHooksJsonWithRaw` reports a
genuine absence as `{ raw: null, config: {} }` and a failed read as
`{ raw: null, config: null }`. Both still fell into the same branch, so a read
that merely failed discarded hook approvals the user had already given — and the
ledger record that would have let a later pass notice.
Only the definitive-absence answer may reach the removal now.
Found while reviewing #15417 and not covered by it: that PR fixed the classifier
and this is a consumer of it that still collapsed the two answers.
The sibling `assertHooksJsonGeneration` guard in codex-real-home-hook-install.ts
has the same `existsSync ? read : null` shape and is deliberately NOT changed
here. Measured, a permission denial leaves existsSync true and throws from the
read, so that path already fails closed; a guard there could not be made to fail
in a test and would be unprovable code.
…d trust (#16147) `cleanupLegacySystemManagedHooks` reads `~/.codex/hooks.json` and, when it finds no hooks, removes Orca's managed trust entries from the system config.toml and deletes that home's grant-ledger record. Since the STA-4823 read classification landed, `readHooksJsonWithRaw` reports a genuine absence as `{ raw: null, config: {} }` and a failed read as `{ raw: null, config: null }`. Both still fell into the same branch, so a read that merely failed discarded hook approvals the user had already given — and the ledger record that would have let a later pass notice. Only the definitive-absence answer may reach the removal now. Found while reviewing #15417 and not covered by it: that PR fixed the classifier and this is a consumer of it that still collapsed the two answers. The sibling `assertHooksJsonGeneration` guard in codex-real-home-hook-install.ts has the same `existsSync ? read : null` shape and is deliberately NOT changed here. Measured, a permission denial leaves existsSync true and throws from the read, so that path already fails closed; a guard there could not be made to fail in a test and would be unprovable code.
…d (STA-4823) (stablyai#15417) * fix(codex): stop rebuilding shared Codex state from a read that failed (STA-4823) Six shared files were rebuilt, erased or reported healthy after a read that had only failed. Batch A of the STA-4606 split: every one of these is reachable and testable on the host lane, so none of them wait on the WSL work. - `config-toml-trust.ts` upsertHookTrustEntries: `existsSync` reported a locked config.toml as absent, so the base content became '' and the upsert rewrote the file from the trust entries alone — a trust-only stub, with the user's model, provider, MCP servers, approvals and comments gone. It refuses now; every hook-service caller already turns that into "trust entries could not be written. Run /hooks in Codex to approve." - `codex-trust-grant-ledger.ts`: an unreadable ledger degraded to empty and the next write persisted a file holding only the home being written, dropping every other home's grants. The write paths refuse; the read path still degrades, and a corrupt ledger is still rebuilt. - `codex-pane-account-registry.ts`: an unreadable registry erased every pane's attribution AND cached that erasure, so it survived the file recovering. The failure is no longer cached, and both write sites refuse rather than persist a registry derived from an empty stand-in. - `hooks-json-read.ts`: the read arm already separated "no hooks" from "could not read", but the `existsSync` arm in front of it returned a valid empty config for a file that could not be opened. One read now classifies both. - `config-settings-baseline.ts`: absent, unparseable and unreadable all collapsed into `null`, so the snapshot rebuilt a baseline it could not read — recording an in-Codex edit as Orca's own write, after which promotion skips it forever. - `config-sync-stall.ts`: an unreadable runtime config read as absent and the status reported `synced` while the mirror was refusing. It reports `managed-home-unavailable`, the existing reason for exactly this, rather than borrowing a source-side one and blaming the wrong path. Absent and malformed still rebuild throughout — resetting corrupt state is the intent, and conflating it with unreadable would wedge a user on a broken file. * fix(codex): close shared state read-denial gaps * fix(codex): recover oversized settings baselines * fix(codex): name the stalled managed config * fix(codex): preserve hooks after failed source reads * test(codex): correct what the denyExistence rig actually models MEASURED on both platforms: a file-permission denial leaves existsSync TRUE and fails only the content read — chmod 000 gives EACCES on macOS, icacls /deny (R) gives EPERM errno -4048 on Windows, with stat/lstat succeeding in both. The rig's docblock claimed this mode modelled that denial. It does not. What it models is the UNC / \\wsl$ transport, where an unreachable distro reports errno UNKNOWN at every level and existsSync folds it to false. The distinction decides what the D29 guard is worth: under a permission denial the pre-fix code already failed safe, because existsSync was true so it took the read branch and threw. Only a transport that lies about existence reaches the rebuild-from-empty path. No behaviour change; the comment was wrong, not the code. * test(codex): exercise live baseline read denial * fix(codex): retry pane attribution writes * fix(codex): retry reconciliation registry writes * fix(codex): report unreadable sync baselines (cherry picked from commit 677718c)
…d trust (stablyai#16147) `cleanupLegacySystemManagedHooks` reads `~/.codex/hooks.json` and, when it finds no hooks, removes Orca's managed trust entries from the system config.toml and deletes that home's grant-ledger record. Since the STA-4823 read classification landed, `readHooksJsonWithRaw` reports a genuine absence as `{ raw: null, config: {} }` and a failed read as `{ raw: null, config: null }`. Both still fell into the same branch, so a read that merely failed discarded hook approvals the user had already given — and the ledger record that would have let a later pass notice. Only the definitive-absence answer may reach the removal now. Found while reviewing stablyai#15417 and not covered by it: that PR fixed the classifier and this is a consumer of it that still collapsed the two answers. The sibling `assertHooksJsonGeneration` guard in codex-real-home-hook-install.ts has the same `existsSync ? read : null` shape and is deliberately NOT changed here. Measured, a permission denial leaves existsSync true and throws from the read, so that path already fails closed; a guard there could not be made to fail in a test and would be unprovable code. (cherry picked from commit 8d08d00)
…d (STA-4823) (stablyai#15417) * fix(codex): stop rebuilding shared Codex state from a read that failed (STA-4823) Six shared files were rebuilt, erased or reported healthy after a read that had only failed. Batch A of the STA-4606 split: every one of these is reachable and testable on the host lane, so none of them wait on the WSL work. - `config-toml-trust.ts` upsertHookTrustEntries: `existsSync` reported a locked config.toml as absent, so the base content became '' and the upsert rewrote the file from the trust entries alone — a trust-only stub, with the user's model, provider, MCP servers, approvals and comments gone. It refuses now; every hook-service caller already turns that into "trust entries could not be written. Run /hooks in Codex to approve." - `codex-trust-grant-ledger.ts`: an unreadable ledger degraded to empty and the next write persisted a file holding only the home being written, dropping every other home's grants. The write paths refuse; the read path still degrades, and a corrupt ledger is still rebuilt. - `codex-pane-account-registry.ts`: an unreadable registry erased every pane's attribution AND cached that erasure, so it survived the file recovering. The failure is no longer cached, and both write sites refuse rather than persist a registry derived from an empty stand-in. - `hooks-json-read.ts`: the read arm already separated "no hooks" from "could not read", but the `existsSync` arm in front of it returned a valid empty config for a file that could not be opened. One read now classifies both. - `config-settings-baseline.ts`: absent, unparseable and unreadable all collapsed into `null`, so the snapshot rebuilt a baseline it could not read — recording an in-Codex edit as Orca's own write, after which promotion skips it forever. - `config-sync-stall.ts`: an unreadable runtime config read as absent and the status reported `synced` while the mirror was refusing. It reports `managed-home-unavailable`, the existing reason for exactly this, rather than borrowing a source-side one and blaming the wrong path. Absent and malformed still rebuild throughout — resetting corrupt state is the intent, and conflating it with unreadable would wedge a user on a broken file. * fix(codex): close shared state read-denial gaps * fix(codex): recover oversized settings baselines * fix(codex): name the stalled managed config * fix(codex): preserve hooks after failed source reads * test(codex): correct what the denyExistence rig actually models MEASURED on both platforms: a file-permission denial leaves existsSync TRUE and fails only the content read — chmod 000 gives EACCES on macOS, icacls /deny (R) gives EPERM errno -4048 on Windows, with stat/lstat succeeding in both. The rig's docblock claimed this mode modelled that denial. It does not. What it models is the UNC / \\wsl$ transport, where an unreachable distro reports errno UNKNOWN at every level and existsSync folds it to false. The distinction decides what the D29 guard is worth: under a permission denial the pre-fix code already failed safe, because existsSync was true so it took the read branch and threw. Only a transport that lies about existence reaches the rebuild-from-empty path. No behaviour change; the comment was wrong, not the code. * test(codex): exercise live baseline read denial * fix(codex): retry pane attribution writes * fix(codex): retry reconciliation registry writes * fix(codex): report unreadable sync baselines
…d trust (stablyai#16147) `cleanupLegacySystemManagedHooks` reads `~/.codex/hooks.json` and, when it finds no hooks, removes Orca's managed trust entries from the system config.toml and deletes that home's grant-ledger record. Since the STA-4823 read classification landed, `readHooksJsonWithRaw` reports a genuine absence as `{ raw: null, config: {} }` and a failed read as `{ raw: null, config: null }`. Both still fell into the same branch, so a read that merely failed discarded hook approvals the user had already given — and the ledger record that would have let a later pass notice. Only the definitive-absence answer may reach the removal now. Found while reviewing stablyai#15417 and not covered by it: that PR fixed the classifier and this is a consumer of it that still collapsed the two answers. The sibling `assertHooksJsonGeneration` guard in codex-real-home-hook-install.ts has the same `existsSync ? read : null` shape and is deliberately NOT changed here. Measured, a permission denial leaves existsSync true and throws from the read, so that path already fails closed; a guard there could not be made to fail in a test and would be unprovable code.
…d (STA-4823) (stablyai#15417) * fix(codex): stop rebuilding shared Codex state from a read that failed (STA-4823) Six shared files were rebuilt, erased or reported healthy after a read that had only failed. Batch A of the STA-4606 split: every one of these is reachable and testable on the host lane, so none of them wait on the WSL work. - `config-toml-trust.ts` upsertHookTrustEntries: `existsSync` reported a locked config.toml as absent, so the base content became '' and the upsert rewrote the file from the trust entries alone — a trust-only stub, with the user's model, provider, MCP servers, approvals and comments gone. It refuses now; every hook-service caller already turns that into "trust entries could not be written. Run /hooks in Codex to approve." - `codex-trust-grant-ledger.ts`: an unreadable ledger degraded to empty and the next write persisted a file holding only the home being written, dropping every other home's grants. The write paths refuse; the read path still degrades, and a corrupt ledger is still rebuilt. - `codex-pane-account-registry.ts`: an unreadable registry erased every pane's attribution AND cached that erasure, so it survived the file recovering. The failure is no longer cached, and both write sites refuse rather than persist a registry derived from an empty stand-in. - `hooks-json-read.ts`: the read arm already separated "no hooks" from "could not read", but the `existsSync` arm in front of it returned a valid empty config for a file that could not be opened. One read now classifies both. - `config-settings-baseline.ts`: absent, unparseable and unreadable all collapsed into `null`, so the snapshot rebuilt a baseline it could not read — recording an in-Codex edit as Orca's own write, after which promotion skips it forever. - `config-sync-stall.ts`: an unreadable runtime config read as absent and the status reported `synced` while the mirror was refusing. It reports `managed-home-unavailable`, the existing reason for exactly this, rather than borrowing a source-side one and blaming the wrong path. Absent and malformed still rebuild throughout — resetting corrupt state is the intent, and conflating it with unreadable would wedge a user on a broken file. * fix(codex): close shared state read-denial gaps * fix(codex): recover oversized settings baselines * fix(codex): name the stalled managed config * fix(codex): preserve hooks after failed source reads * test(codex): correct what the denyExistence rig actually models MEASURED on both platforms: a file-permission denial leaves existsSync TRUE and fails only the content read — chmod 000 gives EACCES on macOS, icacls /deny (R) gives EPERM errno -4048 on Windows, with stat/lstat succeeding in both. The rig's docblock claimed this mode modelled that denial. It does not. What it models is the UNC / \\wsl$ transport, where an unreachable distro reports errno UNKNOWN at every level and existsSync folds it to false. The distinction decides what the D29 guard is worth: under a permission denial the pre-fix code already failed safe, because existsSync was true so it took the read branch and threw. Only a transport that lies about existence reaches the rebuild-from-empty path. No behaviour change; the comment was wrong, not the code. * test(codex): exercise live baseline read denial * fix(codex): retry pane attribution writes * fix(codex): retry reconciliation registry writes * fix(codex): report unreadable sync baselines
…d trust (stablyai#16147) `cleanupLegacySystemManagedHooks` reads `~/.codex/hooks.json` and, when it finds no hooks, removes Orca's managed trust entries from the system config.toml and deletes that home's grant-ledger record. Since the STA-4823 read classification landed, `readHooksJsonWithRaw` reports a genuine absence as `{ raw: null, config: {} }` and a failed read as `{ raw: null, config: null }`. Both still fell into the same branch, so a read that merely failed discarded hook approvals the user had already given — and the ledger record that would have let a later pass notice. Only the definitive-absence answer may reach the removal now. Found while reviewing stablyai#15417 and not covered by it: that PR fixed the classifier and this is a consumer of it that still collapsed the two answers. The sibling `assertHooksJsonGeneration` guard in codex-real-home-hook-install.ts has the same `existsSync ? read : null` shape and is deliberately NOT changed here. Measured, a permission denial leaves existsSync true and throws from the read, so that path already fails closed; a guard there could not be made to fail in a test and would be unprovable code.









ELI5
Orca now treats a failed read as “unknown,” not “missing.” A transient filesystem or transport failure can no longer authorize a rebuild, destructive write, cached erasure, or healthy sync result; genuine absence and malformed state still recover as intended.
What Changed
syncedconfig.tomltrust upsertENOENT/ENOTDIR; propagate every other read failurehooks.jsonobservationPermission-denial correction
An ordinary permission denial cannot reach D29’s rebuild-from-empty branch. On macOS,
chmod 000leavesexistsSynctrue andstat/lstatsuccessful beforereadFileSyncfails withEACCES(-13); on Windows,icacls /deny USER:(R)produces the same metadata shape before the content read fails withEPERM(-4048). Pre-fix D29 therefore took the read branch, threw, and the hook-service caller reported that trust entries could not be written—no trust-only stub was produced.D29 and D33 remain conservative insurance for indeterminate existence/transport states. The host defects that survive the measurement are D15, D26, D30, and D31. D26’s live failure is the promotion/mirror path; its snapshot path was already fail-safe for the measured permission-denial shape.
Pane-attribution durability
One-shot pane attribution updates are now retained while the registry is unreadable and merged after recovery. Automatic retries are bounded to 2,000 pending mutations and delays of 100 ms, 1 s, 5 s, and 30 s; the timer is unreferenced, and failed reconciliation-only writes also retry rather than silently canceling themselves.
Sync-health parity
The final review found that an unreadable D26 baseline safely stopped promotion/mirroring but could still report
synced. Health now observes that baseline too, reuses the existing managed-home-unavailable reason, and includes an optional managed-state path so diagnostics name the file that actually failed; the optional field preserves compatibility with existing status consumers.Linked Issue
Fixes STA-4823. The transport-specific follow-up remains in STA-4606.
Visual Proof
Final-head (
02990b36f1) isolated Electron startup via Playwright CDP: correct branch/worktree identity, zero console errors, and no secrets or unrelated workspace state. The filesystem-denial path has no bespoke rendered control, so this proves clean startup rather than the main-process failure path itself.Testing
The focused STA regression file has 20 cases, with four additional pane-registry retry cases and two baseline-health status/IPC cases. The mutation matrix was rerun against each guard rather than inferred from the happy-path suite:
denyExistencerebuilds from trust entries alone; ordinary content denial remains fail-safe pre-fixdenyExistencereports a present file as valid empty config; ordinary content denial remains unknown pre-fixsyncedRequested main suites after the final fix: 175 files passed, 1 skipped; 1,787 tests passed, 12 skipped across
src/main/codex,src/main/codex-accounts, andsrc/main/agent-hooks.Including the sync-status IPC suite: 176 files passed, 1 skipped; 1,792 tests passed, 12 skipped.
Codex-focused readiness run: 106 files passed, 1 skipped; 1,117 tests passed, 6 skipped.
Renderer stale-pane coverage: 4 files / 71 tests passed.
Node 24 typecheck, changed-code quality, max-lines ratchet, oxfmt, and diff checks passed.
CI passed, including all Node 24/26 test shards and Windows packaging.
macOS and Windows permission behavior was measured directly as described above.
Automated tests added
Manual final-head Electron startup validation
AI Disclosure
N/A — internal.