Skip to content

fix(gateway): reconcile root node workspaces and surface failures - #166441

Merged
steipete merged 1 commit into
mainfrom
steipete/cloud-worker-runpod-ws-20261006
Oct 7, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/cloud-worker-runpod-ws-20261006

Conversation

@steipete

@steipete steipete commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

A RunPod worker running as UID 0 could complete its turn and then fail workspace reconciliation with only node workspace command failed (UNAVAILABLE). The node discarded the underlying exception, and the Gateway discarded most node error messages.

A deterministic cause is present in the reported live build 7880834c: reconciliation acquires quiescence (src/gateway/worker-environments/workspace-result-finalize.ts:215), the node starts an owned/shared-host helper (src/node-host/node-worker-workspace-quiescence.ts:227), and the helper rejected UID 0 before reaching its no-freeze path (src/gateway/worker-environments/workspace-quiescence-scripts.ts:418). Its stderr becomes a thrown error at src/node-host/node-worker-workspace-quiescence.ts:311, which maps to UNAVAILABLE.

User Impact

Native Linux node hosts can reconcile root-owned container sessions. Unexpected workspace failures now retain their error code and a redacted detail bounded to 500 characters at the Gateway, with bounded warnings in the node-host log. Typed transfer errors keep their classification. Operators must update the node host as well as the Gateway; updating only the portable worker bundle does not replace this helper.

No live RunPod rerun was performed. The regression proves a root-only defect sufficient to explain the reported failure; another host-specific failure could still appear after this one is removed.

Why This Change Was Made

Allow root only for the native owned helper. That mode already requires shared-host operation, empty process scopes, exact watchdog identity, and fenced renewal/release. It never sweeps or signals other root processes. Detached helpers still reject root, including detached shared-host helpers whose orphan recovery can signal recorded PIDs.

Reuse boundedWorkerError / boundedWorkerErrorWithCode and their existing redactSensitiveText owner before truncation. The #123280 commit and tests preserve generic errors for unrelated supervisor operations; that protection remains unchanged. Workspace operations now carry sanitized diagnostics instead of generic supervisor text.

The other RunPod differences do not explain the unconditional UID check: workspace operations do not invoke sudo; command HOME is the prepared home or session root (src/node-host/node-worker-workspace.ts:574); managed identity checks validate paths and bindings rather than banning UID 0 (src/node-host/node-worker-workspace-identity.ts:160); Git initializes the repository as the current user (src/node-host/node-worker-workspace-git.ts:34). Later foreign ownership, disk exhaustion, or unavailable ps could independently fail, but the old root guard fires before Git export or process inspection.

Evidence

  • Pre-fix regressions reproduced the exact root error, dropped UNAVAILABLE/TIMEOUT detail, generic node workspace errors, and unredacted INVALID_REQUEST/transfer messages. Both detached-root denial cases passed before and after the fix.
  • pnpm test src/gateway/worker-environments/node-worker-tunnel.test.ts src/node-host/invoke-worker-supervisor.test.ts src/node-host/node-worker-workspace-quiescence.test.ts --maxWorkers=1: 79 tests passed; 294.36 seconds wall time, including 130.60 seconds rebuilding subprocess fixtures. Reported test time by file: tunnel 25.229 s, supervisor 2.262 s, quiescence 0.790 s. The tunnel file's existing Git and 640-file inventory cases dominate its cost; the five new diagnostic cases total 0.101 s.
  • Root coverage executes the actual generated POSIX program with UID 0, real lease files, and simulated OS transport/clock; acquisition, renewal, and release succeed without process scanning/signaling. Existing Windows lifecycle tests still pass.
  • Formatting, touched-file Oxlint, git diff --check, core production types, and all 27 core/test type graphs pass. Independent Codex review is clean at P0/P1 against pinned merge base 27ba9720f2c5; the shared origin/main ref advanced during work, so the initial literal-ref review included unrelated reverse diffs and was repeated against the correct scope. Two test-only shadowed variable names were corrected by mechanical renaming after review.
  • pnpm check:changed stopped at the full-tree Knip scan: seven unused exports in unchanged src/agents/auth-profiles.runtime.ts (getSoonestCooldownExpiry, isProfileInCooldown, loadAuthProfileStoreForRuntime, maybeReprobeWhamBlockedProfiles, resolveAuthProfileEligibility, resolveAuthProfileOrder, resolveProfilesUnavailableReason). Production and script export scans passed. An isolated clean checkout of base 27ba9720f2c5 reproduced exactly the same seven findings (395.39 s wall), confirming this failure is inherited. Touched-file lint, native state-schema, database-first, media-helper, sidecar-loader, import-cycle, webhook, pairing-store, and account-scope guards pass (run separately after the aggregate gate stopped). No scanner exception was added.
  • Exact-head CI run 37569087708 and openclaw/ci-gate passed for dfcf5a6a5ab68d4fbc759b5542fc952fd5673bc5. The requested 40-minute watcher exited GREEN, with zero pending and 13 verified superseded checks; GitHub's raw rollup still includes those superseded failures.
  • Hosted CI reran all three changed test files: supervisor 44 passed, 8.88 s shard wall; quiescence 7 passed, 3.89 s shard wall; tunnel 28 passed, 1.880 s summed case time inside the shared checks-node-changed-compact-large-19 job (192 s job wall). CI's job execution window was 427 s, with 1,464 aggregate job-seconds across nine changed Node test jobs.

