Skip to content

fix(node-host): recover worker hosting after transient initialization failures - #128798

Merged
steipete merged 3 commits into
mainfrom
steipete/fix-node-supervisor-initialization
Aug 24, 2026
Merged

steipete merged 3 commits into
mainfrom
steipete/fix-node-supervisor-initialization

Conversation

@steipete

@steipete steipete commented Aug 24, 2026 •

Copy link
Copy Markdown
Contributor

Closes #128794

What Problem This Solves

Fixes an issue where one transient node worker supervisor reconciliation failure could permanently disable container session hosting or strand native host capacity until the node process restarted.

Why This Change Was Made

Supervisor initialization now coalesces active callers and keeps a successful result cached, but clears the exact rejected attempt so later initialization can retry. The node-host runtime owns one five-second retry timer while alive, clears it during shutdown, and never publishes positive capacity before reconciliation succeeds.

Container failures now have one explicit lifecycle decision. Missing engines, unsupported Windows isolation, synchronous construction failures, and durable engine/daemon-context mismatches remain permanent actionable disable outcomes. Other reconciliation failures retain the same supervisor and retry. If a later retry discovers a permanent context mismatch, the runtime stops retrying, closes that supervisor, and tells the runner to withdraw worker hosting from its published inventory.

Production LOC: +114/-59 (net +55) | Tests: +319/-153 (net +166)

The production growth establishes retry scheduling, permanent/transient error classification, dynamic runner withdrawal, and shutdown ownership. The old one-shot paths were removed. Worker-hosting policy moved out of the broad runtime test file, and the small platform-identity extraction keeps the touched runner below its max-lines boundary without changing behavior.

AI-assisted: yes. I reviewed supervisor initialization coalescing, launch-journal and container ownership recovery, capacity publication, runtime retry timers, permanent engine-context classification, runner inventory withdrawal, close races, and platform identity projection and understand the change.

User Impact

Node session hosts recover automatically after transient launch-journal or container reconciliation failures. Capacity remains unavailable until ownership is safe, then becomes usable without restarting the node process. Permanent engine or daemon-context mismatches remain visibly disabled with instructions to restore the original context, including when the mismatch is discovered on a later retry.

Evidence

  • Pre-fix regressions: a rejected initialize() promise was returned forever; native runtime initialization was attempted once; container reconciliation failure closed/discarded the supervisor and returned workerHostingEnabled=false.
  • ClawSweeper P1 fixed: durable engine/daemon-context mismatch now has a typed closed error, remains permanently disabled during prepare, and also stops a later retry while withdrawing runner hosting.
  • Post-fix focused proof: 6 files, 127 tests passed across runner, runtime lifetime/hosting policy, supervisor ordinary/recovery, and container ownership.
  • Full changed-file gate: node scripts/check-changed.mjs passed after rebase, including core/test typechecking, lint, max-lines, formatting, import-cycle, database-first, and architecture guards.
  • Retry proof covers concurrent coalescing, failure reset, success caching, immediate container recovery on runtime start, five-second native retry, positive-capacity publication only after success, retry cancellation on close, and exactly-once supervisor close.
  • Permanent-failure proof covers missing engines, unsupported Windows, initial engine-context mismatch, late mismatch after a transient failure, supervisor cleanup, actionable reason, and runner inventory withdrawal.
  • Fresh P0/P1 autoreview after the finding fix: no accepted/actionable findings (0.92).
  • CI attempt 1's only failed check was a Blacksmith job canceled before runner assignment; unchanged attempt 2 passed. The updated head requires fresh exact-head CI.
  • Live node/container fault injection not run: deterministically failing only the first launch-journal/container ownership sweep in a real node process requires replacing the owning persistence/engine boundary or disrupting a host daemon. The real supervisor store backs memoization recovery and the shipped runtime/runner lifecycle backs retry, permanent classification, withdrawal, and close behavior; the campaign final current-main live matrix will cover normal node capacity publication and worker turns.

@clawsweeper

clawsweeper Bot commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@openclaw-barnacle openclaw-barnacle Bot added size: L maintainer Maintainer-authored PR labels Aug 24, 2026
@steipete
steipete marked this pull request as ready for review August 24, 2026 16:42
@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P1 High-priority user-facing bug, regression, or broken workflow. 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. labels Aug 24, 2026
@clawsweeper

