Repository navigation
Stage cross-device Codex home promotion beside its destination - #1851
Conversation
Architecture-Review: unchanged; managed account selection and the existing home lock are unchanged, and only EXDEV promotion gains destination staging. Co-Authored-By: Codex <noreply@openai.com>
There was a problem hiding this comment.
loopzero primary review by claude on ad1b69bc515e84c6d05dfbdb0d9e2d0ab23fd722, 32.6s: approve (0 critical, 0 important, 4 suggestion)
Settings per native call (launch configuration and CLI claims, not backend attestation):
- Call 1: requested model claude-opus-5-5 (effort medium); CLI-reported model claude-opus-5-5 (effort unknown); configured model claude-opus-5-5 (effort medium)
Native Claude output is retained in the restricted local review receipt.
| if error == errno.EEXIST: | ||
| return | ||
| raise OSError(error, os.strerror(error), target) | ||
| if is_directory: |
There was a problem hiding this comment.
suggestion: Copy-then-delete can drop writes that a running Codex process makes to the original
A same-device os.rename keeps the inode, so a Codex process that already has the entry open (for example, appending to session-index.jsonl or writing under sessions/) keeps writing into what becomes the shared file. On EXDEV the code copies first and then runs shutil.rmtree(entry) / entry.unlink(). Anything written to the original after the copy starts is lost when the original is removed. .codex-sync.lock only stops two syncs from running at once; it does not stop Codex from writing. If another Codex process can use the same extra home while an account is being selected, either document this limitation or check that nothing changed (size/mtime) before deleting the original.
| raise OSError(error, os.strerror(error), target) | ||
| if is_directory: | ||
| shutil.rmtree(entry) | ||
| else: |
There was a problem hiding this comment.
suggestion: A failure partway through removing the original leaves a partial private copy that is never repaired
If shutil.rmtree(entry) fails after publication (permission error, busy file), the shared target exists but the extra home keeps a partly deleted real directory. On later syncs that entry is skipped (target.exists()), and the mirror step also skips it (dst.exists()), so the account keeps seeing the incomplete copy for good. A crash between renameat2 and the removal leaves the same state with a full copy. One fix is to first rename the original to a hidden name in its own home (same device) and then remove it, or to remove an existing non-symlink entry on a later sync when the shared target already exists.
|
|
||
| # The private staging directory is also excluded from future mirroring | ||
| # by shared() if the process is interrupted before cleanup. | ||
| with tempfile.TemporaryDirectory(dir=target.parent, prefix=".codex-sync-", suffix=".lock") as directory: |
There was a problem hiding this comment.
suggestion: Staging directories left by an interrupted sync accumulate in ~/.codex
shared() excludes the .codex-sync-*.lock staging directories from mirroring, but nothing ever deletes them. A SIGKILL or power loss during a large copytree leaves a full copy of the entry in CODEX_MAIN. While still holding the sync lock, consider removing stale .codex-sync-*.lock directories at the start of _sync_codex_home.
| with pytest.raises(TimeoutError, match="provider HTTP request timed out"): | ||
| helper._http(request, timeout=1) | ||
|
|
||
| @pytest.mark.parametrize("outcome", ["published", "copy failed"]) |
There was a problem hiding this comment.
suggestion: The new test covers only files, and the copy-failure stub cannot reach the directory path
The test moves only a regular file. shutil.copytree binds copy_function=copy2 when the module is defined, so monkeypatching helper.shutil.copy2 would not interrupt a directory copy anyway. As a result, the copytree/rmtree branch has no automated coverage. Add a directory case, for example a nested sessions/ directory, and interrupt it by patching helper.shutil.copytree. Also, PEP 8 expects two blank lines before the new top-level decorator.
|
@Mergifyio queue |
🚫 Left the queue · conflict with base branch5 min in the queue, with no time running CI. So far
Reason The pull request conflicts with Conflicting file: Before this, the pull request was held in the queue behind 1 pull request ahead of it. To get back in the queue
Times in UTC · dashboard · how the merge queue works |
|
No description provided. |
Co-Authored-By: Codex <noreply@openai.com>
There was a problem hiding this comment.
loopzero delta review by claude on bdb5e70d9778ba753d95d3deb93af9132304d8d9, 10.1s: approve (0 critical, 0 important, 0 suggestion)
Settings per native call (launch configuration and CLI claims, not backend attestation):
- Call 1: requested model claude-opus-5-5 (effort medium); CLI-reported model claude-opus-5-5 (effort unknown); configured model claude-opus-5-5 (effort medium)
Native Claude output is retained in the restricted local review receipt.
|
@Mergifyio queue |
✅ Merged into
|
|
No description provided. |
Stage cross-device Codex home promotion beside its destination
Acceptance
Notes
The tests add 25 lines and the change adds zero lines under src. Scratch checks also covered nested directory contents, symlinks and a destination created during staging.
Base
main @ 6efba5d
Validation
Recorded for
bdb5e70d9778uv run --group dev ruff check src tests: exit 0uv run --group dev tach check: exit 0uv run --python 3.14 python scripts/check_architecture_docs.py: exit 0scripts/size_budget.sh: exit 0uv run --group dev pytest -q: exit 0Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.Review