Skip to content

fix(node-host): stop managed nodes looping on owner-only credential repair - #203528

Merged
steipete merged 1 commit into
mainfrom
codex/issue-203489
Nov 22, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/issue-203489

Conversation

@steipete

@steipete steipete commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

A managed headless node runtime (the auto-updated runtime under ~/.openclaw/node-runtime) consumes shared state but is deliberately not allowed to repair it. When client credential preparation reported anything other than ready, startup still entered Doctor maintenance and hit the shared-state repair guard. The managed node then failed, the launcher restarted it about every 4 s, and the only advice was "update that installation", which was wrong when the installation was already current (#203489).

User Impact

Headless node hosts running an auto-updated node runtime no longer sit in an endless 4 s restart loop when an optional credential metadata upgrade is pending. When a real repair is required, the error now points at the command that fixes it, openclaw doctor --fix run with the owning installation, instead of telling users to update an already-current install.

Why This Change Was Made

Root cause:

prepareStartupClientCredentials (src/commands/startup-client-credentials.ts) treats both a required credential migration and an optional metadata upgrade as Doctor work. In the managed runtime that work always reaches assertOpenClawStateSchemaRepairAllowed, so it can never succeed and never defers. Reproduced with the production entry (runNodeHost inside withExistingOpenClawStateSchema, as src/entry.ts runs a managed child):

  • A credential receipt whose recorded state-file identity no longer matches, for example after a restored state DB, gives the "update that installation" loop.
  • A receipt that only needs the optional source metadata upgrade gives the same loop. Unmanaged startup defers this upgrade.

Fix

  • In the managed runtime, an optional credential metadata upgrade is deferred with a warning. Existing credentials stay usable and the node starts.
  • A required credential repair refuses before taking maintenance ownership, with a ClientCredentialMigrationRequiredError naming the state path and the real next step: openclaw doctor --fix with the installation that owns it. The managed node retries automatically.
  • The shared-state repair guard now names the same Doctor command instead of "update that installation".
  • docs/install/updating/automatic-updates.md documents the recovery.

The ownership boundary is unchanged: the managed runtime still never repairs shared state.

Production +16/-1. Tests +48/-1. Docs +7.

Not covered (NEEDS-MAINTAINER-DECISION)

The reporter's preferred outcome is automatic repair by the owning installation, without anyone logging in. That would need the node launcher (node-host-launcher.mjs, intentionally state-free) to run the installed package's Doctor, or fall back to the installed runtime when the managed child reports owner-only maintenance. That changes launcher ownership, so it is left for a maintainer decision. This PR makes the failure state the correct recovery and removes the upgrade loop entirely.

I could not identify which credential invariant the reporter's unclean shutdowns broke. A crash approximation that kept the inode admitted normally on both base and fix; replacing the state DB inode reproduces the reported message exactly.

Evidence

  • New tests in src/node-host/startup-state-readiness.test.ts, both red on base 8d1e59c2fdd and green with the fix:
    • stale credential receipt: base throws the guard's "update that installation" error; the fix throws ClientCredentialMigrationRequiredError with the Doctor command and never prepares the runtime;
    • optional metadata upgrade: base loops on the guard; the fix admits the node and logs the deferral.
  • Consumer suites green, 84 tests: startup-state-readiness, startup-client-credentials, openclaw-agent-execution-cleanup, sqlite-worker-existing-schema, node-host runner.
  • oxfmt and oxlint clean on touched files; git diff --check clean.

Refs #203489

…epair

A managed node runtime consumes shared state but may not repair it. When
client credential preparation reported a required migration or an optional
metadata upgrade, startup still took Doctor maintenance and reached the
schema-repair guard, so the supervisor retried every few seconds forever
with advice to update an installation that was already current.

The managed runtime now defers an optional credential metadata upgrade and
keeps running on its existing credentials. A required repair refuses before
maintenance with the owner's real next step, openclaw doctor --fix with
the installation that owns the state. The repair guard names the same
command instead of an update.

Refs #203489
@clawsweeper

clawsweeper Bot commented Nov 22, 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 commands Command implementations size: S labels Nov 22, 2026
@steipete
steipete marked this pull request as ready for review November 22, 2026 15:44
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-22T15:47:11.232910Z 7adec94 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.

@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. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. 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 Nov 22, 2026
@clawsweeper

clawsweeper Bot commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR defers optional credential metadata upgrades in managed nodes and directs required repairs to the owning installation’s Doctor command.

Example: A managed node finds client/credentials.sqlite with a valid receipt whose source metadata is null.

  • Before: Startup attempts shared-state maintenance and fails with advice to update the installation.
  • After: Startup warns that metadata maintenance is deferred and continues using existing credentials.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The source change is focused and appears correct, with two distinct regression cases; required shipped-entry-point and upgrade proof remain absent, and no production schema or persisted format changes require migration.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: An already-current managed node can fail startup with misleading update advice even when it needs owner-side Doctor repair or only an optional metadata upgrade.
Reason: The linked report accepts actionable recovery guidance, and the maintainer-authored direction preserves the intentional installation ownership boundary without expanding launcher responsibilities.

Merge readiness

✅ Ready for maintainer review

Keep open: this PR makes a useful, focused repair that current main lacks, with no definite introduced code defect found; required repairs still need owner intervention, while optional metadata upgrades stop blocking startup.

Priority: P1
Reviewed head: 7adec94522b9fe6991614c60d859623020cc0c8b

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: Supply redacted shipped-launcher output on the fixed runtime showing optional-upgrade startup, the stale-receipt Doctor diagnostic, and successful startup after owner recovery, including a latest-stable upgrade with credentials and settings preserved.
Agent review details

How this fits together

The managed node entry admits existing shared state, then credential preparation decides whether startup can continue or must defer repair to the installation that owns that state.

flowchart TD
  A[Node launcher] --> B[Managed entry]
  B --> C[Existing state admission]
  C --> D[Credential preparation]
  D --> E[Ready or optional upgrade]
  E --> F[Node runtime]
  D --> G[Required repair diagnostic]
  G --> H[Owning installation Doctor]
Loading

Technical review

Best possible solution:

Keep the small credential-preparation change and existing Doctor ownership, treating automatic owner-side recovery as separate work.

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

The released-version reporter trace and current source establish the stale-receipt path into forbidden maintenance; the added regression also targets optional metadata upgrades, but no target code was executed during this read-only review.

Is this the best way to solve the issue?

The patch uses the existing credential-preparation and schema-policy owners, preserves required repair refusal, and adds no parallel state or maintenance mechanism.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Managed shared-state repair restriction and recovery guidance keeps the original intent (3c4c111: Automatic headless-node updates consume compatible existing state while migration and startup repair remain owned by the installed update workflow.)
  • Automatic credential preparation before node startup keeps the original intent (5f40d22: Supported upgrades prepare credentials automatically while preserving keys and pairing, with optional metadata upgrades allowed to defer when maintenance is unavailable.)
  • Retained legacy approval handling keeps the original intent (a0ec2b5: Conflicting legacy approvals should not stop startup when canonical policy remains usable; the new branch retains that existing early admission path.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 3c4c111 adds src/state/openclaw-state-db-schema-policy.ts:137 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 3c4c111b0f71; files: src/state/openclaw-state-db-schema-policy.ts)
  • Jason (Json): Raw commit 5f40d22 adds src/commands/startup-client-credentials.ts:174 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 5f40d22a366d; files: src/commands/startup-client-credentials.ts)

PR surface

Source +15, Tests +47, Docs +7. Total +69 across 4 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 2 16 1 +15
Tests 1 48 1 +47
Docs 1 7 0 +7
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 71 2 +69

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Labels

Label changes:

  • add P1: The linked released-version failure leaves an unattended managed node offline, and optional credential metadata upgrades can unnecessarily prevent startup.
  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P1: The linked released-version failure leaves an unattended managed node offline, and optional credential metadata upgrades can unnecessarily prevent startup.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rank-up moves

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

  • Provide the fixed-runtime launcher and upgrade evidence described in the proof assessment, redacting IPs, API keys, phone numbers, and non-public endpoints.

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 November 22, 2026, 11:01 AM ET / 16:01 UTC.

@steipete
steipete merged commit feea72c into main Nov 22, 2026
230 of 234 checks passed
@steipete
steipete deleted the codex/issue-203489 branch November 22, 2026 16:22
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 23, 2026
…epair (openclaw#203528)

A managed node runtime consumes shared state but may not repair it. When
client credential preparation reported a required migration or an optional
metadata upgrade, startup still took Doctor maintenance and reached the
schema-repair guard, so the supervisor retried every few seconds forever
with advice to update an installation that was already current.

The managed runtime now defers an optional credential metadata upgrade and
keeps running on its existing credentials. A required repair refuses before
maintenance with the owner's real next step, openclaw doctor --fix with
the installation that owns the state. The repair guard names the same
command instead of an update.

Refs openclaw#203489

Co-authored-by: Peter Steinberger <[email protected]>
tideclaw-bot pushed a commit that referenced this pull request Nov 23, 2026
…epair (#203528)

A managed node runtime consumes shared state but may not repair it. When
client credential preparation reported a required migration or an optional
metadata upgrade, startup still took Doctor maintenance and reached the
schema-repair guard, so the supervisor retried every few seconds forever
with advice to update an installation that was already current.

The managed runtime now defers an optional credential metadata upgrade and
keeps running on its existing credentials. A required repair refuses before
maintenance with the owner's real next step, openclaw doctor --fix with
the installation that owns the state. The repair guard names the same
command instead of an update.

Refs #203489

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

(cherry picked from commit feea72c)

Co-authored-by: RomneyDa <[email protected]>
(cherry picked from commit 4c1293fe055aed2ad1c64bc9b0ec1d46768d6b30)
(cherry picked from commit 5fa858ed3262c40874e067ec59b98a20e4445e7e)
tideclaw-bot pushed a commit that referenced this pull request Nov 30, 2026
…#203236)

* fix(update): back off identical automatic update failures

Automatic campaigns retried a target that kept failing the same way before
activation (for example managed-service-stop-failed) every hour forever. One
install accumulated ~330 failed runs, each costing a validation pass and a
candidate state snapshot.

The campaign already used the newest terminal run rows as its durable backoff
fact for repeated activation failures. Extend that streak to every identical
failure class for the same target: keep the hourly first retry, then wait 2, 4,
8 and 16 hours and once a day after six. A new target, a success, or a manual
update breaks the streak. No new state, store, or config.

Refs #202954

* test(update): assert backoff expiry before the new-candidate reset

Co-authored-by: Peter Steinberger <[email protected]>
(cherry picked from commit adc0876)

Companion audit: #203194 and #203497 change update architecture and are not needed by the backoff; #203274 is chat reset cleanup, #203528 is node credential repair, and #203578 adds a separate database custody refusal. #203152 addresses stopping a Gateway after a Node runtime respawn, not pre-mutation outcome history; no dependency on that process-shutdown repair.

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

commands Command implementations docs Improvements or additions to documentation 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: 👀 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