Skip to content

fix: persist doctor migrations for explicit agent rosters - #134758

Merged
steipete merged 6 commits into
mainfrom
codex/doctor-explicit-roster-migrations
Sep 1, 2026
Merged

steipete merged 6 commits into
mainfrom
codex/doctor-explicit-roster-migrations

Conversation

@steipete

@steipete steipete commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor

Related: #133984. Follow-up to #134706.

What Problem This Solves

Fixes an issue where users running openclaw doctor --fix after an upgrade could still get “No config changes were written” with agents.ownership="explicit" already configured. Legacy per-agent model.timeoutMs remained invalid, while other skipped legacy settings such as memorySearch and sandbox.perSession could be silently removed by unknown-key cleanup.

Why This Change Was Made

Config snapshots normalize agents.list into agents.entries before Doctor runs legacy migrations. Several migration and detection paths still visited only lists, so they missed both normalized and already-keyed fleets. One shared mutable traversal now handles agent defaults and either authored roster shape, with canonical entries taking precedence over a residual list; the existing migration registry remains the owner of conversion, validation still gates writes, and explicit canonical values retain precedence.

The same traversal replaces duplicate walks in neighboring memory, sandbox, runtime-policy, TTS, vLLM, and retired-key migrations. While this PR was being verified, main separately landed the memory-search repair in 494f862 for #134256; this PR integrates it and retains its stronger process regression while repairing the remaining per-agent paths. Ambiguous legacy model-policy wildcards remain migration blockers rather than widening policy. No config options, schemas, dependencies, runtime compatibility readers, or ownership-write rules are added. Production delta: -133 lines; tests +148; docs +2.

CI maintenance: current main exceeded the Control UI startup gzip budget. Two non-rendering HTML comments in boot templates now remain as TypeScript source comments, preserving their explanations without shipping them. Markup, bindings, styles, and budget limits are unchanged. The final hosted build measured 348,197 bytes startup gzip, below the unchanged 348,368-byte limit.

User Impact

Doctor can persist the canonical per-agent configuration even when ownership was already explicit, including when called by the updater. It preserves supported memory and sandbox settings, removes ignored model-selection timeout keys, and leaves a valid configuration that requires no second migration pass. The Doctor documentation describes this behavior.

This fixes a demonstrated failure mode in #133984, not every independently reported failure in that issue. The original reporter's complete config and WSL/systemd environment were unavailable.

Evidence

  • Before repair, four real snapshot → Doctor → file-writer cases refused persistence with agents.entries.ops.model: Invalid input. A separate reproduction without that union-validation blocker silently lost memory and sandbox settings.
  • After repair and integration with the parallel main fix, 441 tests passed across ten files. Coverage includes explicit keyed/list fleets, ordinary and update-in-progress execution, saved values, canonical validation, repeat-pass idempotence, include ownership, existing Doctor repairs, and neighboring TTS/vLLM/model-policy paths.
  • Three new sibling regressions failed before their repair: keyed alias detection, TTS migration, and model-policy wildcard blocking.
  • Codex autoreview: scoped-clean at its configured P0 threshold. Manual and independent source review covered the migration owner, caller/validation/writer ordering, and canonical-value precedence.
  • Shipped-path inspection: v2026.7.1-2 accepted per-agent memorySearch; v2026.8.1 snapshot loading normalizes rosters before migration. Zod's strict-object union errors explain why generic unknown-key cleanup cannot repair the model-timeout case.
  • Local core typecheck and preceding changed-file guards passed. The broader test typecheck stopped because this shared installation resolves [email protected] where the lockfile requires 3.0.1; clean hosted CI owns the remaining verification.
  • Built-CLI proof: all four explicit-roster cases validated, repaired, preserved settings, and left byte-identical config on a second repair. An initial lint correction consolidated an import and rewrote the test fixture; targeted lint and 22 regression tests passed. Pre-sync CI run 33468094237 and its built-CLI confirmation passed. Main integration evidence records the conflict resolution, preserved process coverage, and fresh autoreview. The P1 precedence finding is addressed: a red-before/green-after regression prevents discarded-list settings from creating global model config, and 361 affected tests pass. Final-head built-CLI proof confirms the mixed-roster repair, preserved values, no unwanted vLLM row, and byte-identical second repair. Final CI run 33470568674 passed on head 3c0bce2, including the unchanged UI budget and required openclaw/ci-gate.

Remaining follow-up identified during source review: pruneBindingsForMissingAgents still derives its deletion roster from legacy lists and needs separate routing/deletion-policy work. The WhatsApp legacy-list identity fallback identified during review was independently moved to the plugin Doctor owner, using canonical entries, by main commit a514fc0 while this PR landed. The merge preserves that upstream change.

@clawsweeper

clawsweeper Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime commands Command implementations size: L maintainer Maintainer-authored PR labels Sep 1, 2026
@steipete steipete self-assigned this Sep 1, 2026
@steipete

steipete commented Sep 1, 2026

Copy link
Copy Markdown
Contributor Author

Verified the actual CI-built CLI from head 420a21d using fresh temporary homes and service repair disabled. All four cases passed:

Authored roster Doctor mode Before validation After repair Second repair
keyed entries direct exit 1 exit 0, values preserved exit 0, byte-identical config
keyed entries update in progress exit 1 exit 0, values preserved exit 0, byte-identical config
legacy list direct exit 1 exit 0, values preserved exit 0, byte-identical config
legacy list update in progress exit 1 exit 0, values preserved exit 0, byte-identical config

Each fixture already had agents.ownership="explicit", legacy per-agent model.timeoutMs, memorySearch.enabled=false and custom paths, sandbox.perSession=true, and a second agent with a legacy memory provider. The CLI removed the ignored timeout, retained the model selection, preserved memory settings under the canonical owner, converted sandbox scope, and persisted keyed entries with explicit ownership.

Commands: config validate --json, doctor --fix --non-interactive --no-workspace-suggestions, validation again, then a second identical Doctor invocation. This tests the real CLI and file writer; it is not a full WSL/systemd or npm upgrade proof.

The first CI run found two lint issues (duplicate import and test-fixture map/spread). Commit d3f84d3 fixes only those mechanically; targeted lint and 22 regression tests pass, and fresh Codex autoreview is scoped-clean at P0. CI is rerunning on that head. Final production delta: -125 lines; tests +133; docs +2.

@steipete

steipete commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor Author

Final-head CLI confirmation: the dist-runtime-build artifact from CI run 33468094237 at d3f84d3 also passes the explicit keyed-roster/update-in-progress case. Validation goes from exit 1 to exit 0 after Doctor repair, all expected memory/model/sandbox values are preserved, and a second repair exits 0 without changing a byte of the config. The earlier four-case matrix remains covered; this final check confirms the lint cleanup did not alter behavior.

Artifact provenance: GitHub built merge ref 7769f8127ddf7713c819c2131cae8e95ed30dc32, whose parents are current base adfae9b6fdd43982f4c7994f5e47e2aa3b34ee45 and PR head d3f84d3040511cea25c70ca46f5e2fe2faf24c93. The artifact's build-info matches that merge ref.

@clawsweeper

clawsweeper Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Codex review: found issues before merge. Reviewed September 1, 2026, 12:05 AM ET / 04:05 UTC.

ClawSweeper review

What this changes

The branch makes Doctor apply legacy per-agent configuration migrations to explicit keyed and list-based agent rosters, then persist the valid canonical configuration.

Regression provenance

Possible regression — suspected (reviewed change). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

Keep this maintainer-authored PR open, but it needs one correction: the new shared traversal processes a discarded legacy list even when keyed entries are canonical, allowing that discarded data to create global vLLM compatibility settings.

Priority: P1
Reviewed head: d3f84d3040511cea25c70ca46f5e2fe2faf24c93

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The focused, net-negative repair has credible built-CLI coverage, but a P1 canonical-precedence regression must be corrected before it is merge-ready.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; the supplied CI-built CLI transcript nevertheless exercises the changed Doctor-to-file-writer path for four explicit-roster cases, but not the conflicting-roster regression found here.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; the supplied CI-built CLI transcript nevertheless exercises the changed Doctor-to-file-writer path for four explicit-roster cases, but not the conflicting-roster regression found here.
Evidence reviewed 6 items Introduced trigger: The new shared traversal visits keyed entries and then also visits agents.list; it does not stop when keyed entries are present.
Canonical precedence: The existing roster migration explicitly drops agents.list when agents.entries exists, establishing that keyed entries win over the legacy list.
Causal persisted side effect: The changed model migration runs before list removal and turns each visited agent’s legacy Qwen setting into models.providers.vllm model compatibility configuration, so a list that will be discarded can still affect the final config.
Findings 1 actionable finding [P1] Preserve entries-over-list precedence in the shared traversal
Security None None.

How this fits together

Doctor migrates an operator’s legacy configuration before validating and writing it back. Per-agent migrations run before the legacy list-to-keyed-entry migration, so traversal precedence determines which roster can affect the final persisted configuration.

flowchart LR
  A[Operator configuration] --> B[Doctor migration registry]
  B --> C[Per-agent roster traversal]
  C --> D[Model compatibility migration]
  D --> E[Canonical roster conversion]
  E --> F[Validated persisted configuration]
Loading

Before merge

  • Preserve entries-over-list precedence in the shared traversal (P1) - When both roster shapes exist, Doctor deliberately retains agents.entries and removes agents.list, but this helper now visits both before that removal. The per-agent vLLM migration can therefore create models.providers.vllm compatibility settings from a legacy list that is discarded later. Skip the list whenever entries exists and cover that canonical-wins case with a migratable list value.
  • Resolve merge risk (P1) - An upgrade configuration containing canonical agents.entries plus a residual agents.list can persist vLLM compatibility settings derived only from the list that Doctor intentionally discards.
  • Complete next step (P2) - The P1 repair is mechanically clear, but this maintainer-labeled PR remains in normal human-owned review rather than an automated repair lane.

Findings

  • [P1] Preserve entries-over-list precedence in the shared traversal — src/commands/doctor/shared/legacy-config-record-shared.ts:22-28
Agent review details

Security

None.

PR surface

Source -125, Tests +133, Docs +2. Total +10 across 17 files.

View PR surface stats
Area Files Added Removed Net
Source 11 171 296 -125
Tests 5 154 21 +133
Docs 1 2 0 +2
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 17 327 317 +10

Review metrics

Metric Value Why it matters
Production versus test delta production -125, tests +133, docs +2 The refactor is net-negative in production, but its single shared traversal changes upgrade-migration semantics across several per-agent repair families.
Roster precedence path 1 shared traversal changed It now selects both keyed and list rosters even though canonical conversion retains keyed entries and removes the list.

Stored data model

Persistent data-model change detected: migration/backfill/repair: src/commands/doctor/shared/legacy-config-migrations.runtime.agents.ts, migration/backfill/repair: src/commands/doctor/shared/legacy-config-migrations.runtime.config-tranche.ts, migration/backfill/repair: src/commands/doctor/shared/legacy-config-migrations.runtime.models.codex.ts, migration/backfill/repair: src/commands/doctor/shared/legacy-config-migrations.runtime.tier-eval.ts, migration/backfill/repair: src/commands/doctor/shared/legacy-config-migrations.runtime.tts.ts, migration/backfill/repair: src/commands/doctor/shared/legacy-config-record-shared.ts, and 4 more. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Preserve canonical roster precedence (recommended)
    Change the traversal to skip agents.list whenever agents.entries exists and add coverage for a discarded list containing a migratable vLLM setting.
  2. Pause this refactor
    Keep the existing list-only migration behavior until the shared traversal can encode canonical roster precedence safely.
