惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

D
DataBreaches.Net
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Google DeepMind News
Google DeepMind News
博客园 - 聂微东
Microsoft Azure Blog
Microsoft Azure Blog
V
Visual Studio Blog
IT之家
IT之家
博客园 - 【当耐特】
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
B
Blog
爱范儿
爱范儿
阮一峰的网络日志
阮一峰的网络日志
云风的 BLOG
云风的 BLOG
Vercel News
Vercel News
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
H
Hackread – Cybersecurity News, Data Breaches, AI and More
H
Help Net Security
J
Java Code Geeks
aimingoo的专栏
aimingoo的专栏
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
B
Blog RSS Feed
Blog — PlanetScale
Blog — PlanetScale
S
SegmentFault 最新的问题
Apple Machine Learning Research
Apple Machine Learning Research

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
fix(memory): await search-sync before returning results t...
liuhao1024 · 2026-06-17 · via Recent Commits to openclaw:main
11

// Memory Core tests cover manager.async search plugin behavior.

22

import { describe, expect, it, vi } from "vitest";

33

import { awaitPendingManagerWork, startAsyncSearchSync } from "./manager-async-state.js";

4+

import { MemoryIndexManager } from "./manager.js";

4556

describe("memory search async sync", () => {

6-

it("does not await sync when searching", async () => {

7+

it("waits for dirty sync before querying", async () => {

78

let releaseSync = () => {};

8-

const pending = new Promise<void>((resolve) => {

9+

const pendingSync = new Promise<void>((resolve) => {

910

releaseSync = () => resolve();

1011

});

1112

const syncMock = vi.fn(async () => {

12-

return pending;

13+

return pendingSync;

1314

});

14-

const onError = vi.fn();

15-16-

startAsyncSearchSync({

17-

enabled: true,

15+

const queryMock = vi.fn(async () => []);

16+

const manager = Object.create(MemoryIndexManager.prototype) as MemoryIndexManager;

17+

Object.assign(manager as unknown as Record<string, unknown>, {

18+

providerRequirement: { mode: "fts-only", provider: "none" },

19+

hasIndexedContent: () => true,

20+

settings: {

21+

sync: { onSearch: true },

22+

query: {

23+

minScore: 0,

24+

maxResults: 5,

25+

hybrid: {

26+

enabled: true,

27+

candidateMultiplier: 2,

28+

temporalDecay: { enabled: false, halfLifeDays: 30 },

29+

},

30+

},

31+

},

32+

warmSession: vi.fn(),

33+

ensureProviderInitialized: vi.fn(async () => {}),

34+

assertRequiredProviderAvailable: vi.fn(),

1835

dirty: true,

1936

sessionsDirty: false,

2037

sync: syncMock,

21-

onError,

38+

provider: null,

39+

providerLifecycle: { mode: "fts-only", reason: "test" },

40+

refreshIndexIdentityDirty: () => ({ status: "valid" }),

41+

sources: new Set(["memory"]),

42+

fts: { enabled: true, available: true },

43+

searchKeywordWithFallback: queryMock,

44+

workspaceDir: "",

2245

});

234647+

const searchPromise = manager.search("current memory");

48+

await vi.waitFor(() => expect(syncMock).toHaveBeenCalledWith({ reason: "search" }));

49+

expect(queryMock).not.toHaveBeenCalled();

50+2451

expect(syncMock).toHaveBeenCalledTimes(1);

2552

releaseSync();

26-

await pending;

27-

expect(onError).not.toHaveBeenCalled();

53+

await searchPromise;

54+

expect(queryMock).toHaveBeenCalledTimes(1);

2855

});

29563057

it("waits for in-flight search sync during close", async () => {

@@ -45,9 +72,9 @@ describe("memory search async sync", () => {

4572

await closePromise;

4673

});

477448-

it("skips background search sync when search-triggered sync is disabled", () => {

75+

it("skips background search sync when search-triggered sync is disabled", async () => {

4976

const syncMock = vi.fn(async () => {});

50-

startAsyncSearchSync({

77+

await startAsyncSearchSync({

5178

enabled: false,

5279

dirty: true,

5380

sessionsDirty: false,