fix: avoid stale workspace metadata reuse · openclaw/openclaw@193bfd3
shakkernerd
·
2026-05-17
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -220,6 +220,19 @@ describe("manifest model id normalization", () => {
|
220 | 220 | expect(normalizeDemoModel()).toBe("bravo/demo-model"); |
221 | 221 | }); |
222 | 222 | |
| 223 | +it("does not reuse workspace-scoped current metadata without a workspace context", () => { |
| 224 | +setCurrentPluginMetadataSnapshot( |
| 225 | +createCurrentSnapshot({ |
| 226 | +manifestHash: "alpha", |
| 227 | +prefix: "alpha", |
| 228 | +workspaceDir: "/workspace/a", |
| 229 | +}), |
| 230 | +{ config: {}, env: process.env }, |
| 231 | +); |
| 232 | + |
| 233 | +expect(normalizeDemoModel()).toBeUndefined(); |
| 234 | +}); |
| 235 | + |
223 | 236 | it("reflects manifest edits and state-dir changes on the next lookup", () => { |
224 | 237 | const stateDirA = makeTempDir(); |
225 | 238 | const pluginDirA = path.join(stateDirA, "extensions", "normalizer"); |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -46,7 +46,7 @@ function resolveMetadataSnapshotForPolicies(
|
46 | 46 | const current = getCurrentPluginMetadataSnapshot({ |
47 | 47 | config: params.config, |
48 | 48 | env, |
49 | | -...(workspaceDir !== undefined ? { workspaceDir } : { allowWorkspaceScopedSnapshot: true }), |
| 49 | + workspaceDir, |
50 | 50 | }); |
51 | 51 | if (current) { |
52 | 52 | return { snapshot: current, cacheable: true }; |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -225,6 +225,38 @@ describe("setup-registry runtime fallback", () => {
|
225 | 225 | expect(loadPluginMetadataSnapshotMock).not.toHaveBeenCalled(); |
226 | 226 | }); |
227 | 227 | |
| 228 | +it("does not reuse workspace-scoped current metadata without a workspace context", async () => { |
| 229 | +loadPluginMetadataSnapshotMock.mockReturnValue({ |
| 230 | +index: { |
| 231 | +diagnostics: [], |
| 232 | +plugins: [], |
| 233 | +}, |
| 234 | +plugins: [], |
| 235 | +}); |
| 236 | + |
| 237 | +const { __testing, resolvePluginSetupCliBackendRuntime } = |
| 238 | +await import("./setup-registry.runtime.js"); |
| 239 | +__testing.resetRuntimeState(); |
| 240 | +__testing.setRuntimeModuleForTest(null); |
| 241 | + |
| 242 | +setCurrentPluginMetadataSnapshot( |
| 243 | +createCurrentSnapshot({ |
| 244 | +manifestHash: "alpha", |
| 245 | +cliBackends: ["Codex-CLI"], |
| 246 | +workspaceDir: "/workspace/a", |
| 247 | +}), |
| 248 | +{ config: {}, env: process.env }, |
| 249 | +); |
| 250 | + |
| 251 | +expect( |
| 252 | +resolvePluginSetupCliBackendRuntime({ backend: "codex-cli", config: {} }), |
| 253 | +).toBeUndefined(); |
| 254 | +expect(loadPluginMetadataSnapshotMock).toHaveBeenCalledWith({ |
| 255 | +config: {}, |
| 256 | +env: process.env, |
| 257 | +}); |
| 258 | +}); |
| 259 | + |
228 | 260 | it("preserves fail-closed setup lookup when the runtime module explicitly declines to resolve", async () => { |
229 | 261 | loadPluginMetadataSnapshotMock.mockReturnValue({ |
230 | 262 | index: { |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -60,7 +60,7 @@ function resolveMetadataSnapshotForSetupCliBackends(
|
60 | 60 | const current = getCurrentPluginMetadataSnapshot({ |
61 | 61 | config: params.config, |
62 | 62 | env, |
63 | | -...(workspaceDir !== undefined ? { workspaceDir } : { allowWorkspaceScopedSnapshot: true }), |
| 63 | + workspaceDir, |
64 | 64 | }); |
65 | 65 | if (current) { |
66 | 66 | return { snapshot: current, cacheable: true }; |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。