Repository navigation
fix: chat-requested updates no longer leave the Gateway stopped - #203555
Conversation
…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.
… fixture's own handle
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.
|
🦞👀 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. |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex review: needs changes before merge. What this changesRelease 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.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete 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 Before merge
Findings
Agent review detailsHow this fits togetherThe 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]
Technical reviewBest 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:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 1a0a24dcd2cf. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceAcceptance criteria:
What I checked:
Likely related people:
PR surfaceSource +39, Tests +35. Total +74 across 3 files. Added test files: 0. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. LabelsLabel 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 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.
|
Merged via squash.
|
…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.
) * 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)
…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)
What Problem This Solves
When someone updates OpenClaw from a chat channel (for example
/updatefrom 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-cliexports 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 Gatewayupdate.runwith a Telegram owner as requester.On base
8d1e59c2fdd, the chat-requested update failed with the reported rollback refusal,/readyzreturned nothing, and the unit was inactive. The same update without a requester succeeded. The failing case was reproduced four times on2c473901162before that./proc/locksshowed the helper process holding READ locks onopenclaw.sqliteand its-shmfor 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:/readyzcore-ready. The fake bot token keeps the channel itself unready, as in the harness baseline./readyz200.2026.11.6to 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
17bae7685b0only 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.