Repository navigation
fix(update): prevent stale completion after update ownership changes - #176125
Conversation
Prepare terminal state, notifications, and diagnostic reports while the original executor still owns the operation. Join preparation, release ownership, then emit captured facts; keep unregistered initialization refusals detached after admission attempts. Preserve cancellation and release failures, migrated-parent state isolation, and public refusal identity. Related: #143917. Installed recovery-helper interruption and retirement proof remain separate.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
Adopt the canonical settlement fixture helpers and aliases while preserving every existing case and all four retained terminal-preparation cases. Resolve the overlapping upstream fixture refactor without advancing the source baseline or changing production.
Move the unchanged preparation import and four-case block outside the upstream refactor ranges, preserving the same module hooks, assertions, and runtime semantics.
|
Codex review: needs maintainer review before merge. What this changesThis PR prepares update history, notifications, and reports under the original executor, then emits captured results after successful release. Example: An update activates package version 2.0.0 while another updater attempts to acquire the same installation.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review This PR addresses a current-main ownership defect and retains meaningful work; no introduced correctness or security defect was found. Priority: P2 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherThe CLI updater coordinates package activation, executor leases, persistent update history, restart notifications, diagnostic artifacts, and terminal output. flowchart TD
A[Update CLI] --> B[Original executor]
B --> C[Package activation and joined cleanup]
C --> D[Prepare history notifications and reports]
D --> E[Release executor ownership]
E --> F[Emit captured result]
Technical reviewBest possible solution: Keep terminal effects within the existing executor lifetime and permit only captured-result emission after release. Do we have a high-confidence way to reproduce the issue? Current-main source places terminal state and report work in the post-executor publisher, and the supplied real-swap regression identifies the successor-admission window; this read-only review did not execute a reproduction. Is this the best way to solve the issue? The repair uses existing executor, ledger, notification, and artifact owners, preserves migrated-child isolation, and avoids acquiring replacement authority merely to finish diagnostics. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 5e1e942b362e. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +396, Tests +1342, Other -9. Total +1729 across 49 files. Added test files: 2. View PR surface stats
Review metrics
LabelsLabel changes: No label changes. Label justifications:
Rating scale6/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. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReviewed October 19, 2026, 2:42 AM ET / 06:42 UTC (Revision 3). |
|
@clawsweeper re-review Please review exact head |
|
🦞👀 Re-review progress:
|
Carry captured package versions through detached refusals and preserve revoked-owner state in caller fixtures. Move admission reporting and authority tests into cohesive modules without changing preparation, release, or emission order. This local correction retains the complete reviewed candidate. Fresh lint, affected runtime and type checks, a normal build, full autoreview, and exact-head hosted gates remain required before publication and landing.
Baseline-Refresh: 1e0d58dd02eb75edf7b56d4432b0c4f29cc0903d
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Merged via squash.
|
…penclaw#176125) * fix(update): prevent stale completion after update ownership changes Prepare terminal state, notifications, and diagnostic reports while the original executor still owns the operation. Join preparation, release ownership, then emit captured facts; keep unregistered initialization refusals detached after admission attempts. Preserve cancellation and release failures, migrated-parent state isolation, and public refusal identity. Related: openclaw#143917. Installed recovery-helper interruption and retirement proof remain separate. * test(update): reconcile terminal preparation settlement coverage Adopt the canonical settlement fixture helpers and aliases while preserving every existing case and all four retained terminal-preparation cases. Resolve the overlapping upstream fixture refactor without advancing the source baseline or changing production. * test(update): isolate preparation cases from fixture merge overlap Move the unchanged preparation import and four-case block outside the upstream refactor ranges, preserving the same module hooks, assertions, and runtime semantics. * fix(update): preserve terminal refusal facts and reporting boundaries Carry captured package versions through detached refusals and preserve revoked-owner state in caller fixtures. Move admission reporting and authority tests into cohesive modules without changing preparation, release, or emission order. This local correction retains the complete reviewed candidate. Fresh lint, affected runtime and type checks, a normal build, full autoreview, and exact-head hosted gates remain required before publication and landing. * test(update): remove unused terminal fixture imports * fix: refresh the reviewed correction baseline Baseline-Refresh: 1e0d58dd02eb75edf7b56d4432b0c4f29cc0903d * refactor(update): keep autostart failure reporting with maintenance * test(update): verify timeout custody without late completion Co-authored-by: Vincent Koc <[email protected]>
Related: #143917
What Problem This Solves
An update could finish its history, restart sentinel, and diagnostic report after releasing the executor that authorized those writes. A real successor could appear during notification while the old updater still reported success.
User Impact
Completion now respects cancellation and ownership changes. Release failures suppress stale success. Operators receive the original refusal or a pending-recovery diagnostic, including facts captured before ownership ended.
Why This Change Was Made
The executor joins descendants and prepares terminal state, notification, and reports under its original authority. After successful release, it emits prepared facts. Report writes carry that authority through awaited filesystem effects and the actual atomic publication boundary.
Fresh initialization refusals after an admission attempt use detached captured facts. The already-read package version survives without a late metadata read. Migrated parent processes keep consuming child-owned facts without reopening candidate-upgraded databases.
Admission reporting has one owner and direct callers. Authority and fresh-refusal tests keep explicit isolated routing. The fixed-baseline integration preserves upstream fixture consolidation and the pending-result, complete-state-preservation, and detached-report assertions. Windows autostart failure reporting moved intact beside the existing maintenance owner; its synchronous position before terminal capture is unchanged.
A timeout revokes the original writer before it can finalize history. The retention regression now observes the live fence and complete ledger before abort, then requires joined retention, real lease release, one unsafe-recovery timeout, and unchanged history, sentinel, shared reports and package bytes. A later admitted reconciliation owner may repair the row only after positively observing driver death.
Evidence
Candidate: signed
ee0c87b6036e144d0248f05a83b5be581bbdb4f6, tree1fd69ac48ed79a232179d458ce1fd286fa7cc8d7; full diffc17c3373c6261b7e5f15c933c139a30b86d86ed6587aa0f395a6f610164f366dagainst fixed baseline2d29a6209d2f358a7c193eddf777ee4208d4c4d0.The final test-only correction passed 28/28 tests, 0 failed/skipped: complete already-current (19), activation (7), and executor-deadline (2) files, using pinned Bun 1.4.4 / Vitest 5.0.3. The original timeout case now reaches every preservation assertion. The maintained CLI-update type graph, targeted typed lint, formatting, diff and mock-export ratchet passed. Proof ran on unsigned parent-plus-delta bytes; signed commit hooks and signature verification confirm the exact same delta and file postimage. Receipt SHA256:
6e66f1fd87981c91873998ac77a75567d177736826fe52f122fa14ca5872375f.The unchanged reconciliation worker separately passed 8/8, covering dead-driver repair, adopter races and retained recovery; those are not added to 28. It is the later admitted owner, after positive driver death, that may reconcile the preserved running row. The new witness is here.
The parent with identical production code
4c05a52epassed trusted local fallback on macOS arm64: 14 complete files, 301 tests passed, 0 failed/skipped, using source-pinned Bun 1.4.4 / Vitest 5.0.3, with Node 26.7 orchestration and pnpm 12.11.1. The strict module wrapper also verified its 19 child cases with no failures/skips; those are not added to 301. All four maintained type graphs, 44-file core typed lint, scripts lint, scoped formatting, mock-export ratchet, diff and syntax checks passed.The normal full
pnpm buildpassed in 3m53.2s, including UI, declarations, SDK and postbuild; build metadata names4c05a52e; this successor changes only the timeout fixture. Final source/index/worktree, 48 postimages and 207 dependency inputs remained unchanged. Proof receipt SHA256:11b8c0f5ebf0906393c127543e2d99e5c5464591289282f23459b44d0669b3f4.The original failure was reproduced in execution order with real package swaps: a successor journal appeared after the first update's sentinel commit, and the old updater incorrectly completed successfully.
Fresh full native source review on integrated parent
2c5004e0completed all six passes with zero findings and a passing final source guard. The production successor4c05a52eadds only the independently reviewed synchronous two-file maintenance extraction. The subsequent timeout fixture received a fresh two-pass delta review. Its one accepted P2 caught an Error-instance matcher comparing independent deadline errors; the existing timeout-class constructor matcher resolves it while retaining the separate signal assertion and every state/custody check. The raw findings verdict is preserved, and the exact correction is independently reviewed. Runtime also exposed an overly strict stderr-count assumption: the initiating deadline detail and final custody guidance are separate existing diagnostics. The final witness requires their complete strings in order and exactly one JSON outcome. Earlier raw review reports and their evidence-backed dispositions remain retained; they are not presented as fresh candidate proof.Selected actual stdout from the unchanged-production parent proof (terminal color escapes removed):
The executed final-effect assertions cover both sides of the boundary: a real contender is refused while the original lease is current and admitted after release; allowed publication emits one success with completed history/report; cancellation retains the prior row, creates no report, and emits no success. Post-release history, sentinel and successor-journal bytes remain unchanged, with no additional rename. A replaced-owner case compares the complete history/sentinel/report-bytes/lease snapshot and emits one captured pending JSON diagnostic. See the authority assertions and revoked-owner assertions.
The build returned 0 while reporting one UI budget warning: new-boot JS gzip 1,050,438 > 1,050,000 bytes. No independent hosted UI-performance pass is claimed. The proof log retains a stale predecessor label in its observer START records; the immutable recipe/manifest and actual pre/post source guards bind execution to
4c05a52e, and the correction is recorded without rewriting the raw log.Exact published-head hosted CI, security, ClawSweeper and native landing checks remain required. Historical predecessor results and skipped jobs are not current-head proof. The earlier package on tree
5055ebedremains separate historical component evidence.Installed interrupted-CLI recovery, the sealed plain-Node helper, and partial-retirement resumability remain separate acceptance work under the related draft. This PR does not close it or claim release/deployment proof.
Production: +680/-284 (net +396), for retained terminal ownership, guarded report effects, captured refusal facts and coherent reporting owners. Tests/support: +1548/-206; config: -9 obsolete mock-export exceptions. Total: 2,727 lines of churn.
ClawSweeper's exact-head review reports no findings or before-merge actions. Its test advisory is retained deliberately: the
progress.test.tscase covers an ordinary directprepareResultcaller with no authority callback, no output during preparation, and captured JSON emission after history/report dependencies have been changed to throw. The real executor cases supply authority. A bounded follow-up may consolidate this ordinary-caller contract without losing those checks. No additional installed-CLI replay or red-on-base execution is claimed here.Follow-ups: ownerless low-level finalizer composition; internal unprepared-admission fallback identity consistency. Neither has a discovered supported production entry requiring a speculative fallback here.