Skip to content

fix: preserve Gateway ownership with separate Docker CLI containers - #164236

Merged
steipete merged 7 commits into
mainfrom
upd/upd-docker-owner-liveness-pid-namespace
Oct 3, 2026
Merged

steipete merged 7 commits into
mainfrom
upd/upd-docker-owner-liveness-pid-namespace

Conversation

@steipete

@steipete steipete commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Closes #163961

What Problem This Solves

A separate Compose CLI container could treat the serving Gateway's PID as absent or recycled in its own PID namespace, reclaim shared state ownership, and break later Gateway state access. Thanks @JakeMalis for the report. The original misclassification is src/infra/stale-lock-file.ts:72–76, reached through the state-owner reclamation predicate.

User Impact

Fresh foreign ownership is preserved with an actionable message to run inside the Gateway container or share its PID namespace. A crashed container can recover automatically after about 90 seconds. The Compose operations page documents pid: "service:openclaw-gateway"; tui --local remains embedded-agent execution, not a workaround for sharing state across PID namespaces.

No new application configuration, environment variables, CLI flags, dependencies, or SQLite schema. Legacy locks without namespace identity retain their prior PID behavior until the upgraded Gateway rewrites them.

Why This Change Was Made

The existing state owner qualifies PID evidence with boot and PID-namespace identity. One lifecycle-owned worker renews lock-file mtimes every 15 seconds, independent of synchronous work on the main thread. Each lock acquisition is bound to a retained descriptor: inode/device identity and payload are verified through the descriptor, the custody deadline is checked before renewal, and futimesSync touches that descriptor. A suspended old worker therefore cannot backdate a successor's new inode. Descriptors close on release or lost identity; fs-safe acquisition tokens distinguish newly retained projections.

Renewal errors retry with backoff. After 60 seconds without successful renewal, the owner stops admission through the same custody-loss path used for replacement, then uses existing Gateway restart/close handling. There is no separate worker restart supervisor. Readers retain their could not be verified error, while schema admission retains typed contention and the underlying loss cause.

Failed non-Linux boot observations are cached per process/platform. Previously, an unavailable Windows boot probe could repeat a synchronous 5-second PowerShell timeout on every state access. Linux /proc failures remain retryable and never authorize PID evidence.

Observation Decision
Legacy record without namespace identity Existing PID/start-time rules
Different boot, same host identity Stale immediately
macOS/Windows without namespaces, otherwise Existing PID/start-time rules
Same Linux boot and PID namespace Existing PID/start-time rules
Foreign/unreadable Linux identity; fresh or unavailable mtime UNKNOWN; preserve; CLI refuses immediately
Foreign/unreadable Linux identity; mtime older than 90 seconds Stale; reclaim

Only Gateway startup polls, every five seconds with a 95-second bound. An owner that keeps renewing is preserved. A namespace-bearing old owner that cannot renew ages out from its write mtime.

CI red classification

Suite / failure Classification and repair
openclaw-state-read-worker.ownership.test.ts, gateway-state-owner.read.test.ts PR-caused error precedence, fixed at the owner. The reader's unavailable-ownership error is preserved after fencing.
gateway-state-owner.test.ts (adjacent assertion exposed after the read fix) PR-caused typed-contention regression, fixed. Schema loans and borrows retain GatewayStateOwnerContentionError with the custody-loss cause.
gateway-service-capability.process.test.ts PR-exposed fixture attribution error, fixed. The test's own new heartbeat changed its snapshot. It now models the historical immutable owner, retains full snapshot equality, and rejects child lock I/O or heartbeat creation.
doctor-maintenance.foreground-update.test.ts / rowless-released PR-exposed fixture timer attribution error, fixed. Successful Doctor admission legitimately owns a watchdog. The test holds fake time at the original settlement deadline and requires completion without another poll, then zero timers after cleanup.
server-startup-post-attach.test.ts PR-exposed fixture boundary gap, fixed. The CI log contains 29 cases sharing the zero-worker teardown failure: an unrelated real notice sweep cold-opened state and launched the new schema heartbeat. The existing fixture now isolates that sweep; all readiness/sidecar assertions and the zero-worker guard remain unchanged. Production startup ordering is unchanged.
startup-config-preflight.recovery.test.ts / webhook-repair Main-side stale fixture, now owned by main commit 6e4b44530228a2240142c84dffdcd74d1ff9bc75. This branch takes main’s file verbatim; its duplicate fixture hunk was dropped during the rebase.
Windows exec.windows.integration.test.ts / three 120-second timeouts PR-caused repeated failed-probe mechanism fixed. CI showed 5,019–5,083 ms holds, matching the boot reader's 5,000 ms timeout. New Darwin/Windows regressions prove three ownership checks use one failed boot probe while retaining PID outcomes. Native Windows timing confirmation remains for hosted CI; no native Windows rerun is claimed here.

