Skip to content

Commit 2b55a54

Browse files
SunnyShu0925claude
andcommitted
[AI] fix(doctor): stop repeated bundledDiscovery migration noise on beta
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 #115151 Co-Authored-By: Claude <[email protected]>
1 parent fe9893d commit 2b55a54

2 files changed

Lines changed: 49 additions & 1 deletion

File tree

‎src/infra/state-migrations.config-machine-state.test.ts‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,4 +196,36 @@ describe("legacy config machine-state migration", () => {
196196

197197
expect(readControlUiDeviceAuthMigrationState({ env })).toBeUndefined();
198198
});
199+
200+
it("does not re-report inferred bundledDiscovery on second pass with beta version", () => {
201+
const stateDir = mkdtempSync(join(tmpdir(), "openclaw-config-machine-state-"));
202+
const env = { ...process.env, OPENCLAW_STATE_DIR: stateDir };
203+
204+
// First pass: infer compat and write to SQLite
205+
const firstResult = migrateLegacyConfigMachineState({
206+
env,
207+
config: {
208+
meta: { lastTouchedVersion: "2026.7.2-beta.5" },
209+
plugins: { allow: ["telegram"] },
210+
},
211+
});
212+
expect(firstResult.changes).toContain(
213+
"Migrated plugins.bundledDiscovery → shared SQLite state",
214+
);
215+
expect(readConfigMachineState("plugins.bundledDiscovery", { env })).toBe("compat");
216+
217+
// Second pass (simulating a new CLI process): should not report kept
218+
const secondResult = migrateLegacyConfigMachineState({
219+
env,
220+
config: {
221+
meta: { lastTouchedVersion: "2026.7.2-beta.5" },
222+
plugins: { allow: ["telegram"] },
223+
},
224+
});
225+
expect(secondResult.changes).not.toContain(
226+
"Kept existing shared SQLite plugins.bundledDiscovery state",
227+
);
228+
// Canonical value is preserved
229+
expect(readConfigMachineState("plugins.bundledDiscovery", { env })).toBe("compat");
230+
});
199231
});

‎src/infra/state-migrations.config-machine-state.ts‎

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import type { OpenClawConfig } from "../config/types.openclaw.js";
33
import { compareOpenClawVersions } from "../config/version.js";
44
import {
55
importConfigMachineState,
6+
readConfigMachineState,
67
updateConfigMachineState,
78
} from "../state/config-machine-state.js";
89
import {
@@ -57,7 +58,22 @@ export function migrateLegacyConfigMachineState(params: {
5758
compareOpenClawVersions(meta.lastTouchedVersion, BUNDLED_DISCOVERY_STATE_CUTOVER_VERSION) ===
5859
-1)
5960
) {
60-
entries.push(["plugins.bundledDiscovery", "compat"]);
61+
// Only infer compat when the canonical SQLite row does not already exist.
62+
// Beta versions (e.g. 2026.7.2-beta.5) are treated by SemVer as older than
63+
// the cutover release (2026.7.2), so the inference re-fires on every new
64+
// CLI process. Checking for an existing canonical value here avoids
65+
// re-reporting the already-preserved state as a Doctor change.
66+
let hasCanonicalState = false;
67+
try {
68+
hasCanonicalState =
69+
readConfigMachineState("plugins.bundledDiscovery", { env: params.env }) !== undefined;
70+
} catch {
71+
// SQLite temporarily unavailable — fall through to infer compat;
72+
// importConfigMachineState below will handle it.
73+
}
74+
if (!hasCanonicalState) {
75+
entries.push(["plugins.bundledDiscovery", "compat"]);
76+
}
6177
}
6278
const tts = record(raw.tts);
6379
if (tts && Object.hasOwn(tts, "prefsPath")) {

0 commit comments

Comments
 (0)