Skip to content

fix: stop hidden worktree spawn while its source is busy - #184345

Merged
shakkernerd merged 2 commits into
mainfrom
hidden-source-stop
Oct 26, 2026
Merged

shakkernerd merged 2 commits into
mainfrom
hidden-source-stop

Conversation

@shakkernerd

@shakkernerd shakkernerd commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Closes #184320. Depends on the merged cleanup fix in #184420.

What Problem This Solves

Stopping a hidden native sessions_spawn call 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 95a3ccde1410a55db6262778f8795a9b0ba39b27 and on the later target 2499f2be3e88e025735268fb622e569d69fcd369: 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:

cleans the committed native child when Stop interrupts startup — passed, 2424 ms
cleans the committed native child when Stop interrupts source settlement — passed, 2193 ms
stops native worktree spawn from its invocation signal while its inherited registered source is busy — passed, 2058 ms
stops native worktree spawn from its configured signal while its inherited registered source is busy — passed, 2056 ms

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-specific agent.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.

@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 gateway Gateway runtime agents Agent runtime and tooling size: S 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. labels Oct 26, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. 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 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.

  • Before: Source acquisition continues after Stop until the acquisition settles.
  • After: The pending spawn settles while the independent holder remains active, without publishing a child or checkout.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A focused repair with shipped-entry-point evidence, distinct regression coverage, and no actionable findings; historical runtime evidence is explicitly qualified.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): Supplied built CLI/Gateway output exercises the native tool, real SQLite source contention, public chat.abort, and source-specific agent.wait, showing settlement before holder release and independent accepted-child completion; fresh integrated boundary output covers post-commit cleanup.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Stopping a pending hidden worktree spawn can remain blocked on a busy inherited repository.
Reason: The maintainer-authored direction restores cancellation through existing owners without changing accepted-child lifetime or adding a user-facing option.

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
Reviewed head: 6b40817af9c726f7b09028d5f241c90ee88c2ec8

Before merge

None.

Findings

None.

Agent review details

How this fits together

The 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]
Loading

Technical review

Best 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

  • Hidden managed-worktree preparation keeps the original intent (f2b7222: Reuse the visible session worktree preparation owner for hidden children while retaining native completion and cleanup.)
  • Invocation cancellation keeps the original intent (f61b347: Compose cancellation and retain native descendant Stop ownership.)
  • Committed provisional-child cleanup keeps the original intent (4575e7c: Capture committed child identity before source settlement can fail so the existing cleanup owner can remove that exact child.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 2dd328a adds src/agents/subagents/spawn/subagent-spawn-session-patch.ts:437 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 2dd328a2a0cc; files: src/agents/subagents/spawn/subagent-spawn-session-patch.ts)
  • Shakker: Raw commit 4575e7c adds src/agents/subagents/spawn/subagent-spawn-session-patch.ts:352 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 4575e7cfb655; files: src/agents/subagents/spawn/subagent-spawn-session-patch.ts)

PR surface

Source +6, Tests +114. Total +120 across 7 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 4 6 0 +6
Tests 3 118 4 +114
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 7 124 4 +120

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #184320
Summary: This PR and the overlapping draft repair the same missing startup cancellation handoff; the merged cleanup repair addresses a distinct settlement failure.

Members:

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

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient.
  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🦞 diamond lobster, so this older rating label is no longer current.

Label justifications:

  • P2: Stop can wait unnecessarily during hidden worktree startup under repository contention, while existing guards prevent late publication.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster 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.

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-26T07:39:03.668Z sha b29733e :: needs maintainer review before merge. :: none
  • reviewed 2026-10-26T08:35:53.062Z sha b29733e :: needs maintainer review before merge. :: none

Reviewed October 26, 2026, 7:35 AM ET / 11:35 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. 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

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 the clawsweeper:intake:bug Preliminary submission classification; full source review pending. label Oct 26, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. 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 9532824 into main Oct 26, 2026
146 of 147 checks passed
@shakkernerd
shakkernerd deleted the hidden-source-stop branch October 26, 2026 12:20
@shakkernerd

Copy link
Copy Markdown
Contributor Author

Fixed: stopping a hidden worktree spawn promptly cancels its busy source wait while preserving child cleanup and accepted work.

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

Cancel hidden worktree spawn source waits promptly while preserving exact-child cleanup and accepted child execution.

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

Labels

agents Agent runtime and tooling gateway Gateway runtime P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor 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: Stop waits on busy source access during hidden worktree spawn

1 participant