Repository navigation
fix(doctor): keep migrated agents on their existing workspace - #123808
Patrick-Erichsen merged 1 commit into
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 14, 2026, 8:03 PM ET / August 15, 2026, 00:03 UTC. ClawSweeper reviewWhat this changesDoctor now pins a legacy multi-agent owner’s inherited workspace into its canonical migration candidate so later Doctor writes retain that existing workspace. Regression provenancePossible regression — suspected (reviewed change). No predecessor PR is attributed. Merge readinessKeep open. This focused PR remains necessary: current main still builds Doctor’s persisted migration candidate without materializing the legacy owner workspace, while the later health write persists that stale candidate. No blocking patch findings. Likely related people: steipete (high) and Vincent Koc (medium). Priority: P1 Review scores
Verification
How this fits togetherDoctor converts legacy agent configuration into the current explicit roster before its health checks may write configuration again. The resulting roster determines which workspace each upgraded agent continues to use for memory and workspace files. flowchart LR
A[Legacy multi-agent config] --> B[Doctor migration candidate]
B --> C[Initial config write]
C --> D[Health repair]
D --> E[Final config write]
E --> F[Existing agent workspace]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +8, Tests +83. Total +91 across 3 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep Doctor’s canonical migration candidate complete before the retired marker is removed, leaving runtime normalization read-only and the generic writer free of Doctor-specific state repair. Do we have a high-confidence way to reproduce the issue? Yes. A legacy two-agent config with one retired default marker and a shared defaults workspace, followed by Doctor’s initial write and a health-triggered later write, is a high-confidence source path; the PR also supplies an exact-head CLI transcript of that sequence. Is this the best way to solve the issue? Yes. Materializing the workspace in Doctor’s canonical candidate is the narrow owner-boundary repair; relying on the generic writer alone cannot update Doctor’s retained candidate for the later write. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against d9137961120f. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (3 earlier review cycles) |
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
…aw#123808) Co-authored-by: scotthuang <[email protected]>
What Problem This Solves
Fixes an issue where users upgrading a legacy multi-agent configuration and running
openclaw doctor --fixcould have the previous owner agent silently moved from the sharedagents.defaults.workspaceto a new<workspace>/<agentId>directory after a later Doctor health write.Why This Change Was Made
Doctor now materializes the legacy owner's workspace in its canonical roster migration candidate before retiring the old default marker. Every later Doctor write therefore persists the same authoritative workspace. This keeps explicit multi-agent ownership intact and does not introduce a global default agent or a resolver fallback.
The repair reuses the existing legacy-role materializer at the Doctor persistence boundary. Production delta: +8 net lines; test delta: +83 lines.
User Impact
Existing multi-agent installations keep the owner's current workspace, memory, and workspace files after an upgrade/Doctor repair instead of appearing to start from an empty agent-specific directory.
Evidence
Exact-head real Doctor upgrade proof
2777d6425c730cf7bcbe5e6939e4ee8c317554b3.HOME, state directory, and config. Bundled plugins were disabled; no provider or channel was exercised.--generate-gateway-tokensupplied a deterministic post-migration health mutation, forcing Doctor's final config writer to run after the initial migration write. The token value was never printed; evidence records only whether it exists.Representative legacy input (paths redacted):
{ "agents": { "defaults": { "workspace": "<proof-root>/shared-workspace" }, "entries": { "main": { "default": true }, "cursor": { "workspace": "<proof-root>/shared-workspace" } } }, "gateway": { "mode": "local" } }MEMORY.mdandAGENTS.mdcanaries existed in the shared workspace before the run.Command:
Selected redacted terminal output (unrelated isolated-environment diagnostics omitted):
Sanitized persisted state immediately before the second write (
openclaw.json.bak):{ "ownership": "explicit", "defaults_workspace": "<proof-root>/shared-workspace", "main_workspace": "<proof-root>/shared-workspace", "cursor_workspace": "<proof-root>/shared-workspace", "retired_default_marker_present": false, "gateway_auth_mode": null, "gateway_token_present": false }Sanitized final state after the second write:
{ "ownership": "explicit", "defaults_workspace": "<proof-root>/shared-workspace", "main_workspace": "<proof-root>/shared-workspace", "cursor_workspace": "<proof-root>/shared-workspace", "retired_default_marker_present": false, "gateway_auth_mode": "token", "gateway_token_present": true }Post-run workspace checks:
This proves the real two-write lifecycle at the exact PR head: the later health mutation was persisted, while both agent workspaces and the existing workspace canaries remained in place.
Automated and static verification
node scripts/run-vitest.mjs src/commands/doctor-config-flow.workspace-persistence.test.ts src/config/legacy.roster.test.ts src/commands/doctor/shared/default-agent-role-materialization.write.test.ts— 43 tests passed.pnpm tsgo:core— passed.pnpm tsgo:core:test— passed.Proof status: real behavior passed at the exact PR head. Merge-CI status is tracked independently. Full changed-gate delegation could not start because the local Crabbox binary failed its own version/help sanity check; the required local fallback then stopped on an existing
mainratchet mismatch (OPENCLAW_*count 504 vs budget 502). This patch adds no environment variables.