Skip to content

fix: preserve uncertain Git cleanup after cancellation - #184226

Merged
shakkernerd merged 3 commits into
mainfrom
git-host-settlement
Oct 26, 2026
Merged

shakkernerd merged 3 commits into
mainfrom
git-host-settlement

Conversation

@shakkernerd

@shakkernerd shakkernerd commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Cancelling workspace preparation can hide an uncertain native Git cleanup outcome. The host waits for its admitted Git command, but a worker that has stopped accepting replies leaves the caller with the earlier ordinary cancellation. The snapshot cleanup path also removes its temporary directory after a canonical cleanup error. Both behaviors discard information needed to preserve unfinished work for recovery.

Fixes #184197.

User Impact

The Git host now preserves cleanup uncertainty supplied by its executors after cancellation and leaves its temporary artifacts intact when native cleanup cannot be confirmed. Confirmed-clean cancellation, ordinary command errors, authorization checks, and successful operations keep their existing behavior. This restores the existing recovery contract without adding configuration, persistent state, or a retry policy.

Why This Change Was Made

The Git host already owns native execution and joins outstanding callbacks. It now retains the first canonical cleanup failure independently of worker reply delivery, including callbacks that have already left the outstanding-work set. After joining admitted host work, it reports that failure before deleting temporary artifacts.

The host checks the two existing transport forms directly: text results carry a cleanup status, while buffered results can carry a canonical or privately recorded cleanup error. The normal worker error envelope and generic process and worker APIs stay unchanged. Existing lifecycle fixture helpers move into a test-support module so the regression cases fit the test-file limit without removing assertions or changing timeouts.

Evidence

Six callback/artifact cases fail on the original Git host and pass with this change: three late text cleanup reports, two late buffered cleanup errors, and retained snapshot artifacts after a consumed cleanup exception. These cases use real workers and Git commands, with controlled cleanup reports to cover each result form.

Independent review also found that the lower buffered adapter discarded resolved cleanup uncertainty. That producer correction landed in #184270 and is included in this branch. A new coupled regression uses the real buffered adapter and native runner, a self-terminating child, and the actual snapshot worker. It holds the unchanged native result across worker cancellation, then checks caller settlement, canonical uncertainty, retained temporary ownership, and absence of snapshot publication. This case fails with the producer correction alone and passes with the Git-host repair. It does not inject a result above the adapter or claim to reproduce an escaped operating-system process. The native self-signal fixture runs on POSIX; Windows is explicitly excluded from that fixture.

Remote validation passed changed-source formatting/lint, all selected production/test type groups, and 344 tests across 24 affected files, with one existing skip. The related batch took 183 seconds and includes ordinary cancellation/restart, authority checks, successful Git operations, worktree hydration, and snapshot cleanup controls. The committed tree matches the tested tree.

The integrated result passed independent review and hosted CI. A later upstream snapshot-preparation change required aligning the native fixture with the remaining capacity callback; the production repair and assertions are unchanged. The targeted refresh passed formatting/lint, core and infrastructure test types, and all 30 cases in the two affected lifecycle files. Current-head CI and the same independent reviewer passed that adaptation. A shipped CLI cancellation capture is not included. Shared default-base recovery remains a separate contribution.

@shakkernerd shakkernerd self-assigned this Oct 26, 2026
@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.

@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: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. 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 preserves late Git cleanup uncertainty after cancellation and retains temporary snapshot artifacts when cleanup cannot be confirmed.

Example: The native-buffered-settlement snapshot is cancelled while a buffered SIGTERM result awaits delivery.

  • Before: The caller receives ordinary cancellation and the snapshot temporary directory is removed.
  • After: The caller receives canonical cleanup uncertainty, the temporary directory remains, and no snapshot ref is published.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) A focused, correct host repair with coupled native regression coverage; supplied proof remains at the production-path harness boundary.
Proof confidence 🦐 gold shrimp (3/6) This maintainer-authored PR is outside the ordinary contributor proof gate; its reported evidence exercises real workers and a native SIGTERM child through runCommandBuffered, but remains an in-process regression rather than a shipped CLI or Gateway capture.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Cancelling workspace preparation can erase the cleanup uncertainty needed to preserve unfinished work for recovery.
Reason: The maintainer-authored direction restores an existing recovery contract through its existing owner.

Merge readiness

✅ Ready for maintainer review

Keep open: this maintainer-authored PR fixes a current recovery-safety defect and resolves the earlier buffered-producer concern without an actionable finding.

