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

推荐订阅源

Last Week in AI
Last Week in AI
阮一峰的网络日志
阮一峰的网络日志
P
Proofpoint News Feed
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
MongoDB | Blog
MongoDB | Blog
云风的 BLOG
云风的 BLOG
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
J
Java Code Geeks
WordPress大学
WordPress大学
T
The Blog of Author Tim Ferriss
V
Visual Studio Blog
小众软件
小众软件
Microsoft Azure Blog
Microsoft Azure Blog
博客园_首页
IT之家
IT之家
Vercel News
Vercel News
C
Check Point Blog
Google DeepMind News
Google DeepMind News
月光博客
月光博客
D
DataBreaches.Net
酷 壳 – CoolShell
酷 壳 – CoolShell
美团技术团队
Y
Y Combinator Blog
Hugging Face - Blog
Hugging Face - 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: clear plugin registry broad matchers · openclaw/ope...
steipete · 2026-05-10 · via Recent Commits to openclaw:main

@@ -149,6 +149,49 @@ function createIndex(

149149

};

150150

}

151151152+

function requireRecord(value: unknown, label: string): Record<string, unknown> {

153+

expect(typeof value, label).toBe("object");

154+

expect(value, label).not.toBeNull();

155+

return value as Record<string, unknown>;

156+

}

157+158+

function requireArray(value: unknown, label: string): unknown[] {

159+

expect(Array.isArray(value), label).toBe(true);

160+

return value as unknown[];

161+

}

162+163+

function expectFields(record: Record<string, unknown>, expected: Record<string, unknown>) {

164+

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

165+

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

166+

}

167+

}

168+169+

function expectPluginRecordFields(record: unknown, expected: Record<string, unknown>) {

170+

expectFields(requireRecord(record, "plugin record"), expected);

171+

}

172+173+

function expectDiagnosticCodes(diagnostics: unknown, expectedCodes: string[]) {

174+

const codes = requireArray(diagnostics, "diagnostics").map(

175+

(diagnostic) => requireRecord(diagnostic, "diagnostic").code,

176+

);

177+

expect(codes).toEqual(expectedCodes);

178+

}

179+180+

function expectInstallRecord(

181+

installRecords: unknown,

182+

pluginId: string,

183+

expected: Record<string, unknown>,

184+

) {

185+

const records = requireRecord(installRecords, "install records");

186+

expectFields(requireRecord(records[pluginId], `${pluginId} install record`), expected);

187+

}

188+189+

function expectSnapshotPluginIds(snapshot: InstalledPluginIndex, expectedPluginIds: string[]) {

190+

expect(listPluginRecords({ index: snapshot }).map((plugin) => plugin.pluginId)).toEqual(

191+

expectedPluginIds,

192+

);

193+

}

194+152195

