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

推荐订阅源

G
Google Developers Blog
人人都是产品经理
人人都是产品经理
爱范儿
爱范儿
云风的 BLOG
云风的 BLOG
Last Week in AI
Last Week in AI
H
Hackread – Cybersecurity News, Data Breaches, AI and More
B
Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
H
Help Net Security
B
Blog RSS Feed
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
N
Netflix TechBlog - Medium
S
SegmentFault 最新的问题
The Cloudflare Blog
I
InfoQ
美团技术团队
博客园 - 三生石上(FineUI控件)
MyScale Blog
MyScale Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园 - 司徒正美
L
LangChain Blog
A
About on SuperTechFans
T
The Blog of Author Tim Ferriss
Y
Y Combinator Blog

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): clamp sync interval timers · openclaw/opencl...
steipete · 2026-05-31 · via Recent Commits to openclaw:main
Original file line numberDiff line numberDiff line change

@@ -0,0 +1,95 @@

1+

import type { DatabaseSync } from "node:sqlite";

2+

import type {

3+

OpenClawConfig,

4+

ResolvedMemorySearchConfig,

5+

} from "openclaw/plugin-sdk/memory-core-host-engine-foundation";

6+

import type { MemorySource } from "openclaw/plugin-sdk/memory-core-host-engine-storage";

7+

import { MAX_TIMER_TIMEOUT_MS } from "openclaw/plugin-sdk/number-runtime";

8+

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

9+

import { MemoryManagerSyncOps } from "./manager-sync-ops.js";

10+
11+

type MemoryIndexEntry = {

12+

path: string;

13+

absPath: string;

14+

mtimeMs: number;

15+

size: number;

16+

hash: string;

17+

content?: string;

18+

};

19+
20+

class IntervalSyncHarness extends MemoryManagerSyncOps {

21+

protected readonly cfg = {} as OpenClawConfig;

22+

protected readonly agentId = "main";

23+

protected readonly workspaceDir = "/tmp/openclaw-memory-interval-test";

24+

protected readonly settings: ResolvedMemorySearchConfig;

25+

protected readonly batch = {

26+

enabled: false,

27+

wait: false,

28+

concurrency: 1,

29+

pollIntervalMs: 0,

30+

timeoutMs: 0,

31+

};

32+

protected readonly vector = { enabled: false, available: false };

33+

protected readonly cache = { enabled: false };

34+

protected providerUnavailableReason?: string;

35+

protected providerLifecycle = { mode: "active" as const, providerId: "test" };

36+

protected db = {} as DatabaseSync;

37+
38+

constructor(intervalMinutes: number) {

39+

super();

40+

this.settings = {

41+

sync: { intervalMinutes },

42+

} as ResolvedMemorySearchConfig;

43+

}

44+
45+

arm(): void {

46+

this.ensureIntervalSync();

47+

}

48+
49+

stop(): void {

50+

if (this.intervalTimer) {

51+

clearInterval(this.intervalTimer);

52+

this.intervalTimer = null;

53+

}

54+

}

55+
56+

protected computeProviderKey(): string {

57+

return "test";

58+

}

59+
60+

protected async sync(): Promise<void> {}

61+
62+

protected async withTimeout<T>(promise: Promise<T>): Promise<T> {

63+

return await promise;

64+

}

65+
66+

protected getIndexConcurrency(): number {

67+

return 1;

68+

}

69+
70+

protected pruneEmbeddingCacheIfNeeded(): void {}

71+
72+

protected resetProviderInitializationForRetry(): void {}

73+
74+

protected async indexFile(

75+

_entry: MemoryIndexEntry,

76+

_options: { source: MemorySource; content?: string },

77+

): Promise<void> {}

78+

}

79+
80+

describe("MemoryManagerSyncOps interval sync", () => {

81+

afterEach(() => {

82+

vi.useRealTimers();

83+

});

84+
85+

it("clamps oversized interval sync timers", () => {

86+

vi.useFakeTimers();

87+

const setIntervalSpy = vi.spyOn(globalThis, "setInterval");

88+

const harness = new IntervalSyncHarness(Number.MAX_SAFE_INTEGER);

89+
90+

harness.arm();

91+
92+

expect(setIntervalSpy).toHaveBeenCalledWith(expect.any(Function), MAX_TIMER_TIMEOUT_MS);

93+

harness.stop();

94+

});

95+

});

Original file line numberDiff line numberDiff line change

@@ -33,6 +33,7 @@ import {

3333

type MemorySource,

3434

type MemorySyncProgressUpdate,

3535

} from "openclaw/plugin-sdk/memory-core-host-engine-storage";

36+

import { resolveTimerTimeoutMs } from "openclaw/plugin-sdk/number-runtime";

3637

import { normalizeLowercaseStringOrEmpty } from "openclaw/plugin-sdk/string-coerce-runtime";

3738

import {

3839

createEmbeddingProvider,

@@ -1061,7 +1062,10 @@ export abstract class MemoryManagerSyncOps {

10611062

if (!minutes || minutes <= 0 || this.intervalTimer) {

10621063

return;

10631064

}

1064-

const ms = minutes * 60 * 1000;

1065+

const ms = resolveTimerTimeoutMs(minutes * 60 * 1000, 0, 0);

1066+

if (ms <= 0) {

1067+

return;

1068+

}

10651069

this.intervalTimer = setInterval(() => {

10661070

runDetachedMemorySync(() => this.sync({ reason: "interval" }), "interval");

10671071

}, ms);