Skip to content

fix(codex): make account removal crash-safe - #11655

Closed
kazu-42 wants to merge 9 commits into
stablyai:mainfrom
kazu-42:agent/fix-codex-account-removal-atomicity
Closed

kazu-42 wants to merge 9 commits into
stablyai:mainfrom
kazu-42:agent/fix-codex-account-removal-atomicity

Conversation

@kazu-42

@kazu-42 kazu-42 commented Jul 31, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

Removing a saved Codex account now saves the account change and credit-reset safety records together before deleting its credentials. If a crash or cleanup failure interrupts removal, Orca retains a recoverable record and shows a pending account that can be retried.

What Changed

  • Use the existing asynchronous profile writer to acknowledge account removal and reset-ledger cleanup together. Persist recovery metadata before that commit, including for a lost acknowledgement.
  • Fold selection-only runtime self-healing into the removal commit. Reconcile the host, the account's runtime, and every runtime whose selection changes; restore touched runtimes after a failure.
  • Keep the ownership marker until credential-bearing entries are deleted. Retry interrupted cleanup of an empty home only at its expected account path, using nonrecursive removal. Verify WSL absence through a readable parent directory; an unavailable share stays pending.
  • Publish cleanup records in optional pendingRemovals, keeping the existing selectable account roster compatible with older clients, remote switchers, and mobile. Settings shows retry guidance and disables selection and reauthentication. Preserve confirmation, busy-state, runtime availability, remote ownership, and host lifecycle behavior.

Why

Deleting credentials before storage acknowledges removal can leave contradictory state after a crash. Deleting the ownership marker before a locked credential file also made cleanup impossible to retry. The existing durable mutation queue and ownership checks cover these failures without introducing another writer or trusting an inaccessible filesystem. The inactive-account performance change requested in the maintainer review remains separate.

Linked Issue

Related: #11653. This provides durable recovery metadata and explicit retry; automatic startup/background cleanup remains outside this PR.

Maintainer requirements: #11655 (comment)

Visual Proof

Current-head rendered Electron screenshots and acceptance details: #11655 (comment)

The hidden macOS app exercised active-account removal, pending-row guards, refusal of untrusted cleanup, retry, and restart persistence using disposable credentials and an isolated profile.

Testing

Validated against main at b407d06c1ecd, with final head b538252bbe70:

  • Current-head account/persistence/UI verification: 64 suites, 493 tests passed, including 7 cleanup regressions, Settings snapshot coverage, and the WSL switcher contract. Three cleanup cases and the selectable-roster regression failed before their fixes. The generated WSL script also ran against real Bash fixtures.
  • Full Node/Web/CLI typecheck, changed-code quality across 32 code files, staged lint/React Doctor, formatting, and whitespace checks passed.
  • Fresh Electron dev build and actual Settings UI acceptance passed on macOS. Pending cleanup survived restart; completed removals and deleted homes stayed removed after another restart.
  • All test and app launches used ORCA_BACKGROUND_LAUNCH=1; no window was shown or focused.

All applicable current-head CI checks passed: full unit-test shards, relay integration, static analysis/typecheck, Linux and Windows packaging, six persistence platforms, Linux compatibility, and mobile verification. Native Windows file locks, a real WSL distro, and a real paired SSH mutation were not exercised locally. Packaging and the full repository test/lint matrix are covered by CI rather than claimed as local results.

  • I manually tested these changes locally
  • Automated tests added/updated

AI Disclosure

Implemented with OpenAI Codex (GPT-6), with automated and rendered-app verification.

Review

The review traced persistence ordering, known and indeterminate write failures, reset-credit guards, selection self-healing, runtime restoration, cleanup ownership, restart recovery, and pending-row actions. The asynchronous rename behavior remains unchanged. Cleanup retry fixes and their evidence are documented in the linked review comment.

Agent skill upstream boundary

  • Not applicable; no upstream skill-installer source or assets are copied.

Notes

