Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

feat(ci): check hosts cannot reach the linked-modules bridge

Steven Enamakelc468493ef855
diff --git a/scripts/__tests__/check-module-boundaries.test.mjs b/scripts/__tests__/check-module-boundaries.test.mjs
index 0b8231110f..a69f801fe1 100644
--- a/scripts/__tests__/check-module-boundaries.test.mjs
+++ b/scripts/__tests__/check-module-boundaries.test.mjs
@@ -1,7 +1,7 @@
import assert from 'node:assert/strict';
import { readFileSync } from 'node:fs';
import test from 'node:test';
-import { auditGraph, graph, isImplementation, validatePolicy, CONTRACT_REGISTRY } from '../ci/check-module-boundaries.mjs';
+import { auditGraph, bridgeReach, graph, isImplementation, validatePolicy, CONTRACT_REGISTRY } from '../ci/check-module-boundaries.mjs';
const policy = JSON.parse(readFileSync(new URL('../ci/module-boundaries.json', import.meta.url), 'utf8'));
const strict = { ...policy, exceptions: [] };
@@ -182,3 +182,20 @@ test('linkedHost policy validation rejects an empty parent list and an implement
assert.throws(() => validatePolicy({ ...policy, linkedHost: { package: 'x', allowedParents: [] } }), /linkedHost/);
assert.throws(() => validatePolicy({ ...policy, linkedHost: { package: 'tinydocs-module', allowedParents: ['openhuman-cli'] } }), /implementation/);
});
+
+test('without linked-modules no host reaches the bridge; with it, the CLI does', () => {
+ const without = metadata({ 'openhuman-cli': [['openhuman-rpc']], 'openhuman-tui': [['openhuman-rpc']], openhuman: [] });
+ assert.deepEqual(bridgeReach(without, ['openhuman-cli', 'openhuman-tui', 'openhuman'], policy), []);
+ const withIt = metadata({
+ 'openhuman-cli': [['openhuman-rpc'], ['openhuman-modules-linked']],
+ 'openhuman-tui': [['openhuman-rpc']],
+ openhuman: [],
+ });
+ assert.deepEqual(
+ bridgeReach(withIt, ['openhuman-cli', 'openhuman-tui', 'openhuman'], policy).map(v => v.path),
+ [['openhuman-cli', 'openhuman-modules-linked']]
+ );
+ // A dev edge is not a shipped edge.
+ const dev = metadata({ 'openhuman-cli': [['openhuman-modules-linked', 'dev']], 'openhuman-modules-linked': [] });
+ assert.deepEqual(bridgeReach(dev, ['openhuman-cli'], policy), []);
+});
diff --git a/scripts/ci/check-module-boundaries.mjs b/scripts/ci/check-module-boundaries.mjs
index d41795cf18..4c3c110ef2 100644
--- a/scripts/ci/check-module-boundaries.mjs
+++ b/scripts/ci/check-module-boundaries.mjs
@@ -99,6 +99,37 @@ export function auditGraph(metadata, roots, policy, contract = null) {
return { violations, exceptions };
}
+/**
+ * Roots that reach the linked-modules bridge through normal or build edges.
+ * Used on a metadata resolve WITHOUT `--all-features`: neither the CLI built
+ * without `linked-modules`, nor the TUI, nor the core may reach it. Returns
+ * violation findings shaped like {@link auditGraph}'s.
+ */
+export function bridgeReach(metadata, roots, policy) {
+ const target = policy.linkedHost?.package;
+ if (!target) return [];
+ const { packages, edges } = graph(metadata);
+ const found = [];
+ for (const root of roots) {
+ const candidates = [...packages.values()].filter(pkg => pkg.name === root);
+ if (candidates.length !== 1) throw new Error(`expected exactly one root package ${root}`);
+ const queue = [[candidates[0].id]];
+ const seen = new Set();
+ for (let at = 0; at < queue.length; at++) {
+ const path = queue[at];
+ const id = path.at(-1);
+ if (seen.has(id)) continue;
+ seen.add(id);
+ if (packages.get(id).name === target) {
+ found.push({ scope: 'hosts', package: target, path: path.map(item => packages.get(item).name) });
+ continue;
+ }
+ for (const next of edges(id)) queue.push([...path, next]);
+ }
+ }
+ return found;
+}
+
export function validatePolicy(policy) {
for (const key of ['implementationPackages', 'implementationPrefixes', 'contracts', 'pendingContracts', 'exceptions']) {
if (!Array.isArray(policy[key])) throw new Error(`policy.${key} must be an array`);
@@ -178,6 +209,12 @@ export function run(root, strict = false) {
const metadata = cargo(root, ['--manifest-path', join(root, manifest), '--locked', '--all-features']);
results.push(auditGraph(metadata, roots, policy));
}
+ // Without `linked-modules` (default features) no host reaches the bridge.
+ results.push({
+ violations: bridgeReach(cargo(root, ['--manifest-path', join(root, 'Cargo.toml'), '--locked']),
+ ['openhuman-cli', 'openhuman-tui', 'openhuman'], policy),
+ exceptions: [],
+ });
for (const contract of policy.contracts) {
for (const all of [false, true]) {
results.push(auditGraph(contractMetadata(root, contract, all), [contract.name], policy, contract.name));