Skip to content

fix(doctor): stop repeated bundledDiscovery migration noise on beta - #115208

Merged
steipete merged 1 commit into
openclaw:mainfrom
SunnyShu0925:fix/repeated-bundled-discovery-115151
Jul 29, 2026
Merged

steipete merged 1 commit into
openclaw:mainfrom
SunnyShu0925:fix/repeated-bundled-discovery-115151

Conversation

@SunnyShu0925

Copy link
Copy Markdown
Contributor

What Problem This Solves

Doctor preflight and openclaw status --deep repeatedly report a no-op plugins.bundledDiscovery migration as an auto-migrated legacy state change on every beta CLI process, creating misleading log noise and unnecessary concern that every restart is re-running a migration.

  • Problem: On beta versions (SemVer prerelease < 2026.7.2), migrateLegacyConfigMachineState re-infers plugins.bundledDiscovery = "compat" on every new process. The entry always hits the SQLite kept path, which is then reported as a Doctor change — even though no state actually changed.
  • Solution: Skip the inferred compat candidate when the canonical SQLite row already exists. A try/catch guards against temporary SQLite unavailability.
  • What changed: src/infra/state-migrations.config-machine-state.ts (inference gate), src/infra/state-migrations.config-machine-state.test.ts (regression test)
  • What did NOT change: Explicit plugins.bundledDiscovery handling, importConfigMachineState behavior, keeping/reporting logic for other migration entries, any other Doctor migration source

Change Type (select all)

  • Bug fix
  • Feature
  • Refactor required for the fix
  • Docs
  • Security hardening
  • Chore/infra

Scope (select all)

  • Gateway / orchestration
  • Skills / tool execution
  • Auth / tokens
  • Memory / storage
  • Integrations
  • API / contracts
  • UI / DX
  • CI/CD / infra

Linked Issue/PR

Motivation

Fixes #115151. The bug is fully resolved: after this patch, beta users will no longer see repeated "Kept existing shared SQLite plugins.bundledDiscovery state" messages on every CLI process restart.

Beta versions (e.g. 2026.7.2-beta.5) are treated by SemVer as older than the cutover release 2026.7.2: compareOpenClawVersions("2026.7.2-beta.5", "2026.7.2") returns -1. This means the else if inference branch in migrateLegacyConfigMachineState fires on every new CLI process for any user on a beta version with a non-empty plugin allowlist. The result always goes into importConfigMachineState's kept bucket (the SQLite row already exists), and the caller reports every kept key as a Doctor change. No data corruption was observed, but the repeated "Auto-migrated legacy state" message is misleading and causes unnecessary concern.

Evidence

  • Behavior addressed: No-op plugins.bundledDiscovery migration reported as a Doctor change on every beta CLI process restart
  • Real environment tested: Linux x86_64, Node.js v22.22.3, branch fix/repeated-bundled-discovery-115151
  • Exact steps or command run after this patch:
node --import tsx <<'NODE'
// Test: First pass infers compat, second pass shows no Doctor changes
const stateDir = mkdtempSync(...);  // fresh temp state dir
const env = { ...process.env, OPENCLAW_STATE_DIR: stateDir };

// First call: should infer and write "compat"
migrateLegacyConfigMachineState({
  env,
  config: { meta: { lastTouchedVersion: "2026.7.2-beta.5" }, plugins: { allow: ["telegram"] } },
});
// → changes: ["Migrated plugins.bundledDiscovery → shared SQLite state"]
// → SQLite: "compat"

// Second call (simulates new CLI process): should report no changes
migrateLegacyConfigMachineState({
  env,
  config: { meta: { lastTouchedVersion: "2026.7.2-beta.5" }, plugins: { allow: ["telegram"] } },
});
// → changes: []  ← the fix!
NODE
  • Evidence after fix:
╔══════════════════════════════════════════════════════════╗
║  Scenario: Beta version preflight converges after fix     ║
╚══════════════════════════════════════════════════════════╝

─── Step 1: First pass (infer canon, write to SQLite) ───
  changes: ["Migrated plugins.bundledDiscovery → shared SQLite state"]
  warnings: []
  SQLite plugins.bundledDiscovery: "compat"

─── Step 2: Second pass (simulate new CLI process) ───
  changes: []
  warnings: []
  SQLite plugins.bundledDiscovery: "compat"

─── Verdict ───
  Second pass reports bundledDiscovery as a Doctor change: ✅ NO (FIXED)
  Canonical value preserved: ✅ YES