Removal uses the execution host's store and filesystem. A disconnect or unavailable home never proves deletion. A corrupt reset ledger remains fail-closed for provider resets. No new RPC commands or dependencies are added; the pending-removal snapshot field is optional and the existing selectable roster keeps its semantics. Folder workspaces use the same account service.

Contributor: https://x.com/DevKazu42

Checklist

  • Scope is Codex account-removal safety and recovery
  • User behavior, mechanism, and rationale explained
  • Current-head before/after screenshots attached
  • Self-reviewed correctness, security, and cleanup behavior
  • Cross-platform, SSH ownership, and folder workspace impact considered
  • All applicable current-head CI checks pass; local focused validation is listed above

@kazu-42
kazu-42 marked this pull request as ready for review July 31, 2026 02:06
@kazu-42

kazu-42 commented Jul 31, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 31, 2026 •

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai

coderabbitai Bot commented Jul 31, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It 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 reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Codex persistence now supports temporary settings previews and atomic settings updates with reset-credit ledger changes. Account removal synchronizes runtime targets, rolls back on persistence failure, and remains retryable. Corrupt ledgers no longer block credential removal. Background quota refresh handles startup failures. Durable file publication now uses synchronous renames after generation checks, with regression coverage for competing writers.

🚥 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
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.
Title check ✅ Passed The title clearly summarizes the primary change: making Codex account removal crash-safe.
Description check ✅ Passed The description covers the required sections, including the change, rationale, linked issue, visual proof, testing, review, AI disclosure, and checklist. It also explains the recovery behavior and tes…
  • Fix all pre-merge checks with AI

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.

@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: 1

🧹 Nitpick comments (2)
src/main/codex-accounts/service.ts (1)

719-727: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Optional: collapse the duplicated failure log.

Both the synchronous catch and the promise catch log the same message. A small helper removes the duplication and keeps a single log site.

♻️ Proposed refactor
+    const logFailure = (error: unknown): void => {
+      console.error('[codex-accounts] Quota refresh after account change failed:', error)
+    }
     try {
       void this.rateLimits
         .refreshForCodexAccountChange(outgoingAccountId, target)
-        .catch((error) => {
-          console.error('[codex-accounts] Quota refresh after account change failed:', error)
-        })
+        .catch(logFailure)
     } catch (error) {
-      console.error('[codex-accounts] Quota refresh after account change failed:', error)
+      logFailure(error)
     }
src/main/codex-accounts/service.test.ts (1)

208-216: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Mirror the synchronous-callback contract in the test double.

The real withCodexAccountSettingsPreview throws when the callback returns a thenable. This double accepts any callback. A regression that passes an asynchronous callback from doRemoveAccount would still pass these tests, because the double would restore settings before the callback settled.

Add the same thenable rejection to keep the double aligned with the store contract.

♻️ Proposed change
   const withSettingsPreview = <T>(updates: Partial<GlobalSettings>, action: () => T): T => {
     const previousSettings = settings
     applySettings(updates)
     try {
-      return action()
+      const result = action()
+      if (typeof (result as { then?: unknown })?.then === 'function') {
+        void Promise.resolve(result).catch(() => {})
+        throw new Error('Codex account settings preview callback must be synchronous')
+      }
+      return result
     } finally {
       settings = previousSettings
     }
   }

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 58467c48-bea3-42b2-b8d7-825d025336b5

📥 Commits

Reviewing files that changed from the base of the PR and between 33b6d4d and 5178def37aeaca212b66313ce0c1513d757dfad7.

📒 Files selected for processing (6)
  • src/main/codex-accounts/service.test.ts
  • src/main/codex-accounts/service.ts
  • src/main/durable-file-write.test.ts
  • src/main/durable-file-write.ts
  • src/main/persistence.test.ts
  • src/main/persistence.ts

Comment thread src/main/persistence.ts Resolved
@greptile-apps

greptile-apps Bot commented Jul 31, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 5/5