Rebase and Doctor CI repair

Rebased onto 61f9c3e16dfcc59e378e98908db17feadf3a73fe without conflicts. The webhook fixture is byte-for-byte main’s version. The rebase is the explicitly authorized reason for the lease-protected force push; auto-merge remains off.

The two Doctor failures came from CI run 37132281987, job 111229791127, on head 8b683d7fa94a1de008cea0f25b2070cb731a0881:

Failure Classification
doctor-update-schema-guard.test.ts / different-update claim Confirmed PR-exposed fixture race in code inherited from main. A SQLite child saw Test preload bytes changed, with an empty shim, before database or custody admission. Concurrent processes/threads created the same final shim path before writing its contents. Each execution context now publishes its own PID/thread-qualified shim; exact-byte and alias checks remain. A deterministic two-worker regression fails on the original helper with the same empty-byte assertion and passes after the repair.
doctor-update-refusal.test.ts / detached switching Not reproduced on the rebased branch: the initial run and all three final passes preserve the refusal and recovery text. The same preload race can explain this symptom because readDrivingUpdater errors are caught before returning without refusal, but CI did not retain the swallowed error; historical attribution remains qualified. No assertion or production behavior was weakened.

This round changes only the shared test helper and its regression; Gateway/Doctor production changes are unchanged. Fresh direct-route P1 was not rerun under the maintainer’s production-change-only rule; the prior scoped-clean review remains historical evidence.

Evidence

Current validation

  • Current head: 4ba582e8976f7415cc27acccdc61dc6af7960e9f. Fourteen owner/CI/helper suites passed 3×: 264 tests per pass, in 147.99 s, 132.18 s, and 132.49 s. Both named Doctor suites also passed the initial two-file run (40 tests, 124.40 s wall).
  • Eager-import closure, wrapper source closure, runtime process build graph, and test-plan guards: 155 tests passed, 72.47 s. Export-name collisions passed; Madge reported 0 cycles. The requested swap-fixture module loaded successfully (not an additional swap execution).
  • node scripts/check-changed.mjs passed in 1897.26 s, including all selected typecheck/lint/policy gates. git diff --check passed.
  • The helper regression forces exclusive creation before payload publication with a worker barrier. The old helper fails with the CI’s empty-byte assertion; the repaired helper passes. The complete helper file took 4.40 s wall / 3.45 s Vitest duration locally; the regression took 0.525 s in the first combined pass. New-head hosted CI cost is not yet available.
  • No independent lead baseline execution result was received before this publication. Attempts to inject the preload error into the detached-refusal case did not reach the child and are not claimed as causal proof; temporary diagnostics were removed from source.
  • Whole-branch numstat: production +566/-82 (net +484), tests/support +1160/-12, tooling +4/-0, docs +11/-0. This round adds +60/-1 test/support LOC, with zero production LOC changes.

