Skip to content

fix(gateway): preserve live owners and recover stale Linux locks - #175118

Merged
steipete merged 5 commits into
openclaw:mainfrom
xiaopan-xydt:fix/windows-live-owner-boot-mismatch-174895
Oct 18, 2026
Merged

steipete merged 5 commits into
openclaw:mainfrom
xiaopan-xydt:fix/windows-live-owner-boot-mismatch-174895

Conversation

@xiaopan-xydt

@xiaopan-xydt xiaopan-xydt commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Related: #174895
Fixes #175100

What Problem This Solves

A second OpenClaw process can steal a live Windows Gateway's state lock when boot observations disagree, while a Linux PID recycled as an unrelated worker thread can prevent stale-lock recovery.

User Impact

Live local owners keep exclusive state ownership; dead owners, changed process identities, and Linux worker-TID replacements can be reclaimed. Uncertain process identity preserves the lock and reports how to stop the holder before retrying. No configuration or persisted lock-format change is needed.

The Windows incident did not capture its exact namespace inputs. This fixes the source-confirmed same-host Windows boot-disagreement path; #174895 stays related until the remaining incident ambiguity is resolved.

Why This Change Was Made

Same-host Windows owners now use the existing PID and absolute process-start identity checks in the shared namespace policy. Boot-probe disagreement or an old heartbeat cannot independently revoke that owner. Non-Windows previous-boot recovery and foreign-namespace heartbeat custody keep their existing behavior. Linux's shared process-owner probe also rejects a numeric ID whose procfs Tgid identifies a different leader, preserving permission uncertainty, terminal leaders with live workers, and zero-thread revalidation.

Maintainer cleanup removes the contributor's duplicate boot-comparison helper/export and broad state-owner exception, which ClawSweeper correctly found broke Linux previous-boot Doctor recovery. No detached/background effect or captured authority was introduced; identity is inspected synchronously at the existing checked lock-reclamation boundary.

Original fix by @xiaopan-xydt; maintainer cleanup consolidates the ownership rule and folds in @belbix's worker-TID fix from #175109 with co-author credit. After this PR merges, the coordinator should comment on that draft with the merged PR link and leave it open.

Evidence

