Skip to content

fix: chat-requested updates no longer leave the Gateway stopped - #203555

Merged
steipete merged 5 commits into
mainfrom
codex/update-managed-rollback-connection
Nov 22, 2026
Merged

steipete merged 5 commits into
mainfrom
codex/update-managed-rollback-connection

Conversation

@steipete

@steipete steipete commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

When someone updates OpenClaw from a chat channel (for example /update from a Telegram owner), the managed update could fail partway and leave the Gateway stopped. The update reported "Database rollback could not start … another SQLite connection is active", and the user's assistant stayed offline until someone repaired it by hand.

User Impact

Chat-requested managed updates finish normally again. If a candidate does fail, database rollback can run and the previous Gateway comes back instead of staying stopped.

Why This Change Was Made

The detached update helper checks that the chat requester is still a command owner while the Gateway is serving. Because a live Gateway owns the state database, that check reads shared state through a background read worker, and the worker keeps its idle reader open for up to 30 minutes. The helper then waits while the new version's Doctor takes exclusive database access for migration bookkeeping. The helper's idle WAL reader holds a shared lock, so Doctor refused ("another connection still has it open"), and the database rollback that followed refused for the same reason.

The helper's own requester-check entry points (the two daemon-cli exports only the handoff helper imports) now release worker-held state connections once the check settles, using the existing drain that exists for exactly this WAL shared-lock case. A failed check keeps its original error, and a failed release is reported with it. The shared requester capture is unchanged, so the updater's own concurrent progress reads are not cancelled.

Updates without a chat requester (Control UI, CLI) never ran this check in the helper and were not affected. The daemon exports the helper imports keep their names. The shared capture underneath is renamed internally (prepareUpdateRequesterIdentity), so the export-name check sees one behavior per name and the installed contract does not change.

Related: #203497 rewrites owned global package activation; it does not touch the helper's requester check or state readers, and installs that keep the managed handoff still need this.

Evidence

A managed update was reproduced end to end and then run again on the fix, using real npm package builds of current main (relabelled versions on a local registry) on an AWS Linux box with a systemd user Gateway, started through Gateway update.run with a Telegram owner as requester.

On base 8d1e59c2fdd, the chat-requested update failed with the reported rollback refusal, /readyz returned nothing, and the unit was inactive. The same update without a requester succeeded. The failing case was reproduced four times on 2c473901162 before that. /proc/locks showed the helper process holding READ locks on openclaw.sqlite and its -shm for the whole update, about 250 samples. A node:sqlite trace inside the helper tied the connection to its state-read worker, opened during the requester check.

On fcb54159f8d, three managed updates succeeded with the Gateway active on the target version:

  • main to main with the Telegram owner requester: /readyz core-ready. The fake bot token keeps the channel itself unready, as in the harness baseline.
  • the same requester with the channel disabled: /readyz 200.
  • published 2026.11.6 to the fix: also succeeded.

The new test drives both helper entry points against a real state database and then takes native exclusive access. Without the release it fails with database is locked; with the fix it passes, 15/15 in the file. An independent Codex review of an earlier revision found two issues: draining in the shared capture could cancel the updater's in-flight progress reads, and a release failure could replace the deferred authority error. That review led to the helper-only placement. The final head has a clean autoreview and an independent review with no findings.

The later head 17bae7685b0 only renames the internal capture and keeps the helper runner untouched against base. The managed-handoff lifecycle suite, which covers profile and configured-owner requester rechecks, passes together with the requester tests (88/88), the export-name check passes, and autoreview is clean.

…ay stopped

The managed update helper checks the chat requester's owner authority while the Gateway still serves. With a live owner, that check reads shared state natively through the state-read worker, which retains the idle reader for 30 minutes. The helper then waits while the candidate Doctor takes exclusive migration access and, on failure, database rollback takes removal exclusion; the retained WAL reader's shared lock made both refuse, leaving the Gateway stopped.

Release worker-held connections at the state path after each requester authority capture.
Draining every worker read at the state path from the shared requester capture could cancel the updater's in-flight progress reads and could replace a deferred authority error. Release readers only at the helper's own entry points, after the check settles, preserving the check's failure alongside any release failure.
@clawsweeper