[Critical risk] Rewrites account removal to handle storage failures and crashes.

The PR appears safe to merge based on the reviewed changes.

Summary

The PR makes Codex account removal retryable across uncertain persistence outcomes and adds a removal-pending state to the account row.

  • Persists recovery metadata before committing account removal and reset-ledger cleanup.
  • Preserves a retry path when the commit succeeds but its acknowledgement is lost.
  • Disables selection and reauthentication for recovery-only accounts while retaining Remove.
Diagram
%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Preview and reconcile runtime selection] --> B[Persist removal recovery record]
  B --> C[Commit account removal and reset-ledger cleanup]
  C -->|Acknowledged| D[Remove managed home]
  D -->|Removed or verified absent| E[Clear recovery record]
  C -->|Outcome indeterminate| F[Keep recovery record for retry]
  D -->|Unavailable or untrusted| F
Loading

Reviews (8) · Last reviewed commit: "fix(codex): show pending removal and dis..."

@kazu-42
kazu-42 force-pushed the agent/fix-codex-account-removal-atomicity branch from 5178def to 95e5c39 Compare July 31, 2026 02:37
@kazu-42

kazu-42 commented Jul 31, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 31, 2026 •

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@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.

🧹 Nitpick comments (3)
src/main/codex-accounts/service.test.ts (3)

2869-2875: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick win

Assert that the corrupt ledger is never rewritten.

The test proves the settings-only flush runs. It does not prove the combined settings-and-ledger flush is skipped. Add a negative assertion so a future change that rewrites a corrupt ledger fails this test.

♻️ Proposed additional assertion
     expect(store.updateCodexAccountSettingsAndFlush).toHaveBeenCalledOnce()
+    expect(store.updateCodexAccountSettingsAndResetLedgerAndFlush).not.toHaveBeenCalled()
     expect(() => store.getCodexResetCreditAttemptLedger()).toThrow(
       'Codex reset-credit attempt ledger is corrupt'
     )

3382-3382: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Align the test name with the assertions.

The assertions at Lines 3415-3416 check activeCodexManagedAccountId, which is the selected account, not the runtime target. Rename the test to describe the restored account selection.

✏️ Proposed rename
-  it('restores the selected runtime when account removal persistence fails', async () => {
+  it('restores the selected account when account removal persistence fails', async () => {

239-254: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Type the fixture against Store to catch method drift.

createStore() return type is inferred and passed through store as never at construction, so renamed or changed updateCodexAccountSettingsAndFlush, withCodexAccountSettingsPreview, or updateCodexAccountSettingsAndResetLedgerAndFlush calls can keep the tests passing. Annotate the fixture as satisfies Partial<Store> or Pick<Store, ...> where those Codex persistence methods are needed.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 2a2f0020-3bdd-42e8-a1a1-27448e14dabf

📥 Commits

Reviewing files that changed from the base of the PR and between 5178def37aeaca212b66313ce0c1513d757dfad7 and 95e5c393b20a526c3fff7466de6791a049aeb3bf.

📒 Files selected for processing (6)
  • src/main/codex-accounts/service.test.ts
  • src/main/codex-accounts/service.ts
  • src/main/durable-file-write.test.ts
  • src/main/durable-file-write.ts
  • src/main/persistence.test.ts
  • src/main/persistence.ts
🚧 Files skipped from review as they are similar to previous changes (5)
  • src/main/durable-file-write.ts
  • src/main/durable-file-write.test.ts
  • src/main/codex-accounts/service.ts
  • src/main/persistence.test.ts
  • src/main/persistence.ts

@kazu-42

kazu-42 commented Jul 31, 2026

Copy link
Copy Markdown
Contributor Author

Addressed the three follow-up CodeRabbit nitpicks in 53f2de3c7.

  • The corrupt-ledger removal test now proves the combined settings-and-ledger flush is never called, so corrupt provider data cannot be rewritten accidentally.
  • The persistence rollback test is renamed to describe the selected account it actually asserts.
  • The Store fixture now uses satisfies Partial<Store>, and its generic preview callback is typed from Store['withCodexAccountSettingsPreview'], so production API drift fails type checking.

Verification on the current head: service.test.ts passed 73/73 tests, full pnpm typecheck passed, and full pnpm lint passed. The exact-current five-axis review (correctness, reliability, security/data integrity, compatibility, and maintainability/test quality) found no remaining P0-P3 issues.

@kazu-42

kazu-42 commented Jul 31, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto current main (b5abab8b0) and force-pushed the patch-equivalent final head f283b6bc1.

Post-rebase verification:

  • 3 directly changed test suites / 524 tests passed.
  • Full pnpm typecheck passed.
  • Full pnpm lint passed, including type-aware audit, 55 reliability gates, max-lines ratchet, and localization checks.
  • git range-diff confirmed the three implementation commits are patch-equivalent; the fourth commit is the already-reviewed test-only CodeRabbit nitpick follow-up.
  • The post-rebase five-axis review found no P0-P3 issues.

@kazu-42

kazu-42 commented Jul 31, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 31, 2026 •

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@brennanb2025

Copy link
Copy Markdown
Contributor

Taking a look!

@brennanb2025

Copy link
Copy Markdown
Contributor

Exact-head readiness evidence for 5b2ea47922c64d08acf149e69ab3be914ae011c5:

  • Fixed the P1 inactive-lane path: removal no longer synchronously reconciles an unchanged runtime lane or refreshes its quota; architecture stayed narrow.
  • Fresh K1–K10 fault/SIGKILL matrix passed at this SHA. K8 and commit-before-delete are RED on merge-base and GREEN on head; K4 is the known pre-existing tmp residue, while K5–K7 are the explicit fail-safe EXPECTED_RESIDUE_11653 credential-remanence rows tracked by Codex account removal can leave managed credentials after cleanup failure #11653.
  • Fresh architecture review CLEAN (task_7debd3803596 / ctx_9174e546bdb1) and fresh perf audit CLEAN (task_eaa2d17ea7e1 / ctx_ea070c8c7d20).
  • Final affected tests: 627/627; typecheck and lint passed. Isolated Electron real-Settings removal, managed-home deletion, and restart persistence passed; native Windows and real WSL executable rows also passed.
  • CI: Greptile is green; final-head PR Checks remains action_required. Windows Crash-Survival E2E has no final-head run after this path-filtered follow-up commit.

Brennan action: approve final-head PR Checks, then rerun/approve Windows Crash-Survival E2E at this SHA.

@brennanb2025

Copy link
Copy Markdown
Contributor

Electron QA evidence for exact PR head 5b2ea47922c64d08acf149e69ab3be914ae011c5.

Before — managed Codex account is present

pr-11655-electron-account-before.png

Confirm — destructive removal dialog is shown

pr-11655-electron-account-confirm.png

After — managed account is removed and system-default fallback remains

pr-11655-electron-account-after.png

@brennanb2025

Copy link
Copy Markdown
Contributor

Thanks for this — the crash-safety approach is right, and committing the account settings and the reset-credit ledger through a single durability barrier before the managed home is deleted is exactly what this path needed.

Nothing has been pushed to your branch. I reviewed it closely and have five fixes ready, but they can't land cleanly yet — more on that at the bottom.

The important one: removal is currently impossible in a real case.

The new read-only settings preview throws on any updateSettings call made inside it. But CodexRuntimeHomeService.syncForCurrentSelection legitimately writes a selection back as a self-heal — for example when an active WSL account's auth.json has gone missing — and because a null-distro target gets widened to the default distro, that write can fire for a different lane than the one being removed. Removing an account then throws Cannot update settings during a Codex account settings preview deterministically, and that account can never be removed. The fix is to fold a Codex-selection-only write into the preview and commit it in the same durability barrier; every other settings key should still be rejected.

The other four:

  • A pruned lane can be persisted without ever being reconciled. The new stale-selection pruning can clear a lane the removed account never owned. That lane gets written to disk but never reconciled. Reconciliation needs to be driven from the union of the account's own lane and every lane the commit actually changes.
  • Removal stopped doing two things it used to do. The old code called syncForCurrentSelection() untargeted — i.e. the host lane — after every removal, and reconciling only the account's own lane silently drops that for WSL removals. It also fired onHostSystemDefaultSelected on any host removal landing on the system default, so narrowing that to a non-null → null transition drops a session-migration run. Removal should stay a strict superset of the old behavior.
  • The host lifecycle hook tests the wrong selection. The selection actually persisted after the preview folds in lane clears isn't the one the hook is keyed on. When pruning keeps a host lane but reconciliation then clears it, the host lane durably lands on the system default and the hook is skipped.
  • writeFileDurableIfCurrent should keep its await rename. Its only caller chains every commit through a promise queue, so two writes for one file can never overlap — isCurrent() there is a cost optimization, not a race guard. The synchronous rename buys nothing and blocks the main thread while a 25–60 MB usage-cache inode is freed. (renameDurable keeping renameSync is fine.)

One request. Could you move perf(codex): skip inactive lane reconciliation on removal into a separate PR? We keep PRs to one change each, and that commit is a distinct behavior change from the crash-safety work. To be clear, we do want it — it looks correct, and it also stops removing an inactive account from blanking the active account's quota bars for the length of a cold probe. It just needs to be reviewable and revertable on its own.

The PR is showing conflicts against main right now, so a rebase is needed regardless — dropping that commit during the same rebase would be the easiest moment to do it.

That commit is also why the fixes above are still sitting here rather than on your branch: the superset fix and that commit's gating are genuine alternatives rather than things that stack, so the perf change wants to sit on top of these fixes rather than beside them. Once the rebase lands I'll push the five fixes and their tests; equally happy for you to take them yourself if you'd prefer.

Two things seen and deliberately left alone, so they aren't lost: if the durable flush fails, the rollback re-runs reconciliation outside the preview, so a self-heal write can persist — meaning a failed removal can also clear an invalid host selection. That seems acceptable (the cleared selection is genuinely invalid and would be cleared at next launch anyway, and there was no rollback at all before). And deleting the managed home still follows the durable commit, so a crash in that window can orphan auth.json — that's pre-existing, tracked in #11653, and this PR makes it strictly better.

@kazu-42
kazu-42 force-pushed the agent/fix-codex-account-removal-atomicity branch from 5b2ea47 to 81461be Compare August 10, 2026 07:57
@kazu-42

kazu-42 commented Aug 10, 2026

Copy link
Copy Markdown
Contributor Author

Rebase/split request completed.

  • Rebased the four crash-safety commits onto current main at 73efab9.
  • Dropped perf(codex): skip inactive lane reconciliation on removal from this PR as requested. It remains preserved locally for a separate follow-up after the five correctness fixes establish the right base.
  • New exact PR head: 81461be81d31147e57543361750dad16cb6dfe51.
  • The PR is now mergeable; the new PR Checks run is action_required pending maintainer approval.

Exact-head verification:

  • 3 focused files / 548 tests passed.
  • Full pnpm typecheck passed.
  • Full pnpm lint passed.
  • Range-diff preserves the four crash-safety patches; conflict resolution retained current-main stale-temp cleanup and final-flush guards alongside the PR changes.

I have not folded the five fixes from your review into the rebase, so the branch is ready for the prepared fixes and tests you offered to push.

@nwparker nwparker removed the P0 label Aug 19, 2026
@kazu-42
kazu-42 force-pushed the agent/fix-codex-account-removal-atomicity branch from 81461be to e3b0254 Compare September 22, 2026 05:33
@nwparker

nwparker commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

Adversarial review fixes pushed through b538252bbe7094db63da736b48ef2340cc3cc6ab, after updating the branch to main at b407d06c1ecd.

Fixed four defects:

  • P1: partial deletion destroyed ownership evidence. Recursive removal could unlink .orca-managed-home before failing on a held credential file, making every retry refuse the remaining home. Cleanup now removes other entries first and keeps the marker until those deletions succeed.
  • P2: an interrupted final unlink stranded an empty home. Cleanup now accepts an empty home only at the expected account path and uses nonrecursive removal, preserving files created concurrently.
  • P2: already-deleted WSL homes stayed pending. A readable parent listing must prove that the home or an ancestor is absent. An unavailable share keeps the recovery record.
  • P2: recovery records became selectable in older and remote consumers. The existing accounts roster is used by remote switchers and mobile as a selectable list. Recovery records now use optional pendingRemovals; only Settings merges them into guarded cleanup rows. Older clients can ignore the field without offering an account the backend rejects.

The three initial cleanup regressions and the selectable-roster regression failed before their fixes. Seven cleanup regressions pass, including concurrent file creation and unavailable shares. The generated WSL ownership script ran with real Bash against empty, credential-bearing, wrong-owner, and failed-enumeration fixtures. Added Settings snapshot coverage and a WSL switcher regression.

Validation on the current head:

  • 64 account, persistence, and UI suites: 493 tests passed.
  • Full Node/Web/CLI typecheck, changed-code quality across 32 code files, staged lint/React Doctor, formatting, and whitespace checks passed.
  • Fresh hidden Electron app on macOS with an isolated profile and disposable home: actual Settings confirmation, account/home deletion, pending-row guards, refusal of untrusted cleanup, retry, and restart persistence passed. The live IPC snapshot contained a selectable accounts list and separate pendingRemovals. No window was shown or focused; validation apps were stopped.

All current-head CI workflows completed successfully, including the full unit-test shards, relay integration, static analysis/typecheck, Linux/Windows packaging, six persistence platforms, Linux compatibility, and mobile verification. Native Windows file locks, a real WSL distro, and a paired SSH mutation were not exercised locally; those differ from the portable fault tests and rendered macOS checks above.

Before: an active account and a pending cleanup row, with pending selection and reauthentication disabled.

Guarded pending cleanup

After confirmed removal and cleanup retry, then restarting: both managed homes and rows remain removed; the system default is active.

Completed removal survives restart

@nwparker nwparker 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.

Reviewed final head b538252bbe7094db63da736b48ef2340cc3cc6ab. The crash-safe removal approach is valid; the four cleanup and snapshot compatibility defects found during review are fixed and covered by regressions.

Local verification passed 493 tests across 64 suites, full Node/Web/CLI typecheck, and changed-code quality. Actual hidden Electron Settings checks exercised removal, guarded pending cleanup, retry, and restart persistence. All applicable current-head CI checks passed, including the full unit-test shards, Linux/Windows packaging, and six persistence platforms.

No remaining blocking findings. Detailed review and visual proof: #11655 (comment)

@nwparker nwparker 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.

Request changes on the overall design and maintenance cost. This supersedes my earlier approval, which established correctness of the covered failure cases but did not adequately assess whether the full implementation was proportionate.

The PR adds 461 net production-code lines across 17 production files. The cost is more than a retry record: ProfilePreferences.updateSettings gains a Codex-specific temporary mode, withCodexAccountSettingsPreview swaps live settings, and the shared persistence entry points gain preview guards. reconcileCodexAccountRemoval adds a worklist that repeatedly repairs runtime selections until they stabilize, followed by restoration of touched runtimes on failure. These mechanisms add coupled state and failure behavior to the shared Store and account-removal flow.

The acknowledged account/reset-ledger commit before credential deletion is justified. Retaining ownership checks and a durable cleanup record is also justified. Please simplify the removal flow around the existing durable-mutation queue and distinguish failure before the commit from cleanup failure after it. Evaluate synchronizing runtime state after the acknowledged commit, with cleanup kept pending if synchronization cannot finish, rather than introducing a reversible Store preview. Preserve host/WSL lifecycle behavior and the existing safeguards; any changed failure semantics need explicit tests.

The linked issue identifies a reproducible code-review finding, but it does not establish an affected customer or frequency. That does not invalidate the bug. It does mean the broader architecture needs a clearer justification or a smaller implementation before I recommend shipping this PR. Existing tests and green CI remain valid evidence for the current implementation; they do not resolve the scope concern.

@nwparker

nwparker commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

Opened #25308 as a smaller replacement built from main. It commits account removal, reset-credit cleanup and the retry target together through the existing durable writer, then synchronizes the runtime and deletes credentials after acknowledgement. Failed cleanup stays visible and retries at startup.

The replacement is +330/-98 production lines (net 232), versus net 461 here; the entire diff is +1128/-119 across 28 files. It retains ownership recovery safeguards, credits kazu-42 in the commit, and includes actual before/after UI proof. All 785 focused tests and type/quality checks passed locally.

Leaving this PR open with the replacement linked.

@kazu-42

kazu-42 commented Oct 6, 2026

Copy link
Copy Markdown
Contributor Author

I agree with the requested simplification and am closing this PR in favor of #25308.

I independently reviewed its exact head 5b722344671659d26148024395284e4b0f100eba. It uses the existing durable writer to commit removal and recovery information before runtime synchronization and credential deletion, without Store preview mode or the runtime repair worklist. The ownership, retry and selectable-roster safeguards are retained.

Local verification passed 1,445 tests across 160 distinct files, with four platform/opt-in skips, plus Node/Web/CLI typechecks, changed-code quality and whitespace checks. Current-head hosted checks on #25308 were 27 success and 13 skipped. The detailed approval review is on that replacement PR.

#24944 remains a separate Draft. Its dependency is now #25308, and the prepared codex-removal-integration branch based on the older preview design must not be applied. It needs a fresh adaptation and validation after the durability implementation lands.

Closing this PR records the replacement decision; #25308 is still open and has not been merged. The original branch and implementation history are retained.

@kazu-42 kazu-42 closed this Oct 6, 2026
ggbdpq added a commit to ggbdpq/orca that referenced this pull request Oct 25, 2026
… an inactive account is removed

Removing an inactive managed Codex account unconditionally ran
syncForCurrentSelection() and the quota refresh, which blanks the active
account's usage bars and forces a cold probe even though the selection
never changed (stablyai#24942) — the focused follow-up requested in stablyai#11655's
review.

The refresh is now gated on the removal having changed nothing that the
views depend on: the active account id is unchanged, every runtime lane's
selection is unchanged, and the selected host account's home still passes
Orca's existing read-only ownership probe. Any other outcome — selected
account removed, stale persisted selection, system-default host, or an
ownership probe that cannot prove the home — keeps today's refresh
behavior, so the change is fail-safe toward refreshing.

Generated-by: GLM-5.3-Flash (ZCode)
ggbdpq added a commit to ggbdpq/orca that referenced this pull request Nov 5, 2026
… an inactive account is removed

Removing an inactive managed Codex account unconditionally ran
syncForCurrentSelection() and the quota refresh, which blanks the active
account's usage bars and forces a cold probe even though the selection
never changed (stablyai#24942) — the focused follow-up requested in stablyai#11655's
review.

The refresh is now gated on the removal having changed nothing that the
views depend on: the active account id is unchanged, every runtime lane's
selection is unchanged, and the selected host account's home still passes
Orca's existing read-only ownership probe. Any other outcome — selected
account removed, stale persisted selection, system-default host, or an
ownership probe that cannot prove the home — keeps today's refresh
behavior, so the change is fail-safe toward refreshing.

Generated-by: GLM-5.3-Flash (ZCode)
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.

4 participants