Skip to content

Stage cross-device Codex home promotion beside its destination - #1851

Merged
mergify[bot] merged 2 commits into
mainfrom
lean178/1125-exdev-staging
Nov 26, 2026
Merged

mergify[bot] merged 2 commits into
mainfrom
lean178/1125-exdev-staging

Conversation

@eowca

@eowca eowca commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Stage cross-device Codex home promotion beside its destination

Acceptance

  • Keep the existing rename on the same filesystem. On EXDEV, stage a complete copy on the target filesystem and publish it atomically without replacing an existing target.
  • Keep the original when staging or publication fails. After success remove the original and let the existing mirror step link the shared entry.
  • Verify successful selection and an interrupted copy on two filesystems using the account helper test harness.

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 bdb5e70d9778

  • uv run --group dev ruff check src tests: exit 0
  • uv run --group dev tach check: exit 0
  • uv run --python 3.14 python scripts/check_architecture_docs.py: exit 0
  • scripts/size_budget.sh: exit 0
  • uv run --group dev pytest -q: exit 0

Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

Review

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>

@loopzero-feder-positronics loopzero-feder-positronics Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread tests/test_ai_accounts.py
with pytest.raises(TimeoutError, match="provider HTTP request timed out"):
helper._http(request, timeout=1)

@pytest.mark.parametrize("outcome", ["published", "copy failed"])

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@eowca
eowca marked this pull request as ready for review November 26, 2026 11:50
@eowca

eowca commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

@Mergifyio queue

@mergify

mergify Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

🚫 Left the queue · conflict with base branch

5 min in the queue, with no time running CI.

So far

Reason

The pull request conflicts with main

Conflicting file: tests/test_ai_accounts.py

Before this, the pull request was held in the queue behind 1 pull request ahead of it.

To get back in the queue

  • You should update or rebase your pull request. A pull request in a stack is updated by rebasing the stack onto the branch it conflicts with. A pull request queued by a rule comes back to the queue once updated, as long as the rule still matches.
  • If it was queued with a command, update it, then comment @mergifyio queue to queue it again.

Times in UTC · dashboard · how the merge queue works

@mergify mergify Bot added the queued label Nov 26, 2026
@eowca

eowca commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

No description provided.

@mergify mergify Bot added dequeued and removed queued labels Nov 26, 2026
Co-Authored-By: Codex <noreply@openai.com>

@loopzero-feder-positronics loopzero-feder-positronics Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@mergify mergify Bot removed the dequeued label Nov 26, 2026
@eowca

eowca commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

@Mergifyio queue

@mergify

mergify Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

✅ Merged into main as 691a906 at 12:08 UTC

6 min in the queue, 5 min of it CI.

So far

  • ✅ Entered the queue Thu 26 Nov, 12:02 · rule main · triggered by @eowca with the @mergifyio queue command
  • ✅ Passed · draft #1867
  • ✅ Merged 12:08 · 691a906 · squash
3 merge conditions met
  • github-review-approved · required by GitHub repository ruleset rule main: PR only, Mergify queue, existing checks required
  • any of · required by GitHub repository ruleset rule main: PR only, Mergify queue, existing checks required:
    • check-success = checks
    • check-neutral = checks
    • check-skipped = checks
  • any of · required by GitHub repository ruleset rule main: PR only, Mergify queue, existing checks required:
    • check-success = Loop-zero Eligibility
    • check-neutral = Loop-zero Eligibility
    • check-skipped = Loop-zero Eligibility

Times in UTC · dashboard · how the merge queue works

@eowca

eowca commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

No description provided.

@mergify
mergify Bot merged commit 691a906 into main Nov 26, 2026
18 checks passed
@mergify mergify Bot removed the queued label Nov 26, 2026
@eowca
eowca deleted the lean178/1125-exdev-staging branch November 26, 2026 12:10
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.

Sync extra Codex homes when account state and the main home are on different filesystems

1 participant