All UNAVAILABLE entry points on this private route were audited: missing runtime and unclassified thrown workspace errors (src/node-host/node-worker-supervisor-commands.ts:276, :293); update pause, disconnect cleanup failure, and unadvertised command (src/node-host/runtime.ts:413, :426, :441); unexpected outer dispatch failure (src/node-host/invoke.ts:294); pairing-state or event-send failure (src/gateway/node-registry-private.ts:207, :328); not-ready after progress (src/gateway/node-registry.invoke-stream.ts:137); and missing-code fallback (src/gateway/worker-environments/node-worker-tunnel.ts:272). The generic workspace catch covers database/filesystem/abort, seed, inspection/reset, quiescence, manifest, and process spawn/cleanup errors. Ordinary nonzero child exits remain successful transport replies carrying command results; transfer failures use their dedicated error code.

The retain-publication warning is separate: node invoke authority closed before settlement uses APPROVAL_AUTHORITY_CLOSED (src/gateway/node-registry.invoke-stream.ts:310), not UNAVAILABLE.

@clawsweeper

clawsweeper Bot commented Oct 7, 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 gateway Gateway runtime size: M labels Oct 7, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. 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 7, 2026
@clawsweeper

clawsweeper Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed October 7, 2026, 12:25 AM ET / 04:25 UTC (Revision 3).

ClawSweeper review

What this changes

The PR allows root-owned Linux workspaces to reconcile through the native helper and surfaces bounded, redacted workspace errors in Gateway responses and node logs.

Merge readiness

✅ Ready for maintainer review

This PR remains necessary: current main still rejects root-owned native workspace reconciliation and suppresses useful failure details. No introduced blocking defect was found; the earlier review contains no findings to carry forward.

Priority: P2
Reviewed head: dfcf5a6a5ab68d4fbc759b5542fc952fd5673bc5

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, maintainable repair with meaningful regressions, documented deployment scope, and no blocking finding.
Proof confidence 🌊 off-meta tidepool Not applicable: The supplied MEMBER classification exempts this internal PR from the external-contributor proof gate. Helper and diagnostic regressions are supplemental simulated-boundary evidence, and no live RunPod success is claimed. Existing lease and stored-data formats remain unchanged.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The supplied MEMBER classification exempts this internal PR from the external-contributor proof gate. Helper and diagnostic regressions are supplemental simulated-boundary evidence, and no live RunPod success is claimed. Existing lease and stored-data formats remain unchanged.
Evidence reviewed 8 items Current main still contains the defect: Fetched main unconditionally rejects UID 0 before native shared-host acquisition reaches its no-freeze path. The requested root repair therefore remains absent from current main.
Root allowance retains process-scope safeguards: Owned helpers require shared-host mode. Acquisition rejects nonempty orphan process scopes and live prior watchdogs; renewal and release retain exact watchdog and empty-scope checks. Detached root acquisition remains rejected.
Diagnostics reuse the existing redaction owner: Workspace failures use boundedWorkerErrorWithCode and boundedWorkerError, which redact before truncation. Error classification and generic failures for unrelated supervisor operations remain intact.
Findings None None.
Security None None.

How this fits together