Copy recommended automerge instruction
@clawsweeper automerge

Special instructions:
Preserve entries-over-list precedence in the shared roster traversal and add a regression test proving a discarded list cannot create global model compatibility settings.

Technical review

Best possible solution:

Make the shared per-agent traversal honor the same precedence as roster conversion—visit keyed entries when present, otherwise visit the legacy list—and add a regression proving discarded-list model settings cannot alter the persisted model configuration.

Do we have a high-confidence way to reproduce the issue?

Yes, from source: use a config with agents.entries plus a residual agents.list whose sole agent has a legacy vLLM Qwen setting; the new traversal processes it before the registry drops the list.

Is this the best way to solve the issue?

No. The shared traversal is the right owner boundary, but it must encode the established entries-over-list precedence rather than visit both authored shapes together.

Full review comments:

  • [P1] Preserve entries-over-list precedence in the shared traversal — src/commands/doctor/shared/legacy-config-record-shared.ts:22-28
    When both roster shapes exist, Doctor deliberately retains agents.entries and removes agents.list, but this helper now visits both before that removal. The per-agent vLLM migration can therefore create models.providers.vllm compatibility settings from a legacy list that is discarded later. Skip the list whenever entries exists and cover that canonical-wins case with a migratable list value.
    Confidence: 0.98

Overall correctness: patch is incorrect
Overall confidence: 0.98

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 742801a82aee.

Labels

Label changes:

  • add P1: The introduced migration can silently persist model behavior from configuration that the canonical roster migration discards.
  • add merge-risk: 🚨 compatibility: This modifies upgrade-time configuration migration and can leave existing users with unexpected persisted vLLM compatibility settings.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🦐 gold shrimp.

Label justifications:

  • P1: The introduced migration can silently persist model behavior from configuration that the canonical roster migration discards.
  • merge-risk: 🚨 compatibility: This modifies upgrade-time configuration migration and can leave existing users with unexpected persisted vLLM compatibility settings.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🦐 gold shrimp.

Evidence

What I checked:

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Skip agents.list when agents.entries exists in the shared traversal.
  • Add a regression where a discarded list has a legacy vLLM setting and assert it cannot create or change global model compatibility configuration.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@steipete

steipete commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor Author

Main advanced during landing: 494f862 independently repaired the memory-search slice of this defect for #134256. The first merge attempt stopped before dispatch because that change conflicted with the broader shared traversal here.

Head 37d257d integrates that repair, retains its stronger Doctor process regression, and uses one traversal for the remaining per-agent model-timeout, sandbox, TTS, vLLM, and policy migrations. There is no parallel memory-migration implementation or lost upstream test coverage.

After conflict resolution, 441 tests passed across ten files, including the new upstream process regression and Gateway startup/repair process cases. Fresh Codex autoreview is scoped-clean at P0. Relative to the integrated main baseline, production is -131 lines, tests +133, docs +2. Exact-head CI is running again before merge.

The resolved migration modules, new workspace-persistence regression, and Doctor docs are byte-for-byte identical to the previously CLI-tested head (git diff d3f84d30405 37d257d41cd -- src/commands/doctor/shared src/commands/doctor-config-flow.workspace-persistence.test.ts docs/gateway/doctor.md is empty). The integrated upstream process regression supplies additional preservation proof.

@steipete

steipete commented Sep 1, 2026

Copy link
Copy Markdown
Contributor Author

Addressed the P1 canonical-precedence finding and both Rank-up moves in 9815e22.

The shared visitor now returns after visiting a record-shaped agents.entries, matching roster conversion's existing canonical-wins rule. A residual list cannot influence per-agent repairs or global model targets before the registry removes it.

