mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-05 12:50:22 +00:00
refactor: tighten final boundary guardrails
This commit is contained in:
@@ -23,6 +23,10 @@ const ALLOWED_CONTRACT_BUNDLED_PATH_HELPERS = new Set([
|
||||
"src/plugins/contracts/plugin-sdk-runtime-api-guardrails.test.ts",
|
||||
]);
|
||||
|
||||
const ALLOWED_CHANNEL_BUNDLED_METADATA_CONSUMERS = new Set([
|
||||
"src/channels/plugins/session-conversation.bundled-fallback.test.ts",
|
||||
]);
|
||||
|
||||
describe("plugin contract boundary invariants", () => {
|
||||
it("keeps bundled-capability-metadata confined to contract/test inventory", async () => {
|
||||
const { globSync } = await import("glob");
|
||||
@@ -89,4 +93,35 @@ describe("plugin contract boundary invariants", () => {
|
||||
});
|
||||
expect(offenders).toEqual([]);
|
||||
});
|
||||
|
||||
it("keeps channel production code off bundled-plugin-metadata helpers", async () => {
|
||||
const { globSync } = await import("glob");
|
||||
const files = globSync("src/channels/**/*.ts", {
|
||||
cwd: REPO_ROOT,
|
||||
nodir: true,
|
||||
ignore: ["src/channels/**/*.test.ts"],
|
||||
});
|
||||
const offenders = files.filter((file) => {
|
||||
if (ALLOWED_CHANNEL_BUNDLED_METADATA_CONSUMERS.has(file)) {
|
||||
return false;
|
||||
}
|
||||
const source = readFileSync(resolve(REPO_ROOT, file), "utf8");
|
||||
return source.includes("plugins/bundled-plugin-metadata");
|
||||
});
|
||||
expect(offenders).toEqual([]);
|
||||
});
|
||||
|
||||
it("keeps contract loaders off hand-built bundled extension paths", async () => {
|
||||
const { globSync } = await import("glob");
|
||||
const files = globSync("src/{plugins,channels}/**/*.ts", {
|
||||
cwd: REPO_ROOT,
|
||||
nodir: true,
|
||||
ignore: ["src/**/*.test.ts"],
|
||||
});
|
||||
const offenders = files.filter((file) => {
|
||||
const source = readFileSync(resolve(REPO_ROOT, file), "utf8");
|
||||
return /extensions\/\$\{|\.\.\/\.\.\/\.\.\/\.\.\/extensions\//u.test(source);
|
||||
});
|
||||
expect(offenders).toEqual([]);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user