Repository navigation
fix(cli): keep routed config writes identical to offline writes - #184194
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: blocked before merge. What this changesThis PR prepares routed config edits through the shared writer and refuses edits whose modeled Gateway result differs from the offline result. Example: Set messages.responsePrefix to '${SYNTH_ROUTE_PREFIX}' over an existing '$${SYNTH_ROUTE_PREFIX}' while the Gateway runs.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Blocked before merge - 1 item remains This PR addresses a current config-write fidelity defect; the previous assertion finding is resolved, and no additional concrete code defect was found. Priority: P2 Before merge
FindingsNone. Tests
Agent review detailsHow this fits togetherThe config CLI translates authored edits into authenticated, hash-guarded config.patch requests; the Gateway owns persistence and runtime application. flowchart LR
A[Config CLI edit] --> B[Shared writer preparation]
B --> C[Model Gateway preparation]
C --> D[Compare authored results]
D --> E[Refuse divergent edit]
D --> F[Authenticated config patch]
F --> G[Gateway persistence and reload]
Technical reviewBest possible solution: Keep the shared-writer fidelity check and validate its new topology payloads across a stable-to-current upgrade. Do we have a high-confidence way to reproduce the issue? Main omits intent paths that the shared writer uses for environment-reference restoration and ownership preparation; the body records matching offline-versus-routed failures, and this read-only review ran no target code. Is this the best way to solve the issue? Reusing the existing topology owner and refusing intent that the closed stable protocol cannot carry is a focused repair, with distinct regression cases and no unnecessary production layer. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 2b11e1ea1e02. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +76, Tests +45, Docs +8. Total +129 across 4 files. Added test files: 0. View PR surface stats
LabelsLabel changes:
Label justifications:
Rating scale6/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. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (1 earlier review cycle)
Reviewed October 26, 2026, 1:04 AM ET / 05:04 UTC (Revision 2). |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
) * fix(cli): keep routed config writes identical to offline writes * fix(cli): document the routed merge-model assertion (cherry picked from commit cadea14)
…claw#184194) * fix(cli): keep routed config writes identical to offline writes * fix(cli): document the routed merge-model assertion
…teway runs (#203235) Root cause: src/cli/config-cli-owner-patch.ts:84 builds the routed `replacePaths` consent from the authored config only (`collectReplacePaths(patch, previous)`), while the Gateway's guard at src/gateway/server-methods/config.ts:879-880 (`rejectDestructiveArrayPatchWithoutIntent({ currentConfig: snapshot.config, ... })`) checks the runtime view, where an omitted provider `models` list or a plugin schema default exists as an array. Deleting the section therefore "removes" an array the CLI never named, and the Gateway refuses. Fixes #203175 Thanks @woodmanlegion for the detailed report and source trace. ## What Problem This Solves With the Gateway running, `openclaw config unset models.providers.ollama` (or `config unset models`) fails with `config.patch would remove entries from array path(s): models.providers.ollama.models` when the provider has no `models` list in the file. The same happens for plugin config sections with array schema defaults, such as `plugins.entries.anthropic.config.managedNativeTools`. The same command works with the Gateway stopped, and the error suggests options the CLI does not have. Routed CLI writes are supposed to match offline writes (#184194; docs/cli/config.md: "Output and exit codes match the offline command"). ## User Impact `config unset` of a section holding a runtime-default array now removes it through a running Gateway, and the saved file is byte-for-byte what the offline command writes. No workaround (writing `[]` first, or stopping the Gateway) is needed. ## Why This Change Was Made The CLI already sends consent, in the existing `replacePaths` field, for every array removed below a subtree the command explicitly deletes or replaces. It now also collects those arrays from the Gateway's own `config.get` view (the one the guard checks, read at the same revision as `baseHash`), still only below the removed subtree. The Gateway guard, the request fields and authorization are unchanged. A `set` that would drop entries from an authored list is still refused, and a raw `config.patch` that truncates an authored array without `replacePaths` is still refused by the guard. ## Evidence Built CLI and Gateway (dist), isolated state per side, the issue's steps run against a running Gateway (routed) and with no Gateway (offline) from identical starting files. Proof lines: #203235 (comment) - Base (2821214), routed: `config unset models.providers.ollama`, `config unset models` and `config unset plugins.entries.anthropic.config.managedNativeTools` exit 1 with `config.patch would remove entries from array path(s): ...`; offline the same commands exit 0 and the files differ. - Candidate, routed: all three exit 0 (`Removed ...`), and after each of the 14 steps the routed file equals the offline file byte for byte. - Controls on the candidate: offline results unchanged; `config set models.providers.vllm.models` dropping an authored entry is refused on both paths (`Refusing to replace ...`); unsetting a sibling provider or a sibling key leaves the other arrays untouched (files equal offline); a raw `config.patch` truncating `gateway.nodes.commands.allow` without `replacePaths` is still refused by the Gateway guard. - Tests: `src/cli/config-cli-owner-patch.test.ts` now gives the synthetic owner a runtime view with default arrays inside and outside the removed subtree; it fails on base (inside path missing) and passes here, and the outside path is not consented. `src/cli/config-owner-route.process.test.ts` unsets an ollama provider without `models` through a real in-process Gateway. Line deltas vs merge base: production +26 / -19 (one file, partly formatter rewrap), tests +23 / -7. Merge danger: two-way door. CLI-only, no stored data, schema or protocol change; a revert restores the previous consent list. Blast radius: routed `config set/patch/unset`, `mcp` config commands and Gateway-owned `setup`; if wrong, a routed removal would consent to an array the Gateway materializes under the removed subtree, which the offline command removes too. Co-authored-by: Ayaan Zaidi <[email protected]>
…teway runs (openclaw#203235) Root cause: src/cli/config-cli-owner-patch.ts:84 builds the routed `replacePaths` consent from the authored config only (`collectReplacePaths(patch, previous)`), while the Gateway's guard at src/gateway/server-methods/config.ts:879-880 (`rejectDestructiveArrayPatchWithoutIntent({ currentConfig: snapshot.config, ... })`) checks the runtime view, where an omitted provider `models` list or a plugin schema default exists as an array. Deleting the section therefore "removes" an array the CLI never named, and the Gateway refuses. Fixes openclaw#203175 Thanks @woodmanlegion for the detailed report and source trace. ## What Problem This Solves With the Gateway running, `openclaw config unset models.providers.ollama` (or `config unset models`) fails with `config.patch would remove entries from array path(s): models.providers.ollama.models` when the provider has no `models` list in the file. The same happens for plugin config sections with array schema defaults, such as `plugins.entries.anthropic.config.managedNativeTools`. The same command works with the Gateway stopped, and the error suggests options the CLI does not have. Routed CLI writes are supposed to match offline writes (openclaw#184194; docs/cli/config.md: "Output and exit codes match the offline command"). ## User Impact `config unset` of a section holding a runtime-default array now removes it through a running Gateway, and the saved file is byte-for-byte what the offline command writes. No workaround (writing `[]` first, or stopping the Gateway) is needed. ## Why This Change Was Made The CLI already sends consent, in the existing `replacePaths` field, for every array removed below a subtree the command explicitly deletes or replaces. It now also collects those arrays from the Gateway's own `config.get` view (the one the guard checks, read at the same revision as `baseHash`), still only below the removed subtree. The Gateway guard, the request fields and authorization are unchanged. A `set` that would drop entries from an authored list is still refused, and a raw `config.patch` that truncates an authored array without `replacePaths` is still refused by the guard. ## Evidence Built CLI and Gateway (dist), isolated state per side, the issue's steps run against a running Gateway (routed) and with no Gateway (offline) from identical starting files. Proof lines: openclaw#203235 (comment) - Base (0bcbb56), routed: `config unset models.providers.ollama`, `config unset models` and `config unset plugins.entries.anthropic.config.managedNativeTools` exit 1 with `config.patch would remove entries from array path(s): ...`; offline the same commands exit 0 and the files differ. - Candidate, routed: all three exit 0 (`Removed ...`), and after each of the 14 steps the routed file equals the offline file byte for byte. - Controls on the candidate: offline results unchanged; `config set models.providers.vllm.models` dropping an authored entry is refused on both paths (`Refusing to replace ...`); unsetting a sibling provider or a sibling key leaves the other arrays untouched (files equal offline); a raw `config.patch` truncating `gateway.nodes.commands.allow` without `replacePaths` is still refused by the Gateway guard. - Tests: `src/cli/config-cli-owner-patch.test.ts` now gives the synthetic owner a runtime view with default arrays inside and outside the removed subtree; it fails on base (inside path missing) and passes here, and the outside path is not consented. `src/cli/config-owner-route.process.test.ts` unsets an ollama provider without `models` through a real in-process Gateway. Line deltas vs merge base: production +26 / -19 (one file, partly formatter rewrap), tests +23 / -7. Merge danger: two-way door. CLI-only, no stored data, schema or protocol change; a revert restores the previous consent list. Blast radius: routed `config set/patch/unset`, `mcp` config commands and Gateway-owned `setup`; if wrong, a routed removal would consent to an array the Gateway materializes under the removed subtree, which the offline command removes too. Co-authored-by: Ayaan Zaidi <[email protected]>
…teway runs (#203235) Root cause: src/cli/config-cli-owner-patch.ts:84 builds the routed `replacePaths` consent from the authored config only (`collectReplacePaths(patch, previous)`), while the Gateway's guard at src/gateway/server-methods/config.ts:879-880 (`rejectDestructiveArrayPatchWithoutIntent({ currentConfig: snapshot.config, ... })`) checks the runtime view, where an omitted provider `models` list or a plugin schema default exists as an array. Deleting the section therefore "removes" an array the CLI never named, and the Gateway refuses. Fixes #203175 Thanks @woodmanlegion for the detailed report and source trace. With the Gateway running, `openclaw config unset models.providers.ollama` (or `config unset models`) fails with `config.patch would remove entries from array path(s): models.providers.ollama.models` when the provider has no `models` list in the file. The same happens for plugin config sections with array schema defaults, such as `plugins.entries.anthropic.config.managedNativeTools`. The same command works with the Gateway stopped, and the error suggests options the CLI does not have. Routed CLI writes are supposed to match offline writes (#184194; docs/cli/config.md: "Output and exit codes match the offline command"). `config unset` of a section holding a runtime-default array now removes it through a running Gateway, and the saved file is byte-for-byte what the offline command writes. No workaround (writing `[]` first, or stopping the Gateway) is needed. The CLI already sends consent, in the existing `replacePaths` field, for every array removed below a subtree the command explicitly deletes or replaces. It now also collects those arrays from the Gateway's own `config.get` view (the one the guard checks, read at the same revision as `baseHash`), still only below the removed subtree. The Gateway guard, the request fields and authorization are unchanged. A `set` that would drop entries from an authored list is still refused, and a raw `config.patch` that truncates an authored array without `replacePaths` is still refused by the guard. Built CLI and Gateway (dist), isolated state per side, the issue's steps run against a running Gateway (routed) and with no Gateway (offline) from identical starting files. Proof lines: #203235 (comment) - Base (2821214), routed: `config unset models.providers.ollama`, `config unset models` and `config unset plugins.entries.anthropic.config.managedNativeTools` exit 1 with `config.patch would remove entries from array path(s): ...`; offline the same commands exit 0 and the files differ. - Candidate, routed: all three exit 0 (`Removed ...`), and after each of the 14 steps the routed file equals the offline file byte for byte. - Controls on the candidate: offline results unchanged; `config set models.providers.vllm.models` dropping an authored entry is refused on both paths (`Refusing to replace ...`); unsetting a sibling provider or a sibling key leaves the other arrays untouched (files equal offline); a raw `config.patch` truncating `gateway.nodes.commands.allow` without `replacePaths` is still refused by the Gateway guard. - Tests: `src/cli/config-cli-owner-patch.test.ts` now gives the synthetic owner a runtime view with default arrays inside and outside the removed subtree; it fails on base (inside path missing) and passes here, and the outside path is not consented. `src/cli/config-owner-route.process.test.ts` unsets an ollama provider without `models` through a real in-process Gateway. Line deltas vs merge base: production +26 / -19 (one file, partly formatter rewrap), tests +23 / -7. Merge danger: two-way door. CLI-only, no stored data, schema or protocol change; a revert restores the previous consent list. Blast radius: routed `config set/patch/unset`, `mcp` config commands and Gateway-owned `setup`; if wrong, a routed removal would consent to an array the Gateway materializes under the removed subtree, which the offline command removes too. Co-authored-by: Ayaan Zaidi <[email protected]> (cherry picked from commit 4bedaed) Companion audit: a012e91 is later busy-Gateway saved-edit confirmation and does not participate in array-path consent. Release adaptation: Use the same-revision owner runtime config for explicit subtree array consent; keep the stable closed config.patch request, authored topology comparison and hash fence, and omit unrelated saved-config recovery. Co-authored-by: RomneyDa <[email protected]>
Problem
#182951 routes
openclaw config set/patch/unsetthrough a running Gateway as oneconfig.patch. The offline writer getsexplicitSetPathsandunsetPaths.config.patchcannot carry them, and older Gateways close its schema, so no field can be added. The Gateway's writer therefore works out env-reference restoration and roster/auth/session-store ownership from the merged result alone. I ran the same commands offline and routed against a real in-process Gateway (isolated state and ports, synthetic values) and found three cases where the routed write reports success but saves something else:config set models.providers.p.apiKey '${SYNTH_KEY}'over an escaped"$${SYNTH_KEY}""${SYNTH_KEY}"(reference activated)"$${SYNTH_KEY}", yet the CLI printedUpdated ...(silent no-op)agents.entries.ops+agents.defaults.authInheritance.agentId=ops(roster already explicit)authInheritance.agentId: "ops"authInheritance.agentId: "main"(the writer re-pins the legacy owner)session.store→ new path +agents.defaults.sessionStore.agentId=mainRelated refusals: when adding an agent turns a single-agent config into a multi-agent one, the Gateway rejected the write with
.ownership: multi-agent rosters require agents.ownership="explicit". The offline writer stamps that ownership itself. A routedsession.storechange also dropped the offlineCleared agents.defaults.sessionStore.agentId ...notice.Nothing became plaintext and no reference was lost. Unrelated sets next to
${VAR}refs, setting a literal${VAR}, escaping an active ref, and replacing a parent with the resolved value all matched offline byte for byte. Deferred plugin migrations are inert on both paths: ordinary CLI and Gateway reads load no pending facts, so theconfig-rpc[[]]branch only runs in Doctor/update flows.Solution
prepareConfigOwnerChangeinsrc/cli/config-cli-owner-patch.tsruns the writer's ownprepareConfigWriteTopologytwice:If the two differ, or the second run throws, the CLI refuses before sending. The message says nothing was sent and suggests splitting the owner change into its own command or stopping the Gateway. The CLI now also prints the session-store owner notice for routed writes. No protocol fields were added. Docs list the new refusal group.
Evidence
systemAgentandtalk.agentIdstamping as offline; the only difference is the per-root absolute workspace path.refuses changes the Gateway's writer would save differentlyinsrc/cli/config-owner-route.process.test.ts. Without the fix it fails withexpected +0 to be 1(the escaped-literal no-op). With the fix, all 10 tests pass.oxfmt,oxlinton changed files,pnpm tsgo:core,pnpm tsgo:core:testall pass.Remaining gap: the CLI runs the Gateway-side preparation with its own environment and plugin metadata. A Gateway whose env resolves
${VAR}differently, or an older Gateway whose writer topology differs, is not modeled.Data model and upgrade compatibility
config.patchas before or refuses before sending anything. Offline writes and existing config files are unaffected.raw,baseHashandreplacePaths, all accepted by v2026.10.7's closedconfig.patchschema. The new check runs entirely in the CLI. Against an older Gateway, the model uses this CLI's writer logic, so it can only add refusals. It cannot change what a successful routed write sends. That is the existing fix(cli): route config mutations through a running Gateway #182951 request, already proven against an installed v2026.10.7 Gateway.applyMergePatchreturnsunknown. The modeled merge combines validated configs only to predict the Gateway's result, and the Gateway validates the real merge before writing, so the cast carries a// SAFETY:invariant (the ratchet passes). I avoided running the full config validator here because any normalization it applies could make the equality check refuse valid writes.