PR CI is the test and typecheck gate per maintainer policy. Live Gateway proof, leases, local tests/typechecks, and production-revert negative controls were intentionally skipped under that policy; there are no lease IDs or live-proof claims.

  • Source/history confirms both remaining predicate defects on main. Namespace history: 99fccf43358c, 06da0de86c0a; Linux conservative probe history: b57aca41466b.
  • New regression: uses process identity for a $state Windows owner despite boot disagreement covers live, unreadable, reused, and exited identities through real lock admission, including an expired heartbeat. Probes are injected; no real process spawning or timer waits are added.
  • New regression: rejects a reused worker TID but protects its live process leader covers both public Linux liveness helpers with injected procfs/signal observations. Existing Doctor previous-boot and namespace recovery regressions remain.
  • Changed-file oxlint 1.87.0 and oxfmt 0.72.0 passed using pinned static tools from the external pnpm tool cache. The core lint config retains the repository rules and non-UI overrides, excluding only the unavailable, unrelated Solid plugin. No repository dependencies were installed or changed.
  • Codex autoreview: scoped-clean through P2 on the committed repair; no actionable findings. The prior review’s index-only copy of the original broad exception was replaced by the reviewed repair.
  • Exact-head CI completed for 41b1e25d075569b3e0dbdd7c94e8e0180487bbc9: 59 jobs passed, 29 skipped. All selected Node/UI tests, production types, lint, and guards passed. Local test wall times were not measured.
  • Remaining CI blocker: check-test-types-core-1, job 117331827572 reports TS2741 at src/config/io.health-state-scope.test.ts:71,78: ConfigHealthStateStore no longer implements Disposable, but two declarations still use using. These untouched lines came from main commit 8d8944985883 (refactor(config): simplify captured reads and cached admission #175077). The dedicated repair is test(config): drop stale using declarations after health-state store refactor #175252; this PR does not duplicate that work. The aggregate CI gate fails solely on this typecheck.
  • The latest scheduled main run predates that regression and passed this stripe. Attribution here is source/history-based, not a claimed matching scheduled-CI failure. Integrate the dedicated main repair and refresh exact-head CI before landing.

ClawSweeper revision 2 reviewed this exact head with zero code findings and confirmed that the prior P1 reboot regression is resolved. Its remaining shipped-runtime, negative-control, and existing-data compatibility proof requests are intentionally skipped under the maintainer policy above: PR CI is the proof. The patch changes no persisted lock field, format, database schema, or migration contract.

Diff against merged main: production +13/-6 (net +7), tests +86/-0, docs +1/-0. The small production increase is the two missing platform identity rules; the duplicate proposal helper and staleness branch are gone. No unrelated deletion or weakened check was used to meet a LOC target.

…agrees

When same-host Windows boot identity probes disagree, fall back to PID and
start-time evidence instead of treating the owner as immediately dead. This
preserves a live Gateway lock while retaining recovery for dead or reused PIDs.
@clawsweeper

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

@xiaopan-xydt
xiaopan-xydt marked this pull request as ready for review October 17, 2026 04:55
@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. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. 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. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 17, 2026
@clawsweeper

clawsweeper Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

What this changes

This PR preserves live Windows Gateway owners despite conflicting boot observations and rejects Linux worker TIDs as stale process owners.

Example: A Windows owner records startTime 123 and boot identity 2026-10-17T00:00:00.0000000Z; a second process observes the same startTime but boot identity 2026-10-17T00:00:01.0000000Z.

  • Before: Boot disagreement can authorize removal of the live owner's lock.
  • After: Matching process identity preserves the lock, including when its heartbeat is old.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The focused patch is source-correct with green current-head CI, but supplied evidence does not satisfy the required shipped-behavior gate.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is necessary before merge. See Before merge.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: A second process can disrupt a live Windows Gateway, while recycled Linux worker IDs can preserve stale ownership.
Reason: The changes restore documented ownership behavior, and the feature-history owner supports the consolidated direction without adding configuration or a public API.

Merge readiness

⛔ Blocked before merge - 2 items remain

Keep open: this PR repairs two current-source ownership defects through existing shared owners. The earlier reboot regression is resolved, no new actionable code defect was found, and current-head CI is green.

Priority: P1
Reviewed head: 19b89d2f2682500cc87d91f335d967de81c4b045

Before merge

  • Add real behavior proof - The Windows test reaches real file-lock admission with mocked platform and identity observations; Linux coverage injects procfs observations, and the credited real-thread demonstration exercises only the predicate. No supplied after-fix shipped-Gateway trace demonstrates live-owner preservation and stale-owner recovery. Provide redacted terminal output or logs for those paths, including an upgrade from v2026.10.4 with settings and data intact; redact credentials, IPs, phone numbers, and non-public endpoints. Green CI supports correctness but does not satisfy this external-PR proof gate. After adding proof, update the PR body, then request a new review with @clawsweeper re-review. The PR author or someone with repository write access can request it.
  • 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

None.

Tests

  • Missing end-to-end proof: Supply shipped-Gateway preservation and recovery evidence, including existing-state upgrade behavior; the new regressions are not demonstrated failing on the pinned base.
Agent review details

How this fits together

Gateway startup and Doctor compete for shared-state custody; namespace and process-identity observations determine whether existing file locks and database leases block admission or permit recovery.

flowchart TD
  A[Gateway or Doctor] --> B[Shared ownership admission]
  B --> C[Namespace classifier]
  C --> D[Process identity probes]
  D --> E[Preserve live or uncertain owner]
  D --> F[Recover confirmed stale owner]
  F --> G[Acquire shared state custody]
Loading

Technical review

Best possible solution:

Retain the focused shared-classifier and Linux process-leader fixes while preserving conservative identity handling and existing namespace recovery.

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

Current-main source establishes both predicate errors, consistent with the Windows incident and belbix's real-thread observations; this review executed no target code and does not establish full Gateway reproduction.

Is this the best way to solve the issue?

The patch is the smallest coherent repair: qualify local Windows ownership in the shared namespace owner and reject proven nonleader TIDs in the existing Linux probe, preserving prior recovery safeguards.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Gateway namespace and heartbeat classification changes intended behavior with a stated reason (99fccf4: Protect serving Gateways from sibling-container PID observations while allowing previous-boot and expired foreign-heartbeat recovery; subsequently shared with database leases.)
  • Linux terminal-process classification keeps the original intent (b57aca4: Recognize reaping snapshots without revoking live sibling-thread or uncertain process custody; the new Tgid rule preserves those safeguards.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 06da0de adds src/infra/gateway-lock-payload.ts:69 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 06da0de86c0a; files: src/infra/gateway-lock-payload.ts)

PR surface

Source +7, Tests +86, Docs +1. Total +94 across 5 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 2 13 6 +7
Tests 2 86 0 +86
Docs 1 1 0 +1
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 100 6 +94

Review metrics

Metric Value Why it matters
Production versus test changes Production +13/-6; tests +86/-0 The production growth adds two platform identity rules in existing owners; tests cover distinct live, uncertain, reused, exited, and worker-versus-leader outcomes.

Labels

Label changes:

  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Label justifications:

  • P1: The repaired predicates can restart a serving Windows Gateway or prevent recovery of Linux state ownership.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Provide the redacted shipped-Gateway preservation, recovery, and existing-state upgrade evidence described in the proof assessment.

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.

History

Review history (2 earlier review cycles)
  • reviewed 2026-10-17T05:13:10.344Z sha 4aef633 :: needs real behavior proof before merge. :: [P1] Restrict the boot-disagreement exception to Windows
  • reviewed 2026-10-17T06:38:53.659Z sha 41b1e25 :: needs real behavior proof before merge. :: none

Reviewed October 18, 2026, 7:59 AM ET / 11:59 UTC (Revision 3).

steipete and others added 3 commits October 16, 2026 23:26
Use the shared namespace policy to qualify local Windows PID/start identity
instead of letting disputed boot observations revoke a live state owner.
Preserve non-Windows previous-boot recovery and remove the duplicate
state-owner exception. Reject Linux worker TIDs as process.pid owners while
retaining conservative permission, thread-group, and reaping behavior.

Add deterministic process-identity regressions and recovery guidance. PR CI
owns tests and typechecks; local proof is changed-file lint and formatting.
Related: openclaw#174895. Fixes openclaw#175100. Folds in openclaw#175109 without closing it.

Co-authored-by: xiaopan-xydt <[email protected]>
Co-authored-by: belbix <[email protected]>
@steipete steipete changed the title fix(gateway): prevent spurious restart when Windows boot identity disagrees fix(gateway): preserve live owners and recover stale Linux locks Oct 17, 2026
@steipete

Copy link
Copy Markdown
Contributor

@clawsweeper re-review

Updated head: 41b1e25. The P1 non-Windows reboot regression is fixed at the shared namespace owner, and the Linux worker-TID repair from #175109 is included with credit. Both regressions use injected process identity probes. Changed-file lint/format and Codex autoreview passed.

PR CI is the proof per maintainer policy; live Gateway/lease proof was intentionally skipped. Exact-head CI: https://github.com/openclaw/openclaw/actions/runs/39010322319. The body uses Related for #174895 and records the remaining incident-input ambiguity.

@clawsweeper

clawsweeper Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime labels Oct 17, 2026
@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. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. and removed merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 17, 2026
@clawsweeper clawsweeper Bot removed 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 17, 2026
@xiaopan-xydt

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

The current head is 19b89d2f2682500cc87d91f335d967de81c4b045; the latest durable review was for the previous head 41b1e25d075569b3e0dbdd7c94e8e0180487bbc9. Exact-head CI: https://github.com/openclaw/openclaw/actions/runs/39010322319. No code changes were made after that review.

@clawsweeper

clawsweeper Bot commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@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. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. 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. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 18, 2026
@steipete
steipete merged commit 1446ecc into openclaw:main Oct 18, 2026
158 checks passed
@steipete

Copy link
Copy Markdown
Contributor

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 19, 2026
…nclaw#175118)

* fix(gateway): prevent spurious restart when Windows boot identity disagrees

When same-host Windows boot identity probes disagree, fall back to PID and
start-time evidence instead of treating the owner as immediately dead. This
preserves a live Gateway lock while retaining recovery for dead or reused PIDs.

* fix(gateway): preserve live owners and recover recycled Linux thread IDs

Use the shared namespace policy to qualify local Windows PID/start identity
instead of letting disputed boot observations revoke a live state owner.
Preserve non-Windows previous-boot recovery and remove the duplicate
state-owner exception. Reject Linux worker TIDs as process.pid owners while
retaining conservative permission, thread-group, and reaping behavior.

Add deterministic process-identity regressions and recovery guidance. PR CI
owns tests and typechecks; local proof is changed-file lint and formatting.
Related: openclaw#174895. Fixes openclaw#175100. Folds in openclaw#175109 without closing it.

Co-authored-by: xiaopan-xydt <[email protected]>
Co-authored-by: belbix <[email protected]>

---------

Co-authored-by: Peter Steinberger <[email protected]>
Co-authored-by: belbix <[email protected]>
Co-authored-by: xiaopan-xydt <[email protected]>
@xiaopan-xydt
xiaopan-xydt deleted the fix/windows-live-owner-boot-mismatch-174895 branch October 24, 2026 17:05
RomneyDa added a commit that referenced this pull request Oct 26, 2026
…5118)

