

















@@ -10,6 +10,7 @@ import {
1010} from "openclaw/plugin-sdk/memory-core-host-engine-foundation";
1111import type {
1212MemorySource,
13+MemorySyncParams,
1314MemorySyncProgressUpdate,
1415} from "openclaw/plugin-sdk/memory-core-host-engine-storage";
1516import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
@@ -27,6 +28,7 @@ type MemoryIndexEntry = {
2728type SyncParams = {
2829reason?: string;
2930force?: boolean;
31+sessions?: MemorySyncParams["sessions"];
3032sessionFiles?: string[];
3133progress?: (update: MemorySyncProgressUpdate) => void;
3234};
@@ -38,14 +40,33 @@ class SessionStartupCatchupHarness extends MemoryManagerSyncOps {
3840protected readonly agentId = "main";
3941protected readonly workspaceDir = "/tmp/openclaw-test-workspace";
4042protected readonly settings = {
43+chunking: {
44+overlap: 0,
45+tokens: 256,
46+},
47+extraPaths: [],
48+multimodal: {
49+enabled: false,
50+modalities: [],
51+maxFileBytes: 0,
52+},
53+provider: "none",
54+store: {
55+fts: {
56+tokenizer: "unicode61",
57+},
58+vector: {
59+enabled: false,
60+},
61+},
4162sync: {
4263sessions: {
4364deltaBytes: 100_000,
4465deltaMessages: 50,
4566postCompactionForce: true,
4667},
4768},
48-} as ResolvedMemorySearchConfig;
69+} as unknown as ResolvedMemorySearchConfig;
4970protected readonly batch = {
5071enabled: false,
5172wait: false,
@@ -60,6 +81,7 @@ class SessionStartupCatchupHarness extends MemoryManagerSyncOps {
6081protected db: DatabaseSync;
61826283readonly syncCalls: SyncParams[] = [];
84+readonly indexedPaths: string[] = [];
63856486constructor(sourceRows: SourceStateRow[]) {
6587super();
@@ -81,6 +103,10 @@ class SessionStartupCatchupHarness extends MemoryManagerSyncOps {
81103return await this.markSessionStartupCatchupDirtyFiles();
82104}
83105106+async runSyncForTest(params?: MemorySyncParams): Promise<void> {
107+await this.runSync(params);
108+}
109+84110getDirtySessionFiles(): string[] {
85111return Array.from(this.sessionsDirtyFiles);
86112}
@@ -97,7 +123,7 @@ class SessionStartupCatchupHarness extends MemoryManagerSyncOps {
97123return [];
98124}
99125100-protected async sync(params?: SyncParams): Promise<void> {
126+protected async sync(params?: MemorySyncParams): Promise<void> {
101127this.syncCalls.push(params ?? {});
102128}
103129@@ -120,9 +146,11 @@ class SessionStartupCatchupHarness extends MemoryManagerSyncOps {
120146protected assertRequiredProviderAvailable(): void {}
121147122148protected async indexFile(
123-_entry: MemoryIndexEntry,
149+entry: MemoryIndexEntry,
124150_options: { source: MemorySource; content?: string },
125-): Promise<void> {}
151+): Promise<void> {
152+this.indexedPaths.push(entry.path);
153+}
126154}
127155128156describe("session startup catch-up", () => {
@@ -304,4 +332,28 @@ describe("session startup catch-up", () => {
304332openSpy.mockRestore();
305333}
306334});
335+336+it("does not fall back to full session sync when identity targets normalize away", async () => {
337+await writeSessionFile("thread.jsonl");
338+const harness = new SessionStartupCatchupHarness([]);
339+340+await harness.runSyncForTest({
341+reason: "queued-sessions",
342+sessions: [{ agentId: "other", sessionId: "thread" }],
343+});
344+345+expect(harness.indexedPaths).toEqual([]);
346+});
347+348+it("does not fall back to full session sync for malformed identity session ids", async () => {
349+await writeSessionFile("thread.jsonl");
350+const harness = new SessionStartupCatchupHarness([]);
351+352+await harness.runSyncForTest({
353+reason: "queued-sessions",
354+sessions: [{ agentId: "main", sessionId: "bad/nested" }],
355+});
356+357+expect(harness.indexedPaths).toEqual([]);
358+});
307359});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。