Skip to content

fix: keep new session workspace setup responsive during cleanup - #147358

Merged
VACInc merged 1 commit into
mainfrom
openclaw/diagnosing-failing-test-sessions-and-determining-next-steps
Sep 13, 2026
Merged

VACInc merged 1 commit into
mainfrom
openclaw/diagnosing-failing-test-sessions-and-determining-next-steps

Conversation

@roboclaw-bot

@roboclaw-bot roboclaw-bot commented Sep 13, 2026 •

Copy link
Copy Markdown
Collaborator

Closes #147355

What Problem This Solves

Fixes new worktree-backed sessions waiting behind unrelated background cleanup inspection.

User Impact

Foreground workspace preparation can finish while a slow cleanup inventory waits. Existing capacity, ownership, Git-write, cancellation, and shutdown safeguards remain in force. No configuration changes or migration are required.

Why This Change Was Made

Preparation and maintenance shared one serial Git worker. Keep both workloads serial, but give maintenance its own pool under the existing owner so a pre-lease cleanup scan cannot monopolize preparation. The extra worker uses the existing idle retirement and global pending-operation bound.

Removal that already holds the shared allocation lease still serializes with creation; this patch does not bypass that safeguard.

Evidence

  • Original implementation: both added worker regressions fail after approximately 10 seconds waiting behind held maintenance.
  • Patched implementation: 71 tests pass—11 Git-worker lifecycle tests plus 60 worker-pool, capacity, and removal-lease tests. Cancellation, subprocess cleanup, snapshot ownership, HEAD changes, restart settlement, and disk-headroom serialization remain covered.
  • Isolated real-service before/after: held a pre-lease ignored-file inspection in ManagedWorktreeService.gc and called ManagedWorktreeService.create in another repository. Original code timed out after 10 seconds; patched code created and registered the verified checkout in 133 ms while maintenance was still held.
  • Independent autoreview: scoped-clean through P2.
  • Complete changed-file gate passed, including core/core-test typechecks, lint, formatting, and guards.
  • Full pnpm build passed on the unchanged published head in a clean sequential run. The first attempt hit the compiler input-consistency guard during concurrent validation; the retry required no code changes or guard bypasses.

Found while investigating chats that timed out with unfinished workspace setup. The exact historical timeout source remains uncertain; the blocking defect above is independently reproduced. Archived user sessions were not restored or modified by the repair.

Reported by @VACInc.

Separate serial worktree maintenance from preparation within the Git worker owner. Preserve shared capacity leases, ref serialization, cancellation, and shutdown settlement.

Closes #147355

Co-authored-by: VACInc <[email protected]>
@clawsweeper

clawsweeper Bot commented Sep 13, 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 size: S maintainer Maintainer-authored PR labels Sep 13, 2026
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. 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. labels Sep 13, 2026
@clawsweeper

clawsweeper Bot commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 13, 2026, 4:38 PM ET / 20:38 UTC (Revision 2).

ClawSweeper review

What this changes

The PR separates background workspace inspection and snapshots from foreground preparation into serial Git worker pools so new sessions can prepare their workspaces during slow maintenance.

Merge readiness

✅ Ready for maintainer review

This remains a useful, focused fix for a bottleneck still present on current main. No blocking defects were found, and the updated build explanation resolves the previous review's sole follow-up.

Priority: P1
Reviewed head: c4dafe8d50670f72ecfd893faedf4ab7fab14ec9

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused owner-level repair with meaningful regression coverage, preserved lifecycle safeguards, and the previous build concern addressed.
Proof confidence 🌊 off-meta tidepool Not applicable: The supplied maintainer/bot context exempts this PR from the external-contributor proof gate. Its body additionally reports the relevant isolated real-Git service result: creation completed and registered a verified checkout while cleanup remained held; this review did not independently rerun that observation.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The supplied maintainer/bot context exempts this PR from the external-contributor proof gate. Its body additionally reports the relevant isolated real-Git service result: creation completed and registered a verified checkout while cleanup remained held; this review did not independently rerun that observation.
Evidence reviewed 8 items Verified introduced change: The merge-base-to-head diff changes pool selection and shutdown registration within the existing Git-operation owner. The supplied verified test-merge comparison also confines the merge result to these production and lifecycle-test changes.
Current-main necessity: Fetched main still routes every worktree operation through one serial pool, including foreground preparation and cleanup inspection. It does not contain this isolation fix.
Host safeguards remain authoritative: Creation acquires the shared allocation lease before sizing and provisioning; removal acquires the same lease before snapshotting. Cleanup inspection can run before acquiring it. Git execution still checks current authority and serializes ref mutations in the host.
Findings None None.
Security None None.

How this fits together

Managed worktrees give sessions separate Git checkouts. The Git worker handles their sizing, file inventories, and snapshots, while the host service retains allocation leases, subprocess supervision, and ownership checks.

flowchart TD
  A[New session workspace request] --> B[Host allocation lease]
  B --> C[Serial preparation worker]
  D[Background cleanup and snapshots] --> E[Serial maintenance worker]
  C --> F[Host Git execution and write guards]
  E --> F
  F --> G[Prepared checkout or maintenance result]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +12, Tests +98. Total +110 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 19 7 +12
Tests 1 98 0 +98
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 117 7 +110

Review metrics

Metric Value Why it matters
Worker capacity 1 additional lazy worker; 30-second idle retirement; 128-operation global bound retained The bounded extra worker is the explicit resource cost of isolating foreground preparation from maintenance.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #147355
Summary: This PR is the candidate fix for the explicitly linked workspace-preparation bottleneck.

