Skip to content

fix: allow Gateway startup in PRoot Ubuntu containers - #174974

Merged
steipete merged 1 commit into
mainfrom
fix/proot-gateway-lock
Oct 17, 2026
Merged

steipete merged 1 commit into
mainfrom
fix/proot-gateway-lock

Conversation

@steipete

@steipete steipete commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Related: #171385

What Problem This Solves

Fixes Gateway startup refusing its own state ownership in a PRoot Ubuntu container with GatewayLockNamespaceError.

User Impact

The Gateway can start when PRoot exposes the PID namespace link but cannot follow it with stat(). Unreadable or malformed namespace identities still refuse ownership; foreign-owner and heartbeat rules are unchanged. Thanks @caozhongbin for reporting this.

Why This Change Was Made

Read the kernel namespace inode from readlink("/proc/self/ns/pid"), which returns pid:[inode], instead of following PRoot's synthetic target. This preserves the existing identity format and admission policy without treating unknown identities as matching or adding a same-PID shortcut. No public API, dependency, or schema changes.

Evidence

  • Real before/after through pnpm openclaw gateway run on Linux arm64, Node 24.21.0, Ubuntu 22.04.5, using unmodified Termux PRoot source at 7f2fab0fb3a9e15f63ac47497ebc29d72281206e. The baseline refused its own fresh owner; the patched Gateway reached ready, returned HTTP 200 from /healthz, and both gateway health --json and gateway call health --json returned ok: true with exit code 0. State and ports were isolated.
  • Real main-thread and Worker probes both reproduced stat() failing with ENOENT while readlink() succeeded; the patched production namespace reader returned matching valid identities.
  • Regression failed before the production fix. All 108 focused namespace, owner-lease, Gateway lock, and Doctor tests passed afterward. Core and affected test typechecks, scoped lint/format, runtime builds, and diff checks passed. Independent review found no actionable findings.
  • An earlier generic upstream PRoot 5.4 run passed namespace admission but aborted in readlink_proc before readiness. The unmodified Termux fork completed the full proof above. Actual Android hardware, x64 PRoot, and Bun were not exercised locally; the reporter should retest on the next release.

The production change replaces one probe; test growth covers the readable-link/stat-failure regression and malformed-link refusal. Release-note context: restore Gateway startup in PRoot Ubuntu containers while preserving ownership checks.

CI on the exact head: run 38993644769 failed in two places. The update-CLI mock-export ratchet has the identical diagnostic in scheduled main run 38991549274. Two unchanged state-migration tests expect a completed cursor without the version: 2 field now written by the migration owner; both reproduce locally. Both cases also fail with the identical marker mismatch on clean main 9dd47e67ded4986aabe211c62b5c26fc9eec0299 (2 failed, 59 unselected); the native inherited-failure exception is being used for these baseline failures. No CI rerun or timeout increase was used.

PRoot can expose the kernel PID namespace link while stat returns ENOENT
when following its synthetic target. Parse the link's decimal inode so
same-namespace owners keep their existing identity and admission rules.
Unreadable or malformed links still preserve fresh foreign ownership.

Add a failing-before regression and retain the namespace and Doctor
contention coverage. The isolated live run now passes namespace admission,
but full listener readiness remains blocked by an upstream PRoot assertion.

Refs #171385
@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.

@steipete
steipete marked this pull request as ready for review October 17, 2026 02:06
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-17T02:09:06.830779Z a77cb0d Draft marked ready
ℹ️ 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 docs Improvements or additions to documentation gateway Gateway runtime commands Command implementations size: S labels Oct 17, 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. P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. 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 Oct 17, 2026
@clawsweeper

clawsweeper Bot commented Oct 17, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge.

What this changes

Read Linux PID namespace identity from its procfs symlink so Gateway startup works when PRoot cannot stat the link target.