* fix(gateway): prevent spurious restart when Windows boot identity disagrees

When same-host Windows boot identity probes disagree, fall back to PID and
start-time evidence instead of treating the owner as immediately dead. This
preserves a live Gateway lock while retaining recovery for dead or reused PIDs.

* fix(gateway): preserve live owners and recover recycled Linux thread IDs

Use the shared namespace policy to qualify local Windows PID/start identity
instead of letting disputed boot observations revoke a live state owner.
Preserve non-Windows previous-boot recovery and remove the duplicate
state-owner exception. Reject Linux worker TIDs as process.pid owners while
retaining conservative permission, thread-group, and reaping behavior.

Add deterministic process-identity regressions and recovery guidance. PR CI
owns tests and typechecks; local proof is changed-file lint and formatting.
Related: #174895. Fixes #175100. Folds in #175109 without closing it.

Co-authored-by: xiaopan-xydt <[email protected]>
Co-authored-by: belbix <[email protected]>

---------

Co-authored-by: Peter Steinberger <[email protected]>
Co-authored-by: belbix <[email protected]>
Co-authored-by: xiaopan-xydt <[email protected]>
(cherry picked from commit 1446ecc)

Adapted for 2026.9.x: ported only the Linux Tgid check in
src/shared/pid-alive.ts and its regression. The Windows boot-identity
gateway-lock change, namespace tests, and gateway-lock docs are not
included. 9.x names the procfs helper isZombieProcess and only treats a Z
leader with one thread as exited, so the Tgid rejection runs before that
existing check.
RomneyDa added a commit that referenced this pull request Nov 8, 2026
…5118)

