Skip to content

fix: remove provisional children after startup settlement fails - #184420

Merged
shakkernerd merged 1 commit into
mainfrom
committed-child-cleanup
Oct 26, 2026
Merged

shakkernerd merged 1 commit into
mainfrom
committed-child-cleanup

Conversation

@shakkernerd

@shakkernerd shakkernerd commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #184380

What Problem This Solves

If source settlement rejects after a hidden native child's initial session row commits, startup loses the committed receipt and returns before it binds provisional cleanup. That leaves a durable child session for a startup that was never accepted.

The corrected reproduction is narrower than ordinary cancellation: it keeps the real child write and Gateway deletion path, then deliberately fails source settlement after the commit callback. Ordinary cancellation is a passing control on the base. The issue correction explains the earlier fixture limitation.

User Impact

Failed startup settles the exact provisional child it created. Reset or replacement sessions retain their existing identity protections, and accepted children keep their existing execution and Stop ownership. This requires no configuration or data migration and does not sweep unrelated sessions or worktrees.

Why This Change Was Made

The creation owner now transfers its committed receipt before awaiting source settlement. The existing spawn cleanup owner captures that receipt and remains responsible until the launch pipeline takes over. One finalizer handles the earlier exits, replacing redundant cleanup branches. The cleanup module keeps the session ID and lifecycle revision paired when creation or a committed fork updates ownership.

Evidence

The regression uses the real native spawn tool, session upsert, storage, source commit callback, and Gateway lifecycle deletion. With a deliberately injected settlement rejection, the original production files at 0eb245a leave an extra child row; this patch removes it while preserving the original session inventory and leaving child-run and worktree registries empty. The ordinary cancellation control passes on both revisions.

Changed-file formatting/lint, the line-cap check, and selected production and test type checks pass. Affected cleanup, fork, replacement, authority, attachment, thread-binding, incognito, production-boundary, and direct-caller tests pass. The focused two-case Gateway run took 29.52 seconds including transformation and setup.

Current CI passes on 75dc3d19a0a768f3e26f9229251bc740a7c610d7: all 46 selected jobs succeeded, with 28 unselected jobs skipped. An earlier, unrelated deferred-worktree assertion was reproduced on the unmodified base under Node and pinned Bun, then resolved upstream by #184372. The original case passes on fetched target 54408a978fc91fd20130b6f904534b47c8dfe25a and prospective combined tree fcfff2453de56c224dcf93a9ef22e9c535c953f2; the source-settlement regression still fails on that target and passes with this repair.

A real Gateway/model run passed on the original validated revision 5ab801109acc27449dc8abd86fbd2a940e319531, whose repair is identical to the current revision. The parent requested the hidden child, its real session write committed, and authenticated chat.abort stopped the parent while the fixture held the write return. The source-settlement wrapper then received an explicitly injected failure. The runtime receipt confirms one committed write, removal of that exact child, preservation of another parent's accepted child, no admitted child run, and zero worktree/setup creation. The test took 25.459 seconds, or 55.23 seconds including setup and transformation. This controlled failure is not an ordinary-frequency or natural-failure claim.

The native runner verified source head 5ab801109acc27449dc8abd86fbd2a940e319531 and tree 021f62632b76dc597e697afccd053e4ca0316183. The following captured receipt was emitted after the runtime assertions; the native command then completed with exit 0. Session and run IDs are synthetic fixture identities.

Captured Gateway/model Stop and cleanup receipt
{
  "parent": "agent:main:dashboard:8862a60f-9a7f-48a4-8c26-ebc788e1799b",
  "parentRunId": "0a52486b-1ff6-42bb-a04b-863b5417d501",
  "child": "agent:main:subagent:c6c2dd8d-5f12-4ac8-91d5-d81b1f4b1e4d",
  "sessionId": "676b9fe8-0479-463c-a8bf-02b7a4365eaa",
  "lifecycleRevision": "a7bc9b86-c759-4ab0-b695-4aea9a57cdfb",
  "committedWrites": 1,
  "commitCallbackReturned": true,
  "settlementFailure": "injected",
  "stoppedParent": true,
  "childRemoved": true,
  "acceptedControlPreserved": true,
  "childRegistered": false,
  "childRunAdmitted": false,
  "worktreeCreations": 0,
  "registryAndGitWorktreesUnchanged": true,
  "setupMarkerAbsent": true
}
✓ removes only the unaccepted child after its upsert commits 25459ms
Test Files  1 passed (1)
Tests       1 passed (1)
Duration    55.23s

