Skip to content

fix(subagents): cancel initial hidden worktree source waits - #184343

Closed
wyf027 wants to merge 1 commit into
openclaw:mainfrom
wyf027:fix/hidden-spawn-source-cancellation
Closed

wyf027 wants to merge 1 commit into
openclaw:mainfrom
wyf027:fix/hidden-spawn-source-cancellation

Conversation

@wyf027

@wyf027 wyf027 commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #184320.

When a hidden native sessions_spawn waits for an inherited registered repository, Stop currently closes the invocation's authority guard but leaves source acquisition waiting. Forward the already composed invocation/configured signal through native startup to prepareSessionWorktreeCreation, which already owns cancellable source acquisition.

The optional signal is private startup context. It is consumed by initial preparation and is not added to model arguments, persisted pending-worktree data, child launch requests, or registry records. Existing authority guards and accepted-child lifecycle ownership remain in place. This is independent of #184272 / #184304 (source-wait budget) and #184121 (shared-fetch recovery).

Validation:

  • Linked the actual tool, native spawn, and initial-session modules in a temporary manual harness with explicit substitutes for surrounding dependencies and a controlled held-source wait. On base 7e392e1d4440, all four signal combinations lose cancellation and remain pending after abort until release. With this patch, invocation-only, configured-only, and both composed-signal cancellation cases settle by the 25 ms observation while the source remains held, with zero child writes or launches and no late write after release.
  • Normal acceptance and omitted-signal calls still complete. The harness observes no AbortSignal in durable patches, launch inputs, or registration records. Ten base/fixed scenarios passed.
  • Changed-file formatting and whitespace checks passed. Independent review found no actionable correctness issue. The simplification pass retains only six added lines across four production files, using the existing cancellation owner.

Draft / remaining proof: This local evidence uses dependency substitutes; it is not the reporter's real SQLite lease regression, an isolated Gateway Stop run, or proof of an accepted child's background execution. Those runtime checks, the focused repository suites, and type-aware lint/typecheck remain outstanding. No repository tests were added or modified and no build was run.

The issue discussion and related PR discussions/states were checked before publication; no competing fix for this initial hidden-spawn signal gap was found at that time.

Subsequent overlap (October 26): Maintainer PR #184345 was opened at 07:23:31 UTC, 49 seconds after this PR (07:22:42 UTC). Its production signal forwarding is equivalent and it includes real-contention and accepted-child regression coverage. I read its full body, diff, and both current comments and verified that it remains open, unmerged. Its latest review reports no code findings and is ready for maintainer review; this draft still has the validation gaps above. These are overlapping candidates for the same fix and should be consolidated 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 agents Agent runtime and tooling size: XS triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. 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: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. 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 real behavior proof before merge.

What this changes

This PR forwards invocation cancellation through hidden native spawn startup into initial worktree source acquisition.

Example: A hidden sessions_spawn with worktree=true inherits a registered repository whose checkout lease is held, then the user presses Stop.

  • Before: Source acquisition keeps waiting after the invocation is cancelled.
  • After: The existing source owner receives cancellation and can settle while the repository remains held.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The production wiring is focused and source-correct, but substituted-dependency observations do not satisfy the external PR runtime-proof gate.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is necessary before merge. See Before merge.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Stopping a hidden native spawn can keep waiting for a busy inherited repository after the invocation is already cancelled.
Reason: The maintainer-reported failure has a narrow existing owner, and every introduced hunk serves cancellation propagation without adding settings or changing the child lifecycle.

Merge readiness

⛔ Blocked before merge - 1 item remains

Keep this PR open: it narrowly repairs a current cancellation gap, and no introduced correctness defect was found; the overlapping maintainer PR is not yet ready to supersede it.

Priority: P2
Reviewed head: c8332ab76d935d8cb48c749cf4fa6ba1222f0879

Before merge

  • Add real behavior proof - The body describes real tool, native-spawn, and initial-session modules linked with dependency substitutes, but explicitly leaves real SQLite contention, isolated Gateway Stop, and accepted-child execution unproven; provide redacted runtime logs or terminal evidence showing those paths, removing IPs, API keys, phone numbers, and non-public endpoints. After adding proof, update the PR body, then request a new review with @clawsweeper re-review. The PR author or someone with repository write access can request it.

Findings

None.

Tests

  • Missing end-to-end proof: No committed base-red/head-green real-contention regression or isolated Gateway Stop proof shows settlement before holder release, no late effects, and accepted-child execution surviving the invocation's end.
Agent review details

How this fits together

The sessions_spawn tool prepares a native child through initial session creation, which asks the shared worktree owner for source access before committing child intent.

flowchart TD
  A[Invocation cancellation] --> B[sessions_spawn tool]
  B --> C[Native spawn startup]
  C --> D[Initial session preparation]
  D --> E[Worktree preparation]
  E --> F[Project checkout lease]
  D --> G[Accepted child lifecycle]
Loading

Technical review

Best possible solution:

Carry the composed invocation signal only into existing initial worktree preparation, preserve accepted-child ownership, and consolidate the equivalent fixes when one is ready to land.

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

The maintainer report gives a real held-lease reproduction, and current main visibly drops the signal before an otherwise cancellable acquisition; this read-only review ran no target code.

Is this the best way to solve the issue?

The diff is the smallest complete production repair: it reconnects existing cancellation owners without changing wait budgets, persisted intent, or accepted-child execution.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Hidden managed-worktree preparation and accepted-child ownership keeps the original intent (f2b7222: Reuse shared worktree preparation for hidden native children while leaving later checkout preparation and cleanup with the child's existing lifecycle.)
  • Invocation guards and descendant Stop ownership keeps the original intent (f61b347: Keep native descendant command cleanup associated with the original request and preserve accepted-run ownership during parent Stop.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 2dd328a adds src/agents/subagents/spawn/subagent-spawn-session-patch.ts:284 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 f61b347 adds src/agents/tools/sessions-spawn-tool.ts:658 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: f61b347ee408; files: src/agents/tools/sessions-spawn-tool.ts)

PR surface

Source +6. Total +6 across 4 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 4 6 0 +6
Tests 0 0 0 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 6 0 +6

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #184320
Summary: The canonical issue and two open PRs concern the same missing initial-acquisition cancellation signal; source-wait budgeting and shared-fetch recovery are separate work.

Members:

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

Labels

Label changes:

  • add P2: Stop can unnecessarily wait during hidden-spawn repository contention, with limited scope and no demonstrated data loss or unauthorized publication.
  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Label justifications:

  • P2: Stop can unnecessarily wait during hidden-spawn repository contention, with limited scope and no demonstrated data loss or unauthorized publication.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

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.

Reviewed October 26, 2026, 3:37 AM ET / 07:37 UTC.

@shakkernerd

Copy link
Copy Markdown
Contributor

Closing as a duplicate of #184345, which is already merged. That change forwards cancellation through initial native child preparation and includes regression coverage for source contention and child execution after startup. Thanks for the contribution.

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

Labels

agents Agent runtime and tooling P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: XS status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: Stop waits on busy source access during hidden worktree spawn

2 participants