Skip to content

fix(onboard): rebase non-interactive commit onto first-agent write - #113601

Merged
steipete merged 1 commit into
mainfrom
fix/onboard-first-agent-base-hash
Jul 25, 2026
Merged

steipete merged 1 commit into
mainfrom
fix/onboard-first-agent-base-hash

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

openclaw onboard --non-interactive (any auth choice) fails on a fresh install with ConfigMutationConflictError: config changed since last load and leaves a HALF-WRITTEN config — only the agent roster entry, no model, no provider, no gateway. Found by live testing on current main; reproduced deterministically on fresh state dirs.

Why This Change Was Made

#112678 (roster-only refactor) made onboarding create the first roster agent through createAgent, which WRITES the config file mid-flow. runNonInteractiveSetup captures snapshot.hash before that and passes it as the optimistic-concurrency baseline to the final commit, so the guard rejects onboarding's own write. ensureOnboardingAgent now reports the post-create config hash (only on the path where it actually created the agent), and non-interactive local setup adopts it as the effective baseline. Foreign-write protection is preserved: the baseline is only advanced past a write we made ourselves; every other path keeps the original hash and the original guard semantics.

User Impact

Fresh non-interactive onboarding completes again and writes a full config; no more half-configured installs from a failed first run. Regression window is #112678 (2026-07-24) to now.

Evidence

Live reproduction on current main (fresh OPENCLAW_STATE_DIR, --auth-choice ollama): before = ConfigMutationConflictError + partial config containing only agents.entries.main; after = "Updated config" and a complete config (model ollama/gemma4:latest, provider ollama, roster main, gateway port).

Bisected to #112678 by running the same command on its parent (5f63f744ead — succeeds) vs the commit itself (fails). Config-write tracing pinned the intermediate writer to agent-create's transformConfigFileWithRetry.

Tests: node scripts/run-vitest.mjs src/commands/onboard-agent.test.ts src/commands/onboard-non-interactive — 9 files / 57 passed, including two new regression tests (post-create hash reported; hash omitted when nothing was created); node scripts/run-vitest.mjs src/config/mutate — 46 passed. Autoreview clean (0.94).

Follow-up, intentionally not fixed here: src/commands/setup.ts calls ensureOnboardingAgent and then writes with the pre-create snapshot; it does not pass a baseHash, so it does not throw, but the stale snapshot is a latent hazard.

Related: #112678.

@openclaw-barnacle openclaw-barnacle Bot added commands Command implementations size: XS maintainer Maintainer-authored PR labels Jul 25, 2026
@steipete steipete self-assigned this Jul 25, 2026
@steipete
steipete merged commit faaab9b into main Jul 25, 2026
138 of 142 checks passed
@steipete
steipete deleted the fix/onboard-first-agent-base-hash branch July 25, 2026 10:13
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commands Command implementations maintainer Maintainer-authored PR size: XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant