Skip to content

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

chore: files changed scripts/__tests__/check-module-boundaries.test.mjs,scripts/ci/check-module-boun

Steven Enamakel6ac5087a9b56
diff --git a/scripts/__tests__/check-module-boundaries.test.mjs b/scripts/__tests__/check-module-boundaries.test.mjs
index 53d69dbca4..6fbee1f0e2 100644
--- a/scripts/__tests__/check-module-boundaries.test.mjs
+++ b/scripts/__tests__/check-module-boundaries.test.mjs
@@ -153,3 +153,32 @@ test('contract binary payload serialization permits base64 without admitting cry
assert.deepEqual(auditGraph(invalid, ['tinychannels-bus'], strict, 'tinychannels-bus').violations.map(v => v.package), [dependency]);
}
});
+
+test('the linked-modules bridge is allowed directly under the CLI only, without auditing its subtree', () => {
+ const linked = { ...strict, linkedHost: { package: 'openhuman-modules-linked', allowedParents: ['openhuman-cli'] } };
+ const ok = metadata({ 'openhuman-cli': [['openhuman-modules-linked']], 'openhuman-modules-linked': [['tinydocs-module']], 'tinydocs-module': [['tinydocs']] });
+ assert.deepEqual(auditGraph(ok, ['openhuman-cli'], linked).violations, []);
+ assert.equal(policy.linkedHost.package, 'openhuman-modules-linked');
+ assert.deepEqual(policy.linkedHost.allowedParents, ['openhuman-cli']);
+});
+
+test('deliberate violation: the bridge reached from the app, the TUI, the core or through a wrapper fails', () => {
+ const linked = { ...strict, linkedHost: { package: 'openhuman-modules-linked', allowedParents: ['openhuman-cli'] } };
+ for (const host of ['openhuman-app', 'openhuman-tui', 'openhuman']) {
+ const m = metadata({ [host]: [['openhuman-modules-linked']], 'openhuman-modules-linked': [['tinydocs-module']] });
+ const result = auditGraph(m, [host], linked);
+ assert.deepEqual(result.violations.map(v => v.path), [[host, 'openhuman-modules-linked']], host);
+ }
+ const wrapped = metadata({ 'openhuman-cli': [['wrapper']], wrapper: [['openhuman-modules-linked']] });
+ assert.equal(auditGraph(wrapped, ['openhuman-cli'], linked).violations.length, 1);
+});
+
+test('without a linkedHost policy the bridge subtree is audited like any other dependency', () => {
+ const m = metadata({ 'openhuman-cli': [['openhuman-modules-linked']], 'openhuman-modules-linked': [['tinydocs-module']] });
+ assert.deepEqual(auditGraph(m, ['openhuman-cli'], strict).violations.map(v => v.package), ['tinydocs-module']);
+});
+
+test('linkedHost policy validation rejects an empty parent list and an implementation package', () => {
+ assert.throws(() => validatePolicy({ ...policy, linkedHost: { package: 'x', allowedParents: [] } }), /linkedHost/);
+ assert.throws(() => validatePolicy({ ...policy, linkedHost: { package: 'tinydocs-module', allowedParents: ['openhuman-cli'] } }), /implementation/);
+});
diff --git a/scripts/ci/check-module-boundaries.mjs b/scripts/ci/check-module-boundaries.mjs
index e36e0fcded..d41795cf18 100644
--- a/scripts/ci/check-module-boundaries.mjs
+++ b/scripts/ci/check-module-boundaries.mjs
@@ -67,6 +67,16 @@ export function auditGraph(metadata, roots, policy, contract = null) {
if (seen.has(id)) continue;
seen.add(id);
const name = packages.get(id).name;
+ // The one crate that may link module implementations (local development
+ // only). It is a legitimate edge only directly under an allowed host
+ // crate, and its own subtree is not audited: that is the point of it. Any
+ // other route to it (the app, the TUI, the core, a wrapper) is a finding.
+ if (!contract && policy.linkedHost?.package === name && path.length > 1) {
+ const parent = packages.get(path.at(-2)).name;
+ if (path.length === 2 && policy.linkedHost.allowedParents.includes(parent)) continue;
+ violations.push({ scope: 'hosts', package: name, path: path.map(id => packages.get(id).name) });
+ continue;
+ }
if (path.length > 1) {
const sourceMismatch = !contract && policy.contractManifests?.[name] &&
packages.get(id).manifest_path !== policy.contractManifests[name];
@@ -96,6 +106,13 @@ export function validatePolicy(policy) {
if (!policy.contracts.length || !policy.implementationPackages.length || !policy.implementationPrefixes.length) {
throw new Error('boundary inventory may not be empty');
}
+ if (policy.linkedHost !== undefined) {
+ const { package: pkg, allowedParents } = policy.linkedHost;
+ if (!pkg || !Array.isArray(allowedParents) || allowedParents.length === 0 || !allowedParents.every(Boolean)) {
+ throw new Error('policy.linkedHost needs a package and a non-empty allowedParents list');
+ }
+ if (isImplementation(pkg, policy)) throw new Error('policy.linkedHost.package may not itself be an implementation package');
+ }
const names = new Set();
for (const contract of [...policy.contracts, ...policy.pendingContracts]) {
if (!contract.name?.endsWith('-bus') || !contract.manifest || !contract.owner || names.has(contract.name)) {
diff --git a/scripts/ci/module-boundaries.json b/scripts/ci/module-boundaries.json
index c162ce65ea..5995f8a67c 100644
--- a/scripts/ci/module-boundaries.json
+++ b/scripts/ci/module-boundaries.json
@@ -99,6 +99,10 @@
"owner": "https://github.com/tinyhumansai/tinybox"
}
],
+ "linkedHost": {
+ "package": "openhuman-modules-linked",
+ "allowedParents": ["openhuman-cli"]
+ },
"pendingContracts": [],
"exceptions": [],
"excludedSubsystems": [