Skip to content

🤖 fix: claim a batch of remote background record names in one exec - #5504

Merged
ThomasK33 merged 1 commit into
mainfrom
fix/remote-bg-name-batch-claim
Oct 2, 2026
Merged

ThomasK33 merged 1 commit into
mainfrom
fix/remote-bg-name-batch-claim

Conversation

@ThomasK33

Copy link
Copy Markdown
Member

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() called claimRuntimeSpawnDir once per candidate.

Implementation

  • claimRuntimeSpawnDir takes a list of candidates. Its script defines a claim shell function and calls it per candidate in order: the first mkdir that succeeds prints __MUX_SPAWN_NAME_CLAIMED__:<index>: and exits; an existing entry (directory, file or dangling symlink) moves on; any other mkdir failure exits 1, so the caller aborts as before. When every candidate exists, it prints the held marker and spawn() tries the next batch.
  • spawn() reserves every candidate in reservedProcessIds before 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).
  • Each name keeps the same atomic mkdir claim, so the BgSpawnName model's AtomicClaim fix probe still describes the code. formal/background-processes/check.sh passes on this head with every EXPECT entry matching. The model's line citations are pinned to commit f30a194, so they stay valid.

Validation

  • Test first: claims a name used in earlier sessions in one runtime exec on a non-host runtime seeds reused-job, reused-job (2) and reused-job (3) and counts claim execs. Pre-fix result:
error: expect(received).toBe(expected)
Expected: 1
Received: 4
(fail) BackgroundProcessManager > spawn > claims a name used in earlier sessions in one runtime exec on a non-host runtime
  • New guard: three concurrent same-name spawns from one backend on a remote-like runtime get three distinct directories and never write into a held directory.
  • Post-fix: all 139 tests in backgroundProcessManager.test.ts pass, backgroundProcessesFormalRepro.test.ts passes, make static-check passes, formal/background-processes/check.sh exits 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

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 2, 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-10-02T16:48:56.548350Z 0c0c292 PR opened
🔒 Security Review ✅ Completed 2026-10-02T16:52:31.511192Z 0c0c292 PR opened
ℹ️ 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.

@ThomasK33

Copy link
Copy Markdown
Member Author

Readiness record for head 0c0c292:

  • CI: all checks green on this head.
  • Normal review and security review (automatic, PR opened): both completed on this head with no findings.
  • Final independent check (fresh clean-context agent): READY, no blockers.
  • Assessments used: 3 of 6 (normal 1, security 1, final check 1). Findings: 0.
  • formal/background-processes/check.sh: exit 0, every EXPECT entry matches.
  • Item 1 of 🤖 Remote background record names grow suffixes across sessions after #4889 fix #5485 (suffix growth without a remote prune) stays open, class B in the triage comment.

Generated with xum • Model: anthropic:claude-opus-5-5 • Thinking: high

@ThomasK33
ThomasK33 added this pull request to the merge queue Oct 2, 2026
Merged via the queue into main with commit fef5194 Oct 2, 2026
33 checks passed
@ThomasK33
ThomasK33 deleted the fix/remote-bg-name-batch-claim branch October 2, 2026 17:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant