Repository navigation
fix(cli): let setup run while a Gateway owns state - #185109
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
@clawsweeper review |
|
🦞👀 Re-review progress:
|
|
Codex review: blocked before merge. What this changesThis PR routes baseline setup config changes through the running Gateway while sharing config planning with offline setup. Example: Run openclaw setup --baseline --workspace /Users/alice/workspace while the local Gateway is running.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Regression provenanceRegression provenance — verified: source commit Merge readiness⛔ Blocked before merge - 1 item remains Keep this PR open: it restores a source-confirmed companion-app setup failure while preserving Gateway ownership, and review found no concrete introduced code defect. Priority: P0 Before merge
FindingsNone. Tests
Agent review detailsHow this fits togetherBaseline setup consumes CLI options and existing config, selects the state owner, and produces config updates and setup results; the running Gateway retains config and database write ownership. flowchart TD
A[Baseline setup options] --> B[State owner selection]
B --> C[Offline setup]
B --> D[Gateway routed setup]
C --> E[Shared config plan]
D --> E
E --> F[Existing config writers]
F --> G[Config and setup result]
Technical reviewBest possible solution: Restore automatic companion-app setup through the existing Gateway config writer while retaining the shared offline plan and documented ownership limits. Do we have a high-confidence way to reproduce the issue? Current main unconditionally refuses baseline setup when a foreign Gateway owns state, matching the reported command and error; no target code was executed during this review. Is this the best way to solve the issue? Sharing setup intent and reusing the existing config.patch writer is a focused repair that preserves single-writer ownership without adding a protocol, config option, or competing state owner. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against d209419bb9ef. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +141, Tests +59, Docs +5. Total +205 across 8 files. Added test files: 0. View PR surface stats
Review metrics
LabelsLabel changes:
Label justifications:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
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 Reviewed October 26, 2026, 6:36 PM ET / 22:36 UTC. |
Release adaptation: config set keeps its in-commit owner checks via bindConfigOwner; no database-engine selection, proactive job, or daemon pin migration on this branch; the owner-route fixture already seeds skipBootstrap. (cherry picked from commit 23be3e1)
Related: #168417 (regression source). Evidence run: https://github.com/openclaw/openclaw/actions/runs/40391338974 (
windows-node-context).What Problem This Solves
Fixes: Windows companion app setup fails with
openclaw setup failed (exit 1): Cannot admit setup for agent roster and workspace ... requires exclusive offline state ownershipwhen it runsopenclaw setup --baseline --workspace <abs>after onboarding, while its managed Gateway is running. Every Windows setup hits this; it worked on 2026.10.7, and the released Windows app cannot change.User Impact
User impact:
openclaw setup --baseline(with--workspace,--skip-bootstrap,--json) succeeds again with the local Gateway running and saves the same config the offline command would. An unchanged config is not written. The Gateway stays the only config writer.Accepted limits: with a running Gateway, setup does not seed workspace files itself (the Gateway seeds missing files on the agent's first run), and creating the first config or overriding a value inherited from an included config file still asks you to stop the Gateway.
Why This Change Was Made
Follows the
config setrouting precedent (#182951/#184194).setupCommandnow passes anonForeignOwnercallback: setup computes its config change with the same plan the offline path uses, prepares it the way the offline writer would save it, and commits only that diff withconfig.get→config.patch(baseHash). The change is refused instead of approximated if the Gateway's writer would save something different. CLI-routed patches already returnrestartPendinginstead of failing when a restart is needed.Steps that touch the state database stay with the Gateway: workspace bootstrap (its setup state lives in SQLite) runs on the agent's first turn, Gateway startup already finishes the runtime-pin migration, and agent creation during onboarding already provisioned the proactive job. Setup still creates the session transcripts directory.
The config.get/path-identity/config.patch binding moved from
config-cli.tsintobindConfigOwnerinconfig-cli-owner-patch.ts, soconfig setandsetupshare it.docs/cli/setup.mddescribes the new behavior.Evidence
src/cli/config-owner-route.process.test.ts, with a real Gateway owning the state:setup --baseline --workspace <abs>succeeds and its config (minusmeta) equals an offline run from the same starting config. A rerun with--jsonreportsconfigStatus: "unchanged"and leaves the file byte-identical.--skip-bootstrap --jsonroutesagents.defaults.skipBootstrap. The Gateway keeps running without a restart. Without the fix, the same test fails with the reportedexclusive offline state ownershiperror.pnpm testonconfig-owner-route.process,agent-roster-owner.process,commands/setup,config-cli-owner-patch,config-cli,config-cli.integration: all pass.pnpm tsgo:core,pnpm tsgo:core:test,check:line-cap-ratchet --staged,check:test-mock-exports, oxlint/oxfmt on touched files, docs format/lint: all clean.deadcode:fullreports only 4 existing unused exports outside this change.agents.defaults.workspace,agents.entries,gateway.mode,agents.defaults.skipBootstrap) through the Gateway's existingconfig.patch; the routed setup never opens the state database. The process test and built-CLI proof both start from an existing onboarded config and leave it byte-identical when nothing changes.Built-CLI proof on macOS (isolated HOME, free port)
The non-
--baselinefallback branch (openclaw setup --workspace, only for releases whose help lacks--baseline) runs onboarding, which needs a TTY with or without a Gateway. Current releases always take the--baselinebranch.