Skip to content

fix(update): keep malformed-config previews free of state, cache and scratch artifacts - #187498

Merged
steipete merged 1 commit into
mainfrom
upd/upd-l1963
Oct 29, 2026
Merged

steipete merged 1 commit into
mainfrom
upd/upd-l1963

Conversation

@steipete

@steipete steipete commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes #187431. Malformed-config update previews returned the right refusal plan but still inspected SQLite and created report, support, cache, and scratch artifacts. Thanks @shakkernerd for the reproduction and follow-up to #187367.

User Impact

Text and JSON preview plans now leave the complete profile, cache, and scratch trees unchanged when authored config cannot be parsed. Actual-update refusal reporting and readable-config failure diagnostics retain their existing behavior. No configuration or migration changes are required; the installed CLI must contain this fix.

Why This Change Was Made

The preview path read persisted plugin-migration facts and update history while database-engine selection remained unresolved, then the text renderer published a normal update report. Both reads now consume the engine owner's scoped selection. Preview rendering reuses its captured run facts, and the result owner does not publish artifacts for a prepared dry-run result. Unexpected command failures retain their diagnostic reports.

The existing built-CLI process regression covers text/JSON previews with absent/native-initialized databases, compares the full profile/cache/scratch trees, rejects report/support artifacts, and observes file-backed SQL diagnostics. The legacy-config case keeps its original contract. Production: +28/-15 (net +13); tests: +60/-21 (net +39). The separate exact 39-line allocation pays for those four real-process boundary cases; the shared scalar is unchanged.

Evidence

  • Pre-fix built CLI: the expanded regression fails in 3/4 cases on both Node and Bun. Text creates report artifacts; native-database JSON adds cache/openclaw and tmp/openclaw.
  • Full process file: 23/23 pass on Node 26.12.1 and the pinned Bun fork. Final prepared-preview cases are also rerun against the final source.
  • Real built Node CLI with isolated HOME, state, XDG cache, and TMPDIR: native-database text and JSON previews exit 0, preserve the complete tree, and emit no observed filesystem writes. An actual malformed-config update still exits 1 with invalid-config and saves its refusal report.
  • Core and CLI-update test tsgo, touched-file oxlint/oxfmt, Madge (0 cycles), max-lines/env budget, test-line allocation ratchet, line-cap ratchet, and diff checks pass. Full check:changed SQLite inventory is omitted under the campaign's local gate budget; PR CI owns broad proof.
  • Independent autoreview could not start: its isolation requires temporary storage outside the checkout, conflicting with this lane's worktree-only scratch boundary. No clean-review claim; lead review of the PR head remains required.

Process-file timing: Node 66.05 s wall / 40.844 s tests; Bun 32.11 s wall / 27.716 s tests; longest individual test 6.81 s. Wrapper totals include runtime/compiled-worker preparation (139.27 s and 102.93 s). Real CLI startup is required to catch engine selection, filesystem artifacts, and launcher behavior that helper mocks missed. On final source the four affected cases pass again on each runtime (Node 32.35 s wall, Bun 9.07 s wall). The existing 24-case metadata-diagnostic suite passes after narrowing publication suppression to prepared preview results; a recovery run invalidated by that source edit was rerun successfully on the final source (34/34).

All 34 direct/one-module consumer files found from the changed production basenames ran locally in discovery order. After the targeted correction and reruns: 31 files pass, with 689 passing cases and 6 remaining failures across 3 files. Remaining local gaps are reported rather than claimed green:

Consumer Remaining result and diagnosis
src/plugins/post-core-dependency-health.integration.test.ts 4 transactional-payload cases fail because fs-safe rejects the checkout volume ancestor's group-writable 0775 mode without sticky protection. Volume permissions and dependency policy were left intact.
src/cli/update-cli/update-command-migrated.test.ts 1 legacy foreground case expects the completion-capability refusal but receives an inspection refusal. The fixture writes CommonJS require into .js beneath the mandated worktree scratch root, inheriting the repository's type: module. A standalone reproduction confirms that module-type failure. The other 28 cases pass.
src/cli/update-cli/update-command-post-update.test.ts 1 stale-session-receipt case expects retained_plugin_receipt_superseded but receives redacted Doctor warning text. Transcript preservation and restart assertions preceding it pass; 93 other cases pass. This unchanged owner path mocks the result renderer. A separate-base replay was not performed, so this remains a recorded validation gap.

