Skip to content

fix(update): recover when another user owns shared temp storage - #170174

Merged
steipete merged 2 commits into
mainfrom
upd/upd-l1569
Oct 12, 2026
Merged

steipete merged 2 commits into
mainfrom
upd/upd-l1569

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes package updates and update repair getting stuck after another local user takes ownership of the shared /tmp/openclaw directory.

Fixes #169382.

User Impact

Managed updates use a stable private per-user temporary lease directory. Repair treats an obsolete lease in another user's directory as missing and acquires current private ownership without reading or creating files there. Existing package, launcher, retained-evidence, and unfinished-rollback protections still apply. No configuration, schema, or dependency changes are required.

Why This Change Was Made

Lease placement previously followed the shared temporary-directory resolver, so another user's ownership could move the active lease path. Settlement then tried to prepare the historical database path and failed its ownership check. The lease owner now selects the per-user root explicitly, and package activation settlement and completed-receipt recovery recognize a foreign directory before database admission.

The shared test binding follows the private lease default as well. Two inherited gate failures are repaired with their canonical upstream changes: the internal TransactionRecipes export fix from 4cdac89, and the exact startup-checkpoint test hunk from cca31d7. The latter measures the two WAL-verification calls before a separate conflict probe can reopen the database; it preserves the original assertions.

Evidence

  • All three new regression cases failed before the fix for the intended reasons: shared-path placement and unsafe foreign-directory admission. They pass with the fix, including untouched package/launcher bytes and no foreign-directory changes.
  • Final focused run: 3 files, 10 tests passed (the three new cases plus seven startup-checkpoint cases); 58.89 s Vitest wall time, with 6% in tests and 89% in transform. The earlier two-file regression run passed in 246.68 s, with about 5.2 s in tests and the remainder dominated by shared preparation.
  • Importer selection covered 112 files: 109 passed across the completed local batches; three existing immutable-runtime files remained repository-skipped. The final continuation passed 591 tests across seven shards in 1627.42 s. The shared isolation helper passed all 11 tests after its binding fix.
  • The separately selected live Node-provisioning test passed: 1 file / 1 test, 47.18 s Vitest wall time (38.51 s test time), 51.38 s wrapper wall time. It used an empty task-owned home and state, installed the pinned runtime, released both leases, and reused the installed runtime.
  • Full node scripts/check-changed.mjs passed (exit 0; 1118.58 s), including production types, all 28 core-test type shards, root-test types, lint, ratchets, and runtime import-cycle checks. node --import ./scripts/tsx.mjs scripts/check-madge-import-cycles.ts reported 0 cycles. git diff --check passed.
  • Existing slow compositions were retained without timeout/retry changes: original-service recovery reached 101.95 s per case; Doctor installation reached 97.07 s; legacy finalization took 411.89 s per file. These exercise real state/lease owners, subprocesses, or configuration persistence. An earlier batch was interrupted by the no-output watchdog during a capacity pause; only completed files were reused and the interrupted/pending files were subsequently executed.
  • Independent Codex review could not start because its private-temporary-directory isolation preflight failed. No isolation bypass or clean-review claim; lead review of the published head is still required.

Resolve the unused export reported by main CI 38271415987. The helper remains module-private and DatabaseEngineAdapter.transactions retains its existing structural contract. Full deadcode checks, core types, focused lint/format, and independent review pass.
@clawsweeper

clawsweeper Bot commented Oct 12, 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.

@steipete
steipete marked this pull request as ready for review October 12, 2026 19:37
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation size: S labels Oct 12, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. 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. labels Oct 12, 2026
@clawsweeper

clawsweeper Bot commented Oct 12, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

What this changes

This PR moves managed-update leases into per-user temporary storage and recovers obsolete receipts without opening foreign-owned directories.

Example: Root repairs an update whose recorded /tmp/openclaw directory now belongs to UID 1001.

  • Before: Repair fails with “managed handoff lease directory is unsafe.”
  • After: Eligible recovery acquires ownership under /tmp/openclaw-0 and preserves the foreign directory.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The repair has clear value and meaningful owner-level regressions, but a supported upgrade path is broken and persisted-recovery upgrade compatibility is unproven.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is necessary before merge. See Before merge.
Patch quality 🦪 silver shellfish (2/6) Security review found an item that needs attention.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Managed updates and repair can refuse after another local user recreates the shared temporary directory.
Reason: The report establishes a concrete failure, and the supplied maintainer-authorship context settles the direction; preserving supported upgrade continuations remains an implementation requirement.

Merge readiness

⛔ Blocked before merge - 6 items remain

Keep this PR open: it addresses a confirmed recovery failure, but changing the default lease location breaks a supported legacy managed-update continuation.

Priority: P2
Reviewed head: 32b714fa041d277b2782bb3679701c55c51a3d03

Before merge

  • Add real behavior proof - Authority-chain proof required: the supplied regressions simulate foreign ownership while exercising real settlement code; provide an authorized production-path trace of successful recovery, untouched foreign storage, and competing or revoked executor rejection before journal/package I/O, with IPs, keys, phone numbers, and non-public endpoints redacted. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Preserve the released parent's lease path for legacy finalization (P1) - On a POSIX host where /tmp/openclaw belongs to the updating user, a managed update started by 2026.9.3 holds its parent lease there. The supported grantless continuation in update-migrated-finalize.worker.ts passes legacyManagedParent without existingAuthority, so update-command-executor.ts resolves this newly changed default instead. It opens /tmp/openclaw-UID/managed-update-handoffs.sqlite, where the parent row is absent, and acquireLegacyUpdateExecutorParent throws “Legacy finalizer does not match its live managed parent.” This regresses the successful migrated-update path restored by fix(update): finish 2026.9.3 managed upgrades after migration #148604 and can leave finalization unfinished after the Gateway has stopped. Resolve and pin the historical lease domain for that continuation rather than applying the new-operation default to it, and cover distinct old/new directories in the regression.
  • Resolve security review attention item - Source preserves foreign-directory rejection, but replacement-authority isolation still needs final-effect evidence.
  • Resolve merge risk - Before merging, establish that replacement private-store authority excludes competing or revoked executors before journal or package effects.
  • Improve patch quality - Add final-effect proof that competing and revoked executors cannot mutate the journal or package after replacement-store admission.
  • Add data-model compatibility proof - The review found that existing stored data may not work after upgrade. Show that existing data still loads and works with this change.

Findings

  • [P1] Preserve the released parent's lease path for legacy finalization — src/infra/update-managed-service-handoff-lease.ts:78-80

Tests

  • Missing end-to-end proof: Provide production-path cross-user recovery evidence showing untouched foreign storage and final-effect refusal for competing or revoked authority; the body reports pre-fix regression failures, but the shared test binding maps both lease defaults onto one fixture.
Agent review details

How this fits together

The updater records installation ownership in a temporary SQLite lease store; package recovery consumes that authority to settle persisted publication journals and coordinate filesystem effects.

flowchart TD
  A[Update CLI or Gateway] --> B[Executor admission]
  B --> C[Managed lease store]
  D[Persisted package journal] --> E[Recovery settlement]
  E --> B
  E --> F[Package and launcher verification]
  F --> G[Retained recovery evidence]
Loading

Technical review

Best possible solution:

Keep private defaults for new operations while preserving the exact historical lease domain for supported live continuations and safely settling obsolete foreign-owned receipts.

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

The released-version report and current-main recovery path establish the foreign-directory refusal; source tracing also establishes the introduced legacy-finalizer failure, without executing target code.

Is this the best way to solve the issue?

Repairing the existing placement and settlement owners is appropriate, but changing the global default alone misses the supported released-driver continuation contract.

Full review comments:

  • [P1] Preserve the released parent's lease path for legacy finalization — src/infra/update-managed-service-handoff-lease.ts:78-80
    On a POSIX host where /tmp/openclaw belongs to the updating user, a managed update started by 2026.9.3 holds its parent lease there. The supported grantless continuation in update-migrated-finalize.worker.ts passes legacyManagedParent without existingAuthority, so update-command-executor.ts resolves this newly changed default instead. It opens /tmp/openclaw-UID/managed-update-handoffs.sqlite, where the parent row is absent, and acquireLegacyUpdateExecutorParent throws “Legacy finalizer does not match its live managed parent.” This regresses the successful migrated-update path restored by fix(update): finish 2026.9.3 managed upgrades after migration #148604 and can leave finalization unfinished after the Gateway has stopped. Resolve and pin the historical lease domain for that continuation rather than applying the new-operation default to it, and cover distinct old/new directories in the regression.
    Confidence: 0.97

