Skip to content

fix(update): refuse missing host prerequisites in one line and record a cause per attempt - #198355

Merged
obviyus merged 4 commits into
mainfrom
fix/update-prereq-preflight
Nov 15, 2026
Merged

obviyus merged 4 commits into
mainfrom
fix/update-prereq-preflight

Conversation

@obviyus

@obviyus obviyus commented Nov 13, 2026 •

Copy link
Copy Markdown
Collaborator

What failed in the field

From 3,782 classified upgrade issues and 783 auto-filed update failure reports:

  • Unsupported Node: 99 failures, the largest single cause. 83 of them read npm error [openclaw] error: this OpenClaw release requires Node >=24.22.1 … under Reason code: global-install-failed. The npm preinstall check found the problem after the update had started. All came from updaters at or below 2026.10.9. Main has refused before staging since fix: reject incompatible Gateway Node before package update staging #180769. But that refusal is a 40-line wall: 5 Failing check lines, recovery steps, a triage run, 3 failure JSON files and a diagnostics zip, with the instruction buried in the middle.
  • Old Git: Report on 78 days of automated upgrades on the dev branch using Codex #197195. System Git 2.43 failed with the opaque preflight-no-good-commit. Nothing told the operator "Git ≥ X required".
  • Full disk: nothing refused an update on a nearly full disk. There was only a soft Low disk space … may fail warning.
  • Causes hidden in reports. 276 reports read Reason code: global-install-failed. That code names the place where the update failed, not the reason. Their failing-check codes read [redacted-code] (147) or Error (126). Phase names are redacted as [redacted-command], because a step name with a space looks like a shell command.

What changed

  1. Prerequisite preflight. Before staging, openclaw update refuses with one Update refused: … line that says what to install or free, and changes nothing:
    • Node: the existing engine check reads the service's Node from its launchd plist, systemd unit or Windows task. It now leads with one line that names the target's engines.node and which Node is too old (the service or the updater), followed by the recovery owner's own numbered steps (profile, version-manager install, absolute launcher continuation, and the service-definition owner's step when this updater cannot refresh it). If no supported Node release satisfies the target, it says to pick a compatible OpenClaw version instead.
    • Git (new): Git-checkout updates need Git ≥ 2.31. Older Git echoes git rev-parse --path-format=absolute back instead of failing, so prepareGitCandidateTransfer gets a wrong object directory after the service is prepared for mutation. The check runs the same Git as the updater. The updater puts its Node's directory and /usr/bin ahead of the shell's PATH, so the refusal names the Git that it found.
    • Disk: the soft low-disk warning becomes a refusal sized from the target's registry dist.unpackedSize, read with the target metadata the updater already fetches (one more field, no install measurement). The floor is 4.4× that size: for 2026.11.3 (263 MiB unpacked) a fresh global install with dependencies took 662 MiB (2.5×) and npm's cache 490 MiB (1.9×). Metadata without dist.unpackedSize (some mirrors) skips the check. It runs after the existing measured state-copy check (snapshot-capacity-insufficient), which now leads with its instruction line.
    • These refusals skip triage. A repair agent cannot install Node or Git or free disk space.
  2. One cause per attempt. finishUpdateRunRecord is the single place that writes a terminal update-run record. It now sets origin.cause to one value of a closed enum (none, node-unsupported, git-unsupported, disk-full, permission-denied, network, config-invalid, install-failed, state-migration-failed, plugin-failed, service-failed, interrupted, refused, unknown). Machine facts (an npm ENOSPC, EACCES or network code) win over the site code. The saved report and the auto-filed failure report print Cause: …. Origin compaction keeps the enum intact, so an oversized record stays readable. The Control UI report renderer prints the stored cause and does not bundle the classifier. Because the set is closed, redaction never hides it. It is stored in origin_json, as nextAction already is, so there is no SQL schema change. The wire schema gains one optional enum field.