clawsweeper Bot commented Nov 22, 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.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-22T17:43:02.876759Z 17bae76 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@openclaw-barnacle openclaw-barnacle Bot added cli CLI command changes size: S labels Nov 22, 2026
@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. P0 Emergency: data loss, security bypass, crash loop, or unusable core runtime. proof: sufficient ClawSweeper judged the real behavior proof convincing. 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. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 22, 2026
@clawsweeper

clawsweeper Bot commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge.

What this changes

Release worker-held SQLite readers after the detached update helper checks the chat requester's authority.

Example: A Telegram owner requests a managed update through update.run.

  • Before: The helper retains a SQLite reader, Doctor and rollback refuse exclusive access, and the Gateway remains stopped.
  • After: The helper releases its readers before maintenance; the reported fixed-head update completes with the Gateway active and /readyz returning 200.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The focused repair has production-path and stable-upgrade evidence, but its introduced export collision leaves a concrete CI blocker.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The PR records Gateway update.run exercising the changed helper on Linux/systemd: base requester updates left the unit inactive, final-head requester updates restored an active target Gateway with readiness results, and published 2026.11.6 upgraded successfully.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: A chat-requested update can leave the assistant offline when the helper's SQLite reader prevents both maintenance and rollback.
Reason: This restores intended update and recovery behavior with existing lifecycle operations; maintainer-authored direction is already established.

Merge readiness

⛔ Needs changes before merge - 1 item remains

Keep this PR: it repairs a concrete update outage still present on main, but introduces an export collision that blocks CI.

Priority: P0
Reviewed head: fcb54159f8d901101d0dfcc9f1f0979eb884dfc1

Before merge

  • Resolve the new export collision without changing the daemon contract (P2) - This new function defines prepareManagedUpdateRequesterIdentity alongside the existing definition in src/infra/update-requester-authority.ts. Because it adds cleanup rather than forwarding arguments unchanged, the repository's export guard counts both definitions. The reviewed head's check-source-contracts job fails specifically at lint:tmp:export-name-collisions. Give the underlying capture a distinct internal name and update its consumers, preserving the installed daemon export and helper-only cleanup.

Findings

  • [P2] Resolve the new export collision without changing the daemon contract — src/cli/daemon-cli/lifecycle-context.ts:110-111
Agent review details

How this fits together

The detached update helper checks requester authority through the installed daemon entry point, then coordinates Gateway shutdown, candidate maintenance, and recovery.

flowchart TD
  A[Chat update request] --> B[Gateway update admission]
  B --> C[Detached update helper]
  C --> D[Requester authority check]
  D --> E[Release helper SQLite readers]
  E --> F[Doctor and activation]
  F --> G[Running or restored Gateway]
Loading

Technical review

Best possible solution:

Keep helper-only reader cleanup and automatic Gateway recovery, while giving the shared identity capture a distinct internal export name without changing the installed daemon contract.

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

The helper lifetime, retained WAL-reader contract, and exclusive-access regression establish the source path; the PR reports matching real update failures, but this read-only review ran no target code.

Is this the best way to solve the issue?

Helper-only drainage uses the existing lifecycle owner and avoids cancelling updater progress reads; the shared wrapper serves two real entry points and is justified.

Full review comments:

  • [P2] Resolve the new export collision without changing the daemon contract — src/cli/daemon-cli/lifecycle-context.ts:110-111
    This new function defines prepareManagedUpdateRequesterIdentity alongside the existing definition in src/infra/update-requester-authority.ts. Because it adds cleanup rather than forwarding arguments unchanged, the repository's export guard counts both definitions. The reviewed head's check-source-contracts job fails specifically at lint:tmp:export-name-collisions. Give the underlying capture a distinct internal name and update its consumers, preserving the installed daemon export and helper-only cleanup.
    Confidence: 0.99

Overall correctness: patch is incorrect
Overall confidence: 0.96

AGENTS.md: found and applied where relevant.

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

Provenance checked

Testing

Proof path: shipped entry point.

Security

