Repository navigation
fix(cli): tell operators a racing config set changed nothing - #127554
Conversation
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.
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: found issues before merge. Reviewed August 21, 2026, 5:04 PM ET / 21:04 UTC. ClawSweeper reviewWhat this changesThe PR makes Merge readinessKeep 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 Review scores
Verification
Live VerificationCommand: Result: FAIL (partial) — step 2 Assertions:
How this fits togetherThe 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
Before merge
Findings
Agent review detailsSecurityNone. PR surfaceSource +5, Tests +48, Docs 0. Total +53 across 4 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Copy recommended automerge instructionTechnical reviewBest possible solution: Keep Do we have a high-confidence way to reproduce the issue? Yes. Inject a 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:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 5b67b61964b9. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Merged via squash.
|
…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.
What Problem This Solves
When two
openclaw config setcalls race, the loser fails with a bare, unactionable line. This isthe entire stderr output, exit 1:
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 concurrentopenclaw config set skills.entries.probe-N.enabled trueagainst one config file: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:139throws"config changed since last load; re-run config.get and retry". The local CLI path does not —src/config/mutate.ts:187andsrc/config/io.write-safety.ts:43throw the bareConfigMutationConflictError("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. Runopenclaw config get <path>first if you are unsure of the path."config set <bad value>→ "Config validation failed: gateway.port: Invalid input: expectednumber, received string"
config get→ names either the unset path oropenclaw 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 everyattempt re-checks the caller-supplied
params.baseHash(mutate.ts:1111), andsrc/cli/config-cli.ts:310pinsbaseHash: snapshot.hash. That pin is the point of optimisticconcurrency — 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 parenthesised detail preserves the underlying variant, so the
included config changed since last loadcases (mutate.ts:681/696/708/720) stay distinguishable — those name a different file.config set --dry-run --jsonnow reportskind: "conflict"for this failure. It previouslymislabelled a concurrency conflict as
kind: "schema", which is wrong for a scripted consumerdeciding whether to retry: a schema error never succeeds on retry, a conflict usually does. The
ConfigSetDryRunErrorunion gainsconflict; the addition is additive anddocs/cli/config.mdisupdated to enumerate every kind (it previously listed only three of the four that already existed,
omitting
model).Exit code stays 1.
baseHashpinning, the retry loop, and every throw site outside the CLI boundaryare unchanged.
Evidence
Production
+8/-3(net +5), docs+1/-1, tests+48/-0.node scripts/run-vitest.mjs src/cli/config-cli.test.tsNew coverage: the conflict surfaced through the text path produces the new message and exit 1; the
same through
--dry-run --jsonproduceskind: "conflict"; theincluded config changeddetail ispreserved; 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 getreturningtrue— confirmingthe 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.tspassed on Blacksmith Testbox
tbx_01m0k034p25jy2yc9jaxgstwg3.pnpm buildpassed.$autoreview --mode uncommittedclean, no accepted or actionable findings.oxfmt --checkclean.