mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-30 21:50:21 +00:00
Plugins: reserve context engine ownership
This commit is contained in:
@@ -1082,6 +1082,71 @@ describe("loadOpenClawPlugins", () => {
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it("rejects plugin context engine ids reserved by core", () => {
|
||||
useNoBundledPlugins();
|
||||
const plugin = writePlugin({
|
||||
id: "context-engine-core-collision",
|
||||
filename: "context-engine-core-collision.cjs",
|
||||
body: `module.exports = { id: "context-engine-core-collision", register(api) {
|
||||
api.registerContextEngine("legacy", () => ({}));
|
||||
} };`,
|
||||
});
|
||||
|
||||
const registry = loadRegistryFromSinglePlugin({
|
||||
plugin,
|
||||
pluginConfig: {
|
||||
allow: ["context-engine-core-collision"],
|
||||
},
|
||||
});
|
||||
|
||||
expect(
|
||||
registry.diagnostics.some(
|
||||
(diag) =>
|
||||
diag.level === "error" &&
|
||||
diag.pluginId === "context-engine-core-collision" &&
|
||||
diag.message === "context engine id reserved by core: legacy",
|
||||
),
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it("rejects duplicate plugin context engine ids", () => {
|
||||
useNoBundledPlugins();
|
||||
const first = writePlugin({
|
||||
id: "context-engine-owner-a",
|
||||
filename: "context-engine-owner-a.cjs",
|
||||
body: `module.exports = { id: "context-engine-owner-a", register(api) {
|
||||
api.registerContextEngine("shared-context-engine-loader-test", () => ({}));
|
||||
} };`,
|
||||
});
|
||||
const second = writePlugin({
|
||||
id: "context-engine-owner-b",
|
||||
filename: "context-engine-owner-b.cjs",
|
||||
body: `module.exports = { id: "context-engine-owner-b", register(api) {
|
||||
api.registerContextEngine("shared-context-engine-loader-test", () => ({}));
|
||||
} };`,
|
||||
});
|
||||
|
||||
const registry = loadOpenClawPlugins({
|
||||
cache: false,
|
||||
config: {
|
||||
plugins: {
|
||||
load: { paths: [first.file, second.file] },
|
||||
allow: ["context-engine-owner-a", "context-engine-owner-b"],
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
expect(
|
||||
registry.diagnostics.some(
|
||||
(diag) =>
|
||||
diag.level === "error" &&
|
||||
diag.pluginId === "context-engine-owner-b" &&
|
||||
diag.message ===
|
||||
"context engine already registered: shared-context-engine-loader-test (plugin:context-engine-owner-a)",
|
||||
),
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it("requires plugin CLI registrars to declare explicit command roots", () => {
|
||||
useNoBundledPlugins();
|
||||
const plugin = writePlugin({
|
||||
|
||||
Reference in New Issue
Block a user