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

推荐订阅源

宝玉的分享
宝玉的分享
B
Blog RSS Feed
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
MyScale Blog
MyScale Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
S
SegmentFault 最新的问题
Y
Y Combinator Blog
月光博客
月光博客
IT之家
IT之家
T
Tailwind CSS Blog
Last Week in AI
Last Week in AI
L
LangChain Blog
博客园_首页
MongoDB | Blog
MongoDB | Blog
P
Proofpoint News Feed
博客园 - Franky
WordPress大学
WordPress大学
云风的 BLOG
云风的 BLOG
M
MIT News - Artificial intelligence
V
Visual Studio Blog
小众软件
小众软件
博客园 - 叶小钗
博客园 - 三生石上(FineUI控件)
N
Netflix TechBlog - Medium

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
refactor: move plugin state stores to sqlite (#88609) · o...
steipete · 2026-05-31 · via Recent Commits to openclaw:main
11

import fs from "node:fs";

22

import os from "node:os";

33

import path from "node:path";

4+

import { resetPluginStateStoreForTests } from "openclaw/plugin-sdk/plugin-state-test-runtime";

45

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

56

import { prepareFileConsentActivityFs } from "./file-consent-helpers.js";

67

import {

@@ -50,6 +51,7 @@ async function cleanupTempDirs(): Promise<void> {

50515152

describe("msteams pending uploads (fs-backed)", () => {

5253

beforeEach(() => {

54+

resetPluginStateStoreForTests();

5355

setMSTeamsRuntime(msteamsRuntimeStub);

5456

clearPendingUploads();

5557

});

@@ -105,25 +107,39 @@ describe("msteams pending uploads (fs-backed)", () => {

105107

{ env },

106108

);

107109108-

// Confirm the backing file actually exists on disk with expected shape

110+

// Confirm SQLite-backed plugin state was created instead of a new JSON store.

109111

const storePath = path.join(stateDir, "msteams-pending-uploads.json");

110-

const raw = await fs.promises.readFile(storePath, "utf-8");

111-

const parsed = JSON.parse(raw) as {

112-

version: number;

113-

uploads: Record<string, { bufferBase64: string; filename: string }>;

114-

};

115-

expect(parsed.version).toBe(1);

116-

expect(parsed.uploads["upload-x"]?.filename).toBe("secret.bin");

117-

expect(Buffer.from(parsed.uploads["upload-x"].bufferBase64, "base64").toString("utf8")).toBe(

118-

"top secret",

119-

);

112+

await expect(fs.promises.access(storePath)).rejects.toThrow();

113+

await expect(

114+

fs.promises.access(path.join(stateDir, "state", "openclaw.sqlite")),

115+

).resolves.toBeUndefined();

120116121117

// Second "process": reader using the same state dir

122118

const reader = await getPendingUploadFs("upload-x", { env });

123119

expect(reader?.buffer.toString("utf8")).toBe("top secret");

124120

expect(reader?.filename).toBe("secret.bin");

125121

});

126122123+

it("stores multi-megabyte uploads by chunking payload bytes", async () => {

124+

const stateDir = await makeTempStateDir();

125+

const env = makeEnv(stateDir);

126+

const payload = Buffer.alloc(6 * 1024 * 1024, 7);

127+128+

await storePendingUploadFs(

129+

{

130+

id: "upload-large",

131+

buffer: payload,

132+

filename: "large.bin",

133+

conversationId: "19:conv@thread.v2",

134+

},

135+

{ env },

136+

);

137+138+

const reader = await getPendingUploadFs("upload-large", { env });

139+

expect(reader?.buffer.equals(payload)).toBe(true);

140+

expect(reader?.filename).toBe("large.bin");

141+

});

142+127143

it("removes persisted entries", async () => {

128144

const stateDir = await makeTempStateDir();

129145

const env = makeEnv(stateDir);

@@ -204,14 +220,85 @@ describe("msteams pending uploads (fs-backed)", () => {

204220205221

// Should not throw and should treat as empty

206222

expect(await getPendingUploadFs("anything", { env })).toBeUndefined();

223+

await expect(fs.promises.access(storePath)).rejects.toThrow();

224+225+

const secondStateDir = await makeTempStateDir();

226+

const secondEnv = makeEnv(secondStateDir);

227+

const secondStorePath = path.join(secondStateDir, "msteams-pending-uploads.json");

228+

await fs.promises.writeFile(

229+

secondStorePath,

230+

JSON.stringify({ version: 2, uploads: {} }),

231+

"utf-8",

232+

);

233+

expect(await getPendingUploadFs("anything", { env: secondEnv })).toBeUndefined();

234+

await expect(fs.promises.access(secondStorePath)).rejects.toThrow();

235+

});

207236208-

await fs.promises.writeFile(storePath, JSON.stringify({ version: 2, uploads: {} }), "utf-8");

209-

expect(await getPendingUploadFs("anything", { env })).toBeUndefined();

237+

it("imports a legacy JSON file that appears after an empty migration marker", async () => {

238+

const stateDir = await makeTempStateDir();

239+

const env = makeEnv(stateDir);

240+

const storePath = path.join(stateDir, "msteams-pending-uploads.json");

241+242+

expect(await getPendingUploadFs("upload-late", { env })).toBeUndefined();

243+

await fs.promises.writeFile(

244+

storePath,

245+

`${JSON.stringify({

246+

version: 1,

247+

uploads: {

248+

"upload-late": {

249+

id: "upload-late",

250+

bufferBase64: Buffer.from("late payload").toString("base64"),

251+

filename: "late.txt",

252+

conversationId: "19:conv@thread.v2",

253+

createdAt: Date.now(),

254+

},

255+

},

256+

})}\n`,

257+

"utf-8",

258+

);

259+260+

const loaded = await getPendingUploadFs("upload-late", { env });

261+

expect(loaded?.filename).toBe("late.txt");

262+

expect(loaded?.buffer.toString("utf8")).toBe("late payload");

263+

await expect(fs.promises.access(storePath)).rejects.toThrow();

264+

});

265+266+

it("skips malformed legacy upload rows while importing valid rows", async () => {

267+

const stateDir = await makeTempStateDir();

268+

const env = makeEnv(stateDir);

269+

const storePath = path.join(stateDir, "msteams-pending-uploads.json");

270+

await fs.promises.writeFile(

271+

storePath,

272+

`${JSON.stringify({

273+

version: 1,

274+

uploads: {

275+

broken: {

276+

id: "broken",

277+

filename: "broken.txt",

278+

conversationId: "19:conv@thread.v2",

279+

createdAt: Date.now(),

280+

},

281+

valid: {

282+

id: "valid",

283+

bufferBase64: Buffer.from("valid payload").toString("base64"),

284+

filename: "valid.txt",

285+

conversationId: "19:conv@thread.v2",

286+

createdAt: Date.now(),

287+

},

288+

},

289+

})}\n`,

290+

"utf-8",

291+

);

292+293+

expect(await getPendingUploadFs("broken", { env })).toBeUndefined();

294+

const loaded = await getPendingUploadFs("valid", { env });

295+

expect(loaded?.buffer.toString("utf8")).toBe("valid payload");

210296

});

211297

});

212298213299

describe("prepareFileConsentActivityFs end-to-end", () => {

214300

beforeEach(() => {

301+

resetPluginStateStoreForTests();

215302

setMSTeamsRuntime(msteamsRuntimeStub);

216303

clearPendingUploads();

217304

});