Previous-head evidence

  • Previous candidate: 8b683d7fa94a1de008cea0f25b2070cb731a0881. Twelve touched/CI suites passed 3×: 222 tests per pass, in 119.39 s, 100.08 s, and 106.49 s.
  • The paused-worker negative control failed on the old runtime: it backdated the successor's mtime by 60 seconds. The descriptor-based regression passes and verifies worker exit without changing the successor.
  • The unavailable-boot negative control failed for both Darwin and Windows: 3 probes instead of 1. Both pass with the cache repair; Linux unreadable-identity coverage remains green.
  • Fresh independent Codex P1 review: scoped-clean. Export collision guard passed; Madge reported 0 cycles.
  • Eager-import closure, wrapper source closure, native provisioning, runtime build graph, and test-plan guards: 171 passed, 1 existing platform skip, 412.50 s. The requested swap-fixture module command exited 0; this was module loading, not an additional swap execution.
  • node scripts/check-changed.mjs passed in 1720.19 s; git diff --check passed.
  • Previous-head local Docker with isolated shared state and separate PID namespaces: sibling refusal 19.57 ms (0.369 s wall); SIGKILL/new-namespace recovery 90.48 s (90.865 s wall); synchronous SQLite overlap 93.01 s (93.394 s wall). A contender refused at 90.664 s; oldOwnerCurrent=true, noSuccessor=true. Both payloads and inodes stayed unchanged while mtimes advanced; graceful release removed both locks. All 1,498 inputs were reverified, and all owned containers/volumes removed. This is production ownership-API proof, not a complete authenticated Gateway RPC/TUI session.
  • Whole-branch numstat: production +566/-82 (net +484), tests/support +1109/-12, tooling +4/-0, docs +11/-0.

Inherited evidence and waivers

The pre-repair full build exited 0 with four inherited Control UI [INEFFECTIVE_DYNAMIC_IMPORT] warnings; all implicated inputs were unchanged from that build's base. The maintainer explicitly waived them. They concerned session-roster-cache.runtime.ts, session-snapshot-invalidation.ts, chat-send-actions.ts, and composer-draft-store.runtime.ts, not the heartbeat worker.

The maintainer also waived the remaining 273 importer files after seven passing batches, passing checks/guards, and clean P1 review. They are not claimed as executed. The previous descriptor repair reran the twelve owner/CI suites recorded above; the current round passed fourteen suites three times. Earlier batch 8's live-test auto-routing failure was resolved through the canonical live config with existing opt-in skips; that is collection evidence, not live-provider proof.

The branch was previously rebased onto main b12b4b98bb39f34ebdd907af49e3ad8fec771cb2 with the explicitly authorized rebase-only --force-with-lease, from 82a6eafcbc1f5a2ce3c2cb0c35c0b8b1e219dcf3 to a2ae915250ae1724b124f434521e35566e90167c. The rebase retained main's provenance move and lifecycle changes. The subsequent descriptor repair used a normal push. The current rebase uses the separately authorized --force-with-lease; auto-merge stays off.

Slow pre-existing suites (waived)

  • Native provisioning: current cold/warm sparse case 98.764 s, complete file 398.099 s, passed. The earlier 122.965 s / 120 s APFS timeout was explicitly waived; no timeout/retry/skip changes were made.
  • gateway-backed-exit.process.test.ts previously passed twice alone at 186.42 s and 191.03 s under the maintainer classification. This remains historical transport evidence.
  • doctor-session-sqlite.memory.test.ts: earlier batch/public transcript cases 30.786 s / 36.384 s, passed.
  • server.sessions.fixture-lifecycle.test.ts: earlier retained-fixture close-failure case 34.954 s, passed.
  • Earlier importer batch 5 spent 17m45.1s in shared compiler/runtime preparation; artifact-lock waits and compiler time are recorded separately from test time.

@clawsweeper

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

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation scripts Repository scripts commands Command implementations docker Docker and sandbox tooling size: L labels Oct 3, 2026
@steipete
steipete marked this pull request as ready for review October 3, 2026 10:04
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 3, 2026
@clawsweeper

clawsweeper Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed October 3, 2026, 12:14 PM ET / 16:14 UTC (Revision 5).

ClawSweeper review

What this changes

The PR qualifies Gateway ownership by boot and Docker PID namespace, renews ownership locks in a worker, documents safe CLI container use, and repairs affected test fixtures.

Merge readiness

⛔ Blocked before merge - 3 items remain

The fix remains necessary and has meaningful Docker boundary proof, but the previously reported shutdown retry defect remains in the current head.