describe("plugin registry facade", () => {

153196

it("resolves relative plugin API paths against the plugin root", () => {

154197

const pluginRoot = path.join(makeTempDir(), "plugins", "demo");

@@ -181,7 +224,7 @@ describe("plugin registry facade", () => {

181224

});

182225183226

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

184-

expect(getPluginRecord({ index, pluginId: "demo" })).toMatchObject({

227+

expectPluginRecordFields(getPluginRecord({ index, pluginId: "demo" }), {

185228

pluginId: "demo",

186229

enabled: true,

187230

});

@@ -246,7 +289,7 @@ describe("plugin registry facade", () => {

246289

preferPersisted: false,

247290

});

248291249-

expect(getPluginRecord({ index, pluginId: "demo" })).toMatchObject({

292+

expectPluginRecordFields(getPluginRecord({ index, pluginId: "demo" }), {

250293

pluginId: "demo",

251294

enabled: false,

252295

});

@@ -344,26 +387,19 @@ describe("plugin registry facade", () => {

344387

expect(normalizePluginId("openai-chat")).toBe("openai");

345388

expect(normalizePluginId("unknown-plugin")).toBe("unknown-plugin");

346389347-

expect(

348-

normalizePluginsConfigWithRegistry(

349-

{

350-

allow: ["openai-chat"],

351-

entries: {

352-

"OpenAI-Codex": {

353-

enabled: false,

354-

},

390+

const normalizedConfig = normalizePluginsConfigWithRegistry(

391+

{

392+

allow: ["openai-chat"],

393+

entries: {

394+

"OpenAI-Codex": {

395+

enabled: false,

355396

},

356397

},

357-

index,

358-

),

359-

).toMatchObject({

360-

allow: ["openai"],

361-

entries: {

362-

openai: {

363-

enabled: false,

364-

},

365398

},

366-

});

399+

index,

400+

);

401+

expect(normalizedConfig.allow).toEqual(["openai"]);

402+

expect(normalizedConfig.entries?.openai?.enabled).toBe(false);

367403

});

368404369405

it("normalizes plugin config ids from a provided manifest registry without rereading manifests", () => {

@@ -387,17 +423,14 @@ describe("plugin registry facade", () => {

387423

});

388424389425

expect(normalizePluginId("demo-chat")).toBe("demo");

390-

expect(

391-

normalizePluginsConfigWithRegistry(

392-

{

393-

allow: ["demo-chat"],

394-

},

395-

index,

396-

{ manifestRegistry: lookUpTable.manifestRegistry },

397-

),

398-

).toMatchObject({

399-

allow: ["demo"],

400-

});

426+

const normalizedConfig = normalizePluginsConfigWithRegistry(

427+

{

428+

allow: ["demo-chat"],

429+

},

430+

index,

431+

{ manifestRegistry: lookUpTable.manifestRegistry },

432+

);

433+

expect(normalizedConfig.allow).toEqual(["demo"]);

401434

});

402435403436

it("reads the persisted registry before deriving from discovered candidates", async () => {

@@ -462,12 +495,8 @@ describe("plugin registry facade", () => {

462495

});

463496464497

expect(result.source).toBe("derived");

465-

expect(result.diagnostics).toEqual([

466-

expect.objectContaining({ code: "persisted-registry-stale-source" }),

467-

]);

468-

expect(listPluginRecords({ index: result.snapshot }).map((plugin) => plugin.pluginId)).toEqual([

469-

"demo",

470-

]);

498+

expectDiagnosticCodes(result.diagnostics, ["persisted-registry-stale-source"]);

499+

expectSnapshotPluginIds(result.snapshot, ["demo"]);

471500

});

472501473502

it("falls back to the derived registry when persisted manifest metadata is stale", async () => {

@@ -501,9 +530,7 @@ describe("plugin registry facade", () => {

501530

});

502531503532

expect(result.source).toBe("derived");

504-

expect(result.diagnostics).toEqual([

505-

expect.objectContaining({ code: "persisted-registry-stale-source" }),

506-

]);

533+

expectDiagnosticCodes(result.diagnostics, ["persisted-registry-stale-source"]);

507534

expect(result.snapshot.plugins[0]?.manifestHash).not.toBe(persisted.plugins[0]?.manifestHash);

508535

});

509536

@@ -543,9 +570,7 @@ describe("plugin registry facade", () => {

543570

});

544571545572

expect(result.source).toBe("derived");

546-

expect(result.diagnostics).toEqual([

547-

expect.objectContaining({ code: "persisted-registry-stale-source" }),

548-

]);

573+

expectDiagnosticCodes(result.diagnostics, ["persisted-registry-stale-source"]);

549574

expect(result.snapshot.plugins[0]?.packageJson?.hash).not.toBe(

550575

persisted.plugins[0]?.packageJson?.hash,

551576

);

@@ -583,9 +608,7 @@ describe("plugin registry facade", () => {

583608

});

584609585610

expect(result.source).toBe("derived");

586-

expect(result.diagnostics).toEqual([

587-

expect.objectContaining({ code: "persisted-registry-stale-source" }),

588-

]);

611+

expectDiagnosticCodes(result.diagnostics, ["persisted-registry-stale-source"]);

589612

expect(result.snapshot.plugins[0]?.packageJson).toBeUndefined();

590613

});

591614

@@ -617,12 +640,8 @@ describe("plugin registry facade", () => {

617640

});

618641619642

expect(result.source).toBe("derived");

620-

expect(result.diagnostics).toEqual([

621-

expect.objectContaining({ code: "persisted-registry-stale-source" }),

622-

]);

623-

expect(listPluginRecords({ index: result.snapshot }).map((plugin) => plugin.pluginId)).toEqual([

624-

"demo",

625-

]);

643+

expectDiagnosticCodes(result.diagnostics, ["persisted-registry-stale-source"]);

644+

expectSnapshotPluginIds(result.snapshot, ["demo"]);

626645

});

627646628647

it("falls back to the derived registry when persisted policy is stale", async () => {

@@ -655,17 +674,11 @@ describe("plugin registry facade", () => {

655674

});

656675657676

expect(result.source).toBe("derived");

658-

expect(result.diagnostics).toEqual([

659-

expect.objectContaining({ code: "persisted-registry-stale-policy" }),

660-

]);

661-

expect(listPluginRecords({ index: result.snapshot }).map((plugin) => plugin.pluginId)).toEqual([

662-

"demo",

663-

]);

664-

expect(result.snapshot.installRecords).toMatchObject({

665-

persisted: {

666-

source: "npm",

667-

spec: "persisted-plugin@1.0.0",

668-

},

677+

expectDiagnosticCodes(result.diagnostics, ["persisted-registry-stale-policy"]);

678+

expectSnapshotPluginIds(result.snapshot, ["demo"]);

679+

expectInstallRecord(result.snapshot.installRecords, "persisted", {

680+

source: "npm",

681+

spec: "persisted-plugin@1.0.0",

669682

});

670683

});

671684

@@ -681,12 +694,8 @@ describe("plugin registry facade", () => {

681694

});

682695683696

expect(result.source).toBe("derived");

684-

expect(result.diagnostics).toEqual([

685-

expect.objectContaining({ code: "persisted-registry-missing" }),

686-

]);

687-

expect(listPluginRecords({ index: result.snapshot }).map((plugin) => plugin.pluginId)).toEqual([

688-

"demo",

689-

]);

697+

expectDiagnosticCodes(result.diagnostics, ["persisted-registry-missing"]);

698+

expectSnapshotPluginIds(result.snapshot, ["demo"]);

690699

});

691700692701

it("derives fresh config-scoped registries when the persisted registry is missing", () => {

@@ -740,15 +749,11 @@ describe("plugin registry facade", () => {

740749

});

741750742751

expect(result.source).toBe("derived");

743-

expect(result.diagnostics).toEqual([

744-

expect.objectContaining({

745-

code: "persisted-registry-disabled",

746-

message: expect.stringContaining("deprecated break-glass compatibility switch"),

747-

}),

748-

]);

749-

expect(listPluginRecords({ index: result.snapshot }).map((plugin) => plugin.pluginId)).toEqual([

750-

"demo",

751-

]);

752+

expectDiagnosticCodes(result.diagnostics, ["persisted-registry-disabled"]);

753+

expect(String(requireRecord(result.diagnostics[0], "diagnostic").message)).toContain(

754+

"deprecated break-glass compatibility switch",

755+

);

756+

expectSnapshotPluginIds(result.snapshot, ["demo"]);

752757

});

753758754759

it("derives a fresh registry without dropping persisted install records", async () => {

@@ -776,14 +781,10 @@ describe("plugin registry facade", () => {

776781

});

777782778783

expect(result.source).toBe("derived");

779-

expect(listPluginRecords({ index: result.snapshot }).map((plugin) => plugin.pluginId)).toEqual([

780-

"demo",

781-

]);

782-

expect(result.snapshot.installRecords).toMatchObject({

783-

persisted: {

784-

source: "npm",

785-

spec: "persisted-plugin@1.0.0",

786-

},

784+

expectSnapshotPluginIds(result.snapshot, ["demo"]);

785+

expectInstallRecord(result.snapshot.installRecords, "persisted", {

786+

source: "npm",

787+

spec: "persisted-plugin@1.0.0",

787788

});

788789

});

789790

@@ -794,16 +795,11 @@ describe("plugin registry facade", () => {

794795

const candidate = createCandidate(pluginDir);

795796

const env = hermeticEnv();

796797797-

await expect(

798-

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

799-

).resolves.toMatchObject({

800-

state: "missing",

801-

refreshReasons: ["missing"],

802-

persisted: null,

803-

current: {

804-

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

805-

},

806-

});

798+

const missingInspect = await inspectPluginRegistry({ stateDir, candidates: [candidate], env });

799+

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

800+

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

801+

expect(missingInspect.persisted).toBeNull();

802+

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

807803808804

await refreshPluginRegistry({

809805

reason: "manual",

@@ -812,15 +808,10 @@ describe("plugin registry facade", () => {

812808

env,

813809

});

814810815-

await expect(

816-

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

817-

).resolves.toMatchObject({

818-

state: "fresh",

819-

refreshReasons: [],

820-

persisted: {

821-

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

822-

},

823-

});

811+

const freshInspect = await inspectPluginRegistry({ stateDir, candidates: [candidate], env });

812+

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

813+

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

814+

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

824815

});

825816826817

it("preserves install records when refreshing the persisted registry", async () => {

@@ -846,15 +837,16 @@ describe("plugin registry facade", () => {

846837

env: hermeticEnv(),

847838

});

848839849-

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

850-

installRecords: {

851-

missing: {

852-

source: "npm",

853-

spec: "missing-plugin@1.0.0",

854-

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

855-

},

856-

},

857-

plugins: [],

840+

const persisted = await readPersistedInstalledPluginIndex({ stateDir });

841+

expect(persisted).not.toBeNull();

842+

if (!persisted) {

843+

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

844+

}

845+

expectInstallRecord(persisted.installRecords, "missing", {

846+

source: "npm",

847+

spec: "missing-plugin@1.0.0",

848+

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

858849

});

850+

expect(persisted.plugins).toEqual([]);

859851

});

860852

});