The Gateway reconciles completed worker files back into the session workspace through a paired node host. The node’s quiescence helper protects that reconciliation, while command failures return through the Gateway tunnel.

flowchart TD
  A[Completed worker turn] --> B[Gateway reconciliation]
  B --> C[Node workspace command]
  C --> D[Owned or detached helper]
  D --> E[Workspace lease and manifest fences]
  E --> F[Reconciled workspace]
  C --> G[Redacted errors and node warnings]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +23, Tests +176, Docs +3. Total +202 across 8 files.

View PR surface stats
Area Files Added Removed Net
Source 3 44 21 +23
Tests 3 183 7 +176
Docs 2 3 0 +3
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 8 230 28 +202

Review metrics

Metric Value Why it matters
Diagnostic bound 500 characters per Gateway diagnostic Operator-visible details remain bounded and are redacted before truncation.

Technical review

Best possible solution:

Keep root support confined to the existing owned shared-host helper and preserve actionable diagnostics through the canonical redaction owner.

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

Yes, from source: current main rejects UID 0 during native helper acquisition before reconciliation proceeds. The supplied regressions establish that mechanism, but this review did not execute it or reproduce the full RunPod incident.

Is this the best way to solve the issue?

Yes. The patch narrows the existing root guard to the process-signaling detached path and reuses the established diagnostic formatter without adding another lifecycle owner.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

No label changes.

Label justifications:

  • P2: Repairs a concrete root-container reconciliation failure and improves diagnostics within a bounded worker subsystem.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The supplied MEMBER classification exempts this internal PR from the external-contributor proof gate. Helper and diagnostic regressions are supplemental simulated-boundary evidence, and no live RunPod success is claimed. Existing lease and stored-data formats remain unchanged.

Evidence

What I checked:

  • Current main still contains the defect: Fetched main unconditionally rejects UID 0 before native shared-host acquisition reaches its no-freeze path. The requested root repair therefore remains absent from current main. (src/gateway/worker-environments/workspace-quiescence-scripts.ts:417, 25affa738b0e)
  • Root allowance retains process-scope safeguards: Owned helpers require shared-host mode. Acquisition rejects nonempty orphan process scopes and live prior watchdogs; renewal and release retain exact watchdog and empty-scope checks. Detached root acquisition remains rejected. (src/gateway/worker-environments/workspace-quiescence-scripts.ts:418, dfcf5a6a5ab6)
  • Diagnostics reuse the existing redaction owner: Workspace failures use boundedWorkerErrorWithCode and boundedWorkerError, which redact before truncation. Error classification and generic failures for unrelated supervisor operations remain intact. (src/node-host/node-worker-supervisor-commands.ts:294, dfcf5a6a5ab6)
  • Verified merge-result scope: Raw test-merge parents match the pinned base followed by the pinned PR head. Comparing that result with its main parent preserves the same production changes; base drift does not introduce a removal claim. (7161d8d741f1)
  • Regression coverage and stated runtime limitation: Inspected tests execute the generated helper with real lease files but simulated UID, process transport, identity probes, and expiry clock. They cover acquisition, renewal, release, and both detached-root denials. Diagnostic tests exercise node invocation and Gateway error propagation. The captured PR body reports 79 passing tests and explicitly states that no live RunPod rerun occurred; this review executed no tests. (src/node-host/node-worker-workspace-quiescence.test.ts:252, dfcf5a6a5ab6)
  • Upgrade scope is documented: The documentation requires updating the node host as well as the Gateway and preserves the detached non-root path. The patch changes no lease serialization, database schema, configuration, or protocol dialect. Public docs: docs/gateway/cloud-workers/session-lifecycle.md. (docs/gateway/cloud-workers/session-lifecycle.md:68, dfcf5a6a5ab6)

Likely related people:

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

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 (2 earlier review cycles)
  • reviewed 2026-10-07T03:59:14.482Z sha dfcf5a6 :: needs maintainer review before merge. :: none
  • reviewed 2026-10-07T04:05:44.069Z sha dfcf5a6 :: needs maintainer review before merge. :: none

@steipete
steipete merged commit 7f1bd4f into main Oct 7, 2026
131 of 133 checks passed
@steipete
steipete deleted the steipete/cloud-worker-runpod-ws-20261006 branch October 7, 2026 04:44
@steipete

steipete commented Oct 7, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

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 P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant