Repository navigation
🤖 fix: claim remote background record names with an atomic mkdir - #5486
Conversation
|
@codex review |
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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: afe6067511
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
🛡️ Codex Security Review · Automatically triggeredSecurity review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
|
@codex review |
|
Codex Review: Didn't find any major issues. 🎉 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
🛡️ Codex Security Review · Automatically triggeredSecurity review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
Summary
On runtimes whose background records are not on this host (SSH/Coder, Docker, devcontainer, multi-project), a second backend no longer reinitialises a record directory that another backend still tracks. Spawn now claims the name with an atomic
mkdir(no-p) on the runtime, and any existing directory, including a settled one withexit_code, counts as taken. Fixes the reproduced part of #4889 (finding from the background-processes model, #5464).Background
Host-local names are serialised by the
.spawn-name.lockfile lock (MC_name_hostholds). Non-host runtimes had no cross-backend lock, andruntimeSpawnDirMayHoldLiveProcesscalled a directory free when it heldexit_code. So backend B reinitialised the directory backend A still tracked, even when the spawns never overlapped (TLCMC_name_remote_serial), and two concurrent same-name spawns could share one directory (MC_name_remote). A's later output and status reads then described B's command.Implementation
claimRuntimeSpawnDirreplaces the probe:mkdir -p <workspace dir>, thenmkdir <record dir>. Success means this spawn owns the directory. If it exists (or a dangling symlink sits there), the name is held and the existing suffix loop picks the next name. Any other failure aborts the spawn, as before. No new persisted state, no remote lock. Names,bash:<name>task IDs and monitors keep the existing suffix contract.spawnProcessruns, so two early failures must not leave an empty directory behind (it would hold the name and fail the remote crash-orphan probe closed):spawnProcessremoves the directory on a cwd-check failure, but only when the caller passes the newrecordDirClaimedoption (the manager does for non-host runtimes).rmdir(empty-only).BgSpawnName.tlagets anAtomicClaimfix probe (aClaimstep that creates the directory only when absent). NewMC_name_remote_fixedholds all invariants. The faithful remote rows stay as they are, because they describe the old code.Validation
All with bun 1.3.12.
#4889 … B does not reinitialise the record directory A still tracksis now a plain test. WithbackgroundProcessManager.tsandbackgroundProcessExecutor.tsreverted tomain, it fails at its target (Expected: false,Received: true); the host-local control passes.settled-job (2)and an untouchedexit_code.bun test src/node/services/backgroundProcess*.test.ts src/node/services/tools/bash*.test.ts: 268 pass, 0 fail.TLA_JAVA_OPTS=-Xmx6g formal/background-processes/check.sh: exit 0.make static-check: exit 0.Risks
Low to medium, limited to background spawns on non-host runtimes. A display name used in an earlier session now gets a suffix on those runtimes until
/tmp/mux-bashes/<ws>on the runtime is cleared, and each taken candidate costs one exec round-trip. Tracked in #5485 (a remote prune needs a lock or a race-free design). Host-local spawns are unchanged.Refs #4889 (stays open: its cross-backend evidence requirements are broader), #5464.
Generated with
xum• Model:anthropic:claude-opus-5-5• Thinking:high• Cost:$7.74