Skip to content

fix: preserve unfinished work during completed PR cleanup - #148704

Merged
fuller-stack-dev merged 3 commits into
mainfrom
openclaw/atomic-nonforce-cleanup-20260915
Sep 15, 2026
Merged

fuller-stack-dev merged 3 commits into
mainfrom
openclaw/atomic-nonforce-cleanup-20260915

Conversation

@fuller-stack-dev

@fuller-stack-dev fuller-stack-dev commented Sep 15, 2026 •

Copy link
Copy Markdown
Member

What Problem This Solves

Fixes completed-PR cleanup deleting uncommitted files and unpublished local branch tips when a task merges or closes.

Related: #147527, which established the existing exact-worktree ownership checks.

User Impact

Maintainers keep unfinished work. Clean completed checkouts still clean up, including ignored build artifacts. Reviewed squash-merge branches can be retired using their retained completion receipt, including a local prepared commit whose published GitHub commit has a different ID. Existing branch tracking stays unchanged.

Dirty, locked, ambiguous, or unpublished work produces a visible cleanup-pending result. GitHub merge success remains separate from local cleanup success.

Why This Change Was Made

The previous cleanup used forced Git removal after validating ownership. Those checks do not establish whether new local work was added. Cleanup now uses native non-force Git operations. The same worktree eligibility check serves garbage-collection previews and actual removal. Retained merge receipts provide the source ancestry needed for squash cleanup without bypassing Git's checked-out-branch protections.

Evidence

  • Real Git regression fixtures failed five data-retention scenarios on the unchanged base. The repaired fixture covers tracked edits, untracked files, missing or unresolved receipts, advanced branch tips, ordinary ignored artifacts, and retained evidence.
  • A real source change and squash merge confirmed that plain branch deletion refuses the source tip, while non-force deletion against the completed receipt removes it safely.
  • A separate regression covers preexisting branch tracking. Git stores merge configuration as multiple values, so receipt comparison must not replace or reinterpret an existing upstream.
  • Native wrapper tests cover linked-checkout teardown, operation-lock ownership, exact admin entries, merge completion receipts, and shared branches.
  • The real merge path reproduces incomplete cleanup when local and GitHub commit IDs differ. The fix completes cleanup, retains both verified commit identities through GC, and rejects mismatched trees before merge dispatch.
  • Final targeted suite: 61 passed across worktree evidence, linked native wrapper/operation locks, and merge-outcome completion. The explicit scope skipped 364 unrelated cases.
  • Exact-head CI found six additional fixture failures, reproduced locally. The fixtures now preserve deliberately dirty work, configure capture filters without adding unpublished files, and retain valid local-head receipts before fork-base checks. All eight affected and adjacent cases pass; changed checks and fresh fixture autoreview pass.
  • ClawSweeper identified a linked-wrapper lifetime bug. A two-worktree native GC reproduction removed the wrapper worktree first, then failed on the second target and retained operation locks. Receipt helpers now load before cleanup; 32 owner/native lifecycle/hosted-handoff cases pass, including both removals and deferred lock release.
  • Fresh independent autoreview reports no actionable P0/P1 findings in the production repair, fixture follow-up, and GC lifetime correction. New exact-head hosted CI remains required before landing. The previous run also timed out in unchanged worker-transform tests; that result is not being waived.

No Gateway deployment, public config change, new dependency, or forced production cleanup. Older merge receipts remain readable; if they cannot prove a local branch was published, cleanup retains that branch.

@clawsweeper

clawsweeper Bot commented Sep 15, 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.

@fuller-stack-dev
fuller-stack-dev marked this pull request as ready for review September 15, 2026 02:31
@openclaw-barnacle openclaw-barnacle Bot added scripts Repository scripts size: M maintainer Maintainer-authored PR labels Sep 15, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. 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. labels Sep 15, 2026
@clawsweeper

clawsweeper Bot commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 14, 2026, 10:58 PM ET / September 15, 2026, 02:58 UTC (Revision 3).

ClawSweeper review

What this changes

The PR preserves unfinished files and unpublished branches during completed-PR cleanup while retaining verified local commits needed for safe squash-merge cleanup.

Merge readiness

✅ Ready for maintainer review

The fix remains necessary on current main. The earlier helper-lifetime finding is resolved, and no remaining blocking defect was found. This maintainer-authored PR should proceed through normal merge gates.

