Repository navigation
🤖 fix: claim a batch of remote background record names in one exec - #5504
Merged
Merged
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Member
Author
|
Readiness record for head 0c0c292:
Generated with |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
On SSH/Coder, Docker, devcontainer and multi-project runtimes, a background spawn now claims its record name in one exec round-trip for up to 8 candidates (
job,job (2), …). Before, every taken candidate cost one exec, so a display name used in k earlier app sessions cost k+1 execs per spawn.Refs #5485 (item 2 only). Item 1 (suffixes still grow across sessions because remote records are never pruned) stays open: a lock-free remote prune races another backend's fresh claim, so it needs two-backend evidence (class B in the triage comment).
Background
The #4889 fix claims a remote record name with an atomic
mkdir(no-p) and never reuses an existing directory, even a settled one.spawn()calledclaimRuntimeSpawnDironce per candidate.Implementation
claimRuntimeSpawnDirtakes a list of candidates. Its script defines aclaimshell function and calls it per candidate in order: the firstmkdirthat succeeds prints__MUX_SPAWN_NAME_CLAIMED__:<index>:and exits; an existing entry (directory, file or dangling symlink) moves on; any othermkdirfailure exits 1, so the caller aborts as before. When every candidate exists, it prints the held marker andspawn()tries the next batch.spawn()reserves every candidate inreservedProcessIdsbefore the await, the same way it already reserved the single name. So a concurrent same-name spawn in this backend never targets a batch member and never releases a name this spawn claimed. After the reply, only the claimed name stays reserved (on error, only the first candidate, which the existing disposer releases).mkdirclaim, so theBgSpawnNamemodel'sAtomicClaimfix probe still describes the code.formal/background-processes/check.shpasses on this head with every EXPECT entry matching. The model's line citations are pinned to commit f30a194, so they stay valid.Validation
claims a name used in earlier sessions in one runtime exec on a non-host runtimeseedsreused-job,reused-job (2)andreused-job (3)and counts claim execs. Pre-fix result:backgroundProcessManager.test.tspass,backgroundProcessesFormalRepro.test.tspasses,make static-checkpasses,formal/background-processes/check.shexits 0.Risks
Low to medium, limited to background spawns on non-host runtimes. A wrong index parse would pick the wrong directory, so the parse requires the exact marker form and asserts the index is in range (an assert failure becomes a claim error, which fails the spawn closed). No overlap with #5471, which edits
terminate()in the same file.Generated with
xum• Model:anthropic:claude-opus-5-5• Thinking:high