Priority: P2
Reviewed head: fe76255d1098649ea8bce7d3d6644fd1f9905a94

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: No shipped CLI or Gateway workspace-preparation cancellation capture is supplied; the body reports red/green production-path regression coverage.
Agent review details

How this fits together

The Git worker host brokers worker requests to parent-owned Git executors, joins admitted callbacks, and returns operation results while managing temporary snapshot directories.

flowchart TD
  A[Worktree lifecycle caller] --> B[Git operation host]
  B --> C[Git worker]
  C --> B
  B --> D[Native command executors]
  D --> E[Cleanup outcome]
  E --> B
  B --> F[Caller error and retained artifacts]
Loading

Technical review

Best possible solution:

Land the host-owned cleanup classification and artifact-retention repair alongside the already-merged buffered producer correction.

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

Current-main source establishes discarded late replies and unconditional artifact deletion; the reported red/green lifecycle regressions match those paths, but this read-only review executed no tests.

Is this the best way to solve the issue?

The repair uses the existing Git host, canonical cleanup classifier, and finalizer, preserving uncertainty without changing generic worker semantics or introducing another recovery owner.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Git host settlement and temporary-directory cleanup keeps the original intent (f0fafba: Move bounded Git processing into workers while retaining parent ownership of subprocesses, authority, settlement, and cleanup.)
  • Shared executor dispatch and cleanup timing keeps the original intent (a2e8b34: Bound content subprocesses through cancellation and cleanup while attributing command and queue durations.)
  • Lifecycle fixture extraction keeps the original intent (f0fafba: Exercise real worker, Git subprocess, cancellation, and snapshot-cleanup boundaries; the extraction retains the existing fixtures and assertions.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

PR surface

Source +41, Tests +246. Total +287 across 4 files. Added test files: 2.

View PR surface stats
Area Files Added Removed Net
Source 1 61 20 +41
Tests 3 391 145 +246
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 452 165 +287

Review metrics

Metric Value Why it matters
Production versus test LOC Production +61/-20; tests and test support +391/-145 Production growth retains one operation-local failure and handles the two existing executor contracts; test growth covers distinct uncertainty encodings and native settlement, including mechanical fixture extraction.

Root-cause cluster

Relationship: same_root_cause
Canonical: #184197
Summary: This PR addresses the reported host-settlement defect; the merged buffered producer repair supplies the lower-level uncertainty classification.

Members:

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

Labels

Label changes:

  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: Cancellation can lose cleanup classification and discard recovery artifacts, with a focused affected boundary and no demonstrated widespread incident.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

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 (1 earlier review cycle)
  • reviewed 2026-10-26T05:16:33.779Z sha af80aa5 :: needs changes before merge. :: none

Reviewed October 26, 2026, 5:55 AM ET / 09:55 UTC (Revision 2).

@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. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. 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 8b3f7a9 into main Oct 26, 2026
130 of 131 checks passed
@shakkernerd
shakkernerd deleted the git-host-settlement branch October 26, 2026 12:53
@shakkernerd

Copy link
Copy Markdown
Contributor Author

Fixed: cancelled Git operations preserve uncertain cleanup outcomes and recovery artifacts.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 27, 2026
Preserve late Git cleanup uncertainty after cancellation and retain temporary artifacts needed for recovery.

Fixes openclaw#184197.
RomneyDa added a commit that referenced this pull request Oct 28, 2026
Preserve late Git cleanup uncertainty after cancellation and retain temporary artifacts needed for recovery.

Fixes #184197.

(cherry picked from commit 8b3f7a9)

Co-authored-by: RomneyDa <[email protected]>
(cherry picked from commit e801897a63034ee6c14a2ade31615e19409da17c)
RomneyDa added a commit that referenced this pull request Oct 28, 2026
Preserve late Git cleanup uncertainty after cancellation and retain temporary artifacts needed for recovery.

Fixes #184197.

Beta.5 baseline adaptation: Retain the native beta.5 owners, fixtures and public contracts; add focused regression controls and bounded fixture extraction; apply checkout formatting.

(cherry picked from commit 8b3f7a9)
(cherry picked from commit ca43a38)
Co-authored-by: Peter Steinberger <[email protected]>

Co-authored-by: RomneyDa <[email protected]>
(cherry picked from commit f4776983fc8cec2b9c2bcbc13f564a11f7e02094)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: L 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.

Git cancellation can hide uncertain native cleanup

1 participant