refactor: enforce plugin-owned channel boundaries

This commit is contained in:
Peter Steinberger
2026-04-18 22:45:03 +01:00
parent e89e214516
commit 8bfa06e992
26 changed files with 546 additions and 388 deletions

View File

@@ -23,6 +23,9 @@ const acpCoreProtectedSources = [
const channelCoreProtectedSources = [
path.join(repoRoot, "src", "channels", "thread-bindings-policy.ts"),
path.join(repoRoot, "src", "channels", "thread-bindings-messages.ts"),
path.join(repoRoot, "src", "sessions", "send-policy.ts"),
path.join(repoRoot, "src", "sessions", "session-chat-type-shared.ts"),
path.join(repoRoot, "src", "utils", "delivery-context.ts"),
];
const acpUserFacingTextSources = [
path.join(repoRoot, "src", "auto-reply", "reply", "commands-acp"),
@@ -41,11 +44,18 @@ const channelIds = [
"imessage",
"irc",
"line",
"mattermost",
"matrix",
"msteams",
"nextcloud-talk",
"nostr",
"qqbot",
"signal",
"slack",
"synology-chat",
"telegram",
"tlon",
"twitch",
"web",
"whatsapp",
"zalo",

View File

@@ -0,0 +1,59 @@
#!/usr/bin/env node
import { spawnSync } from "node:child_process";
import path from "node:path";
const repoRoot = path.resolve(import.meta.dirname, "..");
const tsgoPath = path.join(repoRoot, "node_modules", ".bin", "tsgo");
const coreGraphs = [
{ name: "core", config: "tsconfig.core.json" },
{ name: "core-test", config: "tsconfig.core.test.json" },
{ name: "core-test-agents", config: "tsconfig.core.test.agents.json" },
{ name: "core-test-non-agents", config: "tsconfig.core.test.non-agents.json" },
];
function normalizeFilePath(filePath) {
const normalized = filePath.trim().replaceAll("\\", "/");
const normalizedRoot = repoRoot.replaceAll("\\", "/");
if (normalized.startsWith(`${normalizedRoot}/`)) {
return normalized.slice(normalizedRoot.length + 1);
}
return normalized;
}
function listGraphFiles(graph) {
const result = spawnSync(tsgoPath, ["-p", graph.config, "--pretty", "false", "--listFilesOnly"], {
cwd: repoRoot,
encoding: "utf8",
maxBuffer: 256 * 1024 * 1024,
shell: process.platform === "win32",
});
if (result.error) {
throw result.error;
}
if ((result.status ?? 1) !== 0) {
const output = [result.stdout, result.stderr].filter(Boolean).join("\n");
throw new Error(`${graph.name} file listing failed with exit code ${result.status}\n${output}`);
}
return (result.stdout ?? "").split(/\r?\n/u).map(normalizeFilePath).filter(Boolean);
}
const violations = [];
for (const graph of coreGraphs) {
const extensionFiles = listGraphFiles(graph).filter((file) => file.startsWith("extensions/"));
for (const file of extensionFiles) {
violations.push(`${graph.name}: ${file}`);
}
}
if (violations.length > 0) {
console.error("Core tsgo graphs must not include bundled extension files:");
for (const violation of violations) {
console.error(`- ${violation}`);
}
console.error(
"Move extension-owned behavior behind plugin SDK contracts, public artifacts, or extension-local tests.",
);
process.exit(1);
}

View File

@@ -22,6 +22,14 @@ const GRAPH_DEFINITIONS = {
config: "tsconfig.core.test.json",
description: "core colocated test graph",
},
"core-test-agents": {
config: "tsconfig.core.test.agents.json",
description: "core agent colocated test graph",
},
"core-test-non-agents": {
config: "tsconfig.core.test.non-agents.json",
description: "core non-agent colocated test graph",
},
extensions: {
config: "tsconfig.extensions.json",
description: "bundled extension production graph",