

























@@ -42,8 +42,8 @@ const rootMemoryConfig = (workspaceDir: string): OpenClawConfig =>
4242},
4343}) as OpenClawConfig;
444445-const collectionNames = (resolved: ResolvedMemoryBackendConfig): Set<string> =>
46-new Set((resolved.qmd?.collections ?? []).map((collection) => collection.name));
45+const collectionNames = (resolved: ResolvedMemoryBackendConfig): string[] =>
46+(resolved.qmd?.collections ?? []).map((collection) => collection.name).toSorted();
47474848function requireQmdConfig(
4949resolved: ResolvedMemoryBackendConfig,
@@ -73,7 +73,9 @@ const customQmdCollections = (
7373(resolved.qmd?.collections ?? []).filter((collection) => collection.kind === "custom");
74747575const customCollectionPaths = (resolved: ResolvedMemoryBackendConfig): string[] =>
76-customQmdCollections(resolved).map((collection) => collection.path);
76+customQmdCollections(resolved)
77+.map((collection) => collection.path)
78+.toSorted();
77797880let fixtureRoot: string;
7981let fixtureId = 0;
@@ -125,10 +127,7 @@ describe("resolveMemoryBackendConfig", () => {
125127expect(qmd.update.commandTimeoutMs).toBe(30_000);
126128expect(qmd.update.updateTimeoutMs).toBe(120_000);
127129expect(qmd.update.embedTimeoutMs).toBe(120_000);
128-const names = new Set(qmd.collections.map((collection) => collection.name));
129-expect(names.has("memory-root-main")).toBe(true);
130-expect(names.has("memory-dir-main")).toBe(true);
131-expect(names.has("memory-alt-main")).toBe(false);
130+expect(collectionNames(resolved)).toStrictEqual(["memory-dir-main", "memory-root-main"]);
132131expect(requireQmdCollection(resolved, "memory-root-main").pattern).toBe("MEMORY.md");
133132});
134133@@ -138,7 +137,7 @@ describe("resolveMemoryBackendConfig", () => {
138137const cfg = rootMemoryConfig(workspaceDir);
139138const resolved = resolveMemoryBackendConfig({ cfg, agentId: "main" });
140139expect(requireQmdCollection(resolved, "memory-root-main").pattern).toBe("MEMORY.md");
141-expect(collectionNames(resolved).has("memory-alt-main")).toBe(false);
140+expect(collectionNames(resolved)).toStrictEqual(["memory-dir-main", "memory-root-main"]);
142141});
143142});
144143@@ -148,7 +147,7 @@ describe("resolveMemoryBackendConfig", () => {
148147const cfg = rootMemoryConfig(workspaceDir);
149148const resolved = resolveMemoryBackendConfig({ cfg, agentId: "main" });
150149expect(requireQmdCollection(resolved, "memory-root-main").pattern).toBe("MEMORY.md");
151-expect(collectionNames(resolved).has("memory-alt-main")).toBe(false);
150+expect(collectionNames(resolved)).toStrictEqual(["memory-dir-main", "memory-root-main"]);
152151});
153152});
154153@@ -216,10 +215,8 @@ describe("resolveMemoryBackendConfig", () => {
216215const devResolved = resolveMemoryBackendConfig({ cfg, agentId: "dev" });
217216const mainNames = collectionNames(mainResolved);
218217const devNames = collectionNames(devResolved);
219-expect(mainNames.has("memory-dir-main")).toBe(true);
220-expect(devNames.has("memory-dir-dev")).toBe(true);
221-expect(mainNames.has("workspace-main")).toBe(true);
222-expect(devNames.has("workspace-dev")).toBe(true);
218+expect(mainNames).toStrictEqual(["memory-dir-main", "memory-root-main", "workspace-main"]);
219+expect(devNames).toStrictEqual(["memory-dir-dev", "memory-root-dev", "workspace-dev"]);
223220});
224221225222it("merges default and per-agent qmd extra collections", () => {
@@ -267,8 +264,7 @@ describe("resolveMemoryBackendConfig", () => {
267264} as OpenClawConfig;
268265const resolved = resolveMemoryBackendConfig({ cfg, agentId: "main" });
269266const names = collectionNames(resolved);
270-expect(names.has("team-notes")).toBe(true);
271-expect(names.has("notes-main")).toBe(true);
267+expect(names).toStrictEqual(["notes-main", "team-notes"]);
272268});
273269274270it("preserves explicit custom collection names for paths outside the workspace", () => {
@@ -292,10 +288,8 @@ describe("resolveMemoryBackendConfig", () => {
292288const devResolved = resolveMemoryBackendConfig({ cfg, agentId: "dev" });
293289const mainNames = collectionNames(mainResolved);
294290const devNames = collectionNames(devResolved);
295-expect(mainNames.has("memory-dir-main")).toBe(true);
296-expect(devNames.has("memory-dir-dev")).toBe(true);
297-expect(mainNames.has("notion-mirror")).toBe(true);
298-expect(devNames.has("notion-mirror")).toBe(true);
291+expect(mainNames).toStrictEqual(["memory-dir-main", "memory-root-main", "notion-mirror"]);
292+expect(devNames).toStrictEqual(["memory-dir-dev", "memory-root-dev", "notion-mirror"]);
299293});
300294301295it("keeps symlinked workspace paths agent-scoped when deciding custom collection names", async () => {
@@ -319,8 +313,7 @@ describe("resolveMemoryBackendConfig", () => {
319313} as OpenClawConfig;
320314const resolved = resolveMemoryBackendConfig({ cfg, agentId: "main" });
321315const names = collectionNames(resolved);
322-expect(names.has("workspace-main")).toBe(true);
323-expect(names.has("workspace")).toBe(false);
316+expect(names).toStrictEqual(["workspace-main"]);
324317});
325318326319it("keeps unresolved child paths under a symlinked workspace agent-scoped", async () => {
@@ -348,8 +341,7 @@ describe("resolveMemoryBackendConfig", () => {
348341} as OpenClawConfig;
349342const resolved = resolveMemoryBackendConfig({ cfg, agentId: "main" });
350343const names = collectionNames(resolved);
351-expect(names.has("notes-main")).toBe(true);
352-expect(names.has("notes")).toBe(false);
344+expect(names).toStrictEqual(["notes-main"]);
353345});
354346355347it("resolves qmd update timeout overrides", () => {
@@ -443,9 +435,10 @@ describe("memorySearch.extraPaths integration", () => {
443435const result = resolveMemoryBackendConfig({ cfg, agentId: "test-agent" });
444436expect(result.backend).toBe("qmd");
445437const paths = customCollectionPaths(result);
446-expect(paths.length).toBeGreaterThanOrEqual(2);
447-expect(paths).toContain(resolveComparablePath("/home/user/docs"));
448-expect(paths).toContain(resolveComparablePath("/home/user/vault"));
438+expect(paths).toStrictEqual([
439+resolveComparablePath("/home/user/docs"),
440+resolveComparablePath("/home/user/vault"),
441+]);
449442});
450443451444it("merges default and per-agent memorySearch.extraPaths for QMD collections", () => {
@@ -471,8 +464,10 @@ describe("memorySearch.extraPaths integration", () => {
471464const result = resolveMemoryBackendConfig({ cfg, agentId: "my-agent" });
472465expect(result.backend).toBe("qmd");
473466const paths = customCollectionPaths(result);
474-expect(paths).toContain(resolveComparablePath("/agent/specific/path"));
475-expect(paths).toContain(resolveComparablePath("/default/path"));
467+expect(paths).toStrictEqual([
468+resolveComparablePath("/agent/specific/path"),
469+resolveComparablePath("/default/path"),
470+]);
476471});
477472478473it("falls back to defaults when agent has no overrides", () => {
@@ -498,7 +493,7 @@ describe("memorySearch.extraPaths integration", () => {
498493const result = resolveMemoryBackendConfig({ cfg, agentId: "my-agent" });
499494expect(result.backend).toBe("qmd");
500495const paths = customCollectionPaths(result);
501-expect(paths).toContain(resolveComparablePath("/default/path"));
496+expect(paths).toStrictEqual([resolveComparablePath("/default/path")]);
502497});
503498504499it("deduplicates merged memorySearch.extraPaths for QMD collections", () => {
@@ -525,10 +520,10 @@ describe("memorySearch.extraPaths integration", () => {
525520const result = resolveMemoryBackendConfig({ cfg, agentId: "my-agent" });
526521const paths = customCollectionPaths(result);
527522528-expect(
529-paths.filter((collectionPath) => collectionPath === resolveComparablePath("/shared/path")),
530-).toHaveLength(1);
531-expect(paths).toContain(resolveComparablePath("/agent-only"));
523+expect(paths).toStrictEqual([
524+resolveComparablePath("/agent-only"),
525+ resolveComparablePath("/shared/path"),
526+]);
532527});
533528534529it("keeps unnamed extra paths agent-scoped even when they resolve outside the workspace", () => {
@@ -544,9 +539,9 @@ describe("memorySearch.extraPaths integration", () => {
544539},
545540} as OpenClawConfig;
546541const result = resolveMemoryBackendConfig({ cfg, agentId: "my-agent" });
547-expect(customQmdCollections(result).map((collection) => collection.name)).toContain(
542+expect(customQmdCollections(result).map((collection) => collection.name)).toStrictEqual([
548543"custom-1-my-agent",
549-);
544+]);
550545});
551546552547it("matches per-agent memorySearch.extraPaths using normalized agent ids", () => {
@@ -569,7 +564,9 @@ describe("memorySearch.extraPaths integration", () => {
569564570565const result = resolveMemoryBackendConfig({ cfg, agentId: "my-agent" });
571566572-expect(customCollectionPaths(result)).toContain(resolveComparablePath("/agent/mixed-case"));
567+expect(customCollectionPaths(result)).toStrictEqual([
568+resolveComparablePath("/agent/mixed-case"),
569+]);
573570});
574571575572it("deduplicates identical roots shared by memory.qmd.paths and memorySearch.extraPaths", () => {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。