Priority: P1
Reviewed head: 4ba582e8976f7415cc27acccdc61dc6af7960e9f

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Strong ownership-boundary evidence supports the repair, but a definite shutdown lifecycle defect still blocks readiness.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The captured Docker production ownership-API run exercises separate PID namespaces, fresh-owner refusal, crashed-owner recovery, and renewal during synchronous SQLite work. Production inputs are unchanged in the latest test-only round. Additive lock metadata preserves legacy decoding and recovery rules without a schema migration; authenticated RPC/TUI execution is not claimed.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The captured Docker production ownership-API run exercises separate PID namespaces, fresh-owner refusal, crashed-owner recovery, and renewal during synchronous SQLite work. Production inputs are unchanged in the latest test-only round. Additive lock metadata preserves legacy decoding and recovery rules without a schema migration; authenticated RPC/TUI execution is not claimed.
Evidence reviewed 10 items Introduced shutdown defect survives the verified merge: The introduced close wrapper permanently caches its promise, including rejection. The verified test merge has the pinned base and head as its two recorded parents, and its diff against that base retains this wrapper.
Inner shutdown deliberately supports retained-cleanup retries: The core server clears closePromise when a retained plugin-runtime cleanup error occurs. The new outer cache prevents later public close calls from reaching that retry and the subsequent ownership release.
Re-review continuity: The completed previous review reported this same close-cache blocker. Inspection of the earlier reviewed SHA failed because its object was unavailable and remote hydration returned HTTP 403; the finding is independently established by the pinned introduction diff and current source, without claiming a verified earlier-tree comparison.
Findings 1 actionable finding [P2] Allow rejected close attempts to retry retained cleanup
Security None None.

How this fits together

Gateway ownership coordinates access to shared OpenClaw state across the serving Gateway and maintenance processes. Namespace checks and heartbeat renewal determine whether another process must preserve ownership or may reclaim it.

flowchart TD
  A[Gateway or CLI process] --> B[Shared ownership locks]
  B --> C[Boot and PID namespace check]
  C --> D[Preserve fresh owner]
  C --> E[Reclaim stopped owner]
  F[Gateway heartbeat worker] --> B
  D --> G[Refuse competing maintenance]
  E --> H[Admit state access]
Loading

Before merge

  • Allow rejected close attempts to retry retained cleanup (P2) - Previously reported and still present: when plugin cleanup throws a retained-runtime error, server-start.ts clears its inner close promise so cleanup can retry. This newly introduced outer closing promise remains rejected forever, so subsequent public close() calls never reach that retry or ownedLock.release(). Clear the failed outer attempt while preserving concurrent-call coalescing and custody retention until cleanup succeeds.
  • Resolve merge risk (P1) - A retained plugin-cleanup failure permanently rejects the public close handle, leaving cleanup and direct ownership release unreachable on subsequent attempts.
  • Complete next step (P2) - Repair the rejected outer close cache and demonstrate successful cleanup retry before releasing ownership.

Findings

  • [P2] Allow rejected close attempts to retry retained cleanup — src/gateway/server.ts:59-63
Agent review details

Security

None.

PR surface

Source +484, Tests +1148, Docs +11, Other +4. Total +1647 across 33 files.

View PR surface stats
Area Files Added Removed Net
Source 18 566 82 +484
Tests 12 1160 12 +1148
Docs 1 11 0 +11
Config 0 0 0 0
Generated 0 0 0 0
Other 2 4 0 +4
Total 33 1741 94 +1647

Review metrics

Metric Value Why it matters
Production versus test growth production +566/-82; tests/support +1160/-12 Production growth implements namespace classification, independent renewal, and custody fencing; the latest commit adds only fixture isolation and its regression.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #163961
Summary: This PR explicitly proposes the namespace-aware ownership fix for the open Docker report.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge-risk options

Maintainer options:

  1. Restore shutdown retry (recommended)
    Clear the failed outer close attempt while coalescing concurrent calls and releasing ownership only after successful cleanup.
Copy recommended automerge instruction
@clawsweeper automerge

Special instructions:
Repair the outer close promise cache in src/gateway/server.ts and add a regression proving retained cleanup can fail, retry successfully, and release ownership only after success while concurrent callers remain coalesced.

Technical review

Best possible solution:

Keep namespace-qualified ownership and descriptor-bound renewal, with retryable shutdown that retains custody until cleanup succeeds.

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

