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

推荐订阅源

阮一峰的网络日志
阮一峰的网络日志
博客园 - 司徒正美
D
DataBreaches.Net
宝玉的分享
宝玉的分享
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
博客园 - 【当耐特】
人人都是产品经理
人人都是产品经理
博客园 - Franky
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
IT之家
IT之家
博客园 - 三生石上(FineUI控件)
J
Java Code Geeks
腾讯CDC
博客园_首页
The Cloudflare Blog
S
SegmentFault 最新的问题
C
Check Point Blog
美团技术团队
爱范儿
爱范儿
大猫的无限游戏
大猫的无限游戏
Hugging Face - Blog
Hugging Face - Blog
T
The Blog of Author Tim Ferriss
A
About on SuperTechFans
Blog — PlanetScale
Blog — PlanetScale

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: clear installed plugin index store broad matchers ·...
steipete · 2026-05-10 · via Recent Commits to openclaw:main

@@ -79,6 +79,69 @@ function createCandidate(rootDir: string, options: { id?: string } = {}): Plugin

7979

};

8080

}

818182+

function requirePersisted(index: InstalledPluginIndex | null): InstalledPluginIndex {

83+

expect(index).not.toBeNull();

84+

if (!index) {

85+

throw new Error("Expected persisted installed plugin index");

86+

}

87+

return index;

88+

}

89+90+

function expectPluginIds(index: InstalledPluginIndex, expected: string[]) {

91+

expect(index.plugins.map((plugin) => plugin.pluginId)).toEqual(expected);

92+

}

93+94+

function expectPluginFields(

95+

index: InstalledPluginIndex,

96+

pluginId: string,

97+

expected: Record<string, unknown>,

98+

) {

99+

const plugin = index.plugins.find((candidate) => candidate.pluginId === pluginId);

100+

expect(plugin, pluginId).toBeDefined();

101+

if (!plugin) {

102+

throw new Error(`Missing plugin ${pluginId}`);

103+

}

104+

for (const [key, value] of Object.entries(expected)) {

105+

expect(plugin[key as keyof typeof plugin], key).toEqual(value);

106+

}

107+

}

108+109+

function expectInstallRecord(

110+

index: InstalledPluginIndex,

111+

pluginId: string,

112+

expected: Record<string, unknown>,

113+

) {

114+

const record = index.installRecords[pluginId];

115+

expect(record, pluginId).toBeDefined();

116+

if (!record) {

117+

throw new Error(`Missing install record ${pluginId}`);

118+

}

119+

for (const [key, value] of Object.entries(expected)) {

120+

expect(record[key as keyof typeof record], key).toEqual(value);

121+

}

122+

}

123+124+

async function expectPersistedIndex(

125+

stateDir: string,

126+

expected: {

127+

refreshReason?: string;

128+

pluginIds?: string[];

129+

installRecords?: Record<string, Record<string, unknown>>;

130+

},

131+

) {

132+

const persisted = requirePersisted(await readPersistedInstalledPluginIndex({ stateDir }));

133+

if (expected.refreshReason !== undefined) {

134+

expect(persisted.refreshReason).toBe(expected.refreshReason);

135+

}

136+

if (expected.pluginIds) {

137+

expectPluginIds(persisted, expected.pluginIds);

138+

}

139+

for (const [pluginId, fields] of Object.entries(expected.installRecords ?? {})) {

140+

expectInstallRecord(persisted, pluginId, fields);

141+

}

142+

return persisted;

143+

}

144+82145