Members:

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

Technical review

Best possible solution:

Keep preparation responsive through the existing worker owner while preserving shared allocation leases, host-side write guards, and complete cancellation settlement.

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

Yes: holding a pre-lease cleanup Git inventory and creating a worktree in another repository exposes the shared-worker bottleneck on current main. Source and the reported before/after service run support this path; this review did not execute it.

Is this the best way to solve the issue?

Yes: separating the two serial workloads inside the existing owner removes the demonstrated contention without replacing allocation, authorization, or Git-write safeguards.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P1: The source-proven queue bottleneck blocks new worktree-backed session preparation while unrelated cleanup waits.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The supplied maintainer/bot context exempts this PR from the external-contributor proof gate. Its body additionally reports the relevant isolated real-Git service result: creation completed and registered a verified checkout while cleanup remained held; this review did not independently rerun that observation.

Evidence

What I checked:

  • Verified introduced change: The merge-base-to-head diff changes pool selection and shutdown registration within the existing Git-operation owner. The supplied verified test-merge comparison also confines the merge result to these production and lifecycle-test changes. (src/infra/git-worker.ts:67, c4dafe8d5067)
  • Current-main necessity: Fetched main still routes every worktree operation through one serial pool, including foreground preparation and cleanup inspection. It does not contain this isolation fix. (src/infra/git-worker.ts:60, 1c1affa936f6)
  • Host safeguards remain authoritative: Creation acquires the shared allocation lease before sizing and provisioning; removal acquires the same lease before snapshotting. Cleanup inspection can run before acquiring it. Git execution still checks current authority and serializes ref mutations in the host. (src/agents/worktrees/service.ts:451, c4dafe8d5067)
  • Behavioral regression coverage: The added table-driven regression holds the real host Git exchange for cleanup inspection or snapshot work, verifies four preparation operations finish in another repository, and confirms a second maintenance operation remains serialized. Existing cases cover cancellation, shutdown, temporary-directory cleanup, and interrupted snapshot publication. Tests were inspected, not executed during this read-only review. (src/infra/git-worker.lifecycle.test.ts:199, c4dafe8d5067)
  • Prior follow-up resolved: The supplied complete PR body reports that the unchanged published head passed a clean sequential full build; the earlier failure was the compiler input-consistency guard during concurrent validation. This addresses the previous review's request to classify that failure. The body also reports real-service creation in 133 ms while pre-lease cleanup remained held, compared with a 10-second baseline timeout. (c4dafe8d5067)
  • Merged area history: Git history and GitHub commit metadata connect the existing worker implementation to fix: reduce repeated Git work during repository requests #146273. GitHub reports git-worker.ts was added by that merged change and identifies steipete as its commit author. Local blame/follow traversal encountered unavailable objects, so historical routing also uses the inspected raw parent record and GitHub patch. (src/infra/git-worker.ts:81, f0fafba02efd)

Likely related people:

  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (1 earlier review cycle)
  • reviewed 2026-09-13T20:06:24.436Z sha c4dafe8 :: blocked before merge. :: none

@roboclaw-bot
roboclaw-bot marked this pull request as ready for review September 13, 2026 20:28
@VACInc
VACInc merged commit 912ae8d into main Sep 13, 2026
260 of 261 checks passed
@VACInc
VACInc deleted the openclaw/diagnosing-failing-test-sessions-and-determining-next-steps branch September 13, 2026 21:28
vincentkoc added a commit to Alix-007/openclaw that referenced this pull request Sep 13, 2026
…1-prep

* commit '912ae8d96e5964dfdcdf419b79613fb941cdf0a8': (350 commits)
  fix: keep workspace preparation responsive during cleanup (openclaw#147358)
  docs: alphabetize donors and sponsors and add Red Hat logo (openclaw#147302)
  fix(plugins): retain update authority through doctor effects (openclaw#144316)
  refactor(qa): share Multipass mount retry lifecycle (openclaw#147084)
  fix(memory): emit one JSON result for command failures (openclaw#147366)
  improve(plugins): speed up cold metadata loading (openclaw#147411)
  fix(sessions): avoid duplicate work after waited child replies (openclaw#147394)
  fix(agents): retain outstanding child results in parent context (openclaw#112623)
  test: preserve native workflow loader selection (openclaw#147403)
  fix: reduce repeated work while polling session pull requests (openclaw#147373)
  test(qa): preserve task cancellation across process replacement (openclaw#147382)
  fix: prevent sidebar refresh storms during session activity (openclaw#147400)
  refactor: simplify skills CLI formatting (openclaw#147368)
  fix: prevent Git checkout certificate failures behind egress proxy (openclaw#147410)
  fix(qa): stop live threads after their process leader exits (openclaw#147386)
  refactor(release): share agent turn retry lifecycle (openclaw#147076)
  fix(ui): keep uploaded images aligned with their prompts (openclaw#147389)
  fix(fs): guard skill reads and bound worker bundle staging (openclaw#147336)
  fix(ci): restore Linux service ownership fixtures (openclaw#147398)
  fix(plugins): preserve manifest permissions when building plugins (openclaw#147393)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 14, 2026
…47358)

Separate serial worktree maintenance from preparation within the Git worker owner. Preserve shared capacity leases, ref serialization, cancellation, and shutdown settlement.

Closes openclaw#147355

Co-authored-by: roboclaw-bot <[email protected]>
Co-authored-by: VACInc <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainer Maintainer-authored PR P1 High-priority user-facing bug, regression, or broken workflow. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S 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]: New session workspace preparation waits behind unrelated cleanup

2 participants