Skip to content

fix: keep workspace preparation pending during source contention - #184672

Merged
shakkernerd merged 3 commits into
mainfrom
workspace-source-wait
Oct 26, 2026
Merged

shakkernerd merged 3 commits into
mainfrom
workspace-source-wait

Conversation

@shakkernerd

@shakkernerd shakkernerd commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #184272

What Problem This Solves

An accepted workspace request can fail after about 30 seconds when another operation temporarily owns its registered repository. The workspace service already has a longer shared contention budget, but project acquisition uses a separate limit. The same premature failure can occur before checkout, between preparation stages, or while binding the completed workspace to its session.

User Impact

Registered-source waits now use the existing 30-minute creation contention budget. When access returns, preparation continues at its current stage with the selected source, owner, name and base. An already completed checkout or setup is retained while publication waits.

Unrelated repositories keep the allocation independence delivered by #184138. The hard capacity limit, source checks, native-process settlement and cleanup policy are unchanged. There is no new configuration option, persistent representation or public protocol field. Cancellation continues through the existing request owners. This change incorporates the landed hidden-spawn cancellation and committed-child cleanup fixes from #184345 and #184420.

Why This Change Was Made

Related draft #184304 addresses service-side waiting. This contribution also carries the budget through Gateway preflight, the required foreground title read, and final session binding, with the native caller regressions described below.

One acquisition helper uses the existing wait-budget owner and stops charging when the source callback begins. Its budget type lives in the shared worktree contract, so callers do not import the allocation implementation for that type. Gateway preflight, service creation and final binding share the same request-local budget. Immediate reservation attempts retain their typed busy outcome, so the existing safe release-and-reentry path still runs outside global allocation. Later source contention waits at the affected stage rather than restarting creation or setup.

Optional title generation keeps its independent background lifetime and existing deadline; only its required foreground read shares preparation waiting. Existing project-source discovery helpers move into one module to keep the preparation owner within the repository's line limit.

Evidence

The real registered-project/Git-queue/SQLite reproduction on 95a3ccd completed an unrelated workspace, then failed the waiting request after 32.4 seconds. A later oracle on main at 5f1d487 still fails all three source-wait cases: reservation, publication after setup, and Gateway preparation/final binding. The patched composition passes those owner paths and the native Git cleanup-uncertainty check.

The current tree passes changed formatting/lint, the line-cap and import-cycle guards, all selected production/test type groups, and 65 tests across default-base recovery, pending worktree slots, and Gateway preparation. The newly landed recovery caller imports the wait-budget type from its shared owner; no runtime statement changes in that adaptation.

Real Gateway/browser proof keeps the original request pending past 34 seconds and reload, then completes the same session and run after source release. A separate Stop case observes chat.abort and verifies no late checkout, branch or provider request. An unrelated repository completes while the source remains held. These browser cases use the real default sandbox and a scripted loopback model. The matched baseline recording shows the original failure; its later obsolete-locator assertion failed, so the entire baseline command is not reported as passing.

A separate actual OpenAI case through the OpenClaw runtime passes: the agent uses a tool to read a fresh marker from the persisted workspace and returns it, with selected commit, owner, session cwd and binding verified. The three CLI/session/workboard caller suites also pass. Those results and the captures recorded on 64d6c9e, plus the tested 5f1d487 composition, remain applicable after the type-only caller adaptation and qualified upstream changes; current default-base interaction tests cover the newly landed recovery capability.

One earlier worker-authority test had an inherited message mismatch. Exact base/candidate comparison preserved its original assertion and verified no dispatch, binding or leaked checkout on both. Main carries the expectation correction in #184667; this PR does not relax the assertion.

Five alternating ordinary-path pairs after one excluded warmup show unchanged work counts. First-create median/p95 was 1469/1472 ms on the baseline and 1450/1454 ms on the candidate; subsequent creates were 544/550 ms and 541/544 ms. Both made three source acquisitions and four project resolutions, with 22 Git starts for the first create and 21 subsequently. No 20% timing-regression threshold was triggered. These are measurements of that recorded registered-source workload, not production throughput claims.

Current-head hosted CI passes. Independent review is clean, and automated review reports Platinum with no findings.

Visual evidence

Open preview

Before After
Baseline fails the accepted request and offers Try again while its repository remains busy The same accepted request remains pending with Stop available after repository contention and reload

Original request continues after release; a separate request is stopped while waiting

workspace-source-wait.mp4

Visual verification

  • Baseline: 9532824
  • Exact head: 64d6c9eb1681fc67c7dd91141386db1f8dcb368a
  • Scenario: Accept a workspace request through the Gateway API while its registered repository is held; finish an unrelated repository, wait past the former 30-second deadline, reload, then release or click Stop. Browser model replies use a scripted loopback provider.
  • Runtime/build: Real isolated Gateway and default sandbox; runtime tree 8509caca7d91af4659bb6d6825cc002a8d648174; unchanged UI asset sha256 fde621896731a0184190aaa80e43fdb772b16f27077f1f527668b3252876ec89
  • Repository held: Original 32-second wait; candidate still pending at 34.6 seconds after reload. The visible elapsed counter restarts on reload.
  • Continuation: Same session/run/owner/name/source/base; one scripted model reply after release
  • Stop: Observed chat.abort; no owned checkout/branch or model request after settlement
  • Isolation: Unrelated repository completes while the busy source remains held
  • Baseline 9532824 reproduces the source-lease failure. Media predates a later obsolete-locator failure; the entire baseline command did not pass.
  • Candidate continuation and isolated Stop assertions passed on tree 8509caca.
  • All screenshots and full timelines inspected in 1-second frames; no frame-level motion or full-frame playback claim.
  • Original recordings, source identities and media digests retained through assessment.

@clawsweeper

clawsweeper Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime agents Agent runtime and tooling size: L labels Oct 26, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 26, 2026
@clawsweeper

clawsweeper Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR shares the existing creation contention budget across registered-source preparation, checkout publication, and final session binding.

Example: A registered repository remains busy for 35 seconds during workspace creation.

  • Before: The accepted request fails after about 30 seconds and requires another attempt.
  • After: The same request remains cancellable and continues after source release within its remaining 30-minute contention budget.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, source-consistent repair with meaningful regressions and supplied product proof; exact-head CI remains in progress.
Proof confidence 🐚 platinum hermit (4/6) ✨ media proof bonus Sufficient (screenshot): The supplied isolated Gateway/default-sandbox scenario exercises registered-source contention beyond the former deadline, reload, continuation of the original session, unrelated progress, and Stop; inspected screenshots support the visible change, and the body records actual-model workspace consumption and cancellation outcomes on the earlier proven revision.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: An accepted workspace request fails while its registered repository is temporarily busy, forcing the user to retry.
Reason: The maintainer-authored report and PR establish the intended correction, and the implementation preserves the existing allocation, ownership, and cleanup contracts.

Merge readiness

✅ Ready for maintainer review

Keep this PR open: it fixes a current-main workspace-creation failure, preserves existing ownership and cancellation checks, and has no actionable findings.

Priority: P2
Reviewed head: 78780558b17f42c3700cedacfd89a6c3150f5071

Before merge

None.

Findings

None.

Agent review details

How this fits together

Gateway session creation passes selected project access into the managed-worktree service, which reserves capacity, prepares a checkout, publishes its registry record, and binds it to the session.

flowchart TD
 A[Session creation] --> B[Shared contention budget]
 B --> C[Registered source acquisition]
 C --> D[Capacity reservation]
 D --> E[Checkout and setup]
 E --> F[Registry publication]
 F --> G[Final session binding]
 B --> G
Loading

Technical review

Best possible solution:

Retain one acquisition-only budget across preparation and final binding while preserving immediate reservation, current-source checks, cancellation, and completed setup.

Do we have a high-confidence way to reproduce the issue?

Current-main source exposes the separate 30-second limit, and the linked issue documents a real registry/Git/SQLite failure supported by the inspected baseline screenshot.

Is this the best way to solve the issue?

The patch corrects the competing deadline at the existing accounting owner, covers later preparation stages, and moves discovery helpers without creating a parallel implementation.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against eaaa6f1b1376.

