Skip to content

fix(cli): keep targeted config writes out of state migration - #120451

Merged
steipete merged 1 commit into
openclaw:mainfrom
SunnyShu0925:fix/config-patch-migration-120413
Aug 8, 2026
Merged

steipete merged 1 commit into
openclaw:mainfrom
SunnyShu0925:fix/config-patch-migration-120413

Conversation

@SunnyShu0925

@SunnyShu0925 SunnyShu0925 commented Aug 8, 2026 •

Copy link
Copy Markdown
Contributor

Closes #120413

What Problem This Solves

Fixes an issue where openclaw config set and openclaw config patch --stdin could run the startup Doctor/state-migration path before applying a targeted config change. That implicit whole-state repair could rewrite unrelated legacy cron data, including per-job model routing, during an otherwise narrow config update.

Why This Change Was Made

All config commands now opt out of startup state migration. Targeted writers still pass through the config guard and the existing full candidate/schema/plugin validation before writing; only unrelated state repair is removed from their startup envelope. Persistent migration remains owned by explicit openclaw doctor --fix and gateway startup.

This is the canonical owner-boundary fix rather than a cron-specific guard, a new flag, or a writer-side compatibility path. It also protects future targeted config subcommands from inheriting the same implicit-repair bug.

User Impact

config set and config patch now apply only the requested validated config change. They no longer emit Doctor/state-migration output or mutate legacy cron storage as a side effect. Operators who need legacy-state repair continue to use openclaw doctor --fix or normal gateway startup.

No config key, default, schema, protocol, flag, or output shape changes.

Evidence

Exact head: 9a50ce20ae6f2f16853a6ea4af376cdf0228be30

Sanitized AWS Crabbox proof used a fresh public-network lease with no instance profile, no Tailscale, no hydration, isolated HOME, pinned Node/pnpm, and exact-head verification.

  • Focused CLI tests: 447 tests passed across src/cli/argv.test.ts, src/cli/program/config-guard.test.ts, src/cli/program/preaction.test.ts, and src/cli/config-cli.test.ts.
  • Real CLI behavior: built the exact head, created an isolated config plus legacy cron/jobs.json, then ran both targeted writers. The cron file remained byte-identical after config patch --stdin and config set; neither command emitted Doctor/migration output. A subsequent doctor --fix --non-interactive migrated and archived the same legacy cron store.
{"head":"9a50ce20ae6f2f16853a6ea4af376cdf0228be30","patchCronHashPreserved":true,"setCronHashPreserved":true,"patchMigrationOutput":false,"setMigrationOutput":false,"doctorMigratedLegacyCron":true}
  • Gateway/Doctor sibling tests: 12 gateway startup recovery tests and 62 Doctor cron migration tests passed.
  • Structured autoreview: clean, no actionable findings.
  • Independent exact-head read-only review: no findings; judged the whole-config predicate the best fix and confirmed validation and migration-owner paths remain intact.
  • Hosted exact-head CI: affected CLI/config tests, build, types, guards, protocol, and dependency checks are green. The aggregate gate is red only from untouched base files: existing context/session expectation failures, two max-lines violations, and a worktree-migration timeout; the same failure cluster was present on the prior head.

Review metrics

  • Production: +1/-1 (net 0)
  • Tests: +12/-0
  • Config keys/defaults/schemas: 0 added / 0 changed / 0 removed
  • Gateway protocol surfaces: 0 changed
  • Observable migration-routing behavior: 2 commands changed (config set, config patch)
  • Generated/unrelated files: none

Compatibility note

This intentionally removes undocumented incidental migration from targeted config writes. Migration is deferred to its documented owners (doctor --fix and gateway startup), not deleted.

Human contributor credit is preserved in the commit for @SunnyShu0925; issue report by @jerabinovich.

@openclaw-barnacle openclaw-barnacle Bot added cli CLI command changes size: XS triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. labels Aug 8, 2026
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. labels Aug 8, 2026
@clawsweeper