Example: Ubuntu 22.04.5 under Termux PRoot exposes /proc/self/ns/pid as pid:[4026532609], but stat returns ENOENT.

  • Before: Namespace discovery returns null and Gateway startup rejects its own fresh ownership.
  • After: Namespace discovery returns inode 4026532609 and the Gateway can complete ownership admission.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, useful repair with reported shipped-entry-point verification and meaningful regression coverage; CI attribution remains a landing concern.
Proof confidence 🐚 platinum hermit (4/6) The ordinary contributor proof gate is exempt for this maintainer-authored PR; its body reports before-and-after gateway run readiness and health results in isolated Termux PRoot, while source inspection confirms unchanged authority semantics.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Gateway startup refuses its own state ownership in PRoot Ubuntu when procfs namespace stat fails.
Reason: The maintainer-authored change restores a demonstrated startup path through the existing shared owner without changing product policy.

Merge readiness

⛔ Needs changes before merge - 1 item remains

Keep this PR open: it fixes a concrete PRoot startup failure still present on main, with no actionable patch defect found; CI failure attribution remains unfinished.

Priority: P2
Reviewed head: a77cb0de1e9fdc231752cbbb1dbcb1f2da812709

Before merge

  • Complete next step - Establish baseline attribution for the two state-migration cursor failures; repair them here only if this diff causes them.

Findings

None.

Agent review details

How this fits together

Gateway startup, SQLite owner leases, and Doctor share namespace discovery and ownership classification; kernel boot and namespace identities qualify PID evidence before state access or recovery.

flowchart TD
  A[Gateway or Doctor] --> B[Namespace discovery]
  C[Kernel boot and namespace links] --> B
  B --> D[Shared ownership classifier]
  E[Recorded owner and heartbeat] --> D
  D --> F[Admit or refuse state access]
Loading

Technical review

Best possible solution:

Land the shared namespace-reader repair once the remaining CI failure is classified through the existing landing policy.

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

Source establishes that stat failure produces null identity and fresh-owner refusal; the author additionally reports a real isolated PRoot reproduction, but this review executed no target code.

Is this the best way to solve the issue?

Replacing the failing probe in the shared reader addresses the cause without a bypass, duplicate owner, new option, or weaker foreign-owner policy.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Linux namespace discovery keeps the original intent (99fccf4: Qualify PID evidence with boot and namespace identity so separate Docker CLI containers cannot reclaim a serving Gateway's state.)
  • Namespace and Doctor admission tests keeps the original intent (49a092d: Consolidate redundant tests while retaining distinct ownership, recovery, and Doctor admission contracts.)
  • Owner-lease namespace fixture keeps the original intent (06da0de: Use the shared namespace and heartbeat classifier for SQLite owner-lease recovery.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

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

PR surface

Source +3, Tests +43, Docs +1. Total +47 across 5 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 4 1 +3
Tests 3 107 64 +43
Docs 1 1 0 +1
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 112 65 +47

Labels

Label changes:

  • add P2: Restores Gateway startup in a specific PRoot terminal environment while preserving existing ownership protection.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Label justifications:

  • P2: Restores Gateway startup in a specific PRoot terminal environment while preserving existing ownership protection.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

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 16, 2026, 10:37 PM ET / October 17, 2026, 02:37 UTC.

@steipete
steipete merged commit 705d1b2 into main Oct 17, 2026
236 of 243 checks passed
@steipete
steipete deleted the fix/proot-gateway-lock branch October 17, 2026 03:26
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via explicitly authorized admin squash with attributed pre-existing CI failures.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 17, 2026
PRoot can expose the kernel PID namespace link while stat returns ENOENT
when following its synthetic target. Parse the link's decimal inode so
same-namespace owners keep their existing identity and admission rules.
Unreadable or malformed links still preserve fresh foreign ownership.

Add a failing-before regression and retain the namespace and Doctor
contention coverage. The isolated live run now passes namespace admission,
but full listener readiness remains blocked by an upstream PRoot assertion.

Refs openclaw#171385
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commands Command implementations docs Improvements or additions to documentation gateway Gateway runtime P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. 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