Repository navigation
fix: let macOS updates finish when an old Gateway left a dead lock file - #201912
Conversation
A Gateway lock written before 2026.10.1 has no processNamespace. On macOS such a record was always unverifiable, so an orphaned config lock left by a crashed older Gateway made Doctor refuse maintenance forever: the update from 2026.11.4 rolled back with doctor-failed in 19 of 20 attempts, and a started 2026.11.5 Gateway refused the same file. macOS PIDs are host-global like Windows PIDs, so namespace-less macOS file locks now use the existing Windows rule: an expired heartbeat plus native PID death or a changed process start identity proves the owner stopped. Live and unprovable owners stay refused. Linux keeps refusing because a container in another PID namespace can share the lock directory. The legacy refusal now names the recovery step for the file it found. Refs #201472
|
🦞👀 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: needs maintainer review before merge. What this changesExtend automatic dead-owner classification to legacy macOS Gateway locks and add recovery guidance to Doctor refusals. Example: A macOS lock records exited PID 71333, lacks processNamespace, and has an expired heartbeat.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Partial Merge readiness✅ Ready for maintainer review Keep open: this maintainer-authored PR narrowly addresses a current macOS update blocker through the existing lock classifier, and no introduced correctness defect was found. Priority: P0 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherDoctor maintenance and Gateway startup read persisted lock records through the shared ownership classifier, which returns same, dead, or unknown before callers acquire their own state custody. flowchart TD
A[Doctor maintenance] --> C[Legacy lock reader]
B[Gateway startup] --> D[Shared lock classifier]
C --> D
E[Lock record and heartbeat] --> D
F[Native process identity] --> D
D --> G[Admit dead owner or preserve refusal]
Technical reviewBest possible solution: Use the existing classifier for automatic macOS dead-lock recovery and retain separate confirmed recovery for unverifiable Linux owners. Do we have a high-confidence way to reproduce the issue? Current-main source establishes the refusal path, and the linked report supplies released-package controls and macOS observations; this read-only review executed no target code. Is this the best way to solve the issue? The change is the smallest complete macOS repair: it reuses the established classifier, heartbeat threshold, and native identity checks while preserving Linux's distinct namespace boundary. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 576b22128f23. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +13, Tests +15, Docs 0. Total +28 across 5 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 19, 2026, 10:52 AM ET / 15:52 UTC. |
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. |
|
Merged via squash.
|
…t blocks Doctor maintenance On Linux, Doctor refuses maintenance while a historical per-config Gateway lock in the system temporary directory records an owner it cannot verify (no processNamespace), but `openclaw gateway recover-lock` only inspected the state-local lock paths, so it reported nothing present and the documented explicit recovery never reached that file. Updates then rolled back with doctor-failed on every attempt. On Linux, inspection now also observes the legacy lock when its directory and file are owned by the current user and writable by nobody else (deduplicated when a service TMPDIR inside the state directory makes it the same file; otherwise the skipped file and reason are reported), confirmation removes it first under the same unchanged-record checks, and the Doctor refusal names the recovery command for that file. macOS and Windows admit a stopped namespace-less owner by themselves (openclaw#182031, openclaw#201912) and are unchanged. Namespace ownership policy is unchanged: the owner is never reclaimed automatically. Related: openclaw#201472 (an install already rolled back to a release without recover-lock still needs a maintainer-chosen route)
…ce (openclaw#201912) A Gateway lock written before 2026.10.1 has no processNamespace. On macOS such a record was always unverifiable, so an orphaned config lock left by a crashed older Gateway made Doctor refuse maintenance forever: the update from 2026.11.4 rolled back with doctor-failed in 19 of 20 attempts, and a started 2026.11.5 Gateway refused the same file. macOS PIDs are host-global like Windows PIDs, so namespace-less macOS file locks now use the existing Windows rule: an expired heartbeat plus native PID death or a changed process start identity proves the owner stopped. Live and unprovable owners stay refused. Linux keeps refusing because a container in another PID namespace can share the lock directory. The legacy refusal now names the recovery step for the file it found. Refs openclaw#201472 Co-authored-by: Peter Steinberger <[email protected]>
…ce (#201912) A Gateway lock written before 2026.10.1 has no processNamespace. On macOS such a record was always unverifiable, so an orphaned config lock left by a crashed older Gateway made Doctor refuse maintenance forever: the update from 2026.11.4 rolled back with doctor-failed in 19 of 20 attempts, and a started 2026.11.5 Gateway refused the same file. macOS PIDs are host-global like Windows PIDs, so namespace-less macOS file locks now use the existing Windows rule: an expired heartbeat plus native PID death or a changed process start identity proves the owner stopped. Live and unprovable owners stay refused. Linux keeps refusing because a container in another PID namespace can share the lock directory. The legacy refusal now names the recovery step for the file it found. Refs #201472 Co-authored-by: Peter Steinberger <[email protected]> (cherry picked from commit 697b156) Companion audit: Existing expired legacy lock recovery now also uses native Darwin PID identity; live/unknown owners stay protected and Linux namespaces unchanged. Full diff reviewed; no pinned later path fixes. Co-authored-by: RomneyDa <[email protected]> (cherry picked from commit dc423441ea3dc2ee4381be0eee3635fc742cc41e) (cherry picked from commit 67b154a3049570f901f60992ccfe7f29ebb1a355)
Related: #201472
Related: #201893
What Problem This Solves
On macOS, an OpenClaw Gateway that crashed before 2026.10.1 could leave its lock file behind. Every later update then failed. Doctor refused to start maintenance with
Legacy Gateway lock … still has a live or unverified owner (PID …), and the update rolled back, even though that PID had exited weeks earlier. One reporter's Mac rolled back the automatic 2026.11.4 → 2026.11.5 update withdoctor-failedin 19 of 20 attempts over 23 hours. Each attempt restarted the Gateway. A 2026.11.5 Gateway started by hand also refuses the same file.User Impact
User impact: on macOS, updates and Gateway startup recover on their own from a dead lock file left by a Gateway older than 2026.10.1. A lock whose process is still running, or whose death can't be proven, is still refused. Linux behavior is unchanged: such a record still needs explicit recovery. The refusal now names the recovery step for the exact file it found.
Why This Change Was Made
Gateways add a
processNamespace(host, boot, PID namespace) to lock records starting in 2026.10.1 (#164236). Since #178076, a record without one is unverifiable, so a PID probe can't prove its owner stopped. On Linux that's necessary: a Gateway in a container with its own PID namespace can share the lock directory, and its PID means nothing to the host. #182031 added a narrow exception for Windows legacy records, whose PIDs are host-global. The record counts as dead only when its heartbeat (file mtime) is more than 90 seconds old and native PID inspection or a changed process start identity proves the owner stopped.macOS PIDs are host-global too. macOS has no PID namespaces, and containers run inside a VM. The same rule is sound there, so
classifyGatewayLockProcessNamespacenow applies it ondarwinas well aswin32. Both callers go through this one classifier: Doctor's legacy maintenance gate and Gateway startup's historical-lock check. On the macOS LaunchAgent layout, the serviceTMPDIRis$OPENCLAW_STATE_DIR/tmp, so the "legacy" path and the state-local config lock are the same file.The Doctor legacy refusal used to say only "stop the Gateway service and rerun Doctor", which can't help with a file a dead process left. It now names the step that works for that file. For the state-local file it points to
openclaw gateway recover-lock. For the system temporary directory it says to remove the file after confirming the process has stopped, becauserecover-lockinspects only state-local locks.Accepted edge case, the same one #182031 accepted for Windows: another kernel, such as a Linux VM guest or a second machine, writes a pre-2026.10.1 record into shared storage and its Gateway is still running. A dead PID on this host can't see that.
Rejected alternatives:
recover-lock. It remains the candidate for Linux system-temp recovery, for maintainers to decide.Production LOC: +17 / −4 across
gateway-lock-payload.tsandgateway-lock-legacy.ts, plus the docs line indocs/gateway/gateway-lock.md.Evidence
Real macOS, real PIDs, scratch state only. This uses #201472's source-level script, extended to the LaunchAgent
TMPDIR=$OPENCLAW_STATE_DIR/tmplayout and the Gateway-start inspection. The live control uses the script's own running process with its real start identity.44267df6c5e)Linux, Crabbox AWS, published 2026.11.5. The reporter's
reproduce.shrefuses in both layouts. In the state-tmp layout,openclaw gateway recover-locklists the record and its--confirmcommand removes it. In the system-temp layout,recover-lockreports nothing, and removing the file by hand afterps -p <PID>fails works. Doctor exits 0 after either step. This PR leaves Linux classification unchanged.Tests.
gateway-lock-legacy.test.tsnow runs the exited, reused, live, unverifiable and recently-exited owners onwin32,darwinandlinux. On base the macOS exited and reused cases fail.linuxstays refused for every owner and asserts the new recovery hint. The missing-namespace owner-lock test ingateway-lock.namespace.test.tspins Linux, because macOS now reclaims a provably exited owner there.Local results:
gateway-lock, stale lock file): 178/178.oxlintcore shard andoxfmtclean.