Skip to content

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

fix(ci): wire storage-owner check into layout and bypass scripts

Steven Enamakel4b385e1ec75b
diff --git a/package.json b/package.json
index 177676ec7e..6130ef33af 100644
--- a/package.json
+++ b/package.json
@@ -58,13 +58,13 @@
"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:layout": "node scripts/ci/check-openhuman-rust-layout.mjs && node scripts/ci/check-crate-chain.mjs && node scripts/ci/check-storage-bypass.mjs && node scripts/ci/check-storage-owner.mjs",
"ci:module-source": "node scripts/ci/check-ci-module-source.mjs",
"rust:process-statics": "node scripts/ci/check-process-statics.mjs",
"rust:ignored-tests": "node scripts/ci/check-ignored-tests.mjs",
"dep:audit": "bash scripts/dep-audit/run.sh",
"agent:runtime-boundary": "node scripts/ci/check-agent-runtime-boundary.mjs",
- "storage:bypass": "node scripts/ci/check-storage-bypass.mjs",
+ "storage:bypass": "node scripts/ci/check-storage-bypass.mjs && node scripts/ci/check-storage-owner.mjs",
"saas:ambient": "node scripts/ci/check-saas-ambient.mjs",
"typecheck": "pnpm --filter openhuman-app compile",
"tauri:ios:init": "bash scripts/ios-init.sh",
diff --git a/scripts/__tests__/check-storage-owner.test.mjs b/scripts/__tests__/check-storage-owner.test.mjs
new file mode 100644
index 0000000000..624ca8efdb
--- /dev/null
+++ b/scripts/__tests__/check-storage-owner.test.mjs
@@ -0,0 +1,77 @@
+import assert from 'node:assert/strict';
+import { spawnSync } from 'node:child_process';
+import { mkdtempSync, rmSync, writeFileSync } from 'node:fs';
+import { tmpdir } from 'node:os';
+import { dirname, join, resolve } from 'node:path';
+import { test } from 'node:test';
+import { fileURLToPath } from 'node:url';
+
+import { ALLOWLIST, checkMetadata, formatReport } from '../ci/check-storage-owner.mjs';
+
+const CHECKER = resolve(dirname(fileURLToPath(import.meta.url)), '../ci/check-storage-owner.mjs');
+const pkg = (name, deps = [], source = null) => ({
+ name,
+ source,
+ dependencies: deps.map(d => ({ name: d, kind: null, optional: false })),
+});
+const registry = 'registry+https://github.com/rust-lang/crates.io-index';
+
+test('a clean workspace passes', () => {
+ assert.deepEqual(checkMetadata({ packages: [pkg('openhuman', ['serde']), pkg('tinyflows', ['tinystoragedrivers-core'])] }), []);
+});
+
+test('every forbidden backend dependency is rejected', () => {
+ for (const dep of ['rusqlite', 'libsqlite3-sys', 'mongodb', 'object_store', 'sqlx', 'redb', 'sled', 'rocksdb']) {
+ const v = checkMetadata({ packages: [pkg('tinymcp', [dep])] });
+ assert.equal(v.length, 1, dep);
+ assert.equal(v[0].package, 'tinymcp');
+ }
+});
+
+test('tinystoragedrivers crates own the backends', () => {
+ const v = checkMetadata({
+ packages: [pkg('tinystoragedrivers-sqlite', ['rusqlite']), pkg('tinystoragedrivers-file')],
+ });
+ assert.deepEqual(v, []);
+});
+
+test('backend-named crates outside tinystoragedrivers are rejected', () => {
+ for (const name of ['tinyflows-sqlite', 'tinyflows-mongodb', 'thing-file']) {
+ assert.equal(checkMetadata({ packages: [pkg(name)] })[0].kind, 'crate-name', name);
+ }
+});
+
+test('registry crates are ignored', () => {
+ assert.deepEqual(
+ checkMetadata({ packages: [pkg('rusqlite', ['libsqlite3-sys'], registry), pkg('same-file', [], registry)] }),
+ []
+ );
+});
+
+test('allowlisted read-only readers may depend on rusqlite, with a reason', () => {
+ for (const [name, reason] of Object.entries(ALLOWLIST)) {
+ assert.ok(reason.length > 10, `${name} needs a reason`);
+ assert.deepEqual(checkMetadata({ packages: [pkg(name, ['rusqlite'])] }), []);
+ }
+ assert.equal(checkMetadata({ packages: [pkg('tinyskills', ['rusqlite'])] }).length, 1);
+});
+
+test('the report names the offender', () => {
+ assert.match(formatReport(checkMetadata({ packages: [pkg('tinymcp', ['rusqlite'])] })), /tinymcp: depends on rusqlite/);
+ assert.match(formatReport([]), /ok/);
+});
+
+test('CLI exits 1 on a violation, 0 when clean, 2 on unreadable input', () => {
+ const dir = mkdtempSync(join(tmpdir(), 'storage-owner-'));
+ try {
+ const bad = join(dir, 'bad.json');
+ const good = join(dir, 'good.json');
+ writeFileSync(bad, JSON.stringify({ packages: [pkg('tinymcp', ['rusqlite'])] }));
+ writeFileSync(good, JSON.stringify({ packages: [pkg('tinymcp')] }));
+ assert.equal(spawnSync('node', [CHECKER, '--metadata', bad]).status, 1);
+ assert.equal(spawnSync('node', [CHECKER, '--metadata', good]).status, 0);
+ assert.equal(spawnSync('node', [CHECKER, '--metadata', join(dir, 'missing.json')]).status, 2);
+ } finally {
+ rmSync(dir, { recursive: true, force: true });
+ }
+});
diff --git a/scripts/ci/check-storage-owner.mjs b/scripts/ci/check-storage-owner.mjs
index 12bba85db3..c3ff520795 100644
--- a/scripts/ci/check-storage-owner.mjs
+++ b/scripts/ci/check-storage-owner.mjs
@@ -86,7 +86,7 @@ export function formatReport(violations) {
function loadMetadata(root, manifest) {
const r = spawnSync(
'cargo',
- ['metadata', '--format-version', '1', '--no-deps', '--manifest-path', resolve(root, manifest)],
+ ['metadata', '--format-version', '1', '--manifest-path', resolve(root, manifest)],
{ cwd: root, encoding: 'utf8', maxBuffer: 1 << 30 }
);
if (r.status !== 0) throw new Error(`cargo metadata failed for ${manifest}: ${r.stderr}`);
@@ -100,13 +100,23 @@ export function main(argv) {
if (argv[i] === '--metadata') files.push(argv[++i]);
else root = resolve(argv[i]);
}
+ let docs;
try {
- const docs = files.length
+ docs = files.length
? files.map(f => JSON.parse(readFileSync(f, 'utf8')))
: MANIFESTS.map(m => loadMetadata(root, m));
- return { code: 0, docs };
} catch (err) {
console.error(`storage-owner: cannot read inputs: ${err.message}`);
- return { code: 2, docs: [] };
+ return 2;
}
+ const seen = new Set();
+ const violations = docs
+ .flatMap(d => checkMetadata(d))
+ .filter(v => !seen.has(`${v.package}|${v.detail}`) && seen.add(`${v.package}|${v.detail}`));
+ console.log(formatReport(violations));
+ return violations.length ? 1 : 0;
+}
+
+if (import.meta.url === pathToFileURL(process.argv[1] ?? '').href) {
+ process.exit(main(process.argv.slice(2)));
}