Skip to content

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

fix(ci): check every edge into an engine before deduplicating the walk

M3gA-Mind71458e115969
diff --git a/scripts/__tests__/check-storage-owner.test.mjs b/scripts/__tests__/check-storage-owner.test.mjs
index cab123e9bc..7ee4670c77 100644
--- a/scripts/__tests__/check-storage-owner.test.mjs
+++ b/scripts/__tests__/check-storage-owner.test.mjs
@@ -394,6 +394,38 @@ describe('ENGINE_EXCEPTIONS', () => {
assert.deepEqual([...used], ['tinytools-std -> fs2']);
});
+ test('do not hide another edge into the same engine', () => {
+ // tinyflows -> tinytools-std -> fs2 (excepted) and tinyflows -> lockutil -> fs2 (not).
+ const reg = name => `${name} 1.0.0 ${REGISTRY}`;
+ const fixture = {
+ packages: [
+ pathPkg('tinyflows', '1.0.0', `${ROOT}/vendor/tinyflows/Cargo.toml`),
+ pathPkg('tinytools-std', '1.0.0', `${ROOT}/vendor/tinytools-std/Cargo.toml`),
+ regPkg('lockutil', '1.0.0', '/fake/.cargo/registry/src/x/lockutil-1.0.0/Cargo.toml'),
+ regPkg('fs2', '1.0.0', '/fake/.cargo/registry/src/x/fs2-1.0.0/Cargo.toml'),
+ ],
+ resolve: {
+ nodes: [
+ {
+ id: 'tinyflows 1.0.0',
+ deps: [
+ { name: 'tinytools-std', pkg: 'tinytools-std 1.0.0', dep_kinds: NORMAL },
+ { name: 'lockutil', pkg: reg('lockutil'), dep_kinds: NORMAL },
+ ],
+ },
+ { id: 'tinytools-std 1.0.0', deps: [{ name: 'fs2', pkg: reg('fs2'), dep_kinds: NORMAL }] },
+ { id: reg('lockutil'), deps: [{ name: 'fs2', pkg: reg('fs2'), dep_kinds: NORMAL }] },
+ { id: reg('fs2'), deps: [] },
+ ],
+ },
+ };
+ const v = checkMetadata(fixture, ROOT).filter(x => x.package === 'tinyflows');
+ assert.deepEqual(
+ v.map(x => x.path.join(' -> ')),
+ ['tinyflows -> lockutil -> fs2']
+ );
+ });
+
test('do not excuse another engine or another package', () => {
assert.equal(checkMetadata(chain('tinytools-std', 'rusqlite'), ROOT)[0]?.engine, 'rusqlite');
assert.equal(checkMetadata(chain('tinytools-core', 'fs2'), ROOT)[0]?.engine, 'fs2');
diff --git a/scripts/ci/check-storage-owner.mjs b/scripts/ci/check-storage-owner.mjs
index c9e1884bf7..dc711d88a5 100644
--- a/scripts/ci/check-storage-owner.mjs
+++ b/scripts/ci/check-storage-owner.mjs
@@ -229,9 +229,6 @@ export function checkEngineClosure(metadata, roots, used = new Set()) {
if (!has_normal_or_build) continue;
const dep_id = dep.pkg;
- if (seen.has(dep_id)) continue;
- seen.add(dep_id);
-
const dep_pkg = packages[dep_id];
if (!dep_pkg) continue;
@@ -262,7 +259,11 @@ export function checkEngineClosure(metadata, roots, used = new Set()) {
// Continue the walk through this dep, regardless of whether it's
// first-party, owner-owned, or a registry crate. The BFS always
// continues so that we can trace a path all the way to a forbidden
- // crate even when it passes through tsd engine crates.
+ // crate even when it passes through tsd engine crates. `seen` only
+ // stops re-walking a package: every edge into an engine is checked
+ // above, so an excepted edge never hides another path to it.
+ if (seen.has(dep_id)) continue;
+ seen.add(dep_id);
queue.push([dep_id, dep_name, new_path]);
}
}