Overall correctness: patch is incorrect
Overall confidence: 0.94

AGENTS.md: found and applied where relevant.

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

Merge-risk options

Maintainer options:

  1. Prove replacement authority before filesystem effects (recommended)
    Exercise successful foreign-directory recovery and rejection of competing or revoked ownership through the production owners, recording that forbidden attempts cause no journal or package mutation.

Provenance checked

  • Managed-update lease placement changes intended behavior with a stated reason (e07af71: One installation lease owner coordinates managed updates and recovery across process lifetimes.)
  • Historical package-activation settlement keeps the original intent (ff6f58a: Eligible lost or replaced leases are settled under fresh ownership while preserving package verification and unfinished rollback protection.)
  • Shared test isolation keeps the original intent (1f55d63: Bind actual executor storage to private fixtures before imports and refuse unintended shared paths.)
  • Inherited type and checkpoint-test gate repairs changes intended behavior with a stated reason (9dc6466: The PR explains and exactly reuses upstream repairs that keep transaction types internal and measure integrity calls before a separate conflict probe.)

Testing

Proof path: in-process harness.

Security

Needs attention: Source preserves foreign-directory rejection, but replacement-authority isolation still needs final-effect evidence.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit e07af71 adds src/infra/update-managed-service-handoff-lease.ts:99 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: e07af7166c16; files: src/infra/update-managed-service-handoff-lease.ts)

PR surface

Source +28, Tests +135, Docs +6. Total +169 across 8 files. Added test files: 2.

View PR surface stats
Area Files Added Removed Net
Source 3 32 4 +28
Tests 4 140 5 +135
Docs 1 6 0 +6
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 8 178 9 +169

Labels

Label changes:

  • add P2: The requested repair addresses a concrete multi-user administration failure with limited affected setups and an existing manual recovery route.
  • add merge-risk: 🚨 compatibility: The new default disconnects supported released-driver continuations from their waiting parent's lease database.
  • add merge-risk: 🚨 security-boundary: Recovery substitutes a new authority-bearing store for a recorded foreign-owned store without final-effect evidence for competing or revoked ownership.
  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦪 silver shellfish.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Label justifications:

  • P2: The requested repair addresses a concrete multi-user administration failure with limited affected setups and an existing manual recovery route.
  • merge-risk: 🚨 compatibility: The new default disconnects supported released-driver continuations from their waiting parent's lease database.
  • merge-risk: 🚨 security-boundary: Recovery substitutes a new authority-bearing store for a recorded foreign-owned store without final-effect evidence for competing or revoked ownership.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦪 silver shellfish.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

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.

Reviewed October 12, 2026, 3:44 PM ET / 19:44 UTC.

@steipete
steipete merged commit c949e5a into main Oct 12, 2026
205 of 207 checks passed
@steipete
steipete deleted the upd/upd-l1569 branch October 12, 2026 19:53
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 13, 2026
…ge (openclaw#170174)

The managed update handoff lease lived under the shared /tmp/openclaw, whose path flipped to /tmp/openclaw-<uid> whenever another local user created it first; recovery then refused the other user's directory as unsafe and blocked package-swap and update repair. The lease now always uses a stable private per-user directory, and recovery treats a recorded lease under a foreign-owned directory as missing and settles it under current ownership, preserving rollback protections. Fixes openclaw#169382.
RomneyDa pushed a commit that referenced this pull request Oct 16, 2026
…ge (#170174)

The managed update handoff lease lived under the shared /tmp/openclaw, whose path flipped to /tmp/openclaw-<uid> whenever another local user created it first; recovery then refused the other user's directory as unsafe and blocked package-swap and update repair. The lease now always uses a stable private per-user directory, and recovery treats a recorded lease under a foreign-owned directory as missing and settles it under current ownership, preserving rollback protections. Fixes #169382.

(cherry picked from commit c949e5a)
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 merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: S status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Managed update lease lives in shared /tmp/openclaw; another local user owning it moves the lease path and blocks package-swap and update repair

1 participant