Replaying the 783 auto-filed reports through the classifier gives: 271 install-failed, 129 state-migration-failed, 107 service-failed, 97 node-unsupported (before: all hidden behind global-install-failed), 80 unknown, 27 plugin-failed, 27 refused, 15 config-invalid, 13 interrupted, 11 permission-denied, 6 network. The script reconstructs facts from the redacted text, so the real unknown share is lower: new records get their facts before redaction.

Deleted / replaced

  • createLowDiskSpaceWarning and its disk-space-preflight warning step are replaced by describePackageStagingShortfall.
  • The snapshot-capacity-insufficient: prefix lines in both state-copy refusals (snapshot capacity and activation backup) are gone; each now leads with its Update refused: … instruction line.
  • The Git and disk refusals use the default failure fact (check = reason code) instead of a hand-built one.
  • For a fresh prerequisite refusal, the terminal shows the refusal line, the recovery steps and the report path. The Failing check dump, triage run, triage prompt, diagnostics zip and two extra failure JSON files are gone. The report file keeps every detail. Re-rendered history (update status, Control UI) keeps the existing saved-advice qualification.

Production delta against main: +301 / −45 lines (excluding the regenerated predicates.js, whose +2821/−2805 is renumbered check ids from adding one optional field). Tests +224 / −49, docs +27. Most of the growth is the cause map in src/infra/update-run-cause.ts, which is data. The rest is the Git check (+32) and the refusal layout. I found no duplicate Node check to delete: the early engine check and the later activation-runtime check answer different questions (engineOnly versus capability and identity).

Rebased onto main

This PR was stacked on #198268. It is now one commit on current main plus two follow-ups, and its base is main. The #198268 commits are gone. Against main as it is today:

  • update-candidate-snapshot.ts: main still has both state-copy refusals (snapshot capacity and activation backup). Both now lead with an Update refused: … line, and stderrTail keeps the capacity diagnostics.
  • update-failure-public-codes.ts: keeps main's preflight-local-replay-conflict and adds git-version-unsupported.
  • update-failure-facts.ts: no overlap remains.

ClawSweeper findings (review of 9fd15aa)

All four P2 findings were fixed in commits after that review. This head carries the fixes, and the E2E below exercises them:

  1. Cause enum through bounded origin serialization: cause is in preservedTextFields in update-run-codec.ts. update-run-ledger.test.ts round-trips an oversized terminal record through the ledger (red without the codec line: the stored disk value fails validation on read).
  2. Scoped and service-owned recovery steps visible: the Node refusal is the problem line followed by the recovery owner's own numbered steps (formatUpdateRecoverySteps), including the profile export and the absolute launcher. The E2E Node row shows them.
  3. No supported Node satisfies the target: with no recommendation, the single line says no supported Node release satisfies openclaw@X's <range>. Select a compatible OpenClaw version. It does not ask the operator to install Node.
  4. Saved refusal advice: the refusal headline reads only the fresh opts.nextAction, never run.origin.nextAction. Re-rendered history keeps the historical-advice layout. update-run-report.test.ts asserts that a re-render does not announce Update refused.
  5. Data-model compatibility: no SQL schema change; cause is an optional field in origin_json. Records written before this change (no cause) decode unchanged. The 11.3 → head row below upgrades a real 11.3 state and reads its update_runs back.

ClawSweeper findings (review of e296aa6)

  1. [P2] Service-definition step in early Node refusals: fixed. When the early engine check refuses for the service's own Node and this updater cannot refresh that service definition (refreshDefinition: false), the visible block now includes the deployment-owner step before the continuation command. Before the fix, it appeared only when the package was already current. Regression test: update-command-service-plan.test.ts › "keeps the service-definition step when an early refusal cannot refresh the service". It asserts the step is in the block before the blank line, which is the part the terminal shows.
  2. [P3] Snapshot diagnostics in the visible block: fixed. Both state-copy refusals (snapshot capacity and activation backup) now put a blank line between the Update refused: line and the capacity diagnostics, the same separator the Node producer uses. The terminal shows the instruction line, and the saved report keeps the inventory. update-command-git-snapshot.test.ts asserts the separator.

