Skip to content

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

test(ci): split storage-owner fixtures by package source

Steven Enamakele5ea8b5325af
diff --git a/scripts/ci/__tests__/check-storage-owner.test.mjs b/scripts/ci/__tests__/check-storage-owner.test.mjs
index b11385c3e8..bc49c68092 100644
--- a/scripts/ci/__tests__/check-storage-owner.test.mjs
+++ b/scripts/ci/__tests__/check-storage-owner.test.mjs
@@ -1,38 +1,53 @@
/**
* Fixture-based self-tests for check-storage-owner.mjs
*
- * Each fixture is a minimal `cargo metadata --all-features` JSON document.
* Run with: node --test scripts/ci/__tests__/check-storage-owner.test.mjs
- *
- * Fixtures:
- * - transitive-engine.mjson : non-allowlisted crate transitively reaches rusqlite via tsd-sqlite → FAIL
- * - tsd-tag-mismatch.mjson : non-allowlisted crate declares tsd tag "99.0.0" vs vendored "1.0.0" → FAIL
- * - allowlisted-root.mjson : allowlisted crate reaches rusqlite → PASS
- * - naming-violation.mjson : crate named "foo-sqlite" → FAIL
- * - vendored-ok.mjson : all tsd crates are vendored paths → PASS
- * - aws-smithy.mjson : non-allowlisted crate reaches aws-sdk-s3 → FAIL
*/
import { checkMetadata } from '../check-storage-owner.mjs';
const ROOT = '/fake/repo';
const TSD_MANIFEST = `${ROOT}/vendor/tinystoragedrivers/crates/tinystoragedrivers-sqlite/Cargo.toml`;
+const REGISTRY = 'registry+https://github.com/rust-lang/crates.io-index';
+const tsd_git = (tag) => `git+https://github.com/tinyhumansai/tinystoragedrivers?tag=${tag}#`;
// ---------------------------------------------------------------------------
// Helper builders
// ---------------------------------------------------------------------------
-const pkg = (name, version, manifest, source = null, deps = []) => ({
- id: source ? `${name} ${version} ${source}` : `${name} ${version}`,
+/** Package with source=null (path crate, first-party). */
+const pathPkg = (name, version, manifest, deps = []) => ({
+ id: `${name} ${version}`,
+ name,
+ version,
+ manifest_path: manifest,
+ source: null,
+ dependencies: deps,
+});
+
+/** Package from a registry. */
+const regPkg = (name, version, manifest, deps = []) => ({
+ id: `${name} ${version} ${REGISTRY}`,
name,
version,
manifest_path: manifest,
- source,
+ source: REGISTRY,
dependencies: deps,
});
-const node = (name, version, source, deps) => ({
- id: source ? `${name} ${version} ${source}` : `${name} ${version}`,
+/** Package from a git source. */
+const gitPkg = (name, version, manifest, git_source, deps = []) => ({
+ id: `${name} ${version} ${git_source}`,
+ name,
+ version,
+ manifest_path: manifest,
+ source: git_source,
+ dependencies: deps,
+});
+
+/** Resolve node for a path crate. */
+const pathNode = (name, version, deps) => ({
+ id: `${name} ${version}`,
deps: deps.map(([dep_name, dep_ver, dep_source]) => ({
name: dep_name,
pkg: dep_source ? `${dep_name} ${dep_ver} ${dep_source}` : `${dep_name} ${dep_ver}`,
@@ -40,82 +55,94 @@ const node = (name, version, source, deps) => ({
})),
});
-const REGISTRY = 'registry+https://github.com/rust-lang/crates.io-index';
-const tsd_git = (tag) => `git+https://github.com/tinyhumansai/tinystoragedrivers?tag=${tag}#`;
+/** Resolve node for a registry crate. */
+const regNode = (name, version, deps) => ({
+ id: `${name} ${version} ${REGISTRY}`,
+ deps: deps.map(([dep_name, dep_ver, dep_source]) => ({
+ name: dep_name,
+ pkg: dep_source ? `${dep_name} ${dep_ver} ${dep_source}` : `${dep_name} ${dep_ver}`,
+ dep_kinds: [{ kind: null }],
+ })),
+});
// ---------------------------------------------------------------------------
// Fixture: transitive engine through tsd crate → must FAIL
+// tinyagents-session (path) -> tinystoragedrivers-sqlite (path) -> rusqlite (registry)
// ---------------------------------------------------------------------------
const transitive_engine_fixture = {
packages: [
- pkg('tinystoragedrivers-sqlite', '1.0.0', TSD_MANIFEST, null, [
+ pathPkg('tinystoragedrivers-sqlite', '1.0.0', TSD_MANIFEST, [
{ name: 'rusqlite', pkg: `rusqlite 0.32.1 ${REGISTRY}` },
]),
- pkg('rusqlite', '0.32.1', `${ROOT}/.cargo/registry/src/foo/rusqlite-0.32.1/Cargo.toml`, REGISTRY),
- // Non-allowlisted crate depends on tsd-sqlite
- pkg('tinyagents-session', '0.1.0', `${ROOT}/crates/tinyagents-session/Cargo.toml`, null, [
+ regPkg('rusqlite', '0.32.1', `${ROOT}/.cargo/registry/src/foo/rusqlite-0.32.1/Cargo.toml`),
+ pathPkg('tinyagents-session', '0.1.0', `${ROOT}/crates/tinyagents-session/Cargo.toml`, [
{ name: 'tinystoragedrivers-sqlite', pkg: 'tinystoragedrivers-sqlite 1.0.0' },
]),
],
resolve: {
nodes: [
- node('tinyagents-session', '0.1.0', null, [['tinystoragedrivers-sqlite', '1.0.0', null]]),
- node('tinystoragedrivers-sqlite', '1.0.0', null, [['rusqlite', '0.32.1', REGISTRY]]),
- node('rusqlite', '0.32.1', REGISTRY, []),
+ pathNode('tinyagents-session', '0.1.0', [['tinystoragedrivers-sqlite', '1.0.0', null]]),
+ pathNode('tinystoragedrivers-sqlite', '1.0.0', [['rusqlite', '0.32.1', REGISTRY]]),
+ regNode('rusqlite', '0.32.1', []),
],
},
};
// ---------------------------------------------------------------------------
// Fixture: tsd tag mismatch → must FAIL
+// some-odd-crate (path) depends on tinystoragedrivers-core with git tag "99.0.0"
+// but vendored version is "1.0.0".
// ---------------------------------------------------------------------------
const tsd_tag_mismatch_fixture = {
packages: [
- pkg('tinystoragedrivers-core', '1.0.0', `${ROOT}/vendor/tinystoragedrivers/crates/tinystoragedrivers-core/Cargo.toml`),
- pkg('some-odd-crate', '0.1.0', `${ROOT}/crates/some-odd-crate/Cargo.toml`, null, [
+ pathPkg('tinystoragedrivers-core', '1.0.0',
+ `${ROOT}/vendor/tinystoragedrivers/crates/tinystoragedrivers-core/Cargo.toml`),
+ pathPkg('some-odd-crate', '0.1.0', `${ROOT}/crates/some-odd-crate/Cargo.toml`, [
{ name: 'tinystoragedrivers-core', pkg: `tinystoragedrivers-core 1.0.0 ${tsd_git('99.0.0')}` },
]),
],
resolve: {
nodes: [
- node('some-odd-crate', '0.1.0', null, [['tinystoragedrivers-core', '1.0.0', tsd_git('99.0.0')]]),
- node('tinystoragedrivers-core', '1.0.0', null, []),
+ pathNode('some-odd-crate', '0.1.0', [['tinystoragedrivers-core', '1.0.0', tsd_git('99.0.0')]]),
+ pathNode('tinystoragedrivers-core', '1.0.0', []),
],
},
};
// ---------------------------------------------------------------------------
// Fixture: allowlisted root reaches engine → must PASS
+// openhuman (allowlisted) -> rusqlite
// ---------------------------------------------------------------------------
const allowlisted_root_fixture = {
packages: [
- pkg('openhuman', '0.1.0', `${ROOT}/crates/openhuman/Cargo.toml`, null, [
+ pathPkg('openhuman', '0.1.0', `${ROOT}/crates/openhuman/Cargo.toml`, [
{ name: 'rusqlite', pkg: `rusqlite 0.32.1 ${REGISTRY}` },
]),
- pkg('rusqlite', '0.32.1', '/fake/.cargo/registry/src/foo/rusqlite-0.32.1/Cargo.toml', REGISTRY),
+ regPkg('rusqlite', '0.32.1', '/fake/.cargo/registry/src/foo/rusqlite-0.32.1/Cargo.toml'),
],
resolve: {
nodes: [
- node('openhuman', '0.1.0', null, [['rusqlite', '0.32.1', REGISTRY]]),
- node('rusqlite', '0.32.1', REGISTRY, []),
+ pathNode('openhuman', '0.1.0', [['rusqlite', '0.32.1', REGISTRY]]),
+ regNode('rusqlite', '0.32.1', []),
],
},
};
// ---------------------------------------------------------------------------
// Fixture: crate naming violation → must FAIL
+// Name ends with "-sqlite" → forbidden pattern.
// ---------------------------------------------------------------------------
const naming_violation_fixture = {
packages: [
- pkg('my-sqlite-wrapper', '0.1.0', `${ROOT}/crates/my-sqlite-wrapper/Cargo.toml`),
+ pathPkg('tinyagents-sqlite', '0.1.0', `${ROOT}/crates/tinyagents-sqlite/Cargo.toml`),
],
resolve: {
nodes: [
- node('my-sqlite-wrapper', '0.1.0', null, []),
+ pathNode('tinyagents-sqlite', '0.1.0', []),
],
},
};
@@ -126,36 +153,37 @@ const naming_violation_fixture = {
const vendored_ok_fixture = {
packages: [
- pkg('tinystoragedrivers-core', '1.0.0', `${ROOT}/vendor/tinystoragedrivers/crates/tinystoragedrivers-core/Cargo.toml`),
- pkg('tinystoragedrivers-sqlite', '1.0.0', TSD_MANIFEST),
- pkg('openhuman-embed', '0.1.0', `${ROOT}/crates/openhuman-embed/Cargo.toml`, null, [
+ pathPkg('tinystoragedrivers-core', '1.0.0',
+ `${ROOT}/vendor/tinystoragedrivers/crates/tinystoragedrivers-core/Cargo.toml`),
+ pathPkg('tinystoragedrivers-sqlite', '1.0.0', TSD_MANIFEST),
+ pathPkg('openhuman-embed', '0.1.0', `${ROOT}/crates/openhuman-embed/Cargo.toml`, [
{ name: 'tinystoragedrivers-core', pkg: 'tinystoragedrivers-core 1.0.0' },
]),
],
resolve: {
nodes: [
- node('tinystoragedrivers-core', '1.0.0', null, []),
- node('tinystoragedrivers-sqlite', '1.0.0', null, []),
- node('openhuman-embed', '0.1.0', null, [['tinystoragedrivers-core', '1.0.0', null]]),
+ pathNode('tinystoragedrivers-core', '1.0.0', []),
+ pathNode('tinystoragedrivers-sqlite', '1.0.0', []),
+ pathNode('openhuman-embed', '0.1.0', [['tinystoragedrivers-core', '1.0.0', null]]),
],
},
};
// ---------------------------------------------------------------------------
-// Fixture: aws-sdk-s3 reached directly → must FAIL
+// Fixture: aws-sdk-s3 reached directly from non-allowlisted crate → must FAIL
// ---------------------------------------------------------------------------
const aws_s3_fixture = {
packages: [
- pkg('openhuman-rpc', '0.1.0', `${ROOT}/crates/openhuman-rpc/Cargo.toml`, null, [
+ pathPkg('openhuman-rpc', '0.1.0', `${ROOT}/crates/openhuman-rpc/Cargo.toml`, [
{ name: 'aws-sdk-s3', pkg: `aws-sdk-s3 1.0.0 ${REGISTRY}` },
]),
- pkg('aws-sdk-s3', '1.0.0', '/fake/.cargo/registry/src/aws/aws-sdk-s3-1.0.0/Cargo.toml', REGISTRY),
+ regPkg('aws-sdk-s3', '1.0.0', '/fake/.cargo/registry/src/aws/aws-sdk-s3-1.0.0/Cargo.toml'),
],
resolve: {
nodes: [
- node('openhuman-rpc', '0.1.0', null, [['aws-sdk-s3', '1.0.0', REGISTRY]]),
- node('aws-sdk-s3', '1.0.0', REGISTRY, []),
+ pathNode('openhuman-rpc', '0.1.0', [['aws-sdk-s3', '1.0.0', REGISTRY]]),
+ regNode('aws-sdk-s3', '1.0.0', []),
],
},
};
@@ -171,7 +199,7 @@ describe('transitive engine through tsd crate → must FAIL', () => {
const violations = checkMetadata(transitive_engine_fixture, ROOT);
const engineViolations = violations.filter(v => v.kind === 'engine-reach');
if (engineViolations.length === 0) {
- throw new Error(`Expected engine-reach violation for tinyagents-session->rusqlite, got: ${JSON.stringify(violations)}`);
+ throw new Error(`Expected engine-reach violation, got: ${JSON.stringify(violations)}`);
}
});
});
@@ -217,7 +245,9 @@ describe('all tsd crates vendored → must PASS', () => {
describe('aws-sdk-s3 reached directly → must FAIL', () => {
test('produces an engine-reach violation for aws-sdk-s3', () => {
const violations = checkMetadata(aws_s3_fixture, ROOT);
- const engineViolations = violations.filter(v => v.kind === 'engine-reach' && v.engine === 'aws-sdk-s3');
+ const engineViolations = violations.filter(v =>
+ v.kind === 'engine-reach' && v.engine === 'aws-sdk-s3'
+ );
if (engineViolations.length === 0) {
throw new Error(`Expected engine-reach violation for aws-sdk-s3, got: ${JSON.stringify(violations)}`);
}