Priority: P2
Reviewed head: 896d700da70318c5eda03ba5db10843e9682f0a7

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused repair with useful regression coverage and the earlier blocker resolved; no additional correctness repair is identified.
Proof confidence 🌊 off-meta tidepool Not applicable: The MEMBER-authored PR is exempt from ordinary contributor proof requirements. Reported real-Git cleanup and native-wrapper runs match the changed owners; this review inspected their assertions without executing them, and found no material authority expansion requiring additional final-effect proof.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The MEMBER-authored PR is exempt from ordinary contributor proof requirements. Reported real-Git cleanup and native-wrapper runs match the changed owners; this review inspected their assertions without executing them, and found no material authority expansion requiring additional final-effect proof.
Evidence reviewed 7 items Current main still needs the repair: The pinned main implementation still removes worktrees with --force and deletes local branches with -D after ownership checks; it does not perform the new dirty-worktree or non-force ancestry checks.
Cleanup safeguards: Cleanup checks tracked and untracked changes, preserves locked worktrees, uses native non-force removal, and keeps existing branch upstream configuration authoritative. Receipt-based branch deletion is limited to validated non-intent records.
Previous finding resolved: The exact-head GitHub commit patch moves receipt-helper loading to module initialization and removes both per-target reloads. The updated native GC fixture checks two removals and deferred lock release, addressing the previous finding and rank-up request.
Findings None None.
Security None None.

How this fits together

OpenClaw’s maintainer scripts clean up temporary Git worktrees after PR completion. They combine GitHub status, local ownership checks, and retained merge receipts to decide which directories and branches can be removed.

flowchart TD
  A[Completed PR] --> B[Cleanup owner]
  C[Worktree ownership and local changes] --> B
  D[Retained merge receipt] --> B
  B --> E{Safe to remove?}
  E -->|Yes| F[Non-force Git cleanup]
  E -->|No| G[Preserve work and report pending]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Tests +147, Other +50. Total +197 across 8 files.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 4 163 16 +147
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 4 63 13 +50
Total 8 226 29 +197

Review metrics

Metric Value Why it matters
Production and test growth Production net +50 lines; tests net +147 lines Production growth adds preservation checks and retained ancestry; regression fixtures exercise their cleanup and recovery consequences.
Receipt compatibility 1 optional field added; version remains 1 Existing receipts remain readable without rewriting stored merge evidence.

Technical review

Best possible solution:

Keep cleanup with the existing owner, using Git’s non-force protections and retained ancestry while reporting preserved work separately from successful merging.

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

Yes, source establishes the path: completed-PR cleanup on pinned main uses forced removal without checking unfinished files or unpublished branch ancestry. Execution was not performed in this read-only review.

Is this the best way to solve the issue?

Yes. The patch strengthens the existing cleanup owner, preserves native Git protections and branch preferences, and extends existing receipt storage without requiring migration.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The MEMBER-authored PR is exempt from ordinary contributor proof requirements. Reported real-Git cleanup and native-wrapper runs match the changed owners; this review inspected their assertions without executing them, and found no material authority expansion requiring additional final-effect proof.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove merge-risk: 🚨 automation: Current PR review selected no merge-risk labels.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: This repairs destructive cleanup in maintainer tooling with a bounded scope outside application runtime.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The MEMBER-authored PR is exempt from ordinary contributor proof requirements. Reported real-Git cleanup and native-wrapper runs match the changed owners; this review inspected their assertions without executing them, and found no material authority expansion requiring additional final-effect proof.

Evidence

