Skip to content

fix(update): prevent stale completion after update ownership changes - #176125

Merged
vincentkoc merged 8 commits into
mainfrom
test/pr-143917-terminal-publication-20261017
Oct 19, 2026
Merged

vincentkoc merged 8 commits into
mainfrom
test/pr-143917-terminal-publication-20261017

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Oct 18, 2026 •

Copy link
Copy Markdown
Member

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, tree 1fd69ac48ed79a232179d458ce1fd286fa7cc8d7; full diff c17c3373c6261b7e5f15c933c139a30b86d86ed6587aa0f395a6f610164f366d against fixed baseline 2d29a6209d2f358a7c193eddf777ee4208d4c4d0.

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 4c05a52e passed 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 build passed in 3m53.2s, including UI, declarations, SDK and postbuild; build metadata names 4c05a52e; 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 2c5004e0 completed all six passes with zero findings and a passing final source guard. The production successor 4c05a52e adds 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):

✓  infra  src/cli/update-cli/update-command-post-update.test.ts > successful update finalization ordering > reports Windows autostart recovery failure before exiting 290ms
✓  infra  src/cli/update-cli/update-command-terminal-outcome.test.ts > composed cleanup and terminal outcome > suppresses prepared success when the real executor lease cannot be released 199ms
✓  infra  src/cli/update-cli/update-command-terminal-outcome.test.ts > composed cleanup and terminal outcome > reports revoked authority from captured facts without changing retained state 214ms
✓  infra  src/cli/update-cli/update-command-terminal-authority.test.ts > retains terminal authority until release (cancel: false, captured: false) 1905ms
✓  infra  src/cli/update-cli/update-command-terminal-authority.test.ts > retains terminal authority until release (cancel: false, captured: true) 1478ms
✓  infra  src/cli/update-cli/update-command-terminal-authority.test.ts > retains terminal authority until release (cancel: true, captured: false) 1601ms
✓  infra  src/cli/update-cli/update-command-terminal-authority.test.ts > preserves terminal facts when a successor follows prepared-child-failure 786ms

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 5055ebed remains 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.ts case covers an ordinary direct prepareResult caller 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.

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.
@vincentkoc vincentkoc self-assigned this Oct 18, 2026
@clawsweeper

clawsweeper Bot commented Oct 18, 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 cli CLI command changes size: XL labels Oct 18, 2026
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.
@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. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. 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 18, 2026
@clawsweeper

clawsweeper Bot commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This 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.

  • Before: The original updater could release ownership and subsequently write completion state while the successor was active.
  • After: The successor waits until terminal preparation finishes, and post-release output uses captured facts without further state writes.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The focused ownership repair has credible production-boundary evidence and no concrete correctness finding, with confidence bounded by harness coverage.
Proof confidence 🦐 gold shrimp (3/6) Sufficient (terminal): Recorded macOS arm64 execution exercises real package swaps, SQLite leases and history, sentinel/report publication, allowed completion, cancellation, successor admission, and replaced-owner preservation through the production owners; the latest head adds only the separately executed timeout witness.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: An updater can report success or write completion artifacts after its ownership has ended.
Reason: This maintainer-authored repair restores the existing ownership contract without adding configuration, public APIs, or a new persistent owner.

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
Reviewed head: ee0c87b6036e144d0248f05a83b5be581bbdb4f6

Before merge

None.

Findings

None.

Tests

  • Low-value test src/cli/update-cli/progress.test.ts: Remove the added mocked prepareResult call-count case: the real executor regression already proves deferred emission without post-release history or filesystem work.
  • Missing end-to-end proof: An installed-CLI replay and an executed red-on-base regression run are not supplied; the recorded proof covers the production ownership boundary.
Agent review details

How this fits together

The 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]
Loading

Technical review

Best 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

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

PR surface

Source +396, Tests +1342, Other -9. Total +1729 across 49 files. Added test files: 2.

View PR surface stats
Area Files Added Removed Net
Source 19 680 284 +396
Tests 29 1548 206 +1342
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 0 9 -9
Total 49 2228 499 +1729

Review metrics

Metric Value Why it matters
Production versus test changes Production +680/-284; tests and support +1548/-206. Production growth supplies the preparation/emission split and guarded artifact writes; most supporting growth exercises cancellation, replacement, release failure, and fresh refusals.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: Incorrect update completion and stale diagnostic writes are a concrete lifecycle defect with a bounded concurrent-update or cancellation trigger.
  • 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.
  • 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-18T07:36:24.490Z sha 3dce7e0 :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-19T05:47:58.390Z sha 4c05a52 :: needs maintainer review before merge. :: none

Reviewed October 19, 2026, 2:42 AM ET / 06:42 UTC (Revision 3).

@vincentkoc
vincentkoc marked this pull request as ready for review October 18, 2026 07:56
@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

Please review exact head 6c3772dc3a8b1c1239b509209d5a73439345d76e. The merge conflict is resolved, and the PR body now includes recorded allowed/revoked terminal-publication and report-cancellation output, actual tested source bindings, and links to the unchanged current assertions. It distinguishes historical component execution from the fresh 23-case settlement/type proof and the running exact-head hosted CI; skipped Windows/UI-performance jobs are not claimed as passes.

@clawsweeper

clawsweeper Bot commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Oct 18, 2026
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.
@openclaw-barnacle openclaw-barnacle Bot added scripts Repository scripts commands Command implementations labels Oct 19, 2026
@openclaw-barnacle openclaw-barnacle Bot reopened this Oct 19, 2026
@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 19, 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: 🦐 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 19, 2026
@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 19, 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-repro Preliminary submission classification; full source review pending. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 19, 2026
@vincentkoc
vincentkoc merged commit 931de9e into main Oct 19, 2026
180 checks passed
@vincentkoc
vincentkoc deleted the test/pr-143917-terminal-publication-20261017 branch October 19, 2026 07:09
@vincentkoc

Copy link
Copy Markdown
Member Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 20, 2026
…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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes commands Command implementations P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. scripts Repository scripts size: XL 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