clawsweeper Bot commented Aug 24, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge. Reviewed August 24, 2026, 1:30 PM ET / 17:30 UTC.

ClawSweeper review

What this changes

The PR retries node-worker supervisor initialization after transient reconciliation failures and adds recovery and shutdown lifecycle tests.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

Keep open: the prior P1 remains on the exact reviewed head. A durable engine or daemon mismatch is intentionally an actionable disable condition, but this PR treats it as transient and retries forever.

Priority: P1
Reviewed head: 904347d276bdf85ffe5e6fb65e30a8423a85bfb9

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The recovery direction and focused coverage are useful, but the unresolved persistent-versus-transient classification is a blocking correctness gap.
Proof confidence 🌊 off-meta tidepool Not applicable: This MEMBER-authored PR is outside the external-contributor real-behavior-proof gate; its supplied focused tests remain supplemental evidence.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This MEMBER-authored PR is outside the external-contributor real-behavior-proof gate; its supplied focused tests remain supplemental evidence.
Evidence reviewed 5 items Persistent mismatch contract: The container lifecycle rejects a retained worker record whose engine or daemon target differs, explicitly telling the operator to restore the original engine context before enabling hosting.
Indiscriminate retry: The runtime catches every supervisor initialization rejection and schedules another attempt, so the persistent mismatch above is retried indefinitely.
Current-main behavior: The PR base disables container hosting and retains an actionable reconciliation diagnostic when initialization fails after engine resolution; the branch removes that distinction.
Findings 1 actionable finding [P1] Keep engine-context mismatches permanently disabled
Security None None.

Live Verification

Command: pnpm openclaw node --help

Result: PASS (completed)

pnpm openclaw node --helprunner@runnervm76f27:/tmp/clawsweeper-live-proof-128798-0ayMr2/target$ pnpm openclaw node --help
$ node scripts/run-node.mjs node --help
pnpm openclaw node --help
[openclaw] Building TypeScript (dist is stale: missing_build_stamp - build stamp missing).
[openclaw] Building bundled plugin assets.
[canvas] build: node scripts/bundle-a2ui.mjs
[log] ‹DIR›/a2ui.bundle.js  chunk │ size: 399.96 kB
[log] ‹DIR›/a2ui-v0.9.bundle.js  chunk │ size: 615.66 kB
[log]
[success] rolldown v1.2.0 Finished in 102.59 ms
[diffs] build: node --import tsx ../../scripts/build-diffs-viewer-runtime.mts curated








































Assertions:

  • PASS expect_output: node

How this fits together

Node hosts reconcile durable worker records before advertising capacity to session placement. The runtime must publish capacity after safe recovery, retry transient failures, and preserve actionable disable states for persistent ownership mismatches.

flowchart LR
  A[Node host startup] --> B[Resolve container engine]
  B --> C[Create worker supervisor]
  C --> D[Reconcile durable worker ownership]
  D --> E{Failure classification}
  E -->|Ready| F[Publish worker capacity]
  E -->|Transient| G[Retry while runtime is alive]
  E -->|Persistent mismatch| H[Show disabled reason]
Loading

Before merge

  • Keep engine-context mismatches permanently disabled (P1) - NodeWorkerContainerLifecycle deliberately rejects a journal tied to a different engine or daemon and tells the operator how to restore it. This catch schedules the same failure forever, so a persistent mismatch no longer produces the current actionable disabled state; classify it before retrying and add a runtime-boundary regression. This is the still-unfixed P1 from the prior review cycle.
  • Resolve merge risk (P1) - Merging this retry loop would replace an actionable persistent engine or daemon mismatch with an indefinitely unavailable host that repeatedly retries and no longer surfaces the existing startup disable diagnosis.
  • Complete next step (P2) - A narrow mechanical repair can preserve the established permanent mismatch behavior without changing the transient recovery goal.

Findings

  • [P1] Keep engine-context mismatches permanently disabled — src/node-host/runtime.ts:405-415
Agent review details

Security

None.

PR surface

Source +15, Tests +121. Total +136 across 5 files.

View PR surface stats
Area Files Added Removed Net
Source 2 49 34 +15
Tests 3 274 153 +121
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 323 187 +136

Review metrics

Metric Value Why it matters
Production versus test LOC production +49/-34 (net +15); tests +274/-153 (net +121) The production growth is intended to own retry lifecycle behavior, but its failure classification must be corrected before that added path is safe.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #128794
Summary: This PR is the candidate repair for the linked node-worker initialization bug.

Members:

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

Merge-risk options

Maintainer options:

  1. Classify permanent context mismatches (recommended)
    Preserve the existing actionable disabled state for persisted engine or daemon mismatches and retry only explicitly transient reconciliation failures.
Copy recommended automerge instruction
@clawsweeper automerge

Special instructions:
Add a permanent container-context mismatch outcome, retain the disabled diagnostic without scheduling retry, and cover it at the runtime boundary.

Technical review

Best possible solution:

Use an explicit permanent container-context mismatch outcome at the lifecycle boundary, preserve the disabled reason for that outcome, and retry only transient reconciliation failures.

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

Yes from source: seed a retained container record for a different engine or daemon target, then start container hosting. The lifecycle rejects that state, while this branch's generic catch schedules retries instead of retaining the disabled result.

Is this the best way to solve the issue?

No. Resetting every rejected initialization is too broad; the known durable ownership mismatch needs a permanent classified outcome before retry scheduling.

Full review comments:

  • [P1] Keep engine-context mismatches permanently disabled — src/node-host/runtime.ts:405-415
    NodeWorkerContainerLifecycle deliberately rejects a journal tied to a different engine or daemon and tells the operator how to restore it. This catch schedules the same failure forever, so a persistent mismatch no longer produces the current actionable disabled state; classify it before retrying and add a runtime-boundary regression. This is the still-unfixed P1 from the prior review cycle.
    Confidence: 0.99

Overall correctness: patch is incorrect
Overall confidence: 0.99

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 7d08e40e2f1d.

Labels

Label justifications:

  • P1: The changed node-host initialization path can strand worker session capacity or hide the reason it is unavailable.
  • merge-risk: 🚨 compatibility: Existing hosts with persisted workers tied to another engine or daemon would lose their actionable disabled state after upgrade.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: This MEMBER-authored PR is outside the external-contributor real-behavior-proof gate; its supplied focused tests remain supplemental evidence.

Evidence

Acceptance criteria:

  • [P1] pnpm test src/node-host/runtime.worker-hosting.test.ts.
  • [P1] pnpm test src/node-host/node-worker-supervisor.container.test.ts.
  • [P1] node scripts/check-changed.mjs -- src/node-host/runtime.ts src/node-host/node-worker-container-lifecycle.ts src/node-host/runtime.worker-hosting.test.ts.

What I checked:

Likely related people:

  • steipete: Git history attributes the durable node-worker supervision feature and this recovery PR to Peter Steinberger. (role: feature owner and recent area contributor; confidence: high; commits: 6b9bea84f0e2, 904347d276bd; files: src/node-host/runtime.ts, src/node-host/node-worker-supervisor.ts, src/node-host/node-worker-container-lifecycle.ts)

Rank-up moves

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

  • Preserve the actionable disabled result for engine or daemon mismatches.
  • Add a runtime test proving that this permanent outcome schedules no retry and retains its diagnostic.

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 (1 earlier review cycle)
  • reviewed 2026-08-24T16:48:40.514Z sha 904347d :: found issues before merge. :: [P1] Keep engine-context mismatches permanently disabled

@steipete

Copy link
Copy Markdown
Contributor Author

Land-ready proof for exact head 904347d276bdf85ffe5e6fb65e30a8423a85bfb9:

  • CI run 32752359575, attempt 2: green, including the required openclaw/ci-gate and checks-node-compact-large-15.
  • The first attempt's only failure was infrastructure: that shard was canceled before runner assignment with no runner name, steps, or logs; all other checks passed. The exact failed job was rerun unchanged and passed.
  • Pre-fix proof: rejected supervisor initialization was permanently memoized; native runtime initialization never retried; container reconciliation failure discarded a valid supervisor and reported hosting disabled.
  • Post-fix owner proof: 86 tests passed across five runtime/supervisor/recovery/container suites.
  • node scripts/check-changed.mjs: passed after rebase.
  • Fresh P0/P1 autoreview: no accepted/actionable findings (0.91).
  • Native review artifacts validate as READY FOR /prepare-pr with zero findings; native prepare-run passed hosted exact-head gates.
  • Production LOC: +49/-34 (net +15); tests +274/-153 (net +121, including the worker-hosting concept-file split).

The current ClawSweeper review is still running on this exact head and has not published findings or rank-up moves. Repository policy does not require waiting on the publisher once exact-head CI and native review are complete.

