Repository navigation
fix: stop hidden worktree spawn while its source is busy - #184345
Conversation
|
🦞👀 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: needs maintainer review before merge. What this changesThis PR forwards invocation cancellation into hidden subagent startup so a busy repository does not delay Stop. Example: A hidden sessions_spawn requests worktreeName="stopped-child" while another operation holds its inherited repository.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review This PR fixes a current cancellation defect with focused signal forwarding and meaningful regression coverage; no actionable defect was found, and hosted checks remain in progress. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe native sessions_spawn tool passes startup context to initial session creation, which delegates repository access to the existing Gateway worktree preparation owner before handing accepted execution to the child. flowchart TD
A[Invocation or configured cancellation] --> B[Sessions spawn tool]
B --> C[Native subagent startup]
C --> D[Initial session creation]
D --> E[Gateway worktree preparation]
E --> F[Repository source lease]
D --> G[Accepted child lifetime]
Technical reviewBest possible solution: Land the existing signal-forwarding fix with its merged cleanup dependency once required checks pass. Do we have a high-confidence way to reproduce the issue? The linked report and regression identify real repository contention, continued acquisition after abort, and the missing signal handoff on current main; this read-only review did not rerun them. Is this the best way to solve the issue? Forwarding the already-composed signal to the existing cancellable preparation owner is the smallest complete repair, and the merged cleanup dependency handles rejection after a committed child write. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against dc90c458ac03. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +6, Tests +114. Total +120 across 7 files. Added test files: 0. View PR surface stats
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. LabelsLabel changes:
Label justifications:
Rating scale6/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. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReviewed October 26, 2026, 7:35 AM ET / 11:35 UTC (Revision 3). |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
b29733e to
6b40817
Compare
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Fixed: stopping a hidden worktree spawn promptly cancels its busy source wait while preserving child cleanup and accepted work. |
…4345) Cancel hidden worktree spawn source waits promptly while preserving exact-child cleanup and accepted child execution. Fixes openclaw#184320.
Closes #184320. Depends on the merged cleanup fix in #184420.
What Problem This Solves
Stopping a hidden native
sessions_spawncall while its inherited registered repository is busy can leave the call waiting for source access. The invocation is already cancelled, but acquisition continues until it settles. Existing authority checks prevent publication afterward; the defect is the unnecessary wait during cancellation.User Impact
The pending spawn cancels initial source acquisition while the independent repository holder remains active. Both the invocation signal and the signal supplied when constructing the tool are supported. Accepted children retain their own workspace preparation and execution lifetime, with existing source selection, wait budgets, descendant Stop behavior, and configuration.
The integrated result also preserves exact-child cleanup if cancellation arrives after the initial child row commits. It consumes the already-merged cleanup capability from #184420; no cleanup implementation is duplicated here.
Why This Change Was Made
The tool already composes the cancellation signals, and worktree preparation already supports cancellation. The native startup path omitted the signal between those owners. Six production lines forward it through the private native context to initial session preparation, retaining the authority and commit guards without binding it to accepted child execution.
Independent review identified the required cleanup dependency: the new signal can reject source settlement after the child write succeeds. A controlled real-upsert/real-abort comparison with a functioning Gateway cleanup dispatcher passed on the original base and failed on the first candidate. The current branch includes #184420 and passes that same boundary. Its separate injected-settlement test remains distinct from the ordinary abort case.
Evidence
The original source-contention regression fails on baseline
95a3ccde1410a55db6262778f8795a9b0ba39b27and on the later target2499f2be3e88e025735268fb622e569d69fcd369: acquisition continues after abort while the holder stays owned. No child publication, new durable session, managed checkout, or physical checkout appears before or after release.On the current integrated tree
6510483c6050b52dd74ed6cf24a61010e7b0520c, changed-source formatting/lint, affected production/test type checks, and 252 tests across 14 directly affected files pass. The Gateway file passes all 27 cases in 153.98 seconds wall time with--maxWorkers=1. Native execution excerpts:The existing keep/delete worktree scenarios end the invocation signal after acceptance and verify that the child still prepares, runs, and follows its cleanup policy. Five parent completion, Stop, and operator-revocation controls also pass. The earlier 734-test run is reused only for unaffected tool/schema/visible/ACP contracts, rather than claimed as new execution.
A separate built CLI/Gateway run exercised the real OpenClaw agent, native tool, SQLite source lease, public
chat.abort, and source-specificagent.wait; only external provider responses were scripted. Stop settled in 62 ms while the independent holder remained owned, with the tool still pending when Stop was sent. No late child or checkout appeared. A normal accepted child remained active after its parent completed and then finished in its own inherited-source checkout. Sanitized native output follows:{ "evidence": "passed", "source": { "tree": "f8f9e88eb613f8f86de17c0f84628321ce9647c8", "cliSha256": "a8780c949e2da1f84d7153ade8ca17975c24495f772b393ab5f7e27108d2a03c", "forcedRuntime": "openclaw" }, "stop": { "sourceContentionObserved": true, "independentHolderPreservedUntilRelease": true, "settledBeforeRelease": true, "observedMs": 62.114718000011635, "noChildRowBeforeOrAfter": true, "noRegisteredOrPhysicalCheckout": true, "childModelRequests": 0, "nativeToolResultObserved": true, "sourceSpecificRpcSettlementObserved": true }, "positive": { "parentSettledWhileChildRunning": true, "childCompleted": true, "inheritedSource": true, "retainedWorktreeOwnedByChild": true }, "cleanup": { "gatewayProcess": "confirmed-stopped", "errors": 0, "totalErrors": 0 } }That built-Gateway run was executed on the earlier signal-patch tree shown in the receipt. Source comparison qualifies it for the unchanged initial acquisition and accepted-child routes; the newly affected post-commit cleanup boundary has fresh integrated proof above. This is built-source runtime/protocol evidence, not a released-package install or real-provider inference. Current-head hosted checks and independent review closure are required before landing.