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

推荐订阅源

The GitHub Blog
The GitHub Blog
博客园 - 三生石上(FineUI控件)
V
V2EX
博客园 - 司徒正美
小众软件
小众软件
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
T
Tailwind CSS Blog
Last Week in AI
Last Week in AI
雷峰网
雷峰网
月光博客
月光博客
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Apple Machine Learning Research
Apple Machine Learning Research
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
S
SegmentFault 最新的问题
美团技术团队
Hugging Face - Blog
Hugging Face - Blog
WordPress大学
WordPress大学
宝玉的分享
宝玉的分享
爱范儿
爱范儿
博客园 - 聂微东
量子位
J
Java Code Geeks
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Vercel News
Vercel News

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
fix: scope plugin metadata to workspace context · opencla...
shakkernerd · 2026-05-17 · via Recent Commits to openclaw:main

@@ -0,0 +1,130 @@

1+

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

2+

import type { OpenClawConfig } from "../config/types.openclaw.js";

3+4+

const loadManifestMetadataSnapshotMock = vi.hoisted(() => vi.fn());

5+

const getCurrentPluginMetadataSnapshotMock = vi.hoisted(() => vi.fn());

6+

const getActivePluginRegistryWorkspaceDirFromStateMock = vi.hoisted(() => vi.fn());

7+8+

vi.mock("../plugins/current-plugin-metadata-snapshot.js", () => ({

9+

getCurrentPluginMetadataSnapshot: getCurrentPluginMetadataSnapshotMock,

10+

}));

11+12+

vi.mock("../plugins/manifest-contract-eligibility.js", () => ({

13+

loadManifestMetadataSnapshot: loadManifestMetadataSnapshotMock,

14+

}));

15+16+

vi.mock("../plugins/runtime-state.js", () => ({

17+

getActivePluginRegistryWorkspaceDirFromState: getActivePluginRegistryWorkspaceDirFromStateMock,

18+

}));

19+20+

vi.mock("./provider-model-normalization.runtime.js", () => ({

21+

normalizeProviderModelIdWithRuntime: () => undefined,

22+

}));

23+24+

describe("configured model manifest workspace scope", () => {

25+

beforeEach(() => {

26+

vi.resetModules();

27+

loadManifestMetadataSnapshotMock.mockReset();

28+

getCurrentPluginMetadataSnapshotMock.mockReset();

29+

getActivePluginRegistryWorkspaceDirFromStateMock.mockReset();

30+

getCurrentPluginMetadataSnapshotMock.mockReturnValue(undefined);

31+

loadManifestMetadataSnapshotMock.mockReturnValue({

32+

plugins: [

33+

{

34+

modelIdNormalization: {

35+

providers: {

36+

custom: {

37+

prefixWhenBare: "workspace-custom",

38+

},

39+

},

40+

},

41+

},

42+

],

43+

});

44+

});

45+46+

it("does not reuse workspace manifest policies without a workspace context", async () => {

47+

const { buildConfiguredModelCatalog } = await import("./model-selection-shared.js");

48+

const cfg = {

49+

models: {

50+

providers: {

51+

custom: {

52+

models: [{ id: "fast-model" }],

53+

},

54+

},

55+

},

56+

} as unknown as OpenClawConfig;

57+58+

expect(buildConfiguredModelCatalog({ cfg })).toMatchObject([

59+

{

60+

provider: "custom",

61+

id: "fast-model",

62+

},

63+

]);

64+

expect(getCurrentPluginMetadataSnapshotMock).toHaveBeenCalledWith({

65+

config: cfg,

66+

env: process.env,

67+

});

68+

expect(loadManifestMetadataSnapshotMock).not.toHaveBeenCalled();

69+

});

70+71+

it("uses manifest policies when the workspace context is explicit", async () => {

72+

const { buildConfiguredModelCatalog } = await import("./model-selection-shared.js");

73+

const cfg = {

74+

models: {

75+

providers: {

76+

custom: {

77+

models: [{ id: "fast-model" }],

78+

},

79+

},

80+

},

81+

} as unknown as OpenClawConfig;

82+83+

expect(buildConfiguredModelCatalog({ cfg, workspaceDir: "/workspace/a" })).toMatchObject([

84+

{

85+

provider: "custom",

86+

id: "workspace-custom/fast-model",

87+

},

88+

]);

89+

expect(loadManifestMetadataSnapshotMock).toHaveBeenCalledWith({

90+

config: cfg,

91+

workspaceDir: "/workspace/a",

92+

env: process.env,

93+

});

94+

expect(getCurrentPluginMetadataSnapshotMock).not.toHaveBeenCalled();

95+

});

96+97+

it("uses an unscoped current snapshot without falling back to a metadata scan", async () => {

98+

getCurrentPluginMetadataSnapshotMock.mockReturnValue({

99+

plugins: [

100+

{

101+

modelIdNormalization: {

102+

providers: {

103+

custom: {

104+

prefixWhenBare: "global-custom",

105+

},

106+

},

107+

},

108+

},

109+

],

110+

});

111+

const { buildConfiguredModelCatalog } = await import("./model-selection-shared.js");

112+

const cfg = {

113+

models: {

114+

providers: {

115+

custom: {

116+

models: [{ id: "fast-model" }],

117+

},

118+

},

119+

},

120+

} as unknown as OpenClawConfig;

121+122+

expect(buildConfiguredModelCatalog({ cfg })).toMatchObject([

123+

{

124+

provider: "custom",

125+

id: "global-custom/fast-model",

126+

},

127+

]);

128+

expect(loadManifestMetadataSnapshotMock).not.toHaveBeenCalled();

129+

});

130+

});