Skip to content

Commit 72912b1

Browse files
authored
fix(memory): keep doctor discovery free of database imports (#129963)
1 parent 2941b3d commit 72912b1

4 files changed

Lines changed: 13 additions & 37 deletions

File tree

‎extensions/memory-core/src/migration/doctor-dreaming-state.ts‎

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,6 @@ import {
2424
// Import from the defining modules, not the short-term-promotion barrel: the
2525
// barrel pulls memory-host-events/kysely, which doctor enumeration cold-loads.
2626
import { normalizeShortTermPhaseSignalStore } from "../short-term-promotion-store.js";
27-
import {
28-
SHORT_TERM_PHASE_SIGNAL_RELATIVE_PATH,
29-
SHORT_TERM_STORE_RELATIVE_PATH,
30-
} from "../short-term-promotion-types.js";
3127
import { normalizeShortTermRecallStore } from "../short-term-promotion-utils.js";
3228
import { resolveConfiguredWorkspaces } from "./doctor-workspaces.js";
3329
import { dreamingStateComparison } from "./dreaming-state-comparison.js";
@@ -38,17 +34,6 @@ type LegacySource = {
3834
filePath: string;
3935
};
4036

41-
const LEGACY_DAILY_INGESTION_STATE_RELATIVE_PATH = path.join(
42-
"memory",
43-
".dreams",
44-
"daily-ingestion.json",
45-
);
46-
const LEGACY_SESSION_INGESTION_STATE_RELATIVE_PATH = path.join(
47-
"memory",
48-
".dreams",
49-
"session-ingestion.json",
50-
);
51-
5237
async function readJsonFile(filePath: string): Promise<unknown> {
5338
return JSON.parse(await fs.readFile(filePath, "utf8"));
5439
}
@@ -58,15 +43,15 @@ async function collectLegacySources(
5843
env: NodeJS.ProcessEnv,
5944
): Promise<LegacySource[]> {
6045
const sources: LegacySource[] = [];
61-
for (const workspaceDir of resolveConfiguredWorkspaces(config, env)) {
46+
for (const workspaceDir of await resolveConfiguredWorkspaces(config, env)) {
6247
const candidates = [
63-
{ label: "daily ingestion", relativePath: LEGACY_DAILY_INGESTION_STATE_RELATIVE_PATH },
64-
{ label: "session ingestion", relativePath: LEGACY_SESSION_INGESTION_STATE_RELATIVE_PATH },
65-
{ label: "short-term recall", relativePath: SHORT_TERM_STORE_RELATIVE_PATH },
66-
{ label: "phase signals", relativePath: SHORT_TERM_PHASE_SIGNAL_RELATIVE_PATH },
48+
{ label: "daily ingestion", fileName: "daily-ingestion.json" },
49+
{ label: "session ingestion", fileName: "session-ingestion.json" },
50+
{ label: "short-term recall", fileName: "short-term-recall.json" },
51+
{ label: "phase signals", fileName: "phase-signals.json" },
6752
];
6853
for (const candidate of candidates) {
69-
const filePath = path.join(workspaceDir, candidate.relativePath);
54+
const filePath = path.join(workspaceDir, "memory", ".dreams", candidate.fileName);
7055
if (await legacyStateFileExists(filePath)) {
7156
sources.push({ workspaceDir, label: candidate.label, filePath });
7257
}

‎extensions/memory-core/src/migration/doctor-host-event-sources.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export async function collectLegacyMemoryHostEventSources(
4949
const { resolveMemoryHostEventLogPath } = await import("openclaw/plugin-sdk/memory-host-events");
5050
const sources: LegacyMemoryHostEventSource[] = [];
5151
const seenWorkspaces = new Set<string>();
52-
for (const workspaceDir of resolveConfiguredWorkspaces(config, env)) {
52+
for (const workspaceDir of await resolveConfiguredWorkspaces(config, env)) {
5353
let canonicalWorkspaceDir = path.resolve(workspaceDir);
5454
let filePath = resolveMemoryHostEventLogPath(canonicalWorkspaceDir);
5555
try {

‎extensions/memory-core/src/migration/doctor-workspaces.ts‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
import { resolveMemoryDreamingWorkspaces } from "openclaw/plugin-sdk/memory-core-host-status";
2-
3-
export function resolveConfiguredWorkspaces(config: unknown, env: NodeJS.ProcessEnv): string[] {
1+
export async function resolveConfiguredWorkspaces(
2+
config: unknown,
3+
env: NodeJS.ProcessEnv,
4+
): Promise<string[]> {
5+
const { resolveMemoryDreamingWorkspaces } =
6+
await import("openclaw/plugin-sdk/memory-core-host-status");
47
return resolveMemoryDreamingWorkspaces(
58
config as Parameters<typeof resolveMemoryDreamingWorkspaces>[0],
69
{ env },

‎extensions/memory-core/src/short-term-promotion-types.ts‎

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import path from "node:path";
21
import type { MemoryEntryProvenance } from "openclaw/plugin-sdk/memory-core-host-runtime-files";
32
import {
43
DEFAULT_MEMORY_DEEP_DREAMING_MIN_RECALL_COUNT,
@@ -10,17 +9,6 @@ import type { ConceptTagScriptCoverage } from "./concept-vocabulary.js";
109
export const DEFAULT_PROMOTION_MIN_SCORE = DEFAULT_MEMORY_DEEP_DREAMING_MIN_SCORE;
1110
export const DEFAULT_PROMOTION_MIN_RECALL_COUNT = DEFAULT_MEMORY_DEEP_DREAMING_MIN_RECALL_COUNT;
1211
export const DEFAULT_PROMOTION_MIN_UNIQUE_QUERIES = DEFAULT_MEMORY_DEEP_DREAMING_MIN_UNIQUE_QUERIES;
13-
export const SHORT_TERM_STORE_RELATIVE_PATH = path.join(
14-
"memory",
15-
".dreams",
16-
"short-term-recall.json",
17-
);
18-
export const SHORT_TERM_PHASE_SIGNAL_RELATIVE_PATH = path.join(
19-
"memory",
20-
".dreams",
21-
"phase-signals.json",
22-
);
23-
2412
export type PromotionWeights = {
2513
frequency: number;
2614
relevance: number;

0 commit comments

Comments
 (0)