Existing slow-suite evidence: update-command-original-service.test.ts passes all 48 cases in 241.19 s wrapper wall / 232.918 s test time (longest case 13.65 s). Its existing matrix creates fresh real state and two installation roots per case, seeds and closes native databases, and performs recovery inspections. Recorded under the campaign's pre-existing slow-suite exception. The rollback suite passes all 45 cases with 104.564 s test time (longest 3.867 s).

Source base: 00125bb5bbc0bb8e9fb91ee39e6420132041b90e. Submitted head: 25cbe4ffb79bc48c01b2b8a5338e44f87cd74226.

Commands used for the focused process proof:

OPENCLAW_VITEST_RUNTIME=node node scripts/run-vitest.mjs src/cli/update-dry-run-state.process.test.ts --maxWorkers=1
OPENCLAW_VITEST_RUNTIME=bun node scripts/run-vitest.mjs src/cli/update-dry-run-state.process.test.ts --maxWorkers=1
# Final-source replay of the affected cases, once per runtime:
OPENCLAW_VITEST_RUNTIME=node node scripts/run-vitest.mjs src/cli/update-dry-run-state.process.test.ts --maxWorkers=1 -t 'malformed previews'
OPENCLAW_VITEST_RUNTIME=bun node scripts/run-vitest.mjs src/cli/update-dry-run-state.process.test.ts --maxWorkers=1 -t 'malformed previews'

The live native-database fixture used isolated HOME, OPENCLAW_HOME, OPENCLAW_CONFIG_PATH, OPENCLAW_STATE_DIR, XDG_CACHE_HOME, and TMPDIR under .artifacts/native, with OPENCLAW_NO_RESPAWN=1 and NODE_DISABLE_COMPILE_CACHE=1. Exact CLI invocations (the local preload records recursive fs.watch events):

node --import "$PWD/.artifacts/native-watch.mjs" openclaw.mjs update --dry-run --no-restart --timeout 1
node --import "$PWD/.artifacts/native-watch.mjs" openclaw.mjs update --dry-run --no-restart --timeout 1 --json
node openclaw.mjs update --no-restart --timeout 1

Preview outcomes: exit=0, tree_unchanged=true, filesystem_events=[], refusal_guidance=true in both output modes. Actual-update control: exit=1, invalid-config, saved Markdown report and Doctor recovery guidance.

…scratch artifacts

Skip persisted migration facts and history while a preview has no selected
config-driven database engine. Render prepared preview results without
publishing reports or support bundles; preserve actual refusal and unexpected
failure diagnostics. Extend the built-CLI process regression across text/JSON
and absent/native databases, including full cache and scratch tree snapshots.

Fixes #187431. Thanks @shakkernerd.
@clawsweeper

clawsweeper Bot commented Oct 29, 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 cli CLI command changes size: S labels Oct 29, 2026
@steipete
steipete marked this pull request as ready for review October 29, 2026 08:24
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-29T08:27:02.062885Z 25cbe4f 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. P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. 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. labels Oct 29, 2026
@clawsweeper

clawsweeper Bot commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR prevents malformed-config update previews from inspecting databases or creating report, support, cache, and scratch artifacts.

Example: Run openclaw update --dry-run --no-restart --timeout 1 with configuration containing { definitely-not-json.

  • Before: The preview exits 0 but creates update reports and, with an initialized database, cache and scratch directories.
  • After: The preview retains its refusal guidance and exit 0 while leaving the captured profile, cache, and scratch trees unchanged.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) A focused, useful patch with credible shipped-CLI evidence and no actionable defects; the required stable-upgrade scenario remains unshown.
Proof confidence 🦐 gold shrimp (3/6) Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: A preview promises no changes but creates diagnostic, cache, and scratch artifacts when configuration cannot be parsed.
Reason: The change restores the read-only preview contract, and its maintainer-authored direction is already established.

Merge readiness

✅ Ready for maintainer review