Provenance checked

  • Registered-source waiting deadline changes intended behavior with a stated reason (95a3ccd: Release global allocation during project contention while retaining the earlier project's bounded wait.)
  • Cumulative acquisition-only accounting keeps the original intent (c6168a9: Share contention time across creation retries without charging admitted preparation or preventing uncontended publication.)
  • Finite source scopes and final commit authority keeps the original intent (cfec084: Resolve project state through worker-owned finite scopes while preserving cancellation, stale-source refusal, and effect-time authority.)
  • Independent session-title lifetime keeps the original intent (f8b8956: Let worktree callers bound their wait without canceling shared naming work.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

  • Verified introduced patch: Reviewed the pinned merge-base-to-head hunks, their original source, affected callers, and regression coverage; the checkout remained clean. (78780558b17f)
  • Current main still contains the defect: Current main retains a separate PROJECT_CHECKOUT_WAIT_MS source counter despite the longer creation budget; project checkout acquisition defaults to 30 seconds. (src/agents/worktrees/service-preparation.ts:116, eaaa6f1b1376)
  • Existing accounting owner reused: The acquisition helper ends accounting before protected work starts and preserves explicit zero-wait reservation attempts, allowing allocation release and normal reservation re-entry. (src/agents/worktrees/allocation.ts:134, 78780558b17f)
  • Distinct regression coverage: Tests exercise real project, Git, and registry owners with controlled clocks: continued reservation, unrelated progress, publication without repeated setup, cancellation, shared-budget exhaustion, and final binding without charging protected work. (src/gateway/server.worktree-preparation.test.ts:192, 78780558b17f)
  • Supplied product proof inspected: The downloaded before screenshot shows the failed reply and Try again; the after screenshot shows workspace preparation with Stop available. The PR records continuation after release, independent repository progress, cancellation with no late checkout or model request, and an actual-model workspace marker read. Video preparation failed with 'ffprobe failed: spawnSync ffprobe ENOENT'; no browser playback tool was available. The linked gist was inaccessible to the integration and its raw host was blocked, which are reviewer infrastructure limits rather than contributor defects. (64d6c9eb1681)
  • Previous finding resolved: WorktreeWaitBudget now belongs to shared types, and checkout, naming, Gateway preparation, and the newly landed base-preparation caller import it there; REST commit patches verify the type-only adaptations. (src/agents/worktrees/types.ts:12, 78780558b17f)

Likely related people:

  • Shakker: Raw commit 95a3ccd adds src/agents/worktrees/service-preparation.ts:190 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 95a3ccde1410; files: src/agents/worktrees/service-preparation.ts)
  • Peter Steinberger: Raw commit c6168a9 adds src/agents/worktrees/allocation.ts:101 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: c6168a9597e8; files: src/agents/worktrees/allocation.ts)

PR surface

Source +75, Tests +256, Docs 0. Total +331 across 12 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 9 215 140 +75
Tests 2 269 13 +256
Docs 1 1 1 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 12 485 154 +331

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #184272
Summary: This PR is the consolidated candidate fix for the registered-source timeout report.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: Temporary same-project contention causes recoverable workspace-creation failures and manual retries, with no demonstrated data loss.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.
  • proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (2 earlier review cycles)
  • reviewed 2026-10-26T13:40:21.006Z sha 0003f1c :: needs changes before merge. :: [P2] Move the wait-budget type out of the allocation implementation
  • reviewed 2026-10-26T15:41:53.193Z sha 64d6c9e :: needs maintainer review before merge. :: none

Reviewed October 26, 2026, 1:11 PM ET / 17:11 UTC (Revision 3).

@shakkernerd

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Oct 26, 2026
@shakkernerd
shakkernerd force-pushed the workspace-source-wait branch from 64d6c9e to 7878055 Compare October 26, 2026 17:04
@shakkernerd

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 26, 2026
@shakkernerd
shakkernerd merged commit 808672d into main Oct 26, 2026
153 checks passed
@shakkernerd
shakkernerd deleted the workspace-source-wait branch October 26, 2026 17:55
@shakkernerd

Copy link
Copy Markdown
Contributor Author

Fixed: accepted workspace requests now wait through temporary repository contention and continue without repeating completed setup.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 27, 2026
…nclaw#184672)

Keep accepted workspace preparation pending during temporary source contention, sharing the existing wait budget through checkout and final session binding without repeating setup.

Fixes openclaw#184272.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation gateway Gateway runtime P2 Normal backlog priority with limited blast radius. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: L status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: workspace preparation fails after 30 seconds of registered-source contention

1 participant