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

推荐订阅源

MyScale Blog
MyScale Blog
量子位
宝玉的分享
宝玉的分享
爱范儿
爱范儿
云风的 BLOG
云风的 BLOG
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Recent Announcements
Recent Announcements
Apple Machine Learning Research
Apple Machine Learning Research
N
News and Events Feed by Topic
TaoSecurity Blog
TaoSecurity Blog
博客园 - 三生石上(FineUI控件)
小众软件
小众软件
Simon Willison's Weblog
Simon Willison's Weblog
Google DeepMind News
Google DeepMind News
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
aimingoo的专栏
aimingoo的专栏
Cloudbric
Cloudbric
Blog — PlanetScale
Blog — PlanetScale
Latest news
Latest news
S
Security @ Cisco Blogs
Last Week in AI
Last Week in AI
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Vercel News
Vercel News
W
WeLiveSecurity
M
MIT News - Artificial intelligence
P
Proofpoint News Feed
P
Proofpoint News Feed
P
Palo Alto Networks Blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com
T
The Blog of Author Tim Ferriss
腾讯CDC
大猫的无限游戏
大猫的无限游戏
Martin Fowler
Martin Fowler
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
V
V2EX
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Stack Overflow Blog
Stack Overflow Blog
IT之家
IT之家
有赞技术团队
有赞技术团队
Microsoft Security Blog
Microsoft Security Blog
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
美团技术团队
博客园 - 【当耐特】
D
DataBreaches.Net
I
InfoQ
G
GRAHAM CLULEY
S
SegmentFault 最新的问题
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
B
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 test: trim doctor command hotspots · openclaw/openclaw@c66f16a test: isolate agent auth and spawn hotspots · openclaw/openclaw@9285935 test: stabilize MCP startup disposal race · openclaw/openclaw@dd9d2eb test: merge browser contract server suites · openclaw/openclaw@5817a76 test: narrow ollama provider discovery setup · openclaw/openclaw@a0d9598 build: declare qa-lab aimock runtime dependency · openclaw/openclaw@24431e5 test: speed up safe-bins exec harness · openclaw/openclaw@ee856ab test: preserve tool helpers in embedded runner mocks · openclaw/openclaw@acd86a0 refactor: move memory embeddings into provider plugins · openclaw/openclaw@77e6e4c test: reuse system-run temp fixtures · openclaw/openclaw@7e9ff0f test: trim hotspot wait overhead · openclaw/openclaw@12a59b0 Check: avoid duplicate boundary prep · openclaw/openclaw@baf11b8 test: reduce hotspot fixture overhead · openclaw/openclaw@3a59edd feat(ui): overhaul settings and slash command UX (#67819) thanks @Bun… · openclaw/openclaw@2cfb660 QA Matrix: exit cleanly on failure · openclaw/openclaw@42805d2 QA Matrix: isolate scenario coverage · openclaw/openclaw@7e659e1 Matrix: refresh crypto bootstrap state · openclaw/openclaw@94081d8 QA Lab: add provider registry · openclaw/openclaw@bb7e982 Matrix: add plugin changelog · openclaw/openclaw@4acab55 test: trim more hotspot overhead · openclaw/openclaw@f485311 test: trim remaining hotspot tests · openclaw/openclaw@6ba8626 test: narrow hotspot mocks · openclaw/openclaw@dbc8179 test: isolate gemini embedding request helpers · openclaw/openclaw@cd330f5 test: trim memory and mcp hotspots · openclaw/openclaw@fd48dfa test: slim provider registry mocks · openclaw/openclaw@2e08c77 test: harden Parallels update smoke · openclaw/openclaw@1a98090 feat: default Anthropic to Opus 4.7 · openclaw/openclaw@628b454 fix: harden node-host shell payload mutability checks · openclaw/openclaw@75c551e fix: land node-host approval binding for native binaries (#66731) (th… · openclaw/openclaw@29919bb CI: add daily schedule to CodeQL workflow (#67645) · openclaw/openclaw@69d25f5 fix(gateway): capture config hash after plugin auto-enable to prevent… · openclaw/openclaw@8c11210 fix: repair sanitized replay tool results before send (#67620) (thank… · openclaw/openclaw@c3c7a99 fix: restrict HTML timeout short-circuit to transient statuses · openclaw/openclaw@de129a6 fix: keep TUI watchdog bound to active run (#67401) (thanks @xantorres) · openclaw/openclaw@3525273 Gateway/skills: dedupe skills prefix-match + drop dead fallback on log · openclaw/openclaw@d7f489f Extensions/lmstudio: back off inference preload after consecutive fai… · openclaw/openclaw@b555214 TUI/streaming: add watchdog that resets the activity indicator after … · openclaw/openclaw@f44ab20 Agents/tool-loop: enable unknown-tool stream guard by default · openclaw/openclaw@36ed367 Gateway/skills: invalidate session skills snapshot on config write · openclaw/openclaw@b23d59a fix: classify HTML provider error pages correctly (#67642) (thanks @s… · openclaw/openclaw@e588e90 fix(skills): remove unused model-usage import (#67641) · openclaw/openclaw@55f05df docs(changelog): credit codex fix superseded PRs · openclaw/openclaw@e485f24 fix(openai-codex): normalize stale transport metadata in resolution a… · openclaw/openclaw@90801ba CI: pin Docker-related GitHub Actions (#67632) · openclaw/openclaw@f697b01 Android: modernize WebView and discovery API usage (#67627) · openclaw/openclaw@44a6e50 fix(deps): bump hono to 4.12.14 and @hono/node-server to 1.19.14 (GHS… · openclaw/openclaw@fbccc18 fix(deps): bump dompurify to 3.4.0 (#67614) · openclaw/openclaw@2c2dc00 CI: add explicit permissions to all workflow jobs (fixes code-scannin… · openclaw/openclaw@01b7516 fix: register bundled TTS providers and route overrides correctly (#6… · openclaw/openclaw@6ea3cdd fix: align host tilde paths with OS home (#62804) (thanks @stainlu) · openclaw/openclaw@ecfaf64 fix: flush creds queue before reconnect socket open (#67464) (thanks … · openclaw/openclaw@405c63f fix: strip standalone <function> tool call tags from visible text (#6… · openclaw/openclaw@78df859 fix(agents): preserve cli session metadata before transcript persist … · openclaw/openclaw@898fd04 docs(changelog): move cli transcript entry · openclaw/openclaw@c1817c6 fix(agents): normalize cli transcript api field · openclaw/openclaw@3a3fae0 docs(changelog): note cli transcript persistence · openclaw/openclaw@6c343f1 fix(agents): persist cli transcript turns · openclaw/openclaw@b8ef507 fix(msteams): harden security-sensitive flows (#65841) · openclaw/openclaw@c56b56e [Dashboard] Fix exec approval modal overflow for long command content… · openclaw/openclaw@053c5b0 Docs: remove QA changelog entry · openclaw/openclaw@7fd5771 QA: fix private runtime source loading (#67428) · openclaw/openclaw@d5933af docs(gateway): correct protocol.md schema path, hello-ok example, aut… · openclaw/openclaw@489404d CI: pin Node 22 runners to 22.18.0 · openclaw/openclaw@4ffa621 models.authStatus: normalize provider ids + tighten env-backed escape… · openclaw/openclaw@f2fdb9d Update CHANGELOG.md · openclaw/openclaw@7694a92 test(parallels): clean up npm update guard jobs · openclaw/openclaw@045ea7b Plugins: prefer scanDir override paths · openclaw/openclaw@b2974da fix(dreaming): default storage.mode to "separate" so phase blocks sto… · openclaw/openclaw@8c392f0 fix(memory-core): skip dreaming transcript ingestion via session stor… · openclaw/openclaw@a1b01f0 fix: dedupe replayed exec.finished node events (#67281) · openclaw/openclaw@5dcf526
feat(plugins): add SQLite plugin state store (#74190) · openclaw/openclaw@bbf985d
amknight · 2026-04-29 · via Recent Commits to openclaw:main

@@ -0,0 +1,304 @@

1+

import { mkdirSync } from "node:fs";

2+

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

3+

import { requireNodeSqlite } from "../infra/node-sqlite.js";

4+

import { withOpenClawTestState } from "../test-utils/openclaw-test-state.js";

5+

import {

6+

closePluginStateSqliteStore,

7+

createPluginStateKeyedStore,

8+

PluginStateStoreError,

9+

probePluginStateStore,

10+

resetPluginStateStoreForTests,

11+

sweepExpiredPluginStateEntries,

12+

} from "./plugin-state-store.js";

13+

import { resolvePluginStateDir, resolvePluginStateSqlitePath } from "./plugin-state-store.paths.js";

14+

import { MAX_PLUGIN_STATE_ENTRIES_PER_PLUGIN } from "./plugin-state-store.sqlite.js";

15+16+

afterEach(() => {

17+

vi.useRealTimers();

18+

resetPluginStateStoreForTests();

19+

});

20+21+

// ---------------------------------------------------------------------------

22+

// Runtime smoke

23+

// ---------------------------------------------------------------------------

24+

describe("runtime smoke", () => {

25+

it("creates and exercises a keyed store directly", async () => {

26+

await withOpenClawTestState({ label: "e2e-smoke-load" }, async () => {

27+

const store = createPluginStateKeyedStore<{ ready: boolean }>("fixture-plugin", {

28+

namespace: "boot",

29+

maxEntries: 10,

30+

});

31+

expect(store).toBeDefined();

32+

expect(typeof store.register).toBe("function");

33+

expect(typeof store.lookup).toBe("function");

34+

expect(typeof store.consume).toBe("function");

35+

});

36+

});

37+38+

it("writes and reads a value", async () => {

39+

await withOpenClawTestState({ label: "e2e-smoke-rw" }, async () => {

40+

const store = createPluginStateKeyedStore<{ msg: string }>("fixture-plugin", {

41+

namespace: "data",

42+

maxEntries: 10,

43+

});

44+

await store.register("greeting", { msg: "hello" });

45+

await expect(store.lookup("greeting")).resolves.toEqual({ msg: "hello" });

46+

});

47+

});

48+49+

it("consumes a value exactly once", async () => {

50+

await withOpenClawTestState({ label: "e2e-smoke-consume" }, async () => {

51+

const store = createPluginStateKeyedStore<{ token: string }>("fixture-plugin", {

52+

namespace: "tokens",

53+

maxEntries: 10,

54+

});

55+

await store.register("one-shot", { token: "abc123" });

56+57+

const first = await store.consume("one-shot");

58+

expect(first).toEqual({ token: "abc123" });

59+60+

const second = await store.consume("one-shot");

61+

expect(second).toBeUndefined();

62+63+

await expect(store.lookup("one-shot")).resolves.toBeUndefined();

64+

});

65+

});

66+

});

67+68+

// ---------------------------------------------------------------------------

69+

// Persistence

70+

// ---------------------------------------------------------------------------

71+

describe("persistence", () => {

72+

it("survives close and reopen of the store", async () => {

73+

await withOpenClawTestState({ label: "e2e-persist" }, async () => {

74+

const storeA = createPluginStateKeyedStore<{ persisted: boolean }>("fixture-plugin", {

75+

namespace: "durable",

76+

maxEntries: 10,

77+

});

78+

await storeA.register("key1", { persisted: true });

79+

await storeA.register("key2", { persisted: true });

80+81+

// Tear down the cached DB handle and option signatures – simulates

82+

// a full gateway restart while the on-disk DB survives.

83+

resetPluginStateStoreForTests();

84+85+

const storeB = createPluginStateKeyedStore<{ persisted: boolean }>("fixture-plugin", {

86+

namespace: "durable",

87+

maxEntries: 10,

88+

});

89+

await expect(storeB.lookup("key1")).resolves.toEqual({ persisted: true });

90+

await expect(storeB.lookup("key2")).resolves.toEqual({ persisted: true });

91+

});

92+

});

93+

});

94+95+

// ---------------------------------------------------------------------------

96+

// TTL

97+

// ---------------------------------------------------------------------------

98+

describe("TTL", () => {

99+

it("hides expired values and sweep removes the row", async () => {

100+

await withOpenClawTestState({ label: "e2e-ttl" }, async () => {

101+

vi.useFakeTimers();

102+

vi.setSystemTime(10_000);

103+104+

const store = createPluginStateKeyedStore<{ v: number }>("fixture-plugin", {

105+

namespace: "ttl-test",

106+

maxEntries: 10,

107+

});

108+

await store.register("short", { v: 1 }, { ttlMs: 500 });

109+

await store.register("long", { v: 2 }, { ttlMs: 60_000 });

110+111+

// Before expiry – both visible.

112+

await expect(store.lookup("short")).resolves.toEqual({ v: 1 });

113+

await expect(store.lookup("long")).resolves.toEqual({ v: 2 });

114+115+

// Advance past the short TTL.

116+

vi.setSystemTime(10_600);

117+118+

// Expired value is invisible to reads.

119+

await expect(store.lookup("short")).resolves.toBeUndefined();

120+

await expect(store.lookup("long")).resolves.toEqual({ v: 2 });

121+122+

// Sweep physically removes the expired row.

123+

const swept = sweepExpiredPluginStateEntries();

124+

expect(swept).toBe(1);

125+126+

// After sweep the entry list contains only the long-lived record.

127+

const remaining = await store.entries();

128+

expect(remaining).toHaveLength(1);

129+

expect(remaining[0].key).toBe("long");

130+

});

131+

});

132+

});

133+134+

// ---------------------------------------------------------------------------

135+

// Isolation

136+

// ---------------------------------------------------------------------------

137+

describe("isolation", () => {

138+

it("segregates plugins sharing namespace and key", async () => {

139+

await withOpenClawTestState({ label: "e2e-isolation" }, async () => {

140+

const pluginA = createPluginStateKeyedStore<{ owner: string }>("plugin-a", {

141+

namespace: "x",

142+

maxEntries: 10,

143+

});

144+

const pluginB = createPluginStateKeyedStore<{ owner: string }>("plugin-b", {

145+

namespace: "x",

146+

maxEntries: 10,

147+

});

148+149+

await pluginA.register("same", { owner: "a" });

150+

await pluginB.register("same", { owner: "b" });

151+152+

await expect(pluginA.lookup("same")).resolves.toEqual({ owner: "a" });

153+

await expect(pluginB.lookup("same")).resolves.toEqual({ owner: "b" });

154+155+

// Clearing one plugin's namespace does not affect the other.

156+

await pluginA.clear();

157+

await expect(pluginA.lookup("same")).resolves.toBeUndefined();

158+

await expect(pluginB.lookup("same")).resolves.toEqual({ owner: "b" });

159+

});

160+

});

161+

});

162+163+

// ---------------------------------------------------------------------------

164+

// Limits

165+

// ---------------------------------------------------------------------------

166+

describe("limits", () => {

167+

it("accepts a value at the 64 KB boundary", async () => {

168+

await withOpenClawTestState({ label: "e2e-limit-accept" }, async () => {

169+

const store = createPluginStateKeyedStore<string>("fixture-plugin", {

170+

namespace: "size",

171+

maxEntries: 10,

172+

});

173+

// JSON.stringify wraps a string in quotes (+2 bytes).

174+

// 65 534 chars → 65 536 bytes of JSON → exactly at limit.

175+

const boundary = "x".repeat(65_534);

176+

await expect(store.register("big", boundary)).resolves.toBeUndefined();

177+

await expect(store.lookup("big")).resolves.toBe(boundary);

178+

});

179+

});

180+181+

it("rejects a value one byte over 64 KB", async () => {

182+

await withOpenClawTestState({ label: "e2e-limit-reject" }, async () => {

183+

const store = createPluginStateKeyedStore<string>("fixture-plugin", {

184+

namespace: "size",

185+

maxEntries: 10,

186+

});

187+

// 65 535 chars → 65 537 bytes of JSON → over limit.

188+

const oversize = "x".repeat(65_535);

189+

await expect(store.register("big", oversize)).rejects.toMatchObject({

190+

code: "PLUGIN_STATE_LIMIT_EXCEEDED",

191+

});

192+

});

193+

});

194+195+

it("enforces the per-plugin live-row cap", async () => {

196+

await withOpenClawTestState({ label: "e2e-limit-plugin" }, async () => {

197+

// Spread MAX_ENTRIES_PER_PLUGIN rows across several namespaces so

198+

// namespace eviction never fires (each namespace has generous room).

199+

const nsCount = 10;

200+

const perNs = MAX_PLUGIN_STATE_ENTRIES_PER_PLUGIN / nsCount; // 100

201+

const stores = Array.from({ length: nsCount }, (_, i) =>

202+

createPluginStateKeyedStore("fixture-plugin", {

203+

namespace: `ns-${i}`,

204+

maxEntries: perNs + 1,

205+

}),

206+

);

207+208+

for (let ns = 0; ns < nsCount; ns += 1) {

209+

for (let k = 0; k < perNs; k += 1) {

210+

await stores[ns].register(`k-${k}`, { ns, k });

211+

}

212+

}

213+214+

// One more row tips over the plugin-wide limit.

215+

await expect(stores[0].register("overflow", { boom: true })).rejects.toMatchObject({

216+

code: "PLUGIN_STATE_LIMIT_EXCEEDED",

217+

});

218+

});

219+

});

220+221+

it("evicts oldest entries when namespace maxEntries is exceeded", async () => {

222+

await withOpenClawTestState({ label: "e2e-limit-eviction" }, async () => {

223+

vi.useFakeTimers();

224+

const store = createPluginStateKeyedStore<number>("fixture-plugin", {

225+

namespace: "capped",

226+

maxEntries: 3,

227+

});

228+229+

vi.setSystemTime(1000);

230+

await store.register("a", 1);

231+

vi.setSystemTime(2000);

232+

await store.register("b", 2);

233+

vi.setSystemTime(3000);

234+

await store.register("c", 3);

235+

vi.setSystemTime(4000);

236+

await store.register("d", 4); // should evict "a"

237+238+

const entries = await store.entries();

239+

expect(entries).toHaveLength(3);

240+

expect(entries.map((e) => e.key)).toEqual(["b", "c", "d"]);

241+

await expect(store.lookup("a")).resolves.toBeUndefined();

242+

});

243+

});

244+

});

245+246+

// ---------------------------------------------------------------------------

247+

// Failure safety

248+

// ---------------------------------------------------------------------------

249+

describe("failure safety", () => {

250+

it("gives a typed error for unsupported schema versions", async () => {

251+

await withOpenClawTestState({ label: "e2e-fail-schema" }, async () => {

252+

// Pre-seed the DB with a future schema version.

253+

mkdirSync(resolvePluginStateDir(), { recursive: true });

254+

const { DatabaseSync } = requireNodeSqlite();

255+

const db = new DatabaseSync(resolvePluginStateSqlitePath());

256+

db.exec("PRAGMA user_version = 99;");

257+

db.close();

258+259+

const store = createPluginStateKeyedStore("fixture-plugin", {

260+

namespace: "schema",

261+

maxEntries: 10,

262+

});

263+

const error = await store.register("k", { ok: true }).catch((e: unknown) => e);

264+

expect(error).toBeInstanceOf(PluginStateStoreError);

265+

expect(error).toMatchObject({ code: "PLUGIN_STATE_SCHEMA_UNSUPPORTED" });

266+

});

267+

});

268+269+

it("probe returns redacted diagnostics without leaking stored values", async () => {

270+

await withOpenClawTestState({ label: "e2e-fail-probe" }, async () => {

271+

const result = probePluginStateStore();

272+

expect(result.ok).toBe(true);

273+

expect(result.dbPath).toContain("state.sqlite");

274+

expect(result.steps.length).toBeGreaterThanOrEqual(4);

275+

expect(result.steps.every((s) => s.ok)).toBe(true);

276+277+

// The probe's temporary stored value must not leak into the result.

278+

const serialised = JSON.stringify(result);

279+

expect(serialised).not.toContain("probe-value");

280+

});

281+

});

282+283+

it("close and reopen cycle is clean", async () => {

284+

await withOpenClawTestState({ label: "e2e-fail-reopen" }, async () => {

285+

const store = createPluginStateKeyedStore<{ v: number }>("fixture-plugin", {

286+

namespace: "reopen",

287+

maxEntries: 10,

288+

});

289+

await store.register("k", { v: 1 });

290+291+

// First close.

292+

closePluginStateSqliteStore();

293+

await expect(store.lookup("k")).resolves.toEqual({ v: 1 });

294+295+

// Second close (idempotent).

296+

closePluginStateSqliteStore();

297+

await expect(store.lookup("k")).resolves.toEqual({ v: 1 });

298+299+

// Write after reopen.

300+

await store.register("k", { v: 2 });

301+

await expect(store.lookup("k")).resolves.toEqual({ v: 2 });

302+

});

303+

});

304+

});