The new regression failed before the change: a discarded list containing a legacy vLLM Qwen setting created models.providers.vllm. I also reproduced that unwanted persisted global configuration with the previous CI-built CLI. The regression now passes; the related QMD test explicitly preserves the discarded list untouched until roster removal. All 361 affected migration/Doctor tests pass, and fresh Codex autoreview is scoped-clean at P0.

The earlier 441-test integration run and passing CI are retained as prior proof. Exact-head CI and the mixed-roster built-CLI rerun are pending before landing. Final delta against integrated main: production -129, tests +148, docs +2.

@steipete

steipete commented Sep 1, 2026

Copy link
Copy Markdown
Contributor Author

The latest run failed the unrelated Control UI startup-size check: 348,480 bytes gzip against a 348,368-byte limit. Doctor migrations do not enter the UI bundle. Main has since landed the UI simplification in #134791, whose CI measured 348,247 bytes and passed that gate.

Head 8263910 incorporates current main without changing any Doctor migration code, regression, or documentation from 9815e22. The merge was conflict-free; fresh Codex autoreview is scoped-clean at P0. Exact-head CI is running again, followed by the mixed-roster built-CLI confirmation before landing.

@openclaw-barnacle openclaw-barnacle Bot added the app: web-ui App: web-ui label Sep 1, 2026
@steipete

steipete commented Sep 1, 2026

Copy link
Copy Markdown
Contributor Author

The refreshed main combination still measured 348,462 bytes against the 348,368-byte startup budget. Head 3c0bce2 fixes that blocker by moving two explanatory comments out of boot HTML template strings and into ordinary TypeScript source comments. It preserves the rendered markup, bindings, styles, and the existing size limits. This is a two-file, four-line net reduction; no visual change requires screenshot evidence.

The cleanup passed formatting, diff checks, and fresh Codex autoreview at P0. Removing the exact comment strings from the earlier built startup chunk estimates a 227-byte gzip saving; that estimate is not a substitute for the new hosted build. Local standalone Vite encountered the same stale shared pako installation already recorded above; dependencies were not modified. Final CI and built-CLI proof follow on this head.

@steipete

steipete commented Sep 1, 2026

Copy link
Copy Markdown
Contributor Author

Final built-CLI proof passed at head 3c0bce2, using the dist-runtime-build artifact from CI run 33470568674.

For explicit ownership with both canonical entries and a residual legacy list: config validation exited 1 before repair; doctor --fix --non-interactive --no-workspace-suggestions exited 0; validation then exited 0. The saved canonical memory/model/sandbox values matched expectations, the discarded list created no global vLLM configuration, and the second repair exited 0 with a byte-identical config. The same mixed-roster case failed against the prior artifact, which persisted the unwanted vLLM settings.

Artifact build-info identifies merge ref 08075d3ce1d1e14506fd7a00e304e7d3210d5a29. Its verified parents are main 84648e8 and PR head 3c0bce2. The earlier keyed/list × direct/update four-case CLI matrix remains covered by the unchanged Doctor source.

The final hosted build also passed the unchanged Control UI budget: 348,197 bytes startup gzip against 348,368 bytes. The tiny template-comment cleanup resolved the unrelated CI build failure without changing UI behavior. Fresh Codex autoreview is scoped-clean at P0. The latest ClawSweeper P1 and both Rank-up moves are addressed with source, regression, and actual CLI proof.

@steipete
steipete merged commit 127a2ba into main Sep 1, 2026
279 of 280 checks passed
@steipete
steipete deleted the codex/doctor-explicit-roster-migrations branch September 1, 2026 04:50
@steipete

steipete commented Sep 1, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 2, 2026
…34758)

* fix: persist doctor migrations for explicit agent rosters

* style: satisfy doctor migration lint rules

* fix: preserve canonical roster precedence during migration

* perf(ui): keep template explanations out of startup assets
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: web-ui App: web-ui commands Command implementations docs Improvements or additions to documentation gateway Gateway runtime maintainer Maintainer-authored PR size: L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant