Skip to content

fix(codex): preserve disk state when account deletion is uncertain - #3687

Merged
lidge-jun merged 3 commits into
devfrom
codex/c-lane-3536-d778
Sep 5, 2026
Merged

fix(codex): preserve disk state when account deletion is uncertain#3687
lidge-jun merged 3 commits into
devfrom
codex/c-lane-3536-d778

Conversation

@lidge-jun

@lidge-jun lidge-jun commented Sep 5, 2026

Copy link
Copy Markdown
Owner

Summary

If saving an account deletion fails after another writer changed the config file, restoring an old snapshot would overwrite that writer's bytes. Keep the previous runtime state, preserve the actual disk bytes, and stop before credential/runtime cleanup when persistence cannot be verified. Missing or unreadable files also remain untouched.

Carries #3536, retaining SB Yoon's two commits and their source provenance. Existing successful-deletion and post-commit cleanup semantics remain intact; the separate management route's second-save contract is outside this layer.

Stack layer 2/5. Depends on #3682 (codex/c-lane-3638-d778); review only this account-persistence delta. Child #3688 carries OAuth configuration on this branch. Merge bottom-up into dev.

Verification

  • Local tests, typechecks and builds are forbidden by the maintainer and were not run.
  • macmini-cf, Bun 1.4.0, exact head 21f3eb212181f65aed4265c7f46f2b5846316e92: six account/config/auth test files — 314 pass, 0 fail. Source SHA256 verified before execution.
  • Independent security review at that head: PASS; no blocking findings.
  • Regression coverage includes changed bytes, missing/unreadable config, different invalid-UTF8 bytes, unchanged-byte save failure, and successful cleanup ordering.
  • Independent security review and hosted current-head CI must pass before merge; draft pending final verification.

Checklist

  • Scope stays focused and avoids unrelated cleanup.
  • Docs or release notes were updated when needed.
  • Security-sensitive changes were reviewed for secrets, auth, and unsafe defaults.

Co-authored-by: SB Yoon 44089734+yansigit@users.noreply.github.com

@coderabbitai

coderabbitai Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true

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.

@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Deterministic PR hygiene checks passed.

@lidge-jun

Copy link
Copy Markdown
Owner Author

리뷰 · 우선순위 74 / 80

이 PR은 Codex 계정 삭제가 실패한 뒤 오래된 스냅샷으로 디스크를 되돌리던 경로를 없앱니다. 지금 HEAD의 src/codex/account-lifecycle.ts restorePersistedConfig는 저장 실패 후 파일이 바뀌어 있으면 atomicWriteFile로 previousBytes를 다시 씁니다. 그 사이에 다른 작가가 쓴 바이트가 있으면 덮어써서, “삭제 불확실” 상황에서 더 위험해집니다. 이 변경은 롤백 쓰기를 제거하고 assertPersistedConfigUnchanged로 바꿉니다. 디스크 바이트가 스냅샷과 다르면 CodexAccountDeleteRollbackError를 던지고, 런타임 설정만 이전 스냅샷으로 되돌리며, credential/runtime cleanup 전에 멈춥니다. 비교는 utf8 문자열이 아니라 Buffer.equals라서, 디코드는 같아도 바이트가 다르면 변경으로 봅니다. 원본 #3536(SB Yoon) carry이고, C 레인 2/5이며 베이스는 #3682입니다.

테스트가 보안 리뷰 수준입니다. pre-write 실패, post-write 후 디스크 유지, 동시 외부 편집 바이트 보존, invalid-UTF8 별칭, missing/unreadable config, 에러 메시지에서 경로·토큰 제거, transient(설정 파일 없음)는 여전히 credential cleanup. 성공 삭제·post-commit cleanup 계약은 유지한다고 본문에 적혀 있습니다. management route의 second-save는 이번 레이어 밖입니다.

계정 삭제는 credential·quota·websocket·config가 한 트랜잭션처럼 보여야 하는 경계입니다. “실패했는데 디스크는 다른 사람 글이고 credential은 지워짐”이 가장 나쁜 결과인데, 이 PR은 그 반대(디스크 존중·cleanup 중단·런타임 복구)를 고릅니다. C 레인에서 Windows 우선순위 다음 층에 둔 것도, 서비스 안정성 다음에 계정 내구성이라는 읽기 순서와 맞습니다.

경로/심볼 restorePersistedConfigassertPersistedConfigUnchanged - 덮어쓰기 롤백 삭제. fail-closed가 핵심입니다.

경로 previousPersistedConfig Buffer - 바이트 단위 스냅샷. 문자열 동등만 보던 구멍도 막습니다.

경로 테스트 concurrent external edit - 외부 port 변경 바이트가 그대로 남고, 런타임은 복구되며 credential은 아직 안 지웁니다.

경로 테스트 unreadable - 사용자 메시지는 고정 sanitize 문장, cause/경로/시크릿 없음, cleanup spy 미호출.

경로 의존 #3682 - C 레인 1층. 이 PR은 그 위의 account-persistence delta만 보면 됩니다.

경로 원본 #3536 - OPEN. 안착 후 landed로 닫으세요.

메인테이너의 판단이 필요한 지점

  • 디스크는 삭제됐는데 런타임/credential이 남은 “갈라진 상태”를 UX에서 어떻게 안내할지(이미 Restart before retrying 메시지)
  • management second-save 계약을 다음 레이어로 언제 붙일지
  • Windows/mac 이외 플랫폼 CI만으로 충분한지

너의 추천
데이터 손실을 막는 방향이 맞습니다. 부모 #3682 + 이 PR CI/보안 리뷰 통과 후 머지하세요. 그다음 #3536을 닫고 #3688 OAuth 보존 레이어로 이어가면 됩니다.

이 댓글은 grok-bot이 작성했습니다

Base automatically changed from codex/c-lane-3638-d778 to dev September 5, 2026 16:55
@lidge-jun

Copy link
Copy Markdown
Owner Author

Owner explicitly authorized admin merging the C-lane stack. Independent security/code review: PASS at 21f3eb212181f65aed4265c7f46f2b5846316e92. Remote focused verification: 314 pass / 0 fail. Exact-head Cross-platform CI run 33978685977 succeeded with actual Linux/macOS suites and typecheck. Admin merge uses the owner-authorized review bypass; no self-approval is claimed. Original author attribution is retained.

@lidge-jun
lidge-jun marked this pull request as ready for review September 5, 2026 17:09
@lidge-jun
lidge-jun requested a review from Ingwannu as a code owner September 5, 2026 17:09
@lidge-jun
lidge-jun merged commit ed7ecc5 into dev Sep 5, 2026
30 of 35 checks passed
@lidge-jun
lidge-jun deleted the codex/c-lane-3536-d778 branch September 5, 2026 17:09
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 5, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-05T17:11:48.871756Z 21f3eb2 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants