Skip to content

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

refactor(ci): add linkedHostAudit function

Steven Enamakel6bf47c89547b
diff --git a/scripts/__tests__/check-module-boundaries.test.mjs b/scripts/__tests__/check-module-boundaries.test.mjs
index b6f1fead90..4fb804cd89 100644
--- a/scripts/__tests__/check-module-boundaries.test.mjs
+++ b/scripts/__tests__/check-module-boundaries.test.mjs
@@ -2,7 +2,7 @@ import assert from 'node:assert/strict';
import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
import { join, resolve } from 'node:path';
import test from 'node:test';
-import { auditGraph, bridgeReach, graph, isImplementation, run, treeGraph, validatePolicy, CONTRACT_REGISTRY } from '../ci/check-module-boundaries.mjs';
+import { auditGraph, bridgeReach, graph, isImplementation, linkedHostAudit, run, treeGraph, 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: [] };
@@ -174,6 +174,10 @@ test('a legal direct bridge edge does not hide a second path through a wrapper',
auditGraph(m, ['openhuman-cli'], linked).violations.map(v => v.path),
[['openhuman-cli', 'wrapper', 'openhuman-modules-linked']],
);
+ assert.deepEqual(
+ linkedHostAudit(m, 'openhuman-cli', linked).map(v => v.path),
+ [['openhuman-cli', 'wrapper', 'openhuman-modules-linked']],
+ );
});
test('deliberate violation: the bridge reached from the app, the TUI, the core or through a wrapper fails', () => {
diff --git a/scripts/ci/check-module-boundaries.mjs b/scripts/ci/check-module-boundaries.mjs
index 5b584058fa..5597d86880 100644
--- a/scripts/ci/check-module-boundaries.mjs
+++ b/scripts/ci/check-module-boundaries.mjs
@@ -141,6 +141,35 @@ export function bridgeReach(metadata, roots, policy) {
return found;
}
+/** Check bridge incoming edges without auditing feature-unified descendants. */
+export function linkedHostAudit(metadata, root, policy) {
+ const target = policy.linkedHost?.package;
+ if (!target) return [];
+ const { packages, edges } = graph(metadata);
+ const candidates = [...packages.values()].filter(pkg => pkg.name === root);
+ if (candidates.length !== 1) throw new Error(`expected exactly one root package ${root}`);
+ const rootId = candidates[0].id;
+ const queue = [[rootId]];
+ const seen = new Set();
+ const violations = [];
+ 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);
+ for (const next of edges(id)) {
+ if (packages.get(next).name === target) {
+ if (id !== rootId || !policy.linkedHost.allowedParents.includes(root)) {
+ violations.push({ scope: 'hosts', package: target, path: [...path, next].map(item => packages.get(item).name) });
+ }
+ continue;
+ }
+ queue.push([...path, next]);
+ }
+ }
+ return violations;
+}
+
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`);
@@ -341,7 +370,10 @@ export function run(root, strict = false, execute = execFileSync) {
// The linked-modules CLI feature is local-only, never shipped. Audit its
// separately rooted graph for a direct CLI edge; do not let its feature
// unification contaminate the CLI's shipping feature graph above.
- results.push(auditGraph(linkedCliTree(root, execute), ['openhuman-cli'], policy));
+ results.push({
+ violations: linkedHostAudit(linkedCliTree(root, execute), 'openhuman-cli', policy),
+ exceptions: [],
+ });
// Default-feature graphs also guard against accidental bridge activation.
for (const packageName of ['openhuman-cli', 'openhuman-tui', 'openhuman']) {
results.push({