╔══════════════════════════════════════════════════════════╗
║  Control: Fresh SQLite still infers compat on first run  ║
╚══════════════════════════════════════════════════════════╝
  changes: ["Migrated plugins.bundledDiscovery → shared SQLite state"]
  SQLite plugins.bundledDiscovery: "compat"
  First-run inference works: ✅
  • Observed result after fix:
    1. First pass with fresh SQLite still infers compat and writes it — no regression for first-time migration
    2. Second pass (new process, same config) returns changes: [] — no misleading Doctor output
    3. Canonical SQLite value is preserved correctly
    4. All 11 existing + new tests pass (Test Files 1 passed (1), Tests 11 passed (11))
  • What was not tested: Other beta prerelease variants (2026.7.2-beta.10, 2026.7.2-rc.1); other migration sources for the same repeated-kept pattern; browser or mobile app UI flows

Root Cause

Provenance:
  introduced by: PR #111527 (edecdbd05ef) — config-surface reduction tranche 3
                 moved bundledDiscovery inference into migrateLegacyConfigMachineState
  made visible by: 2026.7.2-beta.5 release — first beta after cutover
  carried forward by: PR #112558 (7eec1345f98) — device-auth migration, left logic unchanged
  Confidence: clear

The version comparison compareOpenClawVersions(meta.lastTouchedVersion, "2026.7.2") === -1 follows SemVer rules where prerelease (2026.7.2-beta.5) < release (2026.7.2). This causes the inference to re-fire on every new CLI process for beta users.

Regression Test Plan

Test Coverage
state-migrations.config-machine-state.test.ts New "does not re-report inferred bundledDiscovery on second pass with beta version": first pass writes compat, second pass returns changes: []

Existing tests unaffected (all pass):

  • Unstamped allowlist → infers compat ✅
  • Pre-cutover version (2026.1.1) → infers compat ✅
  • Post-cutover version (2026.7.2) → no inference ✅
  • Explicit bundledDiscovery in config → imported correctly ✅

User-visible / Behavior Changes

Beta users will no longer see the "Auto-migrated legacy state: Kept existing shared SQLite plugins.bundledDiscovery state" message on every openclaw status --deep or openclaw gateway restart. The canonical value is preserved identically.

Security Impact

  • New permissions/capabilities? No
  • Secrets/tokens handling changed? No
  • New/changed network calls? No
  • Command/tool execution surface changed? No
  • Data access scope changed? No

Human Verification

  • Verified scenarios: Beta version + non-empty allowlist + pre-existing canonical SQLite state; fresh SQLite + beta version (first-run inference)
  • Edge cases checked: SQLite temporarily unavailable (try/catch fallback); explicit plugins.bundledDiscovery config path (not affected); empty allowlist (inference not triggered); other migration entries (kept reporting unchanged)
  • What you did NOT verify: Other migration sources for the same pattern; production gateway startup with real plugins

Compatibility / Migration

  • Backward compatible? Yes — inference behavior unchanged for first-run scenarios
  • Config/env changes? No
  • Migration needed? No

Best-fix Verdict

  • Best fix: Yes — skipping the inference at the source when canonical state already exists is the most targeted and self-documenting approach
  • Refactor needed: No — the fix is a focused 12-line addition
  • Alternative considered: (1) Only report result.imported in changes, not result.kept — would suppress useful kept reporting for explicit fields. (2) Track whether entry was inferred vs explicit and filter — more complex, no benefit over current approach

AI Assistance

  • AI-assisted: Yes
  • Co-Authored-By: Claude [email protected]
  • Human confirmed understanding of code changes: Yes
  • AI prompts / session excerpts: Analysis → design (self-critique → v2 with try/catch + test assertion fixes) → implementation → verification

Risks and Mitigations

  • Highest risk area: If readConfigMachineState throws (corrupt SQLite, permission error), the try/catch ensures compat is still inferred (safe fallback)
  • Mitigation: The try/catch block catches all errors and falls through to the existing inference path
  • Compatibility: No breaking change — existing users on stable releases (>= 2026.7.2) are not affected; beta users see the same canonical value, just without the misleading Doctor output

Fixes #115151

Beta versions (e.g. 2026.7.2-beta.5) are treated by SemVer as older than
the cutover release (2026.7.2), so migrateLegacyConfigMachineState would
re-infer plugins.bundledDiscovery = "compat" on every new CLI process.
The inferred entry always went into importConfigMachineState's 'kept'
bucket, which was then reported as a Doctor change — producing misleading
"Auto-migrated legacy state" / "Kept existing shared SQLite ..." output
on every restart.

Fix: skip the inferred compat candidate when the canonical SQLite row
already exists. A try/catch guards against temporary SQLite
unavailability.

Related to openclaw#115151

Co-Authored-By: Claude <[email protected]>
@SunnyShu0925

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Command router queued. I will update this comment with the next step.

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. P2 Normal backlog priority with limited blast radius. labels Jul 28, 2026
@clawsweeper

clawsweeper Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed July 28, 2026, 11:30 AM ET / 15:30 UTC.

ClawSweeper review

What this changes

The branch avoids repeatedly reporting an inferred plugins.bundledDiscovery SQLite migration on beta versions once the canonical state value already exists.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

This PR remains necessary as the focused candidate fix for the repeated beta Doctor migration report tracked by #115151. The proposed gate preserves first-run inference while preventing a pre-existing canonical SQLite value from being re-imported and reported as a new change; no discrete patch defect is supported by the available source, history, and proof evidence.

Priority: P2
Reviewed head: 2b55a5436002cfcc6640d3d8f0026ac4dcf95085

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, regression-tested repair with credible direct behavior evidence; only a current-main refresh is advisable because the branch is behind base.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The PR body supplies after-fix Linux/Node live output for the relevant first-pass and second-pass SQLite migration behavior; it shows the canonical value remains intact and the repeated report disappears.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The PR body supplies after-fix Linux/Node live output for the relevant first-pass and second-pass SQLite migration behavior; it shows the canonical value remains intact and the repeated report disappears.
Evidence reviewed 5 items Changed migration boundary: The branch checks canonical shared SQLite state before adding the inferred plugins.bundledDiscovery = compat candidate; explicit config imports and the downstream import/reporting contract are otherwise untouched.
Focused regression coverage: The added test establishes a beta-stamped allowlist case, verifies the first call stores compat, then verifies the second pass does not report the kept SQLite state while preserving the canonical value.
Feature provenance: The linked merged config-surface reduction work introduced the SQLite-first bundled-discovery migration and documented it as idempotent, matching this PR's narrow correction to repeated reporting rather than a new config contract.
Findings None None.
Security None None.

How this fits together

Doctor's legacy-config migration converts retired config-derived machine state into canonical shared SQLite state before CLI and gateway flows report migration changes. This change affects the inferred bundled-plugin discovery state so repeated preflight runs stop producing misleading migration output while fresh upgrades still retain the compatibility value.

flowchart TD
  A[Legacy config and version stamp] --> B[Doctor state migration]
  C[Shared SQLite machine state] --> D{Canonical bundled-discovery value exists?}
  B --> D
  D -->|No| E[Infer compat and import state]
  D -->|Yes| F[Skip redundant inferred import]
  E --> G[Doctor migration report]
  F --> G
  G --> H[CLI status and gateway startup output]
Loading

Before merge

  • Resolve merge risk (P1) - The branch is behind current main; before landing, refresh the focused migration regression test against the actual merge head so the small SQLite read-before-import change is verified with intervening migration edits.
  • Complete next step (P2) - No repair lane is needed: this is already a focused implementation PR with no supported actionable patch finding.
Agent review details

Security

None.

PR surface

Source +16, Tests +32. Total +48 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 17 1 +16
Tests 1 32 0 +32
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 49 1 +48

Review metrics

None.

Stored data model

Persistent data-model change detected: serialized state: src/infra/state-migrations.config-machine-state.test.ts, serialized state: src/infra/state-migrations.config-machine-state.ts. Migration or upgrade compatibility proof is recorded; maintainers should verify it before merge.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Keep the canonical SQLite state as the single source of truth and land this narrow inferred-candidate gate after rebasing or otherwise refreshing proof on current main, while retaining first-run compatibility inference for pre-cutover configurations.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Keep the canonical SQLite state as the single source of truth and land this narrow inferred-candidate gate after rebasing or otherwise refreshing proof on current main, while retaining first-run compatibility inference for pre-cutover configurations.

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

No independent current-main run was performed in this review, but the source path and supplied focused scenario make the defect reproducible with a beta version stamp, a non-empty plugin allowlist, and an existing plugins.bundledDiscovery SQLite row.

Is this the best way to solve the issue?

Yes. Gating only the inferred compatibility candidate when canonical state already exists is narrower than suppressing all kept-state reporting, so it preserves explicit migration diagnostics and first-run behavior.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 58a3679c4923.

Labels

Label changes:

  • add P2: This is a bounded regression in Doctor/CLI migration reporting that causes persistent user-facing noise but does not alter or lose canonical state.
  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR body supplies after-fix Linux/Node live output for the relevant first-pass and second-pass SQLite migration behavior; it shows the canonical value remains intact and the repeated report disappears.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR body supplies after-fix Linux/Node live output for the relevant first-pass and second-pass SQLite migration behavior; it shows the canonical value remains intact and the repeated report disappears.

Label justifications:

  • P2: This is a bounded regression in Doctor/CLI migration reporting that causes persistent user-facing noise but does not alter or lose canonical state.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR body supplies after-fix Linux/Node live output for the relevant first-pass and second-pass SQLite migration behavior; it shows the canonical value remains intact and the repeated report disappears.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body supplies after-fix Linux/Node live output for the relevant first-pass and second-pass SQLite migration behavior; it shows the canonical value remains intact and the repeated report disappears.

Evidence

What I checked:

  • Changed migration boundary: The branch checks canonical shared SQLite state before adding the inferred plugins.bundledDiscovery = compat candidate; explicit config imports and the downstream import/reporting contract are otherwise untouched. (src/infra/state-migrations.config-machine-state.ts:61, 2b55a5436002)
  • Focused regression coverage: The added test establishes a beta-stamped allowlist case, verifies the first call stores compat, then verifies the second pass does not report the kept SQLite state while preserving the canonical value. (src/infra/state-migrations.config-machine-state.test.ts:199, 2b55a5436002)
  • Feature provenance: The linked merged config-surface reduction work introduced the SQLite-first bundled-discovery migration and documented it as idempotent, matching this PR's narrow correction to repeated reporting rather than a new config contract. (src/infra/state-migrations.config-machine-state.ts:57, edecdbd05efc)
  • After-fix behavior evidence: The PR body includes a real Linux/Node run showing first-pass inference and persistence followed by an empty change list on the second pass, with the SQLite value remaining compat. (2b55a5436002)
  • Current review state: The branch is cleanly mergeable but behind its base, and the supplied checks include successful build, guard, lint, type, smoke, proof, and security lanes. Refreshing the focused test on the merged head remains appropriate before landing. (58a3679c4923)

Likely related people:

  • steipete: The merged config-surface reduction work introduced the bounded Doctor compatibility migration and its bundled-discovery state handling. (role: feature introducer; confidence: high; commits: edecdbd05efc; files: src/infra/state-migrations.config-machine-state.ts)
  • fuller-stack-dev: The later device-auth upgrade migration materially maintained the same config-machine-state migration module and shared SQLite migration boundary. (role: recent area contributor; confidence: medium; commits: 7eec1345f98e; files: src/infra/state-migrations.config-machine-state.ts)

Rank-up moves

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

  • Rebase or otherwise validate the focused migration test on the current merge head before landing.

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 merged commit f5ab77a into openclaw:main Jul 29, 2026
131 of 134 checks passed
@steipete

Copy link
Copy Markdown
Contributor

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 29, 2026
…eta (openclaw#115208)

Beta versions (e.g. 2026.7.2-beta.5) are treated by SemVer as older than
the cutover release (2026.7.2), so migrateLegacyConfigMachineState would
re-infer plugins.bundledDiscovery = "compat" on every new CLI process.
The inferred entry always went into importConfigMachineState's 'kept'
bucket, which was then reported as a Doctor change — producing misleading
"Auto-migrated legacy state" / "Kept existing shared SQLite ..." output
on every restart.

Fix: skip the inferred compat candidate when the canonical SQLite row
already exists. A try/catch guards against temporary SQLite
unavailability.

Related to openclaw#115151

Co-authored-by: Claude <[email protected]>
vincentkoc added a commit that referenced this pull request Jul 29, 2026
…ifecycle-hooks

* origin/main:
  fix(mattermost): key private channels as group on outbound routing (#96645)
  fix(ci): grant Telegram QA runtime scratch access (#115659)
  fix(telegram): stop retrying blocked recipients (#115640)
  fix(tts): persist generated speech in media store (#115647)
  fix(gateway): preserve complete streamed chat completions (#115652)
  fix(mac): prevent app auth from blocking node-host startup (#115533)
  fix(heartbeat): keep message-tool final replies private (#115629)
  fix(gateway): drain root work continuations before direct-stop process exit (#105848)
  fix(ollama): keep active streams within their idle timeout (#115648)
  fix(delivery): keep session keys out of inferred message targets (#115657)
  fix(ci): type code mode matrix catch callback (#115674)
  refactor(agents): centralize bundled CLI backend auth policy (#115633)
  refactor: remove 3,527 lines of runtime and test duplication (#115626)
  [AI] fix(doctor): stop repeated bundledDiscovery migration noise on beta (#115208)

# Conflicts:
#	scripts/code-mode-model-matrix.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: 2026.7.2 beta repeatedly reports a no-op bundledDiscovery migration as Doctor changes

2 participants