Skip to content

fix(update): preserve preparation lock ownership - #207139

Merged
vincentkoc merged 7 commits into
mainfrom
fix/update-prepare-lock-ownership-20261128
Nov 30, 2026
Merged

vincentkoc merged 7 commits into
mainfrom
fix/update-prepare-lock-ownership-20261128

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Nov 28, 2026 •

Copy link
Copy Markdown
Member

What Problem This Solves

An update can lose its preparation lock while still running; late cleanup can then delete a successor's lock. Removing expiry alone also strands an interrupted lock when its PID is reused.

User Impact

New preparation locks retain ownership through slow preparation and joined recovery work. A reused PID with a different recorded process birth can be reclaimed. Competing updates keep the existing update-running refusal while the owner remains live or its identity is unknown.

Why This Change Was Made

The shared store uses pinned fs-safe acquisition at the existing path. Its release capability stays with preparation or the recovery parent through cleanup and finishing. A finishing child records the parent's result without releasing custody.

The store records canonical starttime, including null when capture is unavailable, and uses the existing stale-owner classifier. Gateway retirement compares every custody field before reclaiming an observed lock.

This removes the separate hard-link/reclaim loop, unconditional prefix deletion, caller-supplied PID and PID-based child release. Production +149/-89 (net +60) establishes acquisition-bound ownership, process-instance recovery and the restored recovery caller. Tests +520/-126 (net +394); shared Gateway fixtures remove duplication and the temporary line-budget allocation.

Upgrade Contract

The original runId, pid, startedAt and deadlineMs meanings stay unchanged. starttime is additive and existing JSON readers ignore it. There is no dependency, configuration, database-schema, wire-protocol or public SDK change.

Four-field locks retain their existing deadline policy until retired. That behavior is present in the published beta's store, whose blob 8195db11e5a788099a457e7e9cf8689f7c0308a3 matches the frozen base. Those records cannot distinguish a live original process from a reused PID. Keeping their old behavior avoids introducing permanent lockout during an upgrade; its old live-over-budget limitation remains. No new writer produces that shape. This branch can retire when supported upgrades no longer leave pre-identity locks; Doctor cannot reconstruct a missing birth fact.

The existing local-process lock contract remains; file mtime is not a heartbeat and no cross-container extinction inference is added.

Evidence

  • Signed source 917add3024e21dd2d8f1e746e86e8b0690bcd7db, frozen base b86e2ff658d1e972e53a487a2b89ac32fd1a8f6b.
  • Four regressions failed against prior 6950ad9d510ad33ce63806f4bd36f00120eeec24: reused-PID reclamation, legacy expiry, identity-aware successor fencing and Gateway settlement.
  • Six focused files passed 205 tests on integrated 8a990c: store, recovery, Gateway trial, public Gateway RPC, preparation and preparation failure. The final Gateway fixture rerun passed 31/31. Production bytes are unchanged since 8a990c.
  • Final source tree: formatting, targeted lint (zero warnings/errors), production core and affected other-core/Gateway test types passed. Full pnpm build passed in 307.9 seconds, including unified declarations and UI budgets. That run used checkout 9f5653d plus the final one-line fixture correction; its complete tracked tree was verified equal to 917add3.
  • Autoreview (GPT-6.1 Sol, medium, P0-P3) reviewed the full committed b86e2ff...8a990c range with intact lock/recovery/process-identity context: scoped-clean, no actionable findings. It did not execute project code. The later test-only fixture refactor was independently checked for equivalence; its missing directory binding was caught by tests and corrected before the passing rerun.
  • The acting maintainer read canonical identity/classifier implementations and pinned fs-safe contracts. Independent owner/history audits corroborated the repair. The earlier formal review's INDEX-only incomplete migration was resolved in the recovery integration commit.
  • Hosted proof at verified checkout 8a990c: CI artifact build passed. The published 2026.11.12 updater exited 0, installed the exact 8a990c candidate and recorded success with readiness verified. The cell then failed its installed-file budget (47,562 entries versus 47,500), before its later independent readiness/session probes. A scheduled main run failed earlier with the same 47,562-entry count. This establishes a pre-existing budget failure, not byte-identical trees or an exact-base build. Knip reports an unused TranscriptSearchResult export in unchanged UI source. The UI authorization timeout also matches main, including identical test/helper blobs. The source-built Docker survivor passed both commit and rollback cases, preserving both test rows and refusing a newer schema in the older reader. The manual run remains red: 45 passed, 23 skipped, three underlying failures plus the aggregate gate.
  • Normal exact-head CI and fresh hosted ClawSweeper review are pending. No operator Gateway was changed; the observed upgrade used the isolated CI fixture.

Named Follow-ups

  • Early-recovery abrupt-parent-death settlement: normal joined lifetime is covered; actual orphan survival remains UNKNOWN.
  • Early-recovery run-row finalization after acquisition/bookkeeping failure: separate confirmed producer repair, kept out of this lock fix.

Related: #207040, #207085, #207062.

@vincentkoc vincentkoc self-assigned this Nov 28, 2026
@clawsweeper

clawsweeper Bot commented Nov 28, 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 P2 Normal backlog priority with limited blast radius. impact:other This issue has meaningful maintainer-visible impact outside the owned taxonomy. labels Nov 28, 2026
@vincentkoc
vincentkoc marked this pull request as ready for review November 28, 2026 02:17
@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. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. 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. labels Nov 28, 2026
@clawsweeper

clawsweeper Bot commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: passed.

What this changes

This PR preserves preparation-lock ownership through cleanup and recovery, while using process-birth identity to recover locks after PID reuse.

Example: An update remains alive after its 45-minute preparation budget.

  • Before: Another update can reclaim its lock, and the original updater's cleanup can delete the successor's lock.
  • After: The live updater retains custody until release or exit, and cleanup cannot remove a successor's acquisition.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A worthwhile shared-owner repair with focused custody regressions and published-updater evidence; current-head CI is still pending.
Proof confidence 🐚 platinum hermit (4/6) ✨ media proof bonus Sufficient (linked_artifact): The public evidence records an isolated published-2026.11.12 CLI upgrade installing 8a990c and recording success/readiness, plus source-built commit/rollback coverage; production files match the reviewed head. Later independent probes did not run after the package-budget failure, and detailed hosted logs were blocked by the review network. PID reuse and delayed cleanup are supported by focused regression evidence rather than that upgrade scenario.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Concurrent or interrupted updates can lose preparation ownership, corrupt lock custody, or leave later updates blocked after PID reuse.
Reason: The maintainer-authored repair restores exclusive preparation and recoverable interruption while retaining the existing update refusal and published compatibility behavior.

Merge readiness

✅ Ready for maintainer review

This PR addresses a current update-lock defect, resolves the prior PID-reuse finding, and introduces no actionable correctness finding; exact-head CI remains pending.

Reviewed head: 917add3024e21dd2d8f1e746e86e8b0690bcd7db

Before merge

None.

Findings

None.

Agent review details

How this fits together

The shared update store arbitrates CLI, Gateway, and early-release recovery preparation; the launcher activates prepared releases, and Gateway readiness settles their recorded outcomes.

flowchart TD
  A[CLI or Gateway update] --> B[Preparation owner]
  C[Early release recovery] --> D[Shared update lock store]
  B --> D
  D --> E[Filesystem lock provider]
  B --> F[Resident launcher]
  F --> G[Gateway readiness]
  G --> D
Loading

Technical review

Best possible solution:

Keep the existing shared store as the single custody owner, with acquisition-bound release and process-instance recovery across all callers.

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

Current-main source directly permits expiry of a live preparation and unconditional successor deletion; the PR supplies focused regressions, but this read-only review executed no target code.

Is this the best way to solve the issue?

The repair uses the existing lock provider and stale-owner classifier, migrates all production callers, and preserves the published legacy-lock contract without adding another lifecycle owner.

AGENTS.md: found and applied where relevant.

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

Provenance checked

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

  • Current main still has the defect: Fetched main expires preparation locks by deadline and releases them with unconditional path deletion; the reviewed PR replaces both behaviors. (src/update/store.ts:133, 64d84290c4c7)
  • Prior finding resolved: New locks always record starttime, including explicit null; the existing stale-owner classifier detects changed process identity, while retirement compares all five canonical custody fields. (src/update/store.ts:144, 917add3024e2)
  • Recovery custody cutover: Preparation releases its acquired capability after cleanup; early recovery retains that capability in its parent until joined finishing or failure recording completes, and finishing children no longer release by PID. (src/infra/update-early-release-recovery.ts:586, 917add3024e2)
  • Published lock compatibility: The published v2026.12.1-beta.2 store blob matches the frozen base blob 8195db11e5a788099a457e7e9cf8689f7c0308a3; its four-field locks retain their existing expiry policy, with the legacy live-over-budget limitation explicitly accepted in the maintainer-authored body. (src/update/store.ts:145, 917add3024e2)
  • Imported lock-provider contract: The patch directly imports the already-pinned fs-safe 0.28.2 file-lock API; its source confirms non-reentrant contention, guarded stale reclamation, acquisition-specific release, and retainOnExit support, establishing the dependency-policy applicability signal. (src/sidecar-lock.ts, 1db56aed56c0)
  • Upgrade evidence and verification limit: https://github.com/openclaw/openclaw/actions/runs/46350868673 is pinned to 8a990c9; the public body records a successful published-2026.11.12 installation and readiness before a later package-budget failure, and the changed production files are identical at the reviewed head. Detailed job logs redirect to a host blocked by the review network. (8a990c9973ab)

PR surface

Source +60, Tests +394, Docs +6. Total +460 across 11 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 5 149 89 +60
Tests 5 520 126 +394
Docs 1 8 2 +6
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 11 677 217 +460

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Review metrics

Metric Value Why it matters
Production versus test changes Production +149/-89; tests +520/-126 Growth covers acquisition ownership, process identity, legacy locks, successor preservation, recovery lifetime, and the Gateway RPC failure boundary.

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • remove rating: 🧂 unranked krab: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove merge-risk: 🚨 availability: 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:

  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit 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 readiness starts with the lower of the proof and patch scores. It is capped at 3/6 if the fix is partial, the change offers little benefit, a product decision is still open, or the PR reverses an earlier decision without saying why. ✨ 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 (3 earlier review cycles)
  • reviewed 2026-11-28T02:45:07.027Z sha 07cbca6 :: blocked before merge. :: [P2] [P2] Move the Gateway failure fixture to the new acquisition boundary | [P2] [P2] Integrate updater custody comparisons with the identity ratchet
  • reviewed 2026-11-28T03:16:04.426Z sha 343cc4c :: passed. :: none
  • reviewed 2026-11-28T06:09:26.471Z sha 6950ad9 :: needs changes before merge. :: [P1] [P1] Preserve recovery when an exited preparer's PID is reused

Reviewed November 29, 2026, 11:36 PM ET / November 30, 2026, 04:36 UTC (Revision 4).

@vincentkoc
vincentkoc marked this pull request as draft November 28, 2026 02:56
@vincentkoc
vincentkoc force-pushed the fix/update-prepare-lock-ownership-20261128 branch from 07cbca6 to 343cc4c Compare November 28, 2026 02:56
@openclaw-barnacle openclaw-barnacle Bot added the gateway Gateway runtime label Nov 28, 2026
@vincentkoc
vincentkoc marked this pull request as ready for review November 28, 2026 03:10
@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review — exact head 343cc4c. Both prior findings are repaired; the unchanged identity guard, all 92 updater cases, all 16 Gateway RPC cases, seven type jobs and scoped core lint pass. The existing four-field lock JSON is preserved; the passing store regression writes pre-provider JSON with a real exited PID and reclaims, reads and releases it. Compatibility proof and remaining execution limits are in the PR body.

@clawsweeper

