fix(doctor): invalidate persisted plugin registry when a diagnostic s… · openclaw/openclaw@d160f82
2026-05-10
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -308,4 +308,35 @@ describe("loadPluginRegistrySnapshotWithMetadata", () => {
|
308 | 308 | expect.objectContaining({ code: "persisted-registry-stale-source" }), |
309 | 309 | ); |
310 | 310 | }); |
| 311 | + |
| 312 | +it("treats persisted registry as stale when a diagnostic source path no longer exists", () => { |
| 313 | +const tempRoot = makeTempDir(); |
| 314 | +const stateDir = path.join(tempRoot, "state"); |
| 315 | +const env = { ...createHermeticEnv(tempRoot), OPENCLAW_DISABLE_BUNDLED_PLUGINS: "1" }; |
| 316 | +const config = {}; |
| 317 | +const ghostDir = path.join(tempRoot, "extensions", "lossless-claw"); |
| 318 | +const staleIndex: InstalledPluginIndex = { |
| 319 | + ...loadInstalledPluginIndex({ config, env, stateDir, installRecords: {} }), |
| 320 | +diagnostics: [ |
| 321 | +{ |
| 322 | +level: "warn", |
| 323 | +message: |
| 324 | +"installed plugin package requires compiled runtime output for TypeScript entry index.ts: expected ./dist/index.js", |
| 325 | +pluginId: "lossless-claw", |
| 326 | +source: ghostDir, |
| 327 | +}, |
| 328 | +], |
| 329 | +}; |
| 330 | +writePersistedInstalledPluginIndexSync(staleIndex, { stateDir }); |
| 331 | + |
| 332 | +const result = loadPluginRegistrySnapshotWithMetadata({ config, env, stateDir }); |
| 333 | + |
| 334 | +expect(result.source).toBe("derived"); |
| 335 | +expect(result.snapshot.diagnostics).not.toContainEqual( |
| 336 | +expect.objectContaining({ source: ghostDir }), |
| 337 | +); |
| 338 | +expect(result.diagnostics).toContainEqual( |
| 339 | +expect.objectContaining({ code: "persisted-registry-stale-source" }), |
| 340 | +); |
| 341 | +}); |
311 | 342 | }); |
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。