Proof gap: deterministic first-attempt failure of a live node's launch journal/container sweep would require replacing the owning persistence boundary or disrupting a host daemon. The real supervisor store covers retry memoization; the shipped runtime covers retry scheduling/cancellation; final campaign current-main live proof will cover normal node capacity and worker turns.

Clear failed initialization ownership for retry, retain valid container supervisors after transient reconciliation errors, and retry from the runtime until capacity becomes authoritative or shutdown cancels the lifecycle.\n\nRefs #128794
Keep durable engine and daemon-context mismatches on the actionable disabled path while retrying only transient supervisor reconciliation failures.\n\nRefs #128794
Stop retrying when a later reconciliation attempt proves a permanent container context mismatch, close the supervisor, and withdraw worker hosting from runner inventory.\n\nRefs #128794
@steipete
steipete force-pushed the steipete/fix-node-supervisor-initialization branch from 904347d to a0ef27e Compare August 24, 2026 17:51
@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

The P1 is addressed on head a0ef27ea11c941b8badc7656d3a3634e00c2573c:

  • Added a typed permanent container engine/daemon-context mismatch outcome.
  • Initial mismatch remains actionably disabled and closes the prepared supervisor.
  • A mismatch discovered after an earlier transient failure now stops retries, closes the same supervisor, and withdraws worker hosting from runner inventory.
  • Added initial and late-mismatch runtime coverage; 127 focused tests and the full changed-file gate pass.

@clawsweeper

clawsweeper Bot commented Aug 24, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@steipete

Copy link
Copy Markdown
Contributor Author

Land-ready proof for corrected head a0ef27ea11c941b8badc7656d3a3634e00c2573c:

  • CI run 32759025010: exact-head required gates green. Two optional dispatch/label jobs were canceled; no required check failed or remains pending.
  • ClawSweeper P1 addressed: engine/daemon-context mismatch is a typed permanent outcome at initial preparation and on later retries. Late mismatch stops retry, closes the same supervisor, preserves the actionable reason, and withdraws worker hosting from runner inventory.
  • Pre-fix proof: rejected supervisor initialization was permanently memoized; native initialization never retried; broad container failure permanently discarded valid supervisors.
  • Post-fix owner proof: 127 tests passed across six runner/runtime/supervisor/recovery/container suites.
  • node scripts/check-changed.mjs: passed after rebase, including max-lines and architecture guards.
  • Fresh corrected-head P0/P1 autoreview: no accepted/actionable findings (0.90).
  • Native review artifacts validate as READY FOR /prepare-pr with zero findings; corrected-head prepare-run passed hosted gates.
  • Production LOC: +114/-59 (net +55); tests +319/-153 (net +166). Growth owns retry scheduling, permanent/transient classification, runtime withdrawal, and cleanup; test/platform modules split touched oversized files without suppressions.

A ClawSweeper re-review is running on this exact head. The earlier actionable finding is applied and covered; repository policy does not require waiting on the publisher once exact-head CI and native review are complete.

Proof gap: deterministic first-attempt failure of a live launch journal/container sweep would require replacing persistence or disrupting a host daemon. The real supervisor store covers memoization recovery; shipped runtime and runner paths cover retry, permanent classification, withdrawal, and close; final campaign current-main live proof will cover normal capacity and worker turns.

@steipete
steipete merged commit bf83a4d into main Aug 24, 2026
164 of 166 checks passed
@steipete
steipete deleted the steipete/fix-node-supervisor-initialization branch August 24, 2026 18:06
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 25, 2026
… failures (openclaw#128798)

* fix(node-host): retry worker supervisor initialization

Clear failed initialization ownership for retry, retain valid container supervisors after transient reconciliation errors, and retry from the runtime until capacity becomes authoritative or shutdown cancels the lifecycle.\n\nRefs openclaw#128794

* fix(node-host): preserve permanent container mismatch failures

Keep durable engine and daemon-context mismatches on the actionable disabled path while retrying only transient supervisor reconciliation failures.\n\nRefs openclaw#128794

* fix(node-host): withdraw hosting on late context mismatch

Stop retrying when a later reconciliation attempt proves a permanent container context mismatch, close the supervisor, and withdraw worker hosting from runner inventory.\n\nRefs openclaw#128794
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: L 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.

Transient node supervisor initialization permanently disables session hosting

1 participant