Yes, from source: make retained plugin cleanup reject the first public close call, then retry; the cached rejected promise prevents another inner cleanup attempt. No runtime reproduction was executed during this read-only review.

Is this the best way to solve the issue?

The ownership approach fits the existing coordinator, but the shutdown wrapper must preserve the core server's retry contract before this is a complete repair.

Full review comments:

  • [P2] Allow rejected close attempts to retry retained cleanup — src/gateway/server.ts:59-63
    Previously reported and still present: when plugin cleanup throws a retained-runtime error, server-start.ts clears its inner close promise so cleanup can retry. This newly introduced outer closing promise remains rejected forever, so subsequent public close() calls never reach that retry or ownedLock.release(). Clear the failed outer attempt while preserving concurrent-call coalescing and custody retention until cleanup succeeds.
    Confidence: 0.99

Overall correctness: patch is incorrect
Overall confidence: 0.97

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • remove merge-risk: 🚨 compatibility: Current PR review merge-risk labels are merge-risk: 🚨 availability.

Label justifications:

  • P1: The linked report describes persistent Gateway access failures after a documented separate-container CLI workflow.
  • merge-risk: 🚨 availability: The introduced close cache can prevent recovery and ownership release after retryable cleanup failure.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦞 diamond lobster and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Sufficient (terminal): The captured Docker production ownership-API run exercises separate PID namespaces, fresh-owner refusal, crashed-owner recovery, and renewal during synchronous SQLite work. Production inputs are unchanged in the latest test-only round. Additive lock metadata preserves legacy decoding and recovery rules without a schema migration; authenticated RPC/TUI execution is not claimed.
  • proof: sufficient: Contributor real behavior proof is sufficient. The captured Docker production ownership-API run exercises separate PID namespaces, fresh-owner refusal, crashed-owner recovery, and renewal during synchronous SQLite work. Production inputs are unchanged in the latest test-only round. Additive lock metadata preserves legacy decoding and recovery rules without a schema migration; authenticated RPC/TUI execution is not claimed.

Evidence

Acceptance criteria:

  • [P1] pnpm test src/gateway/server.state-owner.test.ts --maxWorkers=1.
  • [P1] pnpm test src/gateway/server.sessions.fixture-lifecycle.test.ts --maxWorkers=1.
  • [P1] node scripts/check-changed.mjs.
  • [P1] git diff --check.

What I checked:

  • Introduced shutdown defect survives the verified merge: The introduced close wrapper permanently caches its promise, including rejection. The verified test merge has the pinned base and head as its two recorded parents, and its diff against that base retains this wrapper. (src/gateway/server.ts:59, 4ba582e8976f)
  • Inner shutdown deliberately supports retained-cleanup retries: The core server clears closePromise when a retained plugin-runtime cleanup error occurs. The new outer cache prevents later public close calls from reaching that retry and the subsequent ownership release. (src/gateway/server-start.ts:147, 4ba582e8976f)
  • Re-review continuity: The completed previous review reported this same close-cache blocker. Inspection of the earlier reviewed SHA failed because its object was unavailable and remote hydration returned HTTP 403; the finding is independently established by the pinned introduction diff and current source, without claiming a verified earlier-tree comparison. (src/gateway/server.ts:59, 4ba582e8976f)
  • Captured proof body fully inspected: The live body matched captured SHA-256 9596df717807f298aa4a5617d21a8cbc991a000f66051c3ad5e863b7cde5c8f9 and the pinned head. Its Docker production ownership-API run records sibling refusal in 19.57 ms, crashed-owner recovery in 90.48 seconds, and preserved ownership during 93.01 seconds of synchronous SQLite overlap. This is boundary proof, not authenticated RPC/TUI proof. The current round changes only test support. (4ba582e8976f)
  • Existing-state compatibility: The namespace field is optional; absent legacy identity retains the prior PID rules. Maintenance regressions cover legacy records, same namespaces, previous boots, and expired heartbeats. The v2026.9.8 decoder uses a non-strict object schema, allowing the additive field without a database migration. (src/infra/gateway-lock-payload.ts:66, fc23bc864e45)
  • Current main still needs the fix: Current main retains the earlier public close wrapper. Its ownership history and the latest-release lock decoder do not establish namespace-qualified recovery as already implemented. The explicitly linked Docker report remains open at [Bug]: Separate Docker CLI TUI launch is followed by persistent Gateway state-ownership failures on 2026.9.7 #163961. (src/gateway/server.ts:35, f1b983fac8fa)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

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

  • Repair the outer close cache and prove failed retained cleanup can retry successfully before ownership is released.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (4 earlier review cycles)
  • reviewed 2026-10-03T10:10:40.723Z sha c497c731ba5093724eefd7f9a3d8a639d82327b3 :: needs maintainer review before merge. :: none
  • reviewed 2026-10-03T13:13:56.311Z sha 82a6eafcbc1f5a2ce3c2cb0c35c0b8b1e219dcf3 :: needs changes before merge. :: none
  • reviewed 2026-10-03T14:07:51.497Z sha a2ae915250ae1724b124f434521e35566e90167c :: blocked before merge. :: [P2] Allow rejected close attempts to retry retained cleanup
  • reviewed 2026-10-03T15:17:15.690Z sha 8b683d7fa94a1de008cea0f25b2070cb731a0881 :: blocked before merge. :: [P2] Allow rejected close attempts to retry retained cleanup

@github-actions

github-actions Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ Security sensitive changes

This maintainer PR changes sensitive security components.

No secops approval is required. This comment is informational because the PR author has Maintain or Admin access.

  • Current SHA: 4ba582e8976f7415cc27acccdc61dc6af7960e9f
  • Maintainer: @steipete
  • Repository role: admin

These security sensitive changes were made:

  • src/gateway/operator-role-policy.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.

Carefully review these changes before merging.

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: XL and removed size: L labels Oct 3, 2026
@clawsweeper clawsweeper Bot added the merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. label Oct 3, 2026
@steipete
steipete force-pushed the upd/upd-docker-owner-liveness-pid-namespace branch from 82a6eaf to a2ae915 Compare October 3, 2026 13:59
@clawsweeper clawsweeper Bot added merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. 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 rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 3, 2026
@openclaw-barnacle openclaw-barnacle Bot added the cli CLI command changes label Oct 3, 2026
Qualify PID liveness using the recorded boot and PID namespace before
reclaiming shared state. Renew lock mtimes without replacing fs-safe's
immutable ownership receipts, and fence expired or replaced local owners.

CLI maintenance refuses a fresh foreign owner immediately. Gateway startup
waits up to 95 seconds for a crashed container's heartbeat to expire, while
same-namespace and same-host reboot recovery retain their fast paths.

Closes #163961. Thanks @JakeMalis for reporting the Docker TUI failure.
steipete added a commit that referenced this pull request Oct 3, 2026
The executable-graph allowlist in tsdown-runtime-config.test.ts rejected
infra/gateway-state-owner-heartbeat.worker. #164236 (99fccf4) added that
worker to standaloneRuntimeProcessBuildEntries, and every standalone runtime
graph installs the state-schema inline plugin, exactly like the listed
state-lease heartbeat worker. #164296 (ba8cb92) landed seven minutes later
and edited the same allowlist without the new graph, so main has failed this
case since both merged. The config is correct; the expectation was stale.

Proof: CI=1 node scripts/run-vitest.mjs run
test/scripts/tsdown-runtime-config.test.ts --maxWorkers=1 fails 1/33 on
8db9539 and passes 33/33 with this change (52 s wall).
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 4, 2026
…penclaw#164236)

A CLI run in a sibling Docker container (different PID namespace) saw the Gateway's owner lock, could not observe the owner PID, classified the live owner as stale (src/infra/stale-lock-file.ts) and reclaimed custody of a running Gateway's state. PID evidence is now qualified by the owner's recorded boot/namespace identity (linux: boot id + PID namespace inode; macOS/Windows: boot id); a lifecycle-owned worker thread renews the lock's mtime every 15 s through the verified file descriptor, so a resumed worker can only touch the inode it verified; foreign or unreadable Linux identity decides by heartbeat age (fresh: UNKNOWN, preserve, CLI refuses; older than 90 s: stale, reclaim); a different boot on the same host is stale; legacy locks keep the old rules. The owner fences itself (custody lost) after 60 s without a successful renewal via the existing replacement path; Gateway startup waits up to 95 s for a fresh foreign heartbeat to age out. Docker proof: sibling refusal 1.66 ms, SIGKILL/restart recovery 90.5 s, 93 s synchronous-SQLite overlap keeps the owner. Closes openclaw#163961. Thanks @JakeMalis for the report.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 4, 2026
…nce as the state lock (openclaw#164546)

A Gateway could not start, and Doctor could not enter maintenance, on its own state after a crash loop or a container recreate: the SQLite owner lease's recovery was hostname-only, so a changed hostname made the dead owner 'unknown' and a lease without expiry blocked startup indefinitely ('Another Gateway owner lease is still active for this state directory'). Lease liveness now uses the state lock's shared boot/PID-namespace classifier and the 90 s heartbeat policy from openclaw#164236: a proven-dead owner (dead PID in the same namespace, or a changed boot on the same host) or an unverifiable namespace whose heartbeat is older than 90 s is reclaimed; fresh unverifiable owners and qualified live owners still refuse; renewal every 15 s; Gateway startup waits out a fresh unverifiable lease; Doctor names the wait. Acquisition rechecks ownership transactionally. No schema change. Closes openclaw#155644. Reported again today on Discord (main crash loop; Docker 2026.9.8 container).
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 4, 2026
The executable-graph allowlist in tsdown-runtime-config.test.ts rejected
infra/gateway-state-owner-heartbeat.worker. openclaw#164236 (0625edd) added that
worker to standaloneRuntimeProcessBuildEntries, and every standalone runtime
graph installs the state-schema inline plugin, exactly like the listed
state-lease heartbeat worker. openclaw#164296 (a2b2534) landed seven minutes later
and edited the same allowlist without the new graph, so main has failed this
case since both merged. The config is correct; the expectation was stale.

Proof: CI=1 node scripts/run-vitest.mjs run
test/scripts/tsdown-runtime-config.test.ts --maxWorkers=1 fails 1/33 on
2be9bee and passes 33/33 with this change (52 s wall).
steipete added a commit that referenced this pull request Oct 13, 2026
Portable workers start the state-owner heartbeat during SQLite admission, but the archive omitted its entry. Build and stage the existing worker, register its sealed sibling URL, and resolve that URL through the existing runtime owner. Keep custody and error handling intact.

The existing relocated authorization regression now uses a dist/worker path and existing artifact fixtures include the heartbeat. Culprit: 99fccf4 (#164236), exposed by d0554f4 (#170790). Scoped Codex review and changed-file format/lint checks pass; focused hosted execution is pending.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 14, 2026
Portable workers start the state-owner heartbeat during SQLite admission, but the archive omitted its entry. Build and stage the existing worker, register its sealed sibling URL, and resolve that URL through the existing runtime owner. Keep custody and error handling intact.

The existing relocated authorization regression now uses a dist/worker path and existing artifact fixtures include the heartbeat. Culprit: 0625edd (openclaw#164236), exposed by 1fa2181 (openclaw#170790). Scoped Codex review and changed-file format/lint checks pass; focused hosted execution is pending.
RomneyDa pushed a commit that referenced this pull request Oct 14, 2026
Portable workers start the state-owner heartbeat during SQLite admission, but the archive omitted its entry. Build and stage the existing worker, register its sealed sibling URL, and resolve that URL through the existing runtime owner. Keep custody and error handling intact.

The existing relocated authorization regression now uses a dist/worker path and existing artifact fixtures include the heartbeat. Culprit: 99fccf4 (#164236), exposed by d0554f4 (#170790). Scoped Codex review and changed-file format/lint checks pass; focused hosted execution is pending.

(cherry picked from commit 9e52f76)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes commands Command implementations docker Docker and sandbox tooling docs Improvements or additions to documentation gateway Gateway runtime merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. scripts Repository scripts security-sensitive-changed size: XL 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.

[Bug]: Separate Docker CLI TUI launch is followed by persistent Gateway state-ownership failures on 2026.9.7

1 participant