describe("installed plugin index persistence", () => {

83146

it("resolves the persisted index path under the state plugins directory", () => {

84147

const stateDir = makeTempDir();

@@ -101,7 +164,10 @@ describe("installed plugin index persistence", () => {

101164

if (process.platform !== "win32") {

102165

expect(fs.statSync(filePath).mode & 0o777).toBe(0o600);

103166

}

104-

await expect(readPersistedInstalledPluginIndex({ stateDir })).resolves.toMatchObject(index);

167+

const persisted = requirePersisted(await readPersistedInstalledPluginIndex({ stateDir }));

168+

expect(persisted.version).toBe(index.version);

169+

expect(persisted.policyHash).toBe(index.policyHash);

170+

expectPluginIds(persisted, ["demo"]);

105171

});

106172107173

it("does not preserve prototype poison keys from persisted index JSON", async () => {

@@ -128,12 +194,9 @@ describe("installed plugin index persistence", () => {

128194129195

const persisted = await readPersistedInstalledPluginIndex({ stateDir });

130196131-

expect(persisted).toMatchObject({

132-

plugins: [expect.objectContaining({ pluginId: "demo" })],

133-

installRecords: {

134-

demo: expect.objectContaining({ source: "npm" }),

135-

},

136-

});

197+

const persistedIndex = requirePersisted(persisted);

198+

expectPluginIds(persistedIndex, ["demo"]);

199+

expectInstallRecord(persistedIndex, "demo", { source: "npm" });

137200

expect(Object.prototype.hasOwnProperty.call(persisted as object, "__proto__")).toBe(false);

138201

expect(Object.prototype.hasOwnProperty.call(persisted?.installRecords ?? {}, "__proto__")).toBe(

139202

false,

@@ -174,16 +237,15 @@ describe("installed plugin index persistence", () => {

174237

VITEST: "true",

175238

};

176239177-

await expect(

178-

inspectPersistedInstalledPluginIndex({ stateDir, candidates: [candidate], env }),

179-

).resolves.toMatchObject({

180-

state: "missing",

181-

refreshReasons: ["missing"],

182-

persisted: null,

183-

current: {

184-

plugins: [expect.objectContaining({ pluginId: "demo" })],

185-

},

240+

const missingInspect = await inspectPersistedInstalledPluginIndex({

241+

stateDir,

242+

candidates: [candidate],

243+

env,

186244

});

245+

expect(missingInspect.state).toBe("missing");

246+

expect(missingInspect.refreshReasons).toEqual(["missing"]);

247+

expect(missingInspect.persisted).toBeNull();

248+

expectPluginIds(missingInspect.current, ["demo"]);

187249188250

const current = await refreshPersistedInstalledPluginIndex({

189251

reason: "manual",

@@ -192,40 +254,34 @@ describe("installed plugin index persistence", () => {

192254

env,

193255

});

194256195-

await expect(

196-

inspectPersistedInstalledPluginIndex({ stateDir, candidates: [candidate], env }),

197-

).resolves.toMatchObject({

198-

state: "fresh",

199-

refreshReasons: [],

200-

persisted: current,

201-

current: {

202-

plugins: [expect.objectContaining({ pluginId: "demo", enabled: true })],

203-

},

257+

const freshInspect = await inspectPersistedInstalledPluginIndex({

258+

stateDir,

259+

candidates: [candidate],

260+

env,

204261

});

262+

expect(freshInspect.state).toBe("fresh");

263+

expect(freshInspect.refreshReasons).toEqual([]);

264+

expect(freshInspect.persisted).toEqual(current);

265+

expectPluginFields(freshInspect.current, "demo", { enabled: true });

205266206-

await expect(

207-

inspectPersistedInstalledPluginIndex({

208-

stateDir,

209-

candidates: [candidate],

210-

config: {

211-

plugins: {

212-

entries: {

213-

demo: {

214-

enabled: false,

215-

},

267+

const policyInspect = await inspectPersistedInstalledPluginIndex({

268+

stateDir,

269+

candidates: [candidate],

270+

config: {

271+

plugins: {

272+

entries: {

273+

demo: {

274+

enabled: false,

216275

},

217276

},

218277

},

219-

env,

220-

}),

221-

).resolves.toMatchObject({

222-

state: "stale",

223-

refreshReasons: ["policy-changed"],

224-

persisted: current,

225-

current: {

226-

plugins: [expect.objectContaining({ pluginId: "demo", enabled: false })],

227278

},

279+

env,

228280

});

281+

expect(policyInspect.state).toBe("stale");

282+

expect(policyInspect.refreshReasons).toEqual(["policy-changed"]);

283+

expect(policyInspect.persisted).toEqual(current);

284+

expectPluginFields(policyInspect.current, "demo", { enabled: false });

229285230286

fs.writeFileSync(

231287

path.join(pluginDir, "openclaw.plugin.json"),

@@ -238,20 +294,15 @@ describe("installed plugin index persistence", () => {

238294

"utf8",

239295

);

240296241-

await expect(

242-

inspectPersistedInstalledPluginIndex({ stateDir, candidates: [candidate], env }),

243-

).resolves.toMatchObject({

244-

state: "stale",

245-

refreshReasons: ["stale-manifest"],

246-

persisted: current,

247-

current: {

248-

plugins: [

249-

expect.objectContaining({

250-

pluginId: "demo",

251-

}),

252-

],

253-

},

297+

const staleManifestInspect = await inspectPersistedInstalledPluginIndex({

298+

stateDir,

299+

candidates: [candidate],

300+

env,

254301

});

302+

expect(staleManifestInspect.state).toBe("stale");

303+

expect(staleManifestInspect.refreshReasons).toEqual(["stale-manifest"]);

304+

expect(staleManifestInspect.persisted).toEqual(current);

305+

expectPluginIds(staleManifestInspect.current, ["demo"]);

255306

});

256307257308

it("refreshes and persists a rebuilt index without loading plugin runtime", async () => {

@@ -273,9 +324,9 @@ describe("installed plugin index persistence", () => {

273324274325

expect(index.refreshReason).toBe("manual");

275326

expect(index.plugins.map((plugin) => plugin.pluginId)).toEqual(["demo"]);

276-

await expect(readPersistedInstalledPluginIndex({ stateDir })).resolves.toMatchObject({

327+

await expectPersistedIndex(stateDir, {

277328

refreshReason: "manual",

278-

plugins: [expect.objectContaining({ pluginId: "demo" })],

329+

pluginIds: ["demo"],

279330

});

280331

});

281332

@@ -324,7 +375,7 @@ describe("installed plugin index persistence", () => {

324375

});

325376326377

expect(refreshed.plugins).toHaveLength(initial.plugins.length);

327-

expect(refreshed.plugins[0]).toMatchObject({

378+

expectPluginFields(refreshed, "demo", {

328379

pluginId: "demo",

329380

enabled: false,

330381

manifestHash: initial.plugins[0]?.manifestHash,

@@ -399,25 +450,21 @@ describe("installed plugin index persistence", () => {

399450

},

400451

});

401452402-

expect(index).toMatchObject({

403-

installRecords: {

404-

missing: {

405-

source: "npm",

406-

spec: "missing-plugin@1.0.0",

407-

installPath: path.join(stateDir, "plugins", "missing"),

408-

},

409-

},

410-

plugins: [],

453+

expectInstallRecord(index, "missing", {

454+

source: "npm",

455+

spec: "missing-plugin@1.0.0",

456+

installPath: path.join(stateDir, "plugins", "missing"),

411457

});

412-

await expect(readPersistedInstalledPluginIndex({ stateDir })).resolves.toMatchObject({

458+

expectPluginIds(index, []);

459+

await expectPersistedIndex(stateDir, {

460+

pluginIds: [],

413461

installRecords: {

414462

missing: {

415463

source: "npm",

416464

spec: "missing-plugin@1.0.0",

417465

installPath: path.join(stateDir, "plugins", "missing"),

418466

},

419467

},

420-

plugins: [],

421468

});

422469

});

423470

@@ -466,34 +513,34 @@ describe("installed plugin index persistence", () => {

466513

},

467514

});

468515469-

const expected = {

516+

const expectedRecord = {

517+

source: "clawhub",

518+

spec: "clawhub:clawpack-demo@2026.5.1-beta.2",

519+

installPath,

520+

version: "2026.5.1-beta.2",

521+

integrity: "sha256-archive",

522+

resolvedAt: "2026-05-01T00:00:00.000Z",

523+

clawhubUrl: "https://clawhub.ai",

524+

clawhubPackage: "clawpack-demo",

525+

clawhubFamily: "code-plugin",

526+

clawhubChannel: "official",

527+

artifactKind: "npm-pack",

528+

artifactFormat: "tgz",

529+

npmIntegrity: "sha512-clawpack",

530+

npmShasum: "1".repeat(40),

531+

npmTarballName: "clawpack-demo-2026.5.1-beta.2.tgz",

532+

clawpackSha256: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",

533+

clawpackSpecVersion: 1,

534+

clawpackManifestSha256: "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",

535+

clawpackSize: 4096,

536+

};

537+

expectInstallRecord(index, "clawpack-demo", expectedRecord);

538+

expectPluginIds(index, []);

539+

await expectPersistedIndex(stateDir, {

540+

pluginIds: [],

470541

installRecords: {

471-

"clawpack-demo": {

472-

source: "clawhub",

473-

spec: "clawhub:clawpack-demo@2026.5.1-beta.2",

474-

installPath,

475-

version: "2026.5.1-beta.2",

476-

integrity: "sha256-archive",

477-

resolvedAt: "2026-05-01T00:00:00.000Z",

478-

clawhubUrl: "https://clawhub.ai",

479-

clawhubPackage: "clawpack-demo",

480-

clawhubFamily: "code-plugin",

481-

clawhubChannel: "official",

482-

artifactKind: "npm-pack",

483-

artifactFormat: "tgz",

484-

npmIntegrity: "sha512-clawpack",

485-

npmShasum: "1".repeat(40),

486-

npmTarballName: "clawpack-demo-2026.5.1-beta.2.tgz",

487-

clawpackSha256: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",

488-

clawpackSpecVersion: 1,

489-

clawpackManifestSha256:

490-

"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",

491-

clawpackSize: 4096,

492-

},

542+

"clawpack-demo": expectedRecord,

493543

},

494-

plugins: [],

495-

};

496-

expect(index).toMatchObject(expected);

497-

await expect(readPersistedInstalledPluginIndex({ stateDir })).resolves.toMatchObject(expected);

544+

});

498545

});

499546

});