Keep open: this maintainer-authored PR repairs a confirmed preview side effect still present on main; no introduced correctness or security defects were found.

Priority: P2
Reviewed head: 25cbe4ffb79bc48c01b2b8a5338e44f87cd74226

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: The supplied evidence does not show an upgrade from v2026.10.8 followed by the changed preview flow with existing settings and data preserved.
Agent review details

How this fits together

The update CLI reads authored configuration, resolves update admission and target facts, and renders either a preview or an actual update result with diagnostic artifacts.

flowchart TD
  A[Update CLI] --> B[Authored configuration]
  B --> C[Scoped engine selection]
  C --> D[Target and admission facts]
  D --> E[Preview renderer]
  D --> F[Actual update result]
  E --> G[Console output]
  F --> H[Reports and support artifacts]
Loading

Technical review

Best possible solution:

Keep the focused repair in the existing engine-selection and result owners while preserving actual-update refusal diagnostics.

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

The linked report gives concrete built-CLI reproductions, and current-main source confirms the unresolved-engine reads and unconditional report publication; no target code was executed during this review.

Is this the best way to solve the issue?

The patch fixes the causes at their existing owners, preserves real-failure reporting, and adds meaningful process coverage without new state or parallel machinery.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Persisted plugin-migration facts keeps the original intent (20bd4bd: Update preparation carries deferred plugin migration facts explicitly while ordinary config reads avoid database queries.)
  • Preview history and captured rendering facts changes intended behavior with a stated reason (abc4188: Private update helpers were consolidated without changing command behavior; this PR explains why unreadable-source previews cannot safely reopen history.)
  • Terminal report publication changes intended behavior with a stated reason (1e48d0c: Actual update outcomes and Doctor diagnostics must retain saved terminal reports; this PR narrowly excludes prepared preview results and preserves unexpected-failure reporting.)
  • Malformed and legacy preview regression coverage keeps the original intent (f533fef: Malformed previews must return best-effort plans without changing existing state, while legacy-config previews retain their original behavior.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit abc4188 adds src/cli/update-cli/update-command-schema.ts:173 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: abc41881fa42; files: src/cli/update-cli/update-command-schema.ts)
  • Jason (Json): Raw commit 8af7f3e adds src/cli/update-cli/progress.ts:273 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 8af7f3e640b7; files: src/cli/update-cli/progress.ts)
  • Vincent Koc: Raw commit 931de9e adds src/cli/update-cli/progress.ts:284 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 931de9e55a35; files: src/cli/update-cli/progress.ts)

PR surface

Source +13, Tests +39, Docs +2, Other +3. Total +57 across 7 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 4 28 15 +13
Tests 1 60 21 +39
Docs 1 2 0 +2
Config 0 0 0 0
Generated 0 0 0 0
Other 1 3 0 +3
Total 7 93 36 +57

Review metrics

Metric Value Why it matters
Production versus regression coverage Production +28/-15; tests +60/-21 The modest production growth reuses existing owners, and the test growth covers distinct text/JSON and absent/initialized-database failures through the built CLI.

Labels

Label changes:

  • add P2: The defect violates an advanced CLI preview contract by creating artifacts, while canonical configuration and database bytes remain intact.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P2: The defect violates an advanced CLI preview contract by creating artifacts, while canonical configuration and database bytes remain intact.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

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 October 29, 2026, 4:41 AM ET / 08:41 UTC.

@steipete
steipete merged commit 2df9f69 into main Oct 29, 2026
223 of 225 checks passed
@steipete
steipete deleted the upd/upd-l1963 branch October 29, 2026 08:48
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 30, 2026
…scratch artifacts (openclaw#187498)

Update previews with unparseable config no longer read plugin-migration facts or update history while the database engine is unresolved, and prepared dry-run results no longer publish update reports or support bundles. Text and JSON previews leave the profile, cache and scratch trees unchanged; real malformed-config updates still refuse with invalid-config and save their report.

Fixes openclaw#187431 (follow-up to openclaw#187367). Thanks @shakkernerd for the report.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes docs Improvements or additions to documentation P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. 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.

fix: malformed update previews create state and scratch artifacts

1 participant