What I checked:

  • Current main still needs the repair: The pinned main implementation still removes worktrees with --force and deletes local branches with -D after ownership checks; it does not perform the new dirty-worktree or non-force ancestry checks. (scripts/pr-lib/common.sh:511, e903d3ece751)
  • Cleanup safeguards: Cleanup checks tracked and untracked changes, preserves locked worktrees, uses native non-force removal, and keeps existing branch upstream configuration authoritative. Receipt-based branch deletion is limited to validated non-intent records. (scripts/pr-lib/common.sh:512, 896d700da703)
  • Previous finding resolved: The exact-head GitHub commit patch moves receipt-helper loading to module initialization and removes both per-target reloads. The updated native GC fixture checks two removals and deferred lock release, addressing the previous finding and rank-up request. (scripts/pr-lib/common.sh:3, 896d700da703)
  • Receipt compatibility and retention: localHead is optional for existing version-1 receipts. New receipts retain it as a commit parent and validate its tree against the hosted head; merge verification rejects mismatched trees before dispatch. (scripts/pr-lib/merge-outcome.sh:65, 896d700da703)
  • Meaningful regression coverage: The worktree fixture covers dirty files, ignored artifacts, legacy receipts without localHead, unresolved intent, advanced branch tips, existing tracking, and invalid local trees. The merge fixture additionally checks that verified local commits survive reflog expiry and Git GC. (test/scripts/pr-worktree-evidence.test.ts:190, 896d700da703)
  • Reported validation and review continuity: The captured PR body and fix: preserve unfinished work during completed PR cleanup #148704 (comment) report before-fix reproduction and 32 passing cleanup/native lifecycle/hosted-handoff cases after the lifetime correction. These are contributor-reported results; this read-only review did not execute tests. (896d700da703)

Likely related people:

  • vincentkoc: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (2 earlier review cycles)
  • reviewed 2026-09-15T02:38:24.280Z sha aa35b68 :: blocked before merge. :: [P2] Load receipt helpers before GC can delete their source worktree
  • reviewed 2026-09-15T02:51:29.627Z sha 3f00eab :: blocked before merge. :: [P2] Load receipt helpers before GC can delete their source worktree

@fuller-stack-dev

Copy link
Copy Markdown
Member Author

Addressed the linked-wrapper GC finding in 896d700da70318c5eda03ba5db10843e9682f0a7.

Receipt helpers now load when the common module initializes, before cleanup can remove its source worktree. Both per-target reloads are gone. The native linked-wrapper GC fixture now removes two eligible worktrees in one invocation and verifies their branches, operation refs, and deferred supervisor release.

The regression reproduced the missing-source failure and retained operation locks before the fix. Afterward, 32 related cleanup/native lifecycle/hosted-handoff cases passed, changed-file checks passed, and fresh independent review found no actionable P0/P1 findings. No force, ownership, receipt, or upstream-tracking protection was weakened.

The earlier six CI fixture failures also reproduced locally and pass after the preceding fixture correction. The separate subprocess timeouts in unchanged CI files remain recorded; this head still requires a green CI gate before landing.

@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 15, 2026
@fuller-stack-dev
fuller-stack-dev merged commit a4a3e56 into main Sep 15, 2026
236 of 239 checks passed
@fuller-stack-dev
fuller-stack-dev deleted the openclaw/atomic-nonforce-cleanup-20260915 branch September 15, 2026 03:24
@fuller-stack-dev

Copy link
Copy Markdown
Member Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 15, 2026
…48704)

* fix: preserve unfinished work during completed PR cleanup

* test: preserve cleanup fixture contracts without forced removal

* fix: keep cleanup helpers loaded after linked wrapper removal
vincentkoc added a commit that referenced this pull request Sep 15, 2026
* commit 'd8e50a38fd1c4df6dd69bcbc155697c464e1be45': (23 commits)
  fix(cron): release queued reservations when activation fails (#141008)
  fix(gateway): reduce CPU work in session lists and searches (#148713)
  feat(gateway): add admin CPU profile diagnostics (#148004)
  fix(gateway): cap device-required probe cache to prevent unbounded growth (#147708)
  fix(ci): align Gateway E2E expectations (#148653)
  refactor(ai): remove unused overflow wrapper (#148719)
  feat: stage selected chat text as editable comments (#148649)
  fix(ci): admit reachable release refs with large histories (#148161)
  fix(agents): allow authorized email CLI actions (#148521)
  improve(agents): trim large tool results with less CPU (#148718)
  refactor(docker): share image version parsing (#148243)
  fix(ci): retain passing hosted checks after skipped duplicates (#148722)
  fix(update): report configuration failures during repair (#144819)
  refactor(imessage): share handle classification (#148229)
  fix(ui): keep the selected agent across Settings pages (#148667)
  test(telegram): reuse deferred fixture helper (#148501)
  fix(media): resize images before understanding (#122431)
  fix: preserve unfinished work during completed PR cleanup (#148704)
  refactor(migrate-hermes): reuse canonical config record coercion (#148645)
  perf(channels): reduce history worker metadata footprint (#148711)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. scripts Repository scripts 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.

1 participant