clawsweeper Bot commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added 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. labels Nov 28, 2026
@vincentkoc
vincentkoc marked this pull request as draft November 28, 2026 03:33
@vincentkoc
vincentkoc force-pushed the fix/update-prepare-lock-ownership-20261128 branch from 343cc4c to cec31b9 Compare November 28, 2026 03:37
@clawsweeper clawsweeper Bot removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Nov 28, 2026
@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review — exact head 6950ad9. The restored early-release recovery caller now retains acquisition-bound custody in its parent through joined finishing and failure recording. All 181 distinct owner/sibling cases pass across focused runs; the two files affected by host suspension passed all 56 cases awake with unchanged timeouts. Production and targeted test types, lint, formatting and the full exact-head build pass. Current proof and the INDEX-only review finding's resolution are recorded in the PR body. Please review the canonical lock owner and recovery caller integration.

@clawsweeper

clawsweeper Bot commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Nov 28, 2026
@vincentkoc
vincentkoc marked this pull request as draft November 30, 2026 03:31
@openclaw-barnacle openclaw-barnacle Bot added the docs Improvements or additions to documentation label Nov 30, 2026
@vincentkoc
vincentkoc force-pushed the fix/update-prepare-lock-ownership-20261128 branch from 0737678 to 8a990c9 Compare November 30, 2026 03:57
@vincentkoc
vincentkoc marked this pull request as ready for review November 30, 2026 04:31
@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review — exact prepared head 917add3.

The reused-PID finding is fixed at the shared lock owner: canonical process-birth identity, explicit unknown identity for new writers, complete retirement snapshots, and the published four-field legacy recovery contract. Four focused regressions failed against the prior implementation. Integrated owner/sibling coverage passed 205 tests; the final Gateway fixture rerun passed 31/31. Formatting, targeted lint, production/affected test types and the full final-source-tree build passed. Independent P0–P3 review found no actionable issue; later test-fixture deduplication was separately checked.

The published 2026.11.12 updater installed the exact candidate and recorded success/readiness. Its subsequent entry-budget failure and the UI timeout also occur on contemporaneous main; linked evidence and the later unrun probes remain explicit in the PR body. Source-built commit/rollback proof passed. Normal exact-head CI is now starting. Please review the repaired ownership and process-reuse boundary.

@clawsweeper

clawsweeper Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. 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: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Nov 30, 2026
@vincentkoc
vincentkoc enabled auto-merge (squash) November 30, 2026 04:42
@vincentkoc
vincentkoc merged commit 743f83a into main Nov 30, 2026
231 of 232 checks passed
@vincentkoc
vincentkoc deleted the fix/update-prepare-lock-ownership-20261128 branch November 30, 2026 05:15
@vincentkoc

Copy link
Copy Markdown
Member Author

Merged via squash auto-merge.

vincentkoc added a commit that referenced this pull request Nov 30, 2026
* commit 'b21f557c8fa038ebc1842e204e356eb063aea4c6': (46 commits)
  test(ui): keep real exports in the channel settings distribution mock (#208855)
  test(normalization): preserve inline code in quoted previews (#208857)
  fix(ci): restore adaptive priors across large repository trees (#208838)
  test(agents): cover typography preservation in patch updates (#208851)
  fix(ci): wait for selected agent during model setup proof (#208847)
  fix: keep Telegram topic messages out of Home’s chat history (#208778)
  fix(worktrees): name the session to restore and say agents can't (#208828)
  fix: tell an idle parent when a child result couldn't reach its chat (#208772)
  fix: keep the provider search focused when accounts load (#208780)
  fix(clawrouter): respect permitted speeds on model fallback (#208830)
  fix(ui): show provider rejection details without Markdown escapes (#208829)
  fix: make the cloud worker deletion test reliable across reconnects (#208812)
  fix(update): preserve preparation lock ownership (#207139)
  chore(release): update appcast for 2026.11.12 (#208820)
  fix(android): Talk does nothing when mic access is permanently denied (#206609)
  test(config): preserve media model primaries across repeated edits (#208837)
  fix(browser): use the mock keychain for new headed macOS profiles (#208814)
  fix: start source workers without synchronous filesystem reads in the caller (#208789)
  refactor(ios): stop loading retired Overview data (#208795)
  perf(knowledge): stop repeating write-input schemas in batch and correct tools (#208617)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation gateway Gateway runtime impact:other This issue has meaningful maintainer-visible impact outside the owned taxonomy. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. 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.

1 participant