* fix(gateway): prevent spurious restart when Windows boot identity disagrees

When same-host Windows boot identity probes disagree, fall back to PID and
start-time evidence instead of treating the owner as immediately dead. This
preserves a live Gateway lock while retaining recovery for dead or reused PIDs.

* fix(gateway): preserve live owners and recover recycled Linux thread IDs

Use the shared namespace policy to qualify local Windows PID/start identity
instead of letting disputed boot observations revoke a live state owner.
Preserve non-Windows previous-boot recovery and remove the duplicate
state-owner exception. Reject Linux worker TIDs as process.pid owners while
retaining conservative permission, thread-group, and reaping behavior.

Add deterministic process-identity regressions and recovery guidance. PR CI
owns tests and typechecks; local proof is changed-file lint and formatting.
Related: #174895. Fixes #175100. Folds in #175109 without closing it.

Co-authored-by: xiaopan-xydt <[email protected]>
Co-authored-by: belbix <[email protected]>

---------

Co-authored-by: Peter Steinberger <[email protected]>
Co-authored-by: belbix <[email protected]>
Co-authored-by: xiaopan-xydt <[email protected]>

(cherry picked from commit 1446ecc)

Release adaptation: Apply Linux Tgid validation and same-host Windows namespace handling through the existing release identity owner; preserve PID/start-time and conservative probe behavior.

Co-authored-by: RomneyDa <[email protected]>
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 P1 High-priority user-facing bug, regression, or broken workflow. 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]: Linux Gateway startup refuses stale state locks when the old PID is reused as an unrelated worker TID

2 participants