refactor: tighten final boundary guardrails

This commit is contained in:
Peter Steinberger
2026-04-05 21:13:22 +01:00
parent 714ba48a6f
commit 8206328a94
10 changed files with 280 additions and 170 deletions

View File

@@ -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([]);
});
});