None.

Evidence

Acceptance criteria:

  • pnpm lint:tmp:export-name-collisions
  • pnpm test src/infra/update-requester-authority.test.ts --maxWorkers=1
  • pnpm tsgo:core
  • git diff --check

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 76bf977 adds src/cli/daemon-cli/lifecycle-context.ts:1 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 76bf977faefe; files: src/cli/daemon-cli/lifecycle-context.ts)
  • Vincent Koc: Raw commit f1d2c5b adds src/cli/daemon-cli/lifecycle-context.ts:3 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: f1d2c5b91f80; files: src/cli/daemon-cli/lifecycle-context.ts)

PR surface

Source +39, Tests +35. Total +74 across 3 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 2 44 5 +39
Tests 1 35 0 +35
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 79 5 +74

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.

Labels

Label changes:

  • add P0: A community user requesting an update from chat can lose the Gateway and require manual repair, meeting the update/recovery UX priority override.
  • add proof: sufficient: Contributor real behavior proof is sufficient.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🐚 platinum hermit and patch quality is 🦐 gold shrimp.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Label justifications:

  • P0: A community user requesting an update from chat can lose the Gateway and require manual repair, meeting the update/recovery UX priority override.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🐚 platinum hermit and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.
  • 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.

Reviewed November 22, 2026, 11:51 AM ET / 16:51 UTC.

The export-name-collision check rejects a second behavior under prepareManagedUpdateRequesterIdentity. The handoff helper imports the releasing entry from the same installed runtime before the update command starts, so renaming it is a same-version contract.
Keep prepareManagedUpdateRequesterIdentity as the daemon-cli export the handoff helper imports, and give the underlying capture its own internal name instead, so the export-name check sees one behavior per name without changing the installed contract.
@steipete
steipete merged commit 832fa6a into main Nov 22, 2026
136 of 138 checks passed
@steipete
steipete deleted the codex/update-managed-rollback-connection branch November 22, 2026 18:10
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 23, 2026
…claw#203555)

* fix(update): chat-requested managed updates no longer leave the Gateway stopped

The managed update helper checks the chat requester's owner authority while the Gateway still serves. With a live owner, that check reads shared state natively through the state-read worker, which retains the idle reader for 30 minutes. The helper then waits while the candidate Doctor takes exclusive migration access and, on failure, database rollback takes removal exclusion; the retained WAL reader's shared lock made both refuse, leaving the Gateway stopped.

Release worker-held connections at the state path after each requester authority capture.

* test(update): isolate the requester reader-release check from the run fixture's own handle

* fix(update): release requester-check readers only in the update helper

Draining every worker read at the state path from the shared requester capture could cancel the updater's in-flight progress reads and could replace a deferred authority error. Release readers only at the helper's own entry points, after the check settles, preserving the check's failure alongside any release failure.

* fix(update): give the helper's requester identity entry its own name

The export-name-collision check rejects a second behavior under prepareManagedUpdateRequesterIdentity. The handoff helper imports the releasing entry from the same installed runtime before the update command starts, so renaming it is a same-version contract.

* refactor(update): keep the installed daemon requester export name

Keep prepareManagedUpdateRequesterIdentity as the daemon-cli export the handoff helper imports, and give the underlying capture its own internal name instead, so the export-name check sees one behavior per name without changing the installed contract.
tideclaw-bot pushed a commit that referenced this pull request Nov 23, 2026
)

* fix(update): chat-requested managed updates no longer leave the Gateway stopped

The managed update helper checks the chat requester's owner authority while the Gateway still serves. With a live owner, that check reads shared state natively through the state-read worker, which retains the idle reader for 30 minutes. The helper then waits while the candidate Doctor takes exclusive migration access and, on failure, database rollback takes removal exclusion; the retained WAL reader's shared lock made both refuse, leaving the Gateway stopped.

Release worker-held connections at the state path after each requester authority capture.

* test(update): isolate the requester reader-release check from the run fixture's own handle

* fix(update): release requester-check readers only in the update helper

