Skip to content

Commit d0e881e

Browse files
committed
test: classify runtime api guardrails exactly
1 parent 64ecb1f commit d0e881e

1 file changed

Lines changed: 39 additions & 4 deletions

File tree

‎src/plugins/contracts/plugin-sdk-runtime-api-guardrails.test.ts‎

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,39 @@ import { bundledPluginFile, getBundledPluginRoots } from "./test-helpers/bundled
77

88
const ROOT_DIR = resolve(dirname(fileURLToPath(import.meta.url)), "../..");
99

10+
function runtimeApiPluginFile(pluginId: string): string {
11+
return bundledPluginFile({ rootDir: ROOT_DIR, pluginId, relativePath: "runtime-api.ts" });
12+
}
13+
14+
const UNGUARDED_RUNTIME_API_PLUGIN_IDS = [
15+
"acpx",
16+
"browser",
17+
"canvas",
18+
"clickclack",
19+
"copilot-proxy",
20+
"diffs",
21+
"feishu",
22+
"google",
23+
"line",
24+
"lmstudio",
25+
"lobster",
26+
"mattermost",
27+
"memory-core",
28+
"ollama",
29+
"open-prose",
30+
"phone-control",
31+
"qa-channel",
32+
"qa-lab",
33+
"qa-matrix",
34+
"qqbot",
35+
"tlon",
36+
"tokenjuice",
37+
"webhooks",
38+
"zai",
39+
"zalo",
40+
"zalouser",
41+
] as const;
42+
1043
const RUNTIME_API_EXPORT_GUARDS: Record<string, readonly string[]> = {
1144
[bundledPluginFile({ rootDir: ROOT_DIR, pluginId: "discord", relativePath: "runtime-api.ts" })]: [
1245
'export { discordMessageActions, handleDiscordAction, isDiscordModerationAction, readDiscordChannelCreateParams, readDiscordChannelEditParams, readDiscordChannelMoveParams, readDiscordModerationCommand, readDiscordParentIdParam, requiredGuildPermissionForModerationAction, type DiscordModerationAction, type DiscordModerationCommand } from "./runtime-api.actions.js";',
@@ -287,11 +320,13 @@ function readExportStatements(path: string): string[] {
287320
}
288321

289322
describe("runtime api guardrails", () => {
290-
it("keeps runtime api surfaces on an explicit export allowlist", () => {
323+
it("keeps runtime api surfaces classified and guarded exports pinned", () => {
291324
const runtimeApiFiles = collectRuntimeApiFiles();
292-
expect(runtimeApiFiles).toEqual(
293-
expect.arrayContaining(Object.keys(RUNTIME_API_EXPORT_GUARDS).toSorted()),
294-
);
325+
const expectedRuntimeApiFiles = [
326+
...Object.keys(RUNTIME_API_EXPORT_GUARDS),
327+
...UNGUARDED_RUNTIME_API_PLUGIN_IDS.map(runtimeApiPluginFile),
328+
].toSorted();
329+
expect(runtimeApiFiles.toSorted()).toEqual(expectedRuntimeApiFiles);
295330

296331
for (const file of Object.keys(RUNTIME_API_EXPORT_GUARDS).toSorted()) {
297332
expect(readExportStatements(file), `${file} runtime api exports changed`).toEqual(

0 commit comments

Comments
 (0)