clawsweeper Bot commented Aug 8, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 8, 2026, 6:37 AM ET / 10:37 UTC.

ClawSweeper review

What this changes

This PR stops all openclaw config commands from starting unrelated state migration while keeping targeted config validation and writes intact.

Regression provenance

Possible regression — probable (reproduction; reviewed change). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

No blocking findings. Current main and the latest release still run migration for targeted config writers, while this PR applies the shared CLI-boundary fix with sufficient isolated CLI proof; it should remain open pending normal merge handling.

Priority: P1
Reviewed head: 9a50ce20ae6f2f16853a6ea4af376cdf0228be30

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) Focused owner-boundary repair with exact-head CLI behavior proof and no actionable review finding.
Proof confidence 🦞 diamond lobster (5/6) ✨ media proof bonus Sufficient (linked_artifact): The PR body provides exact-head isolated CLI evidence that both targeted writers preserve legacy cron bytes and explicit Doctor repair still migrates the store.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (linked_artifact): The PR body provides exact-head isolated CLI evidence that both targeted writers preserve legacy cron bytes and explicit Doctor repair still migrates the store.
Evidence reviewed 7 items Shared migration boundary: The PR changes the common path predicate so every top-level config command skips startup state migration.
Validation remains in place: The config guard continues through normal config snapshot and validation when migration is skipped; only Doctor preflight is bypassed.
Current main still has the bug: Current main excludes only config get and unset, so config set and config patch still enter the migration path.
Findings None None.
Security None None.

How this fits together

CLI pre-action derives a command path and decides whether startup Doctor migration runs before the command handler. Config writers then validate and persist configuration; Doctor and gateway startup remain the explicit owners of persistent-state repair.

flowchart LR
  A[Operator config command] --> B[CLI command-path parsing]
  B --> C{Run startup migration?}
  C -->|Config command| D[Validate and write config]
  C -->|Other startup path| E[Doctor migration preflight]
  D --> F[Requested config update]
  E --> G[Repaired legacy state]
Loading

Before merge

  • Resolve merge risk (P1) - This intentionally removes undocumented incidental state repair from targeted config commands; operators who need legacy-state migration must use openclaw doctor --fix or gateway startup.
  • Complete next step (P2) - The linked open implementation PR already owns this bounded repair; no separate ClawSweeper fix lane is appropriate.
Agent review details

Security

None.

PR surface

Source 0, Tests +12. Total +12 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 1 1 1 0
Tests 2 12 0 +12
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 13 1 +12

Review metrics

Metric Value Why it matters
Production versus test delta production +1/-1; tests +12/-0 The net-neutral production change moves migration policy at one shared boundary and adds coverage for both formerly affected writers.
Config contract surface 0 keys, defaults, schemas, flags, or protocol parameters changed The compatibility change is limited to startup migration routing rather than the public config shape.

Stored data model

Persistent data-model change detected: migration/backfill/repair: src/cli/program/config-guard.test.ts. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #120413
Summary: This PR is the open candidate fix for the canonical targeted-config-write migration defect.

Members:

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

Merge-risk options

Maintainer options:

  1. Accept explicit migration ownership (recommended)
    Merge the documented behavior change: targeted config writes stay validated but legacy-state repair runs only through Doctor or gateway startup.

Technical review

Best possible solution:

Merge the shared command-path exclusion so targeted writes remain narrow and validated while explicit Doctor and gateway startup retain migration ownership.

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

Yes—current-main source shows config set and config patch reach Doctor migration through the shared predicate, and the PR supplies an exact-head isolated CLI after-fix transcript.

Is this the best way to solve the issue?

Yes—the shared command-path predicate is the best fix because per-writer or cron-specific guards would miss sibling and future config commands, while writer-level changes occur after startup migration.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 6ae7a8684aba.

Labels

