Repository navigation
fix(node-host): stop managed nodes looping on owner-only credential repair - #203528
Conversation
…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
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex review: needs maintainer review before merge. What this changesThis 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.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete 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 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherThe 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]
Technical reviewBest 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
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +15, Tests +47, Docs +7. Total +69 across 4 files. Added test files: 0. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. LabelsLabel changes:
Label justifications:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale6/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. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed November 22, 2026, 11:01 AM ET / 16:01 UTC. |
|
Merged via squash.
|
…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]>
…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)
…#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]>
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 thanready, 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 --fixrun 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 reachesassertOpenClawStateSchemaRepairAllowed, so it can never succeed and never defers. Reproduced with the production entry (runNodeHostinsidewithExistingOpenClawStateSchema, assrc/entry.tsruns a managed child):sourcemetadata upgrade gives the same loop. Unmanaged startup defers this upgrade.Fix
ClientCredentialMigrationRequiredErrornaming the state path and the real next step:openclaw doctor --fixwith the installation that owns it. The managed node retries automatically.docs/install/updating/automatic-updates.mddocuments 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
src/node-host/startup-state-readiness.test.ts, both red on base8d1e59c2fddand green with the fix:ClientCredentialMigrationRequiredErrorwith the Doctor command and never prepares the runtime;git diff --checkclean.Refs #203489