Current revision 75dc3d19a0a768f3e26f9229251bc740a7c610d7 includes the upstream repair from #184372. The commit-range comparison confirms that this PR's four-file repair is unchanged. The runtime receipt above retains its original tested identity; the combined-result test and inspection of subsequent changes establish that the relevant cleanup behavior is unchanged. Independent engineering review remains clean for this patch. CI is green on the new revision. Its completed exact-head automated review rates readiness, proof confidence, and patch quality Diamond, with no actionable findings.

@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: M 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: 👀 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

Retain a committed child's cleanup receipt before source settlement and remove that child if startup fails before launch.

Example: A hidden sessions_spawn call with worktree: true commits its child session, then source settlement rejects.

  • Before: Startup returns an error while leaving an extra durable child session.
  • After: Startup removes the exact provisional child while preserving other sessions.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) Focused owner-level repair with applicable runtime proof, meaningful regression coverage, successful current-head CI, and no actionable findings.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The supplied Gateway/model run exercises hidden native spawn, a real committed session write, authenticated parent Stop, and injected source-settlement rejection; its captured output confirms exact-child removal and preservation of another parent's accepted child, and all changed-file blobs match the current head.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Failed hidden-child startup can leave an extra durable session even though the child was never accepted.
Reason: The maintainer-authored repair restores existing rollback behavior without adding settings, schemas, or another lifecycle owner.

Merge readiness

✅ Ready for maintainer review

This PR fixes a current provisional-session cleanup gap through the existing lifecycle owner; no actionable introduced defects remain.

Priority: P2
Reviewed head: 75dc3d19a0a768f3e26f9229251bc740a7c610d7

Before merge

None.

Findings

None.

Agent review details

How this fits together

Native subagent startup creates session state, prepares context, and hands ownership to the launch pipeline; failed provisional startup uses guarded Gateway session deletion.

flowchart TD
A[Native sessions_spawn] --> B[Commit child session]
B --> C[Capture cleanup receipt]
C --> D[Settle source]
D --> E[Launch pipeline]
D --> F[Startup failure]
F --> G[Guarded session deletion]
Loading

Technical review

Best possible solution:

Retain committed child identity before settlement and settle failed startup through the existing guarded cleanup owner.

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

The corrected real-persistence regression supplies a precise failing boundary, and current-main source confirms the lost-receipt path; this read-only review executed no target code.

Is this the best way to solve the issue?

The patch repairs receipt custody at creation and consolidates early exits under the existing cleanup owner while preserving pipeline and exact-incarnation protections.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Hidden-child worktree creation and source settlement keeps the original intent (f2b7222: Reuse visible-session worktree preparation and session deletion while deferring checkout allocation to the accepted child's first turn.)
  • Gateway-bound cleanup independent of parent lifetime keeps the original intent (715077a: Preserve the original operator and Gateway ownership across queued and delegated work without borrowing later authority.)
  • Exact-incarnation cleanup and fork ownership keeps the original intent (30772d5: Carry committed fork facts and protect replacement sessions during failure compensation.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Shakker: Raw commit 715077a adds src/agents/subagents/spawn/subagent-spawn-cleanup.ts:16 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 715077a3befb; files: src/agents/subagents/spawn/subagent-spawn-cleanup.ts)
  • Peter Steinberger: Raw commit 7555e3f adds src/agents/subagents/spawn/subagent-spawn-cleanup.ts:50 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 7555e3f88132; files: src/agents/subagents/spawn/subagent-spawn-cleanup.ts)

PR surface

Source +13, Tests +86. Total +99 across 4 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 3 83 70 +13
Tests 1 87 1 +86
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 170 71 +99

Labels

Label changes:

No label changes.

Label justifications:

  • P2: Controlled source-settlement failure leaves an unaccepted durable child session, with limited demonstrated impact and no established urgent regression.
  • 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-26T09:15:44.066Z sha 5ab8011 :: needs maintainer review before merge. :: none
  • reviewed 2026-10-26T09:41:09.729Z sha 5ab8011 :: needs maintainer review before merge. :: none

Reviewed October 26, 2026, 6:29 AM ET / 10:29 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. 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 force-pushed the committed-child-cleanup branch from 5ab8011 to 75dc3d1 Compare October 26, 2026 09:57
@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. 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 4575e7c into main Oct 26, 2026
170 checks passed
@shakkernerd
shakkernerd deleted the committed-child-cleanup branch October 26, 2026 10:38
@shakkernerd

Copy link
Copy Markdown
Contributor Author

Fixed: provisional child sessions are removed when source settlement rejects after creation.

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: M 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.

fix: stopped native child startup leaves a committed provisional session

1 participant