Skip to content

fix(cli): tell operators a racing config set changed nothing - #127554

Merged
steipete merged 1 commit into
mainfrom
steipete/config-set-conflict-next-step
Aug 21, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/config-set-conflict-next-step

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

When two openclaw config set calls race, the loser fails with a bare, unactionable line. This is
the entire stderr output, exit 1:

config changed since last load

The operator is not told that nothing was written, that the failure is transient, or that re-running
resolves it.

Reproduced on the real dist CLI with an isolated HOME and OPENCLAW_CONFIG_PATH — six concurrent
openclaw config set skills.entries.probe-N.enabled true against one config file:

w1 exit=1 :: config changed since last load
w2 exit=0 :: Updated skills.entries.probe-2.enabled. No gateway restart needed.
w3 exit=1 :: config changed since last load
w4 exit=1 :: config changed since last load
w5 exit=1 :: config changed since last load
w6 exit=1 :: config changed since last load

resulting keys: ['probe-2']  (1 of 6)

Why This Change Was Made

The concurrency control is correct and is not touched here: exactly one writer won, five failed
loudly, and no update was silently lost. Only the operator-facing message was the defect.

The gateway path already gets the wording right. src/gateway/server-methods/config.ts:139 throws
"config changed since last load; re-run config.get and retry". The local CLI path does not —
src/config/mutate.ts:187 and src/config/io.write-safety.ts:43 throw the bare
ConfigMutationConflictError("config changed since last load"), which the CLI surfaces verbatim.