Draining every worker read at the state path from the shared requester capture could cancel the updater's in-flight progress reads and could replace a deferred authority error. Release readers only at the helper's own entry points, after the check settles, preserving the check's failure alongside any release failure.

* fix(update): give the helper's requester identity entry its own name

The export-name-collision check rejects a second behavior under prepareManagedUpdateRequesterIdentity. The handoff helper imports the releasing entry from the same installed runtime before the update command starts, so renaming it is a same-version contract.

* refactor(update): keep the installed daemon requester export name

Keep prepareManagedUpdateRequesterIdentity as the daemon-cli export the handoff helper imports, and give the underlying capture its own internal name instead, so the export-name check sees one behavior per name without changing the installed contract.

(cherry picked from commit 832fa6a)

Co-authored-by: RomneyDa <[email protected]>
(cherry picked from commit 7fc2da6f56f9f755cfc212c617c6e6e85623865a)
(cherry picked from commit 6b9395ffe4f2705ff91690c5c2bda55122bbab5d)
tideclaw-bot pushed a commit that referenced this pull request Nov 24, 2026
…ate acts on it (#201668)

* fix(update): verify recorded data-at-risk marks before repair acts on them

* fix(update): verify any unverified data-at-risk mark and honor receipts in handoff recovery

* fix(update): recognize a Git release-mode service as its checkout's own

* fix(update): check a recorded data-at-risk mark before the next update, including already-current runs

* fix(update): lead data-at-risk refusals with triage and record them on the refused run

* fix(update): keep data-at-risk refusals within the recorded warning limit

* test(e2e): finish the seeded data-at-risk run with a terminal phase

* fix(update): name the agent route in killed-update recovery refusals

* fix(update): drop an unused import

* test(update): expect the agent route in killed-update refusals

* fix(update): verify the newest mark before restoration without comparing run ids

* fix(update): address review: keep the Gateway down on any inconsistent mark, resolve all marks, harden release ownership

* fix(update): break the admission-root import cycle and type the e2e schema read

* fix(update): address rating findings: agent rollback leftovers, helper restart, blocking findings first, shared Git metadata

* test(e2e): prove the next plain update resolves a mark with the Gateway running

* fix(update): address rating round 2: refuse marks before Doctor, registry-based rollback check, handoff fallback, async history read

* test(update): pick the repair run, not a settlement row, in the data-at-risk cell

* fix(update): resolve live-writer marks after Doctor holds the state

* fix(doctor): say a skipped stale-Gateway stop left the PID running

* fix(update): address rating round 3: leftovers before deferrals, retained rollback files, refusal after Doctor fails finalization

* docs(update): note retained rollback files and refusals after Doctor

* fix(doctor): say a stale Gateway stop could not be confirmed when nothing shows it running

* fix(update): address landing review: revert release-mode ownership, check leftovers first, handoff entry guard, durable rollback evidence

* test(update): follow main's Git release link layout in the launcher refusal test

* fix(update): treat uninspectable leftovers and unreadable databases as unchecked; true wording after Doctor

Release adaptation: Retain the stable installed-recovery harness. Do not add main's installed Docker service cell, later retired by #203808, or Git release-launcher wording/test because stable uses the in-place Git updater. Keep the state-verification, next-update, repair and interrupted-handoff paths and their compatible regressions.

Companion audit: #203486 is present-equivalent at 3081077 (preserved). #201978 is selected next in this lane. #203808 and #203966 involve the inapplicable installed service-cell layout; #203497 and #203194 change main's package/Git activation layout and are not applicable; #204017 depends on that release-install layout. #204077, #204043, #203555 and #203520 are independent authority, cleanup, helper-fixture and config-validation changes. #204151, #203917, #203849 and #203406 are separate guidance, cleanup or status changes, not required by the data-risk verifier. #203569 fixes a separate cron receipt fixture in the same Doctor suite; the touched stale-stop cases do not depend on it.

(cherry picked from commit a28f211)
Co-authored-by: RomneyDa <[email protected]>
(cherry picked from commit f8d4bc138ed2512c413cf96f66fe0eefb3b28d65)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes P0 Emergency: data loss, security bypass, crash loop, or unusable core runtime. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: S status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant