Skip to content

Commit c105fad

Browse files
committed
perf(doctor): avoid loading unused plugin runtimes
1 parent 0c487c9 commit c105fad

10 files changed

Lines changed: 458 additions & 394 deletions

‎CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ Docs: https://docs.openclaw.ai
3434

3535
### Fixes
3636

37+
- **Doctor memory:** keep Matrix migration codecs separate from the live client and avoid loading the ACP runtime when no legacy session records need inspection.
3738
- **Agent prompts:** keep model-identity guidance conditional so ordinary requests are not mistaken for questions about the current model.
3839

3940
- **Update/Doctor:** preserve `update --no-restart` by requiring an offline managed Gateway during updater-owned repair and leaving restart ownership with the parent.

‎config/assertion-safety-baseline.txt‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,6 @@ extensions/matrix/src/matrix/actions/summary.ts 2
657657
extensions/matrix/src/matrix/actions/verification.ts 1
658658
extensions/matrix/src/matrix/client-bootstrap.ts 1
659659
extensions/matrix/src/matrix/client/config.ts 5
660-
extensions/matrix/src/matrix/client/file-sync-store.ts 5
661660
extensions/matrix/src/matrix/client/logging.ts 3
662661
extensions/matrix/src/matrix/client/runtime.ts 1
663662
extensions/matrix/src/matrix/config-update.ts 4

‎extensions/acpx/src/session-owner-migration.test.ts‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,34 @@ async function fixture(mode: "persistent" | "oneshot" = "persistent", sessionKey
134134
};
135135
}
136136

137+
it.each(["missing", "empty"])(
138+
"does not inspect session claims when the legacy directory is %s",
139+
async (directoryState) => {
140+
const directory = directories.make("acpx-empty-owner-migration-");
141+
if (directoryState === "empty") {
142+
await fs.mkdir(path.join(directory, "state", "sessions"), { recursive: true });
143+
}
144+
const context: PluginDoctorStateMigrationContext = {
145+
openPluginStateKeyedStore() {
146+
throw new Error("No record requires a state store");
147+
},
148+
async inspectAcpSessionClaims() {
149+
throw new Error("No record requires canonical ownership evidence");
150+
},
151+
};
152+
await expect(
153+
acpxSessionOwnerMigration.detectLegacyState({
154+
config: {},
155+
env: { ...process.env, OPENCLAW_STATE_DIR: directory },
156+
stateDir: directory,
157+
oauthDir: path.join(directory, "oauth"),
158+
serviceWorkspaceDir: directory,
159+
context,
160+
}),
161+
).resolves.toBeNull();
162+
},
163+
);
164+
137165
it.each(["none", "publication", "canonical"])(
138166
"preserves raw history and resumes idempotently after interruption=%s",
139167
async (interrupted) => {

‎extensions/acpx/src/session-owner-migration.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ async function legacyRecords(input: MigrationInput): Promise<{ directory: string
4848
.filter((name) => name.endsWith(".json"))
4949
.map((name) => decodeURIComponent(name.slice(0, -5)))
5050
.filter((id) => !id.startsWith("agent:") && !id.startsWith(".openclaw-owner-"));
51+
if (ids.length === 0) {
52+
return { directory, ids };
53+
}
5154
const evidence = await input.context.inspectAcpSessionClaims?.();
5255
const { decodeAcpxRuntimeHandleState } = await import("acpx/runtime");
5356
return {

‎extensions/matrix/doctor-contract-api.ts‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,20 @@ import {
1212
requiresExplicitMatrixDefaultAccount,
1313
resolveMatrixDefaultOrOnlyAccountId,
1414
} from "./src/account-selection.js";
15-
import {
16-
hasMatrixSyncCacheStateInStore,
17-
openMatrixSyncCacheStoreOptions,
18-
readLegacyMatrixSyncCacheState,
19-
writeMatrixSyncCacheStateToStore,
20-
type MatrixSyncCacheRecord,
21-
} from "./src/matrix/client/file-sync-store.js";
2215
import {
2316
hasMatrixStorageMetaStateInStore,
2417
normalizeMatrixStorageMetadata,
2518
openMatrixStorageMetaStoreOptions,
2619
writeMatrixStorageMetaStateToStore,
2720
type MatrixStorageMetadata,
2821
} from "./src/matrix/client/storage.js";
22+
import {
23+
hasMatrixSyncCacheStateInStore,
24+
openMatrixSyncCacheStoreOptions,
25+
readLegacyMatrixSyncCacheState,
26+
writeMatrixSyncCacheStateToStore,
27+
type MatrixSyncCacheRecord,
28+
} from "./src/matrix/client/sync-cache-state.js";
2929
import {
3030
MATRIX_CREDENTIALS_MAX_ENTRIES,
3131
MATRIX_CREDENTIALS_NAMESPACE,

‎extensions/matrix/src/matrix/client/file-sync-store.test.ts‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,9 @@ import {
1010
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
1111
import { getMatrixRuntime } from "../../runtime.js";
1212
import { installMatrixTestRuntime } from "../../test-runtime.js";
13-
import {
14-
openMatrixSyncCacheStoreOptions,
15-
SqliteBackedMatrixSyncStore,
16-
type MatrixSyncCacheRecord,
17-
} from "./file-sync-store.js";
13+
import { SqliteBackedMatrixSyncStore } from "./file-sync-store.js";
1814
import { openMatrixStorageMetaStoreOptions } from "./storage.js";
15+
import { openMatrixSyncCacheStoreOptions, type MatrixSyncCacheRecord } from "./sync-cache-state.js";
1916

2017
function createSyncResponse(nextBatch: string): ISyncResponse {
2118
return {

0 commit comments

Comments
 (0)