The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
feat(ci): ratchet loadable module dependency boundaries
Steven Enamakel53df4df6dc1d
diff --git a/AGENTS.md b/AGENTS.mdindex e2ae8e2346..ac4dc6ef5b 100644--- a/AGENTS.md+++ b/AGENTS.md@@ -513,6 +513,8 @@ builds after changing a gate. Use `scripts/assert-shed.sh` or## Loadable modules and bus contracts+Hosts must interface with loadable components through their minimal `*-bus` contracts. Never import, re-export, link, or call their implementation libraries directly, including through wrapper crates or indirect dependencies. Execute component behavior through the compiled TinyBus module. If the required types or operations are missing, extend the contract and implementation in the owning repository and raise a PR against its canonical upstream first; then consume the released module and update OpenHuman’s gitlink and adapter. Do not introduce a host-side implementation workaround.+### Submodule ownershipOpenHuman is the host and orchestrator for these components. It composes them,diff --git a/docs/module-boundary-inventory.md b/docs/module-boundary-inventory.mdnew file mode 100644index 0000000000..a6324081d0--- /dev/null+++ b/docs/module-boundary-inventory.md@@ -0,0 +1,71 @@+# Loadable module boundary inventory++Status: migration incomplete. This inventory records the pinned source at+`ad89cddbca`; it does not assert that the host already uses only contracts.+The machine-readable dependency policy is+[`scripts/ci/module-boundaries.json`](../scripts/ci/module-boundaries.json).++Every owner below is the canonical upstream under+`https://github.com/tinyhumansai/`. Contract changes land there first. OpenHuman+host adapters switch only after compatible per-platform artifacts are released+and their digests pinned. Do not remove a dependency by removing its capability,+copying its implementation into a host, or accepting weaker isolation.++| Owner | Linked implementation packages | Contract | Host consumers | Required module work |+| --- | --- | --- | --- | --- |+| tinyjuice | tinyjuice | tinyjuice-bus | core tools, compression, CCR REPL | HTML extraction, query supplied artifacts against module CCR store, schema and tool declarations; retain turn-bound model callbacks |+| tinyconnectors | tinyconnectors, tinyconnectors-sync | tinyconnectors-bus | core integrations, credentials and triggers | Argument preparation, calendar defaults, task windows, structured provider errors, trigger archives; preserve sign-in/out reconciliation |+| tinymcp | tinymcp | tinymcp-bus | core MCP registry, supervisor, CLI stdio/HTTP server | Supervisor notifications, server protocol operations and callbacks for approved host tools/resources/prompts |+| tinychannels | tinychannels, tinychannels-runtime; runtime/crypto code in contract | tinychannels-bus | core channels and podcast email, TinyHumans host, CLI REPL | Move providers, signing and pairing out of contract; relay config, pairing, start/stop/send/status, inbound/status callbacks, bounded delivery/draining |+| tinyhosts | tinyhosts | tinyhosts-bus (missing at pin) | core hosting tools | Extract vocabulary and tool declarations; consume Execute/Providers after host validation/approval |+| tinywallet | tinywallet-crypto, tinywallet-web3, tinywallet-x402 via bus and direct imports | tinywallet-bus | core wallet/web3/x402 | Move behavioral re-exports out of bus; validation, transaction construction, quotes, swaps, payments, budgets, ledger; retain host custody/approval and confidential attestation |+| tinybox | tinybox-core, tinybox-jail, tinybox-docker, tinybox-host, tinybox-ssh | tinybox-bus (missing at pin) | core sandbox and security, desktop gateways | Discovery-only module needs handle-based sandbox/exec/streams/cancel/files/forward/status/close and shell-analysis facts; pre-core gateways use process loader |+| tinycomputer | tinycomputer-accessibility | tinycomputer-bus | core voice, paste/focus and permission checks | Permission, focus, paste, Globe listener vocabulary/operations; preserve native thread and target rules |+| tinyvoice | tinyvoice, cpal (also through accessibility probe) | tinyvoice-bus | core voice capture/hotkeys | Devices, recording/capture and hotkey lifecycle, bounded event batches; computer module permission decisions |+| tinyruntime | tinyruntime-pyserver | tinyruntime-bus | core Python worker, optional TinyJuice ML | Prepare/start/request/status/stop workers; module owns install, handshakes, retries/backoff and idle expiry |+| tinydocs / tinymemory | pdf-extract, calamine through tinymemory-integrations/documents-office | tinydocs-bus | core memory converter and file sources | Replace OfficeConverter with bus DocumentConverter; XLSX extraction plus existing PDF/DOCX/PPTX metadata/format coverage |+| tinysearch | none observed | tinysearch-bus | core module search proxy | Preserve existing bus adapter; enforce contract and host dependency graphs |++## Gate behavior++`pnpm rust:module-boundaries` checks the resolved normal and build dependency+closure of core, CLI, TUI and the excluded desktop workspace with all features.+Dev-only dependencies are excluded, including the test-only TinyWallet key+implementation. Package IDs, not dependency aliases, determine graph identity.+Target-specific dependencies are retained by Cargo metadata without a platform+filter. A new implementation package within an inventoried owner namespace+fails unless it is a registered contract.++Contracts are resolved separately in generated probe workspaces, once with+default features and once with every declared feature. Only serialization,+schema and error-derive closures are approved. This catches optional runtime or+implementation imports independently of host feature selection. Probes do not+compile native module code, and their manifests and lockfiles are kept under+`target/module-boundaries/` in the checkout.++Exceptions are exact package/scope pairs with reasons. Host exceptions still+traverse their descendants. Contract exceptions stop at the first unsafe edge:+its implementation closure is not approved, and that edge must be removed with+the owning migration. The channel and wallet contract migrations remain+explicitly outstanding. An unused exception fails, prompting removal instead+of leaving future regressions silently exempted.++`pnpm rust:module-boundaries:complete` also fails while any exception or pending+contract exists. Passing the transitional gate means no unlisted boundary+violation was observed; it does not mean this plan is complete.++## Remaining acceptance work++The shared `openhuman_rpc::embed::modules::ModuleClient` takes explicit runtime+configuration and uses the same process-wide loader before or after core+startup. It has no linked fallback. Resolution reports and client errors use a+closed reason vocabulary, registry metadata and a bounded deduplication cache;+raw loader paths and remote fault prose are absent from these Sentry events.+Existing domain adapters still need to migrate through this reporting path.++Upstream operations and artifacts, gateway integration, frozen tool restoration,+lifecycle regressions and coverage of all migrated adapter failures are still+required. No capability migration has landed in this change. The minimal/default/product/individual-feature build matrix,+platform compilation, runtime bus fixtures and shed measurements remain+separate acceptance checks. Dependency counts alone do not demonstrate a+build-time or binary-size improvement.diff --git a/gitbooks/developing/architecture/README.md b/gitbooks/developing/architecture/README.mdindex 6eff1df319..d172c32a8e 100644--- a/gitbooks/developing/architecture/README.md+++ b/gitbooks/developing/architecture/README.md@@ -97,3 +97,22 @@ The code is at [github.com/tinyhumansai/openhuman](https://github.com/tinyhumans- [Frontend](frontend.md) and [Tauri shell](tauri-shell.md) for the two outer layers.- [Loadable modules](../loadable-modules.md) and [Pluggable engines](../engines.md) for what plugs into the core.- [`AGENTS.md`](https://github.com/tinyhumansai/openhuman/blob/main/AGENTS.md) for the repo-wide rules, including which `vendor/` submodule owns what.++## Loadable component dependency boundary++Hosts execute loadable component behavior through compiled TinyBus modules and+link only the components' minimal `*-bus` vocabulary. Contract crates contain+serialized types, errors, identifiers, versions, schemas and tool declarations;+providers, parsers, cryptography, storage, native resources and execution+algorithms belong inside modules. OpenHuman retains policy, credentials,+approvals, cancellation and product orchestration. Stateful resources cross+the bus as opaque handles with explicit cleanup operations.++This boundary is still being migrated. The+[module boundary inventory](../../../docs/module-boundary-inventory.md) names+existing exceptions and required upstream work. `pnpm rust:module-boundaries`+checks host normal/build dependency graphs and independently resolved contract+graphs. Its transitional pass does not certify completion;+`pnpm rust:module-boundaries:complete` requires an empty exception list and no+pending contracts. Host adapters switch after compatible module artifacts are+released and pinned, preserving lazy loading and cached resolution.diff --git a/package.json b/package.jsonindex 8ae60b12e1..a943a3ac7a 100644--- a/package.json+++ b/package.json@@ -56,6 +56,8 @@"test:install-ps1": "pwsh -NoProfile -File scripts/tests/OpenHumanWindowsInstall.Tests.ps1","rust:check": "pnpm --filter openhuman-app rust:check","rust:clippy": "cargo clippy -p openhuman -p openhuman-cli -p openhuman-tinyhumans -- -D warnings && pnpm --filter openhuman-app rust:clippy",+ "rust:module-boundaries": "node scripts/ci/check-module-boundaries.mjs",+ "rust:module-boundaries:complete": "node scripts/ci/check-module-boundaries.mjs --require-complete","rust:layout": "node scripts/ci/check-openhuman-rust-layout.mjs && node scripts/ci/check-crate-chain.mjs && node scripts/ci/check-storage-bypass.mjs","rust:ignored-tests": "node scripts/ci/check-ignored-tests.mjs","dep:audit": "bash scripts/dep-audit/run.sh",diff --git a/scripts/__tests__/check-module-boundaries.test.mjs b/scripts/__tests__/check-module-boundaries.test.mjsnew file mode 100644index 0000000000..0c564dc32b--- /dev/null+++ b/scripts/__tests__/check-module-boundaries.test.mjs@@ -0,0 +1,102 @@+import assert from 'node:assert/strict';+import { readFileSync } from 'node:fs';+import test from 'node:test';+import { auditGraph, graph, isImplementation, validatePolicy } 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: [] };+function metadata(edges, names = {}) {+ const ids = [...new Set(Object.entries(edges).flatMap(([id, deps]) => [id, ...deps.map(d => d[0])]))];+ return {+ packages: ids.map(id => ({ id, name: names[id] ?? id })),+ resolve: { nodes: ids.map(id => ({ id, deps: (edges[id] ?? []).map(([pkg, kind = null, target = null]) => ({ pkg, dep_kinds: [{ kind, target }] })) })) },+ };+}++test('checked-in inventory has explicit owners and reasoned exceptions', () => validatePolicy(policy));+test('host traversal rejects direct, wrapper and build dependencies', () => {+ const m = metadata({ host: [['wrapper'], ['tinyvoice', 'build']], wrapper: [['tinyjuice']] });+ const result = auditGraph(m, ['host'], strict);+ assert.deepEqual(result.violations.map(v => v.path), [['host', 'tinyvoice'], ['host', 'wrapper', 'tinyjuice']]);+});+test('dev-only implementation dependencies do not enter shipped graphs', () => {+ const m = metadata({ host: [['test-helper', 'dev']], 'test-helper': [['tinyjuice']] });+ assert.deepEqual(auditGraph(m, ['host'], strict).violations, []);+});+test('a dependency with both dev and normal kinds remains forbidden', () => {+ const m = metadata({ host: [['tinyjuice', 'dev']] });+ m.resolve.nodes[0].deps[0].dep_kinds.push({ kind: null, target: null });+ assert.equal(auditGraph(m, ['host'], strict).violations.length, 1);+});+test('platform-specific build and normal dependencies are inspected', () => {+ const m = metadata({ host: [['tinybox-jail', null, 'cfg(windows)'], ['tinyvoice', 'build', 'cfg(target_os = "macos")']] });+ assert.equal(auditGraph(m, ['host'], strict).violations.length, 2);+});+test('package identity is not a dependency alias', () => {+ const m = metadata({ host: [['pkg#implementation']] }, { 'pkg#implementation': 'tinyjuice' });+ assert.equal(auditGraph(m, ['host'], strict).violations[0].package, 'tinyjuice');+});+test('new implementation packages in owning repositories are forbidden', () => {+ assert.equal(isImplementation('tinywallet-new-provider', strict), true);+ assert.equal(isImplementation('tinywallet-bus', strict), false);+ assert.equal(isImplementation('tinywallet-unregistered-bus', strict), true);+ assert.equal(isImplementation('tinysearch', strict), true);+});+test('contracts permit only the serialization/schema/error closure', () => {+ const m = metadata({ 'tinyjuice-bus': [['serde'], ['thiserror']], serde: [['serde_derive']], serde_derive: [['syn']], thiserror: [['thiserror-impl']] });+ assert.deepEqual(auditGraph(m, ['tinyjuice-bus'], strict, 'tinyjuice-bus').violations, []);+});+test('contracts reject transport, runtime, HTTP, database and native libraries', () => {+ for (const dependency of ['tinybus', 'tokio', 'reqwest', 'rusqlite', 'cpal', 'tinyjuice']) {+ const m = metadata({ 'tinyjuice-bus': [[dependency]] });+ assert.equal(auditGraph(m, ['tinyjuice-bus'], strict, 'tinyjuice-bus').violations[0].package, dependency);+ }+});+test('contracts reject an indirect implementation in an approved dependency', () => {+ const m = metadata({ 'tinyjuice-bus': [['serde']], serde: [['tinyjuice']] });+ assert.deepEqual(auditGraph(m, ['tinyjuice-bus'], strict, 'tinyjuice-bus').violations[0].path, ['tinyjuice-bus', 'serde', 'tinyjuice']);+});+test('host exceptions do not exempt contract dependencies', () => {+ const m = metadata({ 'tinyjuice-bus': [['tinyjuice']] });+ assert.equal(auditGraph(m, ['tinyjuice-bus'], policy, 'tinyjuice-bus').violations.length, 1);+});+test('exceptions retain findings and do not hide new host descendants', () => {+ const m = metadata({ host: [['tinyjuice']], tinyjuice: [['tinyjuice-new-engine']] });+ const result = auditGraph(m, ['host'], policy);+ assert.equal(result.exceptions.length, 1);+ assert.equal(result.violations[0].package, 'tinyjuice-new-engine');+});+test('cycles terminate and versions preserve distinct package identities', () => {+ const m = metadata({ host: [['juice-old'], ['juice-new']], 'juice-old': [['host']] }, { 'juice-old': 'tinyjuice', 'juice-new': 'tinyjuice' });+ assert.equal(auditGraph(m, ['host'], strict).violations.length, 2);+});+test('missing resolve, missing roots and dangling edges fail closed', () => {+ assert.throws(() => graph({ packages: [] }), /resolved dependency graph/);+ assert.throws(() => auditGraph(metadata({ host: [] }), ['missing'], strict), /root package/);+ const m = metadata({ host: [['serde']] });+ m.resolve.nodes.pop();+ assert.throws(() => auditGraph(m, ['host'], strict), /unresolved dependency/);+});+test('missing dependency kinds fail closed rather than assuming dev-only', () => {+ const m = metadata({ host: [['tinyjuice']] });+ m.resolve.nodes[0].deps[0].dep_kinds = [];+ assert.throws(() => auditGraph(m, ['host'], strict), /missing dependency kinds/);+});+test('inventory rejects broad, duplicate, empty-reason or mis-scoped exceptions', () => {+ for (const item of [+ { scope: 'hosts', package: '*', reason: 'broad' },+ { scope: 'hosts', package: 'tinyjuice', reason: '' },+ { scope: 'tinyjuice-bus', package: 'serde', reason: 'approved' },+ { scope: 'missing-bus', package: 'tokio', reason: 'untracked' },+ policy.exceptions[0],+ ]) assert.throws(() => validatePolicy({ ...policy, exceptions: [...policy.exceptions, item] }));+});++test('a same-named contract from another source cannot evade independent auditing', () => {+ const m = metadata({ host: [['tinyjuice-bus']] });+ m.packages.find(pkg => pkg.name === 'tinyjuice-bus').manifest_path = '/unexpected/Cargo.toml';+ const pinned = { ...strict, contractManifests: { 'tinyjuice-bus': '/pinned/Cargo.toml' } };+ assert.equal(auditGraph(m, ['host'], pinned).violations.length, 1);+ m.packages.find(pkg => pkg.name === 'tinyjuice-bus').manifest_path = '/pinned/Cargo.toml';+ assert.equal(auditGraph(m, ['host'], pinned).violations.length, 0);+});diff --git a/scripts/__tests__/self-hosted-lanes.test.mjs b/scripts/__tests__/self-hosted-lanes.test.mjsindex 8339f4bf03..bb108a9094 100644--- a/scripts/__tests__/self-hosted-lanes.test.mjs+++ b/scripts/__tests__/self-hosted-lanes.test.mjs@@ -641,3 +641,18 @@ test("the rust-core path filter arms the lane for every crate the tui depends onassert.ok(block.includes(`'crates/openhuman-${crate}/**'`), crate);}});++test("module boundaries run for Rust and scripts changes in both profiles", () => {+ for (const profile of ["hosted", "ex63"]) {+ for (const area of ["rustCore", "rustTauri", "scripts"]) {+ const plan = buildPlan({+ profile,+ areas: { ...NONE, [area]: true },+ env: profile === "ex63" ? EX63_ENV : {},+ });+ const check = plan.lanes.flatMap(lane => lane.checks).find(check => check.name === "module-boundaries");+ assert.equal(check.when, true, `${profile}:${area}`);+ assert.equal(check.run, "bash scripts/ci-cancel-aware.sh node scripts/ci/check-module-boundaries.mjs");+ }+ }+});diff --git a/scripts/ci/README.md b/scripts/ci/README.mdindex a756855e86..3f28a7e490 100644--- a/scripts/ci/README.md+++ b/scripts/ci/README.md@@ -24,6 +24,17 @@ changed-line diff-cover check (>= 80%) in `ci-lite.yml`.## Running locally+The module boundary audit (`pnpm rust:module-boundaries`) resolves the root and+excluded desktop host with all features, traversing normal and build edges on+all platforms. It also resolves each bus contract independently with default+and all features, outside the owning module workspace, to avoid feature+unification with implementation crates. It runs in the Rust scripts lane.+Temporary exceptions in [`module-boundaries.json`](module-boundaries.json) must+have reasons; unused exceptions fail the audit. A passing transitional audit is+not a completed migration. `pnpm rust:module-boundaries:complete` additionally+rejects all exceptions and pending contracts. Cargo failure is an audit failure.+Generated probes and lockfiles stay in the checkout's `target/module-boundaries/`.+Only `check-openhuman-rust-layout.mjs` and `check-crate-chain.mjs` are wired to a pnpm script(`pnpm rust:layout`); the rest are invoked directly, e.g.`node scripts/ci/check-feature-forwarding.mjs` ordiff --git a/scripts/ci/check-module-boundaries.mjs b/scripts/ci/check-module-boundaries.mjsnew file mode 100644index 0000000000..2f339a282d--- /dev/null+++ b/scripts/ci/check-module-boundaries.mjs@@ -0,0 +1,187 @@+#!/usr/bin/env node+// Audit resolved normal/build edges, never Cargo.lock membership or dev edges.+import { execFileSync } from 'node:child_process';+import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';+import { dirname, join, resolve } from 'node:path';+import { fileURLToPath, pathToFileURL } from 'node:url';++export const CONTRACT_CLOSURE = new Set([+ 'serde', 'serde_core', 'serde_derive', 'serde_json', 'itoa', 'memchr', 'zmij',+ 'thiserror', 'thiserror-impl', 'schemars', 'schemars_derive', 'dyn-clone',+ 'ref-cast', 'ref-cast-impl', 'serde_derive_internals',+ 'proc-macro2', 'quote', 'syn', 'unicode-ident',+]);++export function isImplementation(name, policy) {+ return policy.implementationPackages.includes(name) ||+ policy.implementationPrefixes.some(prefix => name.startsWith(prefix) &&+ !policy.contracts.some(contract => contract.name === name));+}++/** Fail closed on unresolved metadata; retain package IDs (including versions). */+export function graph(metadata) {+ if (!metadata.resolve?.nodes || !metadata.packages?.length) {+ throw new Error('Cargo metadata must contain packages and a resolved dependency graph');+ }+ const packages = new Map(metadata.packages.map(pkg => [pkg.id, pkg]));+ const nodes = new Map(metadata.resolve.nodes.map(node => [node.id, node]));+ const edges = id => {+ const node = nodes.get(id);+ if (!packages.has(id) || !node) throw new Error(`missing resolved package ${id}`);+ if (!Array.isArray(node.deps)) throw new Error(`missing dependency kinds for ${id}`);+ return node.deps.filter(dep => {+ if (!Array.isArray(dep.dep_kinds) || dep.dep_kinds.length === 0) {+ throw new Error(`missing dependency kinds for ${dep.pkg}`);+ }+ if (dep.dep_kinds.some(kind => ![null, 'build', 'dev'].includes(kind.kind))) {+ throw new Error(`unknown dependency kind for ${dep.pkg}`);+ }+ return dep.dep_kinds.some(kind => kind.kind === null || kind.kind === 'build');+ }).map(dep => {+ if (!packages.has(dep.pkg) || !nodes.has(dep.pkg)) {+ throw new Error(`unresolved dependency ${dep.pkg}`);+ }+ return dep.pkg;+ });+ };+ return { packages, edges };+}++/** One shortest dependency path per forbidden package, including build scripts. */+export function auditGraph(metadata, roots, policy, contract = null) {+ const { packages, edges } = graph(metadata);+ const violations = [];+ const exceptions = [];+ 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);+ const name = packages.get(id).name;+ if (path.length > 1) {+ const sourceMismatch = !contract && policy.contractManifests?.[name] &&+ packages.get(id).manifest_path !== policy.contractManifests[name];+ const forbidden = contract ? !CONTRACT_CLOSURE.has(name) :+ isImplementation(name, policy) || sourceMismatch;+ if (forbidden) {+ const scope = contract ?? 'hosts';+ const exemption = policy.exceptions.find(item => item.scope === scope && item.package === name);+ const finding = { scope, package: name, path: path.map(id => packages.get(id).name) };+ (exemption ? exceptions : violations).push(finding);+ // Contract exceptions pin the first unsafe dependency. Its implementation+ // closure is deliberately NOT approved vocabulary and must disappear+ // with this edge. Hosts still traverse it to catch indirect implementations.+ if (contract) continue;+ }+ }+ for (const next of edges(id)) queue.push([...path, next]);+ }+ }+ return { violations, exceptions };+}++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`);+ }+ if (!policy.contracts.length || !policy.implementationPackages.length || !policy.implementationPrefixes.length) {+ throw new Error('boundary inventory may not be empty');+ }+ 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)) {+ throw new Error(`invalid or duplicate contract ${contract.name}`);+ }+ if (policy.pendingContracts.includes(contract) && !contract.reason?.trim()) {+ throw new Error(`pending contract ${contract.name} needs a reason`);+ }+ names.add(contract.name);+ }+ const seen = new Set();+ for (const item of policy.exceptions) {+ const key = `${item.scope}:${item.package}`;+ if (!item.reason?.trim() || !item.package || !item.scope || seen.has(key)) {+ throw new Error(`invalid or duplicate exception ${key}`);+ }+ if (item.scope === 'hosts' ? !isImplementation(item.package, policy) :+ !names.has(item.scope) || CONTRACT_CLOSURE.has(item.package)) {+ throw new Error(`exception ${key} does not name a forbidden dependency`);+ }+ seen.add(key);+ }+}++function cargo(root, args) {+ // All generated manifests and logs stay under the checkout's target/.+ const stdout = execFileSync('bash', [join(root, 'scripts/ci-cancel-aware.sh'),+ 'cargo', 'metadata', '--format-version', '1', ...args], {+ cwd: root, encoding: 'utf8', maxBuffer: 128 * 1024 * 1024, stdio: ['ignore', 'pipe', 'inherit'],+ });+ return JSON.parse(stdout);+}++/** Resolve only this contract's selected features, without module/host unification. */+function contractMetadata(root, contract, allFeatures) {+ const manifest = resolve(root, contract.manifest);+ const listing = cargo(root, ['--manifest-path', manifest, '--no-deps']);+ const pkg = listing.packages.find(pkg => resolve(pkg.manifest_path) === manifest);+ if (!pkg || pkg.name !== contract.name) throw new Error(`missing contract ${contract.name}`);+ const harness = join(root, 'target/module-boundaries', contract.name, allFeatures ? 'all' : 'default');+ mkdirSync(join(harness, 'src'), { recursive: true });+ const features = allFeatures ? Object.keys(pkg.features) : [];+ writeFileSync(join(harness, 'Cargo.toml'), `[workspace]\n[package]\nname = "boundary-probe"\nversion = "0.0.0"\nedition = "2024"\n[dependencies]\n${contract.name} = { path = ${JSON.stringify(dirname(manifest))}, features = ${JSON.stringify(features)} }\n`);+ writeFileSync(join(harness, 'src/lib.rs'), '');+ return cargo(root, ['--manifest-path', join(harness, 'Cargo.toml')]);+}++export function run(root, strict = false) {+ const policy = JSON.parse(readFileSync(join(root, 'scripts/ci/module-boundaries.json'), 'utf8'));+ validatePolicy(policy);+ policy.contractManifests = Object.fromEntries(policy.contracts.map(contract =>+ [contract.name, resolve(root, contract.manifest)]));+ for (const contract of policy.pendingContracts) {+ if (existsSync(join(root, contract.manifest))) {+ throw new Error(`pending contract ${contract.name} now exists: register it for independent auditing`);+ }+ }+ const results = [];+ for (const [manifest, roots] of [+ ['Cargo.toml', ['openhuman', 'openhuman-cli', 'openhuman-tui']],+ ['crates/openhuman-app/Cargo.toml', ['openhuman-app']],+ ]) {+ const metadata = cargo(root, ['--manifest-path', join(root, manifest), '--locked', '--all-features']);+ results.push(auditGraph(metadata, roots, policy));+ }+ for (const contract of policy.contracts) {+ for (const all of [false, true]) {+ results.push(auditGraph(contractMetadata(root, contract, all), [contract.name], policy, contract.name));+ }+ }+ const violations = results.flatMap(result => result.violations);+ const exceptions = results.flatMap(result => result.exceptions);+ for (const item of violations) console.error(`FORBIDDEN [${item.scope}] ${item.path.join(' -> ')}`);+ const used = new Set(exceptions.map(item => `${item.scope}:${item.package}`));+ const stale = policy.exceptions.filter(item => !used.has(`${item.scope}:${item.package}`));+ for (const item of stale) console.error(`STALE exception [${item.scope}] ${item.package}: remove it`);+ const pending = policy.pendingContracts.length + policy.exceptions.length;+ console.log(`Module boundaries: ${violations.length} violations, ${stale.length} stale exceptions; ${policy.exceptions.length} temporary exceptions, ${policy.pendingContracts.length} pending contracts.`);+ if (pending) console.log('Migration INCOMPLETE. --require-complete rejects every temporary exception and pending contract.');+ return violations.length === 0 && stale.length === 0 && (!strict || pending === 0);+}++if (process.argv[1] && import.meta.url === pathToFileURL(resolve(process.argv[1])).href) {+ try {+ const args = process.argv.slice(2);+ if (args.some(arg => arg.startsWith('--') && arg !== '--require-complete')) throw new Error('unknown option');+ const root = resolve(args.find(arg => !arg.startsWith('--')) ?? join(dirname(fileURLToPath(import.meta.url)), '../..'));+ process.exitCode = run(root, args.includes('--require-complete')) ? 0 : 1;+ } catch (error) {+ console.error(`Module boundary audit could not complete: ${error.message}`);+ process.exitCode = 2;+ }+}diff --git a/scripts/ci/module-boundaries.json b/scripts/ci/module-boundaries.jsonnew file mode 100644index 0000000000..6c91e291d9--- /dev/null+++ b/scripts/ci/module-boundaries.json@@ -0,0 +1,286 @@+{+ "implementationPackages": [+ "tinyjuice",+ "tinyconnectors",+ "tinyconnectors-sync",+ "tinymcp",+ "tinychannels",+ "tinychannels-runtime",+ "tinyhosts",+ "tinybox-core",+ "tinybox-jail",+ "tinybox-docker",+ "tinybox-host",+ "tinybox-ssh",+ "tinycomputer-accessibility",+ "tinyvoice",+ "tinyruntime-pyserver",+ "tinywallet-crypto",+ "tinywallet-web3",+ "tinywallet-x402",+ "pdf-extract",+ "calamine",+ "tinybox-linux",+ "tinybox-microvm",+ "tinybox-sync",+ "tinydocs",+ "tinydocs-core",+ "tinydocs-extract",+ "tinysearch",+ "tinysearch-core",+ "tinyruntime",+ "cpal"+ ],+ "implementationPrefixes": [+ "tinyjuice-",+ "tinyconnectors-",+ "tinymcp-",+ "tinychannels-",+ "tinyhosts-",+ "tinybox-",+ "tinywallet-",+ "tinycomputer-",+ "tinyvoice-",+ "tinyruntime-",+ "tinydocs-",+ "tinysearch-"+ ],+ "contracts": [+ {+ "name": "tinyjuice-bus",+ "manifest": "vendor/tinyjuice/crates/tinyjuice-bus/Cargo.toml",+ "owner": "https://github.com/tinyhumansai/tinyjuice"+ },+ {+ "name": "tinyconnectors-bus",+ "manifest": "vendor/tinyconnectors/crates/tinyconnectors-bus/Cargo.toml",+ "owner": "https://github.com/tinyhumansai/tinyconnectors"+ },+ {+ "name": "tinymcp-bus",+ "manifest": "vendor/tinymcp/crates/tinymcp-bus/Cargo.toml",+ "owner": "https://github.com/tinyhumansai/tinymcp"+ },+ {+ "name": "tinychannels-bus",+ "manifest": "vendor/tinychannels/crates/tinychannels-bus/Cargo.toml",+ "owner": "https://github.com/tinyhumansai/tinychannels"+ },+ {+ "name": "tinywallet-bus",+ "manifest": "vendor/tinywallet/crates/tinywallet-bus/Cargo.toml",+ "owner": "https://github.com/tinyhumansai/tinywallet"+ },+ {+ "name": "tinycomputer-bus",+ "manifest": "vendor/tinycomputer/crates/tinycomputer-bus/Cargo.toml",+ "owner": "https://github.com/tinyhumansai/tinycomputer"+ },+ {+ "name": "tinyvoice-bus",+ "manifest": "vendor/tinyvoice/crates/tinyvoice-bus/Cargo.toml",+ "owner": "https://github.com/tinyhumansai/tinyvoice"+ },+ {+ "name": "tinyruntime-bus",+ "manifest": "vendor/tinyruntime/crates/tinyruntime-bus/Cargo.toml",+ "owner": "https://github.com/tinyhumansai/tinyruntime"+ },+ {+ "name": "tinydocs-bus",+ "manifest": "vendor/tinydocs/crates/tinydocs-bus/Cargo.toml",+ "owner": "https://github.com/tinyhumansai/tinydocs"+ },+ {+ "name": "tinysearch-bus",+ "manifest": "vendor/tinysearch/crates/tinysearch-bus/Cargo.toml",+ "owner": "https://github.com/tinyhumansai/tinysearch"+ }+ ],+ "pendingContracts": [+ {+ "name": "tinybox-bus",+ "manifest": "vendor/tinybox/crates/tinybox-bus/Cargo.toml",+ "owner": "https://github.com/tinyhumansai/tinybox",+ "reason": "Sandbox execution, shell analysis and pre-core gateways need a bus contract."+ },+ {+ "name": "tinyhosts-bus",+ "manifest": "vendor/tinyhosts/crates/tinyhosts-bus/Cargo.toml",+ "owner": "https://github.com/tinyhumansai/tinyhosts",+ "reason": "Hosting contract crate has not been published."+ }+ ],+ "exceptions": [+ {+ "scope": "hosts",+ "package": "tinyjuice",+ "reason": "HTML extraction, REPL execution and schema vocabulary still call the implementation."+ },+ {+ "scope": "hosts",+ "package": "tinyconnectors",+ "reason": "Argument preparation, provider errors and trigger archives still call the implementation."+ },+ {+ "scope": "hosts",+ "package": "tinyconnectors-sync",+ "reason": "Argument preparation, provider errors and trigger archives still call the implementation."+ },+ {+ "scope": "hosts",+ "package": "tinymcp",+ "reason": "Protocol servers and supervisor operations still call the implementation."+ },+ {+ "scope": "hosts",+ "package": "tinychannels",+ "reason": "Providers, relay, pairing and delivery lifecycles still call the implementation."+ },+ {+ "scope": "hosts",+ "package": "tinychannels-runtime",+ "reason": "Providers, relay, pairing and delivery lifecycles still call the implementation."+ },+ {+ "scope": "hosts",+ "package": "tinyhosts",+ "reason": "Hosting contract crate has not been published."+ },+ {+ "scope": "hosts",+ "package": "tinybox-core",+ "reason": "Sandbox execution, shell analysis and pre-core gateways need a bus contract."+ },+ {+ "scope": "hosts",+ "package": "tinybox-jail",+ "reason": "Sandbox execution, shell analysis and pre-core gateways need a bus contract."+ },+ {+ "scope": "hosts",+ "package": "tinybox-docker",+ "reason": "Sandbox execution, shell analysis and pre-core gateways need a bus contract."+ },+ {+ "scope": "hosts",+ "package": "tinybox-host",+ "reason": "Sandbox execution, shell analysis and pre-core gateways need a bus contract."+ },+ {+ "scope": "hosts",+ "package": "tinybox-ssh",+ "reason": "Sandbox execution, shell analysis and pre-core gateways need a bus contract."+ },+ {+ "scope": "hosts",+ "package": "tinycomputer-accessibility",+ "reason": "Focus, paste, permission and Globe-listener operations need bus members."+ },+ {+ "scope": "hosts",+ "package": "tinyvoice",+ "reason": "Capture and hotkey lifecycles need module operations."+ },+ {+ "scope": "hosts",+ "package": "tinyruntime-pyserver",+ "reason": "Python-worker lifecycle needs module operations."+ },+ {+ "scope": "hosts",+ "package": "tinywallet-crypto",+ "reason": "Validation, transaction construction, web3 and x402 need module operations."+ },+ {+ "scope": "hosts",+ "package": "tinywallet-web3",+ "reason": "Validation, transaction construction, web3 and x402 need module operations."+ },+ {+ "scope": "hosts",+ "package": "tinywallet-x402",+ "reason": "Validation, transaction construction, web3 and x402 need module operations."+ },+ {+ "scope": "hosts",+ "package": "pdf-extract",+ "reason": "Memory documents-office still enables local PDF extraction."+ },+ {+ "scope": "hosts",+ "package": "calamine",+ "reason": "Memory documents-office still enables local XLSX parsing."+ },+ {+ "scope": "tinychannels-bus",+ "package": "anyhow",+ "reason": "Channel trait, relay signing and pairing implementations remain in the contract; move them to the module."+ },+ {+ "scope": "tinychannels-bus",+ "package": "async-trait",+ "reason": "Channel trait, relay signing and pairing implementations remain in the contract; move them to the module."+ },+ {+ "scope": "tinychannels-bus",+ "package": "base64",+ "reason": "Channel trait, relay signing and pairing implementations remain in the contract; move them to the module."+ },+ {+ "scope": "tinychannels-bus",+ "package": "hex",+ "reason": "Channel trait, relay signing and pairing implementations remain in the contract; move them to the module."+ },+ {+ "scope": "tinychannels-bus",+ "package": "hmac",+ "reason": "Channel trait, relay signing and pairing implementations remain in the contract; move them to the module."+ },+ {+ "scope": "tinychannels-bus",+ "package": "parking_lot",+ "reason": "Channel trait, relay signing and pairing implementations remain in the contract; move them to the module."+ },+ {+ "scope": "tinychannels-bus",+ "package": "rand",+ "reason": "Channel trait, relay signing and pairing implementations remain in the contract; move them to the module."+ },+ {+ "scope": "tinychannels-bus",+ "package": "sha2",+ "reason": "Channel trait, relay signing and pairing implementations remain in the contract; move them to the module."+ },+ {+ "scope": "tinychannels-bus",+ "package": "tokio",+ "reason": "Channel trait, relay signing and pairing implementations remain in the contract; move them to the module."+ },+ {+ "scope": "tinychannels-bus",+ "package": "tracing",+ "reason": "Channel trait, relay signing and pairing implementations remain in the contract; move them to the module."+ },+ {+ "scope": "tinychannels-bus",+ "package": "uuid",+ "reason": "Channel trait, relay signing and pairing implementations remain in the contract; move them to the module."+ },+ {+ "scope": "tinywallet-bus",+ "package": "tinywallet-crypto",+ "reason": "Compatibility behavioral re-exports still link implementation; move vocabulary into the contract."+ },+ {+ "scope": "tinywallet-bus",+ "package": "tinywallet-x402",+ "reason": "Compatibility behavioral re-exports still link implementation; move vocabulary into the contract."+ },+ {+ "scope": "hosts",+ "package": "cpal",+ "reason": "Voice capture and the accessibility microphone probe still link host audio-device access."+ }+ ]+}diff --git a/scripts/ci/self-hosted/lanes-plan.mjs b/scripts/ci/self-hosted/lanes-plan.mjsindex c7b80638ab..ed0b1379fc 100644--- a/scripts/ci/self-hosted/lanes-plan.mjs+++ b/scripts/ci/self-hosted/lanes-plan.mjs@@ -231,6 +231,11 @@ export function buildPlan({ profile, areas, env = {}, isPullRequest = true }) {when: true,run: "node scripts/ci/check-crate-chain.mjs",},+ {+ name: "module-boundaries",+ when: rust || areas.scripts,+ run: "bash scripts/ci-cancel-aware.sh node scripts/ci/check-module-boundaries.mjs",+ },{name: "module-pins",when: true,