It was also the odd one out among its immediate neighbours, all of which name a next step:

  • config unset <missing> → "Config path not found: X. Nothing was changed. Run
    openclaw config get <path> first if you are unsure of the path."
  • config set <bad value> → "Config validation failed: gateway.port: Invalid input: expected
    number, received string"
  • config get → names either the unset path or openclaw config schema (fix(cli): tell config get apart a typo from an unset key #127369)

The retry loop deliberately cannot rescue this caller, so retrying harder was not the fix.
transformConfigFileWithRetry (src/config/mutate.ts:1163) retries up to five times, but every
attempt re-checks the caller-supplied params.baseHash (mutate.ts:1111), and
src/cli/config-cli.ts:310 pins baseHash: snapshot.hash. That pin is the point of optimistic
concurrency — apply only if the file is still what I read. The right fix is to explain the outcome,
not to weaken the precondition.

User Impact

The config file changed while this command was writing (config changed since last load), so nothing
was changed. Re-run the same command to pick up the new file and try again.

The parenthesised detail preserves the underlying variant, so the included config changed since last load cases (mutate.ts:681/696/708/720) stay distinguishable — those name a different file.

config set --dry-run --json now reports kind: "conflict" for this failure. It previously
mislabelled a concurrency conflict as kind: "schema", which is wrong for a scripted consumer
deciding whether to retry: a schema error never succeeds on retry, a conflict usually does. The
ConfigSetDryRunError union gains conflict; the addition is additive and docs/cli/config.md is
updated to enumerate every kind (it previously listed only three of the four that already existed,
omitting model).

Exit code stays 1. baseHash pinning, the retry loop, and every throw site outside the CLI boundary
are unchanged.

Evidence

Production +8/-3 (net +5), docs +1/-1, tests +48/-0.

node scripts/run-vitest.mjs src/cli/config-cli.test.ts

  • Before the fix: 196 passed, the 2 new cases failed as intended.
  • After: 198/198 passed.

New coverage: the conflict surfaced through the text path produces the new message and exit 1; the
same through --dry-run --json produces kind: "conflict"; the included config changed detail is
preserved; and non-conflict errors are unchanged.

Re-ran the six-way race against a freshly built dist: one writer succeeded, five exited 1 with the
new message, and re-running a loser then succeeded with config get returning true — confirming
the advice the message now gives is actually correct.

node scripts/check-changed.mjs -- src/cli/config-cli-runner.ts src/cli/config-set-dryrun.ts src/cli/config-cli.test.ts
passed on Blacksmith Testbox tbx_01m0k034p25jy2yc9jaxgstwg3. pnpm build passed.
$autoreview --mode uncommitted clean, no accepted or actionable findings. oxfmt --check clean.

When two config writes raced, the loser printed a bare "config changed
since last load" and exited 1 — no statement that its write was abandoned
and no hint that re-running works. The gateway sibling already says
"re-run config.get and retry".

Format ConfigMutationConflictError at handleConfigMutationError, the single
CLI boundary, so the low-level throw sites keep serving gateway and
programmatic callers unchanged. Dry-run JSON now reports kind "conflict"
instead of mislabelling a concurrency conflict as a schema error.

Concurrency control itself is unchanged: baseHash pinning and the retry
loop stay exactly as they were.
@clawsweeper

clawsweeper Bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@steipete
steipete marked this pull request as ready for review August 21, 2026 20:58
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation cli CLI command changes size: S maintainer Maintainer-authored PR labels Aug 21, 2026
@clawsweeper clawsweeper Bot added 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: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 21, 2026
@clawsweeper

clawsweeper Bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Codex review: found issues before merge. Reviewed August 21, 2026, 5:04 PM ET / 21:04 UTC.

ClawSweeper review

What this changes

The PR makes openclaw config set explain optimistic-concurrency conflicts in text output and classify them as conflict in dry-run JSON.

Merge readiness

⚠️ Needs maintainer review before merge - 2 items remain

Keep open. The common write-race guidance is well scoped, but the new formatter incorrectly tells operators to retry conflicts explicitly marked non-retryable.

Priority: P2
Reviewed head: 70033ac17d45c1e7a135ef05934c741a6106e959

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The common race has credible proof, but one contract-aligned correction is required before merge.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The PR body reports an after-fix isolated real-dist six-writer race with observed loser messages and successful reruns; the remaining issue is a separate permanent-conflict case.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The PR body reports an after-fix isolated real-dist six-writer race with observed loser messages and successful reruns; the remaining issue is a separate permanent-conflict case.
Evidence reviewed 6 items Changed CLI boundary: The PR formats every ConfigMutationConflictError as a file race and always instructs the operator to rerun.
Conflict contract: The shared error type supports explicitly non-retryable conflicts through its retryable flag.
Sibling behavior: Gateway config writes append retry advice only for retryable conflicts and name path ownership as a non-retryable case.
Findings 1 actionable finding [P2] Honor non-retryable conflict errors
Security None None.

Live Verification

Command: node scripts/run-vitest.mjs src/cli/config-cli.test.ts

Result: FAIL (partial) — step 2 expect_output config cli: expected terminal output was not visible within 30 seconds: "config cli"

node scripts/run-vitest.mjs src/cli/config-cli.test.ts
runner@runnervm76f27:/tmp/clawsweeper-live-proof-127554-qmqg7Y/target$ node scripts/run-vitest.mjs src/cli/config-cli.test.ts
node scripts/run-vitest.mjs src/cli/config-cli.test.ts
[test] starting test/vitest/vitest.cli.config.ts

 RUN  v4.1.10 /tmp/clawsweeper-live-proof-127554-qmqg7Y/target

error: unknown option '--provider-allow-insecure-path'
error: unknown option '--provider-allow-symlink-command'
 ✓  cli  src/cli/config-cli.test.ts (198 tests) 4185ms
       ✓ prints the generated JSON schema as plain text  395ms

 Test Files  1 passed (1)
      Tests  198 passed (198)
   Start at  21:05:11
   Duration  6.07s (transform 4.13s, setup 1.06s, import 445ms, tests 4.19s, environment 0ms)

[test] passed 1 Vitest shard in 12.10s
runner@runnervm76f27:/tmp/clawsweeper-live-proof-127554-qmqg7Y/target$ node scripts/run-vitest.mjs src/cli/config-cli.test.ts
[test] starting test/vitest/vitest.cli.config.ts

 RUN  v4.1.10 /tmp/clawsweeper-live-proof-127554-qmqg7Y/target

error: unknown option '--provider-allow-insecure-path'
error: unknown option '--provider-allow-symlink-command'
 ✓  cli  src/cli/config-cli.test.ts (198 tests) 2281ms
       ✓ prints the generated JSON schema as plain text  301ms

 Test Files  1 passed (1)
      Tests  198 passed (198)
   Start at  21:05:23
   Duration  3.14s (transform 1.26s, setup 456ms, import 152ms, tests 2.28s, environment 0ms)

[test] passed 1 Vitest shard in 9.16s
runner@runnervm76f27:/tmp/clawsweeper-live-proof-127554-qmqg7Y/target$
















Assertions:

  • FAIL expect_output: config cli

How this fits together

The Config CLI conditionally rewrites the operator’s configuration file. Its mutation boundary turns write-owner failures into terminal and JSON output while preserving optimistic concurrency safeguards.

flowchart LR
  A[Operator config command] --> B[Config CLI]
  B --> C[Conditional config write]
  C --> D{Write outcome}
  D -->|Committed| E[Success output]
  D -->|Retryable race| F[Conflict guidance]
  D -->|Permanent conflict| G[Specific error]
  F --> H[Text or JSON result]
  G --> H
Loading

Before merge

  • Honor non-retryable conflict errors (P2) - ConfigMutationConflictError deliberately carries retryable: false for path and ownership conflicts, and Gateway config writes only append retry advice when it is true. This change tells operators every conflict was a file race and to rerun, so permanent conflicts receive incorrect recovery guidance. Preserve detail for non-retryable errors and add coverage for that case.
  • Resolve merge risk (P1) - The documented dry-run JSON error union gains conflict; scripted consumers need an accurate retry signal, including for non-retryable conflicts.

Findings

  • [P2] Honor non-retryable conflict errors — src/cli/config-cli-runner.ts:519-521
Agent review details

Security

None.

PR surface

Source +5, Tests +48, Docs 0. Total +53 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 2 8 3 +5
Tests 1 48 0 +48
Docs 1 1 1 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 57 4 +53

Review metrics

Metric Value Why it matters
Production versus test delta production +6 net, tests +48 The production growth changes public failure semantics, so both retryable and permanent conflicts need regression coverage.
Dry-run JSON contract 1 error kind added: conflict Automation consuming errors[].kind receives a new documented value.

Merge-risk options

Maintainer options:

  1. Honor the retry contract (recommended)
    Gate the file-race wording and rerun instruction on error.retryable, then test a non-retryable path conflict.
  2. Accept universal retry guidance
    Merge unchanged only if maintainers intentionally want ownership and path conflicts presented as retryable.
Copy recommended automerge instruction
@clawsweeper automerge

Special instructions:
Preserve raw non-retryable conflict detail and add focused text and dry-run JSON coverage for both retryable and non-retryable conflicts.

Technical review

Best possible solution:

Keep conflict as the JSON kind, but retain the underlying detail without retry advice when retryable is false and cover both conflict classes.

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

Yes. Inject a ConfigMutationConflictError with retryable: false at the CLI mutation boundary; the changed formatter claims a file race and recommends retrying despite the contract.

Is this the best way to solve the issue?

No. Applying retryable race guidance to every typed conflict conflicts with the shared error contract and the Gateway sibling implementation.

Full review comments:

  • [P2] Honor non-retryable conflict errors — src/cli/config-cli-runner.ts:519-521
    ConfigMutationConflictError deliberately carries retryable: false for path and ownership conflicts, and Gateway config writes only append retry advice when it is true. This change tells operators every conflict was a file race and to rerun, so permanent conflicts receive incorrect recovery guidance. Preserve detail for non-retryable errors and add coverage for that case.
    Confidence: 0.96

Overall correctness: patch is incorrect
Overall confidence: 0.96

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 5b67b61964b9.

Labels

Label changes:

  • add P2: A bounded CLI failure path can give incorrect recovery guidance for permanent conflicts.
  • add merge-risk: 🚨 compatibility: The PR changes the documented JSON error-kind union used by command-line automation.
  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR body reports an after-fix isolated real-dist six-writer race with observed loser messages and successful reruns; the remaining issue is a separate permanent-conflict case.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🐚 platinum hermit and patch quality is 🦐 gold shrimp.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Sufficient (live_output): The PR body reports an after-fix isolated real-dist six-writer race with observed loser messages and successful reruns; the remaining issue is a separate permanent-conflict case.

Label justifications:

  • P2: A bounded CLI failure path can give incorrect recovery guidance for permanent conflicts.
  • merge-risk: 🚨 compatibility: The PR changes the documented JSON error-kind union used by command-line automation.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🐚 platinum hermit and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Sufficient (live_output): The PR body reports an after-fix isolated real-dist six-writer race with observed loser messages and successful reruns; the remaining issue is a separate permanent-conflict case.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body reports an after-fix isolated real-dist six-writer race with observed loser messages and successful reruns; the remaining issue is a separate permanent-conflict case.

Evidence

What I checked:

Likely related people:

  • Ayaan Zaidi: Current-main blame attributes the shared CLI mutation-error boundary to this contributor. (role: recent area contributor; confidence: medium; commits: 43c54af3ea90; files: src/cli/config-cli-runner.ts)
  • steipete: Previously merged config-CLI diagnostic work is directly adjacent to this operator-guidance surface. (role: recent adjacent contributor; confidence: medium; commits: 98c02e0112bf; files: src/cli/config-cli.test.ts, src/cli/config-cli-path.ts)

Rank-up moves

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

  • Apply retry guidance only when error.retryable is true and cover a permanent path conflict.
  • Rerun the focused CLI test after the correction.

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.

@steipete
steipete merged commit 69e4fbb into main Aug 21, 2026
302 of 309 checks passed
@steipete
steipete deleted the steipete/config-set-conflict-next-step branch August 21, 2026 21:33
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 22, 2026
…w#127554)

When two config writes raced, the loser printed a bare "config changed
since last load" and exited 1 — no statement that its write was abandoned
and no hint that re-running works. The gateway sibling already says
"re-run config.get and retry".

Format ConfigMutationConflictError at handleConfigMutationError, the single
CLI boundary, so the low-level throw sites keep serving gateway and
programmatic callers unchanged. Dry-run JSON now reports kind "conflict"
instead of mislabelling a concurrency conflict as a schema error.

Concurrency control itself is unchanged: baseHash pinning and the retry
loop stay exactly as they were.
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 maintainer Maintainer-authored PR 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: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: S status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant