Repository navigation
fix(worktrees): allow concurrent empty-workspace dispatches - #179240
Conversation
Scope known session source reads to their worktree and owner selection before awaiting registry reads. Preserve selected-source invalidation and cover concurrent empty workspaces at dispatch preparation.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
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. |
|
Landing note for head
All other required checks are green, the concurrent create-and-prepare reproduction fails on base and passes here, own-worktree changes still reject, and Codex autoreview is clean. Landing via the inherited-failure admin exception. |
…#179240) Concurrent empty-workspace dispatches could fail with 'Spawn parent managed worktree changed; retry from its current session' (seen live when three cloud sessions dispatched together). Dispatch and spawn-parent preparation captured a registry-wide worktree revision for the async lookup, so an unrelated sibling registration invalidated the guard even though the session's own worktree was unchanged. When the worktree and owner are already known, the read guard is now scoped to that row and owner selection; discovery reads keep the registry-wide capture until they narrow, and real changes to the session's own worktree still reject. Fixes openclaw#179229
Keep local workspace resolution and retirement guarded by their already-known worktree ID while awaiting the registry reader. Unrelated concurrent publication must not revoke the selected row; identity and removal changes to that row still reject the operation. The native Btrfs morning replay exposed this existing main regression from #166236. Reuse the selection contract introduced in #179240 instead of retrying or serializing the callers. The deterministic regression fails on exact parent 3a6cc65 and passes with this repair, including selected-row revocation controls. Allocate 46 regression-test lines for the real registry/session owner interleave.
Fixes #179229
What Problem This Solves
Fresh-workspace dispatch can fail with
Spawn parent managed worktree changedwhen another session registers an unrelated empty workspace during its registry lookup.User Impact
Independent empty-workspace sessions can prepare and dispatch concurrently. Changes to the selected session's own worktree still reject stale preparation with the existing error.
Why This Change Was Made
The registry guard captured a registry-wide revision before its asynchronous read, even when the session's worktree ID and owner were already known. Scope that read to the known row and owner selection, retaining the existing identity, removal, database-admission, and synchronous effect checks. Dispatch and managed-parent preparation both supply their known binding. Discovery reads retain their existing behavior.
The regression uses actual empty workspaces, session storage, and the dispatch preparation owner with a deterministic barrier. It also covers removal, repository changes, and replacement of the selected owner. The production change adds no state, queries, locks, or retries.
Evidence
resolveWorkerPlacementSessionTarget: reproduced the exact error on basee2f330eb480bin 320.71 s; the same two-session overlap passes with the fix in 201.95 s. Both sessions use real isolated empty workspaces and SQLite session/registry state; no cloud provider is needed.src/gateway/server-worker-placement-session-target.worktree.test.tsto the database-worker lane. The localOPENCLAW_VITEST_RUNTIME=node pnpm test src/gateway/server-worker-placement-session-target.worktree.test.ts --maxWorkers=1run did not reach assertions on the heavily loaded host; the interrupted run took 627.14 s wall time (exit 130). Compiled-worker preparation alone took 264.918 s. This is an incomplete setup run, not a product verdict; PR CI must run the committed regression and broader consumer suites. A queued Testbox attempt was stopped; no remote test result is claimed.pnpm run tsgo:core: passed, 113.36 s wall time.node scripts/run-oxlint.mjs --tsconfig config/tsconfig/oxlint.core.json <changed code/test files>reported only the inheritedeslint(max-lines)failure insession-worktree-preparation.ts: 725 counted lines on the unchanged base, 729 with this change, limit 700. The base failure was independently reproduced with the same rule settings; no lint exception was added.pnpm exec oxfmt --check <all six changed files>andgit diff --check: passed.