Skip to content

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

fix(ci): count cargo's null-kind normal edges in the storage-owner closure

M3gA-Mind65b45a96e1fe
diff --git a/scripts/__tests__/check-storage-owner.test.mjs b/scripts/__tests__/check-storage-owner.test.mjs
index 550f6620aa..5d2bdbe898 100644
--- a/scripts/__tests__/check-storage-owner.test.mjs
+++ b/scripts/__tests__/check-storage-owner.test.mjs
@@ -40,8 +40,8 @@ const regPkg = (name, version, manifest, deps = []) => ({
dependencies: deps,
});
-/** Normal dep_kinds entry. */
-const NORMAL = [{ kind: 'normal' }];
+/** Normal dep_kinds entry: `cargo metadata` reports a normal edge as `kind: null`. */
+const NORMAL = [{ kind: null }];
/** Resolve node for a path crate. */
const pathNode = (name, version, deps) => ({
@@ -64,24 +64,26 @@ const regNode = (name, version, deps) => ({
});
// ---------------------------------------------------------------------------
-// Fixture: transitive engine through tsd crate → must FAIL
-// tinyagents-session (path) -> tinystoragedrivers-sqlite (path) -> rusqlite (registry)
+// Fixture: transitive engine through a non-engine tsd crate → must FAIL
+// tinyagents-session (path) -> tinystoragedrivers-core (path) -> rusqlite (registry)
// ---------------------------------------------------------------------------
+const TSD_CORE_MANIFEST = `${ROOT}/vendor/tinystoragedrivers/crates/tinystoragedrivers-core/Cargo.toml`;
+
const transitive_engine_fixture = {
packages: [
- pathPkg('tinystoragedrivers-sqlite', '1.0.0', TSD_MANIFEST, [
+ pathPkg('tinystoragedrivers-core', '1.0.0', TSD_CORE_MANIFEST, [
{ name: 'rusqlite', pkg: `rusqlite 0.32.1 ${REGISTRY}` },
]),
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' },
+ { name: 'tinystoragedrivers-core', pkg: 'tinystoragedrivers-core 1.0.0' },
]),
],
resolve: {
nodes: [
- pathNode('tinyagents-session', '0.1.0', [['tinystoragedrivers-sqlite', '1.0.0', null]]),
- pathNode('tinystoragedrivers-sqlite', '1.0.0', [['rusqlite', '0.32.1', REGISTRY]]),
+ pathNode('tinyagents-session', '0.1.0', [['tinystoragedrivers-core', '1.0.0', null]]),
+ pathNode('tinystoragedrivers-core', '1.0.0', [['rusqlite', '0.32.1', REGISTRY]]),
regNode('rusqlite', '0.32.1', []),
],
},
@@ -207,12 +209,16 @@ const aws_s3_fixture = {
const { test, describe } = await import('node:test');
-describe('transitive engine through tsd crate → must FAIL', () => {
- test('produces at least one engine-reach violation', () => {
+describe('transitive engine through a non-engine tsd crate → must FAIL', () => {
+ test('reports rusqlite and the path that reaches it', () => {
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, got: ${JSON.stringify(violations)}`);
+ if (
+ engineViolations.length !== 1 ||
+ engineViolations[0].engine !== 'rusqlite' ||
+ engineViolations[0].path.join(' -> ') !== 'tinyagents-session -> tinystoragedrivers-core -> rusqlite'
+ ) {
+ throw new Error(`Expected one rusqlite engine-reach via tinystoragedrivers-core, got: ${JSON.stringify(violations)}`);
}
});
});
diff --git a/scripts/ci/check-storage-owner.mjs b/scripts/ci/check-storage-owner.mjs
index 243d95cd86..85b81c1c66 100644
--- a/scripts/ci/check-storage-owner.mjs
+++ b/scripts/ci/check-storage-owner.mjs
@@ -180,11 +180,12 @@ export function checkEngineClosure(metadata, roots) {
if (!node) continue;
for (const dep of node.deps ?? []) {
- // Only normal and build edges count.
- // dep_kinds may be absent (defaults to normal per cargo convention).
+ // Only normal and build edges count. `cargo metadata` reports a normal
+ // edge as `kind: null` ("dev", "build", or null); dep_kinds may also be
+ // absent, which is a normal edge too.
const dep_kinds = dep.dep_kinds ?? [{ kind: null }];
const has_normal_or_build = dep_kinds.some(
- dk => dk.kind === undefined || dk.kind === 'normal' || dk.kind === 'build'
+ dk => dk.kind == null || dk.kind === 'normal' || dk.kind === 'build'
);
if (!has_normal_or_build) continue;