Proof: real openclaw update, exact head 3eca2b8 code

Setup (macOS, each scenario isolated):

  • This head is built with ocx build --dts and packed with scripts/package-openclaw-for-docker.mjs.
  • A local registry serves the real [email protected] metadata from npmjs, plus this head repacked as 2026.11.20 and 2026.11.21. Only package.json/build-info.json versions change, plus the content-inventory entry for build-info.json.
  • 2026.11.21 declares engines.node: >=24.22.1 <25 || >=26.12.1. Both carry a real dist.unpackedSize. dist.unpackedSize is the du size of the unpacked package (344 MiB), so the floor is 4.4 × 344 MiB ≈ 1.5 GiB.
  • Each run uses env -i with its own OPENCLAW_PROFILE/OPENCLAW_STATE_DIR and its own LaunchAgent and port. Fault scenarios ran in parallel.
Scenario Command Result Terminal output update_runs (status / reason / origin.cause)
Old Node (LaunchAgent Gateway on Node 24.21.0, target needs ≥24.22.1) openclaw update --tag 2026.11.21 --yes exit 1 in 14 s; nothing staged; Gateway kept serving /readyz 200 10 lines: ⚠️ Update refused: [email protected] needs Node >=24.22.1 <25 || >=26.12.1, but the Gateway service runs Node 24.21.0 at …/24.21.0/bin/node. No changes were made., the report path, then 4 numbered steps (keep the state overrides, export OPENCLAW_PROFILE=… OPENCLAW_LAUNCHD_LABEL=…, install Node 24.22.1, node …/openclaw.mjs --profile <p> update --tag 2026.11.21) failed / preflight-node-runtime-incompatible / node-unsupported
Old Git (Git-checkout install, upstream one commit ahead; a git reporting 2.23.0 beside the updater's Node) openclaw update --tag 2026.11.21 --yes (Git updates ignore --tag) exit 1 in 22 s; HEAD unchanged (3eca2b8) 8 lines: ⚠️ Update refused: Git 2.23.0 at <scratch>/node-oldgit/git is too old for Git-checkout updates. Replace it with Git 2.31 or newer, then retry openclaw update. No changes were made. failed / git-version-unsupported / git-unsupported
Near-full disk (install, npm cache, tmp and state on one 2 GiB APFS sparse image, 1.0 GiB free) openclaw update --tag 2026.11.21 --yes exit 1; nothing staged (node_modules holds only openclaw) 5 lines: ⚠️ Update refused: 1.0 GiB free on the volume holding /Volumes/…/prefix/lib/node_modules; this package update needs about 1.5 GiB. Free 456 MiB there, then retry openclaw update. No changes were made. failed / preflight-insufficient-space / disk-full
Latest stable → head (real [email protected] + LaunchAgent) openclaw update --tag 2026.11.20 --yes exit 0 in 793 s: ✅ OpenClaw updated to 2026.11.20 (from 2026.11.3); build 3eca2b8; /readyz 200 — succeeded / – / none
Normal update, head → next (2026.11.20 + LaunchAgent → 2026.11.21, which also exercises the Node and disk checks passing) openclaw update --tag 2026.11.21 --yes run 2: exit 0 in 1401 s, ✅ OpenClaw updated to 2026.11.21 (from 2026.11.20); /readyz 200 — succeeded / – / none

Normal update, run 1 (same setup, load average about 70): activation and Recorded verification: service running (2026.11.21); version verified; … core ready succeeded, then the updater failed update-executor-settlement because SQLite returned database is locked while the CLI and the new Gateway were settling the record. The recorded cause was unknown, because this reason has no entry in the cause map. Run 2 passed unchanged. This PR adds no database writes; the cause is computed in memory inside the existing terminal write. The same contention on main is unmeasured.

Old Git, without the shim beside Node: when the old git was only on the shell's PATH (Node symlinked from elsewhere), the updater used /usr/bin/git 2.54 and did not refuse. That is the documented "the check looks where the updater looks" behavior.

Wall time was measured on a shared host with a 1-minute load average of 35 to 100. Refusals took 14–46 s. The full updates took 13–23 minutes each, most of it the updater's existing runtime retention and candidate checks. The time per step was not measured.

Focused tests (ocx test, this head): update-run-cause, update-run-ledger, update-run-report, update-check, update-runner-git-commands, disk-space, update-database-backup-space, update-command-git-snapshot, update-command-target.n1-prefix, update-command-metadata-diagnostics, update-candidate-rehearsal.resources, update-command-package-space. pnpm tsgo:core, pnpm check:test-types, oxlint and oxfmt on the changed files, and git diff --check pass. update-cli.target-schema.test.ts and update-runner-git-admission.test.ts time out or read the host agent's environment when run inside the agent shell under load. CI runs them on this head.

Accepted edge cases

  • The disk floor is an estimate. 4.4× dist.unpackedSize comes from one measured release; a release with a very different dependency weight shifts it. A warm npm cache needs less, so a host near the floor may be refused although it would have finished; the message names the exact amount to free. Registries without dist.unpackedSize skip the check and keep the install's own ENOSPC handling.
  • The original-state capture still runs before target admission. It wrote about 3 MiB under <state>.update-captures/ for each refusal above, and it keeps that copy. Moving it after preflight changes initialization order, so it is left for a follow-up.
  • The check looks where the updater looks. The updater searches its Node directory and /usr/bin before the caller's PATH. An old Git that only appears later in the shell's PATH is neither used nor flagged.
  • Targets given as a tarball or file spec still skip the engine check, as before. Only registry metadata carries engines.node before staging.
  • A future reason code missing from the map records unknown. It is a single data table to extend.

@clawsweeper

clawsweeper Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review blocked

Automated review did not run, so no review verdict was produced.

Reason: The input-safety check rejected material in this revision. No detected value, path, or scanner output is reproduced here.

Automatic review is on hold, including after source changes. Request a fresh re-review after resolving the failure; maintainers can also release the hold through an intentional scanner-policy update.

Next step: If this is a genuine credential, remove and rotate it. If it is an intentional test fixture, a maintainer must review and qualify it.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation app: web-ui App: web-ui gateway Gateway runtime cli CLI command changes size: XL labels Nov 13, 2026
@obviyus
obviyus marked this pull request as ready for review November 13, 2026 16:12
@clawsweeper clawsweeper Bot added the clawsweeper:intake:bug Preliminary submission classification; full source review pending. label Nov 13, 2026
@openclaw-barnacle openclaw-barnacle Bot added the scripts Repository scripts label Nov 13, 2026
@obviyus

obviyus commented Nov 13, 2026

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@obviyus

obviyus commented Nov 13, 2026

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Nov 13, 2026
@clawsweeper

clawsweeper Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR adds early Git and disk prerequisite refusals, clearer Node recovery guidance, and a recorded cause for completed update attempts.

Example: A package update has 256 MiB free and a target unpacked size of 100 MiB.

  • Before: The updater warns about low disk space and continues.
  • After: The updater refuses before staging, asks the operator to free 184 MiB, and records disk-full.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Useful, focused changes with real CLI and stable-upgrade evidence; the prior blockers are resolved.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): Supplied macOS output exercises real openclaw update prerequisite refusals, recorded causes, healthy service retention, and successful updates at 3eca2b8; later changes retain those paths and add focused regressions for visible recovery guidance and diagnostic separation.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Updates can proceed into avoidable host-prerequisite failures or leave operators with opaque failure codes and buried recovery instructions.
Reason: The reported failures justify earlier actionable admission and durable causes; maintainer authorship establishes direction for the deliberate disk-policy change.

Merge readiness

✅ Ready for maintainer review

This maintainer-authored PR remains useful, resolves the previous findings, and introduces no new blocking defect found in this review.

Priority: P2
Reviewed head: 14312618702cfb1fbc17d4b035e41f7f6a6d9c67

Before merge

None.

Findings

None.

Agent review details

How this fits together

Update target admission consumes installation, runtime, registry, and filesystem facts; the existing run ledger and shared renderer publish the resulting outcome and recovery instructions.

flowchart TD
  A[Update request] --> B[Target admission]
  C[Host and registry facts] --> B
  B --> D[Prerequisite refusal]
  B --> E[Existing update execution]
  D --> F[Terminal run record]
  E --> F
  F --> G[CLI and saved reports]
Loading

Technical review

Best possible solution:

Retain the focused prerequisite checks and shared cause field while preserving existing recovery ownership and stored-history compatibility.

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

Current main still uses advisory package-space warnings and lacks the cause field; the supplied real CLI traces demonstrate the changed outcomes without this review executing target code.

Is this the best way to solve the issue?

The change uses existing target admission, terminal-record, and report owners, removes the superseded warning path, and keeps the classifier separate from presentation.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Package disk admission changes intended behavior with a stated reason (e7f19d4: The earlier update change moved low-space warnings before expensive work while deliberately keeping estimates advisory.)
  • Node refusal and recovery guidance keeps the original intent (3755040: Reject incompatible service Node before package staging while retaining the selected release and service-specific recovery instructions.)
  • Historical report presentation keeps the original intent (2558513: Lead with actionable explanations and distinguish saved recovery advice from current observations.)
  • Snapshot and activation-backup space checks keeps the original intent (8738c09: Use activation's backup-space calculation before staging without turning unknown measurements into refusals.)
  • Failure-triage settlement keeps the original intent (ce2985b: Preserve command cleanup and recovery ownership before handling or reporting update failures.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

PR surface

Source +277, Tests +200, Docs +27, Other 0. Total +504 across 35 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 18 3130 2853 +277
Tests 14 250 50 +200
Docs 1 27 0 +27
Config 0 0 0 0
Generated 0 0 0 0
Other 2 1 1 0
Total 35 3408 2904 +504

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.

Review metrics

Metric Value Why it matters
Stored and public diagnostic contract 1 optional cause enum; 0 SQL migrations The diagnostic extends existing origin_json and protocol schemas without rewriting older records.

Labels

Label changes:

  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: Earlier prerequisite refusals and clearer failure causes improve update reliability and recovery with limited scope.
  • merge-risk: 🚨 compatibility: Package updates gain a hard estimated disk floor and Git updates require Git 2.31; the maintainer-authored PR explicitly accepts the resulting warm-cache false refusals.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

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.

History

Review history (2 earlier review cycles)
  • reviewed 2026-11-13T19:32:00.880Z sha 9fd15aa :: blocked before merge. :: [P2] Preserve the cause enum through bounded origin serialization | [P2] Keep scoped and service-owned recovery instructions visible | [P2] Report an incompatible target when no supported Node can run it | [P2] Qualify saved refusal advice before promoting it to the headline
  • reviewed 2026-11-15T14:53:03.361Z sha e296aa6 :: needs changes before merge. :: [P2] Keep the service-definition step in early Node refusals | [P3] Separate snapshot diagnostics from the visible refusal block

Reviewed November 15, 2026, 10:12 AM ET / 15:12 UTC (Revision 3).

@obviyus
obviyus force-pushed the fix/update-prereq-preflight branch from be717cf to 8beaaa7 Compare November 15, 2026 13:47
@obviyus
obviyus changed the base branch from perf/update-remove-candidate-canary to main November 15, 2026 13:47
@obviyus

obviyus commented Nov 15, 2026

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label Nov 15, 2026
…napshot diagnostics out of the refusal block

Co-authored-by: obviyus <[email protected]>
@obviyus

obviyus commented Nov 15, 2026

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added 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. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Nov 15, 2026
@obviyus
obviyus merged commit 764761e into main Nov 15, 2026
156 checks passed
@obviyus
obviyus deleted the fix/update-prereq-preflight branch November 15, 2026 15:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: web-ui App: web-ui cli CLI command changes docs Improvements or additions to documentation gateway Gateway runtime merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. scripts Repository scripts size: XL 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