Label justifications:

  • P1: The PR addresses silent mutation of unrelated legacy cron routing during ordinary targeted config updates.
  • merge-risk: 🚨 compatibility: Existing workflows may have relied on incidental migration during config commands, which this change intentionally moves to explicit owners.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (linked_artifact): The PR body provides exact-head isolated CLI evidence that both targeted writers preserve legacy cron bytes and explicit Doctor repair still migrates the store.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body provides exact-head isolated CLI evidence that both targeted writers preserve legacy cron bytes and explicit Doctor repair still migrates the store.

Evidence

What I checked:

  • Shared migration boundary: The PR changes the common path predicate so every top-level config command skips startup state migration. (src/cli/argv.ts:628, 9a50ce20ae6f)
  • Validation remains in place: The config guard continues through normal config snapshot and validation when migration is skipped; only Doctor preflight is bypassed. (src/cli/program/config-guard.ts:236, 9a50ce20ae6f)
  • Current main still has the bug: Current main excludes only config get and unset, so config set and config patch still enter the migration path. (src/cli/argv.ts:628, 6ae7a8684aba)
  • Migration can alter legacy cron state: Doctor preflight invokes legacy cron repair when migration is enabled, matching the linked report’s owner boundary. (src/commands/doctor-config-preflight.ts:484, 6ae7a8684aba)
  • Predicate provenance: Blame attributes the prior get/unset-only predicate to the recent CLI policy change; the repair updates that same boundary. (src/cli/argv.ts:628, cd53ac012d1d)
  • Real behavior proof: The PR body links an exact-head isolated CLI run where config patch and config set preserve legacy cron bytes and emit no migration output, followed by successful explicit Doctor migration. (9a50ce20ae6f)

Likely related people:

  • steipete: Authored the current repair and is the strongest history signal across the CLI predicate, config guard, and Doctor preflight. (role: recent area contributor; confidence: high; commits: cd53ac012d1d, 9a50ce20ae6f; files: src/cli/argv.ts, src/cli/program/config-guard.ts, src/commands/doctor-config-preflight.ts)
  • metaforismo: Recent history includes related read-only startup-migration policy work in the command-path area. (role: adjacent policy contributor; confidence: medium; commits: 0388d009; files: src/cli/argv.ts)
  • VincentKoc: Recent config-guard history connects this person to the startup validation boundary that consumes the predicate. (role: recent config-guard contributor; confidence: medium; commits: 953db045; files: src/cli/program/config-guard.ts)

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 (4 earlier review cycles)
  • reviewed 2026-08-08T03:35:41.193Z sha a059e3e656c836ce8e3171b5959058fe247164dd :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-08T04:44:30.717Z sha 8d7ef71f1b9a0b438056fc5d596cbdeb3b049297 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-08T05:39:57.801Z sha 2fa84e1196fffc6935e25fec955a1873cac28f4a :: needs maintainer review before merge. :: none
  • reviewed 2026-08-08T06:45:21.157Z sha 5f95bbb5be931b47ba1da832fde4a7520a5616f1 :: needs maintainer review before merge. :: none

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: S and removed triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. size: XS labels Aug 8, 2026
@openclaw-barnacle openclaw-barnacle Bot closed this Aug 8, 2026
@openclaw-barnacle openclaw-barnacle Bot reopened this Aug 8, 2026
@SunnyShu0925
SunnyShu0925 force-pushed the fix/config-patch-migration-120413 branch from f31e89e to 8d7ef71 Compare August 8, 2026 04:37
@openclaw-barnacle openclaw-barnacle Bot added size: XS and removed gateway Gateway runtime size: S labels Aug 8, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. 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: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. labels Aug 8, 2026
@SunnyShu0925
SunnyShu0925 force-pushed the fix/config-patch-migration-120413 branch 2 times, most recently from be6cffe to 2fa84e1 Compare August 8, 2026 05:14
@openclaw-barnacle openclaw-barnacle Bot added the docs Improvements or additions to documentation label Aug 8, 2026
@SunnyShu0925
SunnyShu0925 force-pushed the fix/config-patch-migration-120413 branch from 2fa84e1 to 5f95bbb Compare August 8, 2026 06:18
@clawsweeper clawsweeper Bot added rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Aug 8, 2026
@steipete
steipete force-pushed the fix/config-patch-migration-120413 branch from 5f95bbb to 9a50ce2 Compare August 8, 2026 08:09
@openclaw-barnacle openclaw-barnacle Bot removed the docs Improvements or additions to documentation label Aug 8, 2026
@steipete

steipete commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Maintainer repair sweep updated this PR to exact head 9a50ce20ae6f2f16853a6ea4af376cdf0228be30.

The branch now contains only the canonical owner-boundary repair: all config commands skip unrelated startup state migration while targeted writers retain config/schema/plugin validation. The unrelated generated plugin-SDK baseline change was removed, and @SunnyShu0925 is preserved as co-author.

Proof on the exact head:

Hosted CI run https://github.com/openclaw/openclaw/actions/runs/31247778098 has the affected CLI/config lanes, build, types, guards, protocol, and dependency checks green. The aggregate gate is red only from untouched base-file failures already present on the previous head: context/session expectations, max-lines violations, and a worktree-migration timeout.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 8, 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 repository_dispatch).
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

steipete commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

@clawsweeper re-review

Targeted config writes retain validation while Doctor and the gateway own state migration.

Fixes openclaw#120413

Co-authored-by: SunnyShu <[email protected]>
@steipete
steipete force-pushed the fix/config-patch-migration-120413 branch from 9a50ce2 to 02c6ddb Compare August 8, 2026 15:44
@steipete

steipete commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Command router queued. I will update this comment with the next step.

@steipete
steipete merged commit 1beb963 into openclaw:main Aug 8, 2026
119 checks passed
@steipete

steipete commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Post-merge landing proof

Recorded after merge because the concurrent native landing completed before this phase could post the pre-merge land-ready note.

  • Exact source head: 02c6ddb1654df50909c86356d33c5936345cd813
  • Focused proof: node scripts/run-vitest.mjs src/cli/argv.test.ts src/cli/program/config-guard.test.ts src/cli/program/preaction.test.ts passed 262 tests across two shards (142 + 120).
  • Exact-head CI: CI run 31265207725 passed; Workflow Sanity run 31265207693 passed.
  • Native prepare passed at 2026-08-08T16:11:59Z in hosted_exact_or_recent_parent mode. Exact-head hosted checks satisfied the gate, so no Testbox provider, lease, or run was needed.
  • Fresh Codex autoreview was clean with no accepted or actionable findings.
  • The rebase preserved the patch byte-for-byte: SHA-256 3479b21e98dc5973b016d643897c7a7f9a14d2436db30443450e9867e6b3e23c before and after.
  • ClawSweeper exact-head generation 31265274649 succeeded, but durable exact-head publication remained stale: no final exact-head findings or Rank-up moves: list was published. The prior patch-identical durable review rated the change diamond lobster, marked proof sufficient, and reported no code findings.
  • Landed commit: 1beb96378dba936b9e3e66128a4dc39ac3699444

steipete added a commit that referenced this pull request Aug 8, 2026
* refactor(cli): inline state migration policy

Remove the single-use exported helper so migration policy now lives at ensureConfigReady, its lifecycle owner. Move duplicate argv and preaction coverage into the lifecycle-owner test table while preserving behavior. This follows #120451.

* refactor(cli): preserve gateway migration rationale

Keep the ownership invariant beside the inlined gateway-call exception.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 9, 2026
Targeted config writes retain validation while Doctor and the gateway own state migration.

Fixes openclaw#120413

Co-authored-by: Peter Steinberger <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 9, 2026
* refactor(cli): inline state migration policy

Remove the single-use exported helper so migration policy now lives at ensureConfigReady, its lifecycle owner. Move duplicate argv and preaction coverage into the lifecycle-owner test table while preserving behavior. This follows openclaw#120451.

* refactor(cli): preserve gateway migration rationale

Keep the ownership invariant beside the inlined gateway-call exception.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: XS 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.

[Bug]: config patch --stdin triggers implicit doctor/migration pass that silently mutates unrelated config (cron model overrides lost)

2 participants