Skip to content

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

fix(ci): stop the storage-owner walk at roots; record the two known reaches

M3gA-Mind92787d55e36e
diff --git a/scripts/__tests__/check-storage-owner.test.mjs b/scripts/__tests__/check-storage-owner.test.mjs
index 5d2bdbe898..cab123e9bc 100644
--- a/scripts/__tests__/check-storage-owner.test.mjs
+++ b/scripts/__tests__/check-storage-owner.test.mjs
@@ -9,7 +9,7 @@
* - Dev dep: { kind: "dev" }
*/
-import { checkMetadata, formatReport } from '../ci/check-storage-owner.mjs';
+import { ENGINE_EXCEPTIONS, checkMetadata, formatReport, staleExceptions } from '../ci/check-storage-owner.mjs';
const ROOT = '/fake/repo';
const TSD_MANIFEST = `${ROOT}/vendor/tinystoragedrivers/crates/tinystoragedrivers-sqlite/Cargo.toml`;
@@ -347,3 +347,68 @@ describe('the CLI', () => {
}
});
});
+
+// ---------------------------------------------------------------------------
+// Normal edges, composition roots and engine exceptions
+// ---------------------------------------------------------------------------
+
+/** A one-path chain fixture: names[0] -> names[1] -> ... ; the last is a registry crate. */
+const chain = (...names) => {
+ const last = names.length - 1;
+ const id = (name, i) => (i === last ? `${name} 1.0.0 ${REGISTRY}` : `${name} 1.0.0`);
+ return {
+ packages: names.map((name, i) =>
+ i === last
+ ? regPkg(name, '1.0.0', `/fake/.cargo/registry/src/x/${name}-1.0.0/Cargo.toml`)
+ : pathPkg(name, '1.0.0', `${ROOT}/vendor/${name}/Cargo.toml`, [
+ { name: names[i + 1], pkg: id(names[i + 1], i + 1) },
+ ])
+ ),
+ resolve: {
+ nodes: names.map((name, i) => ({
+ id: id(name, i),
+ deps: i === last ? [] : [{ name: names[i + 1], pkg: id(names[i + 1], i + 1), dep_kinds: NORMAL }],
+ })),
+ },
+ };
+};
+
+describe('a normal edge, as cargo reports it (kind: null)', () => {
+ test('is followed to the engine', () => {
+ const v = checkMetadata(chain('tinyflows', 'rusqlite'), ROOT);
+ assert.equal(v.length, 1);
+ assert.equal(v[0].engine, 'rusqlite');
+ });
+});
+
+describe('a composition root', () => {
+ test('stops the walk: what the root reaches is its own', () => {
+ assert.deepEqual(checkMetadata(chain('openhuman-embed', 'openhuman', 'rusqlite'), ROOT), []);
+ });
+});
+
+describe('ENGINE_EXCEPTIONS', () => {
+ test('excuse exactly their edge, wherever the walk starts, and record the match', () => {
+ const used = new Set();
+ assert.deepEqual(checkMetadata(chain('tinyagents-harness', 'tinytools-std', 'fs2'), ROOT, used), []);
+ assert.deepEqual([...used], ['tinytools-std -> 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');
+ });
+
+ test('every entry names its edge, a reason and a follow-up', () => {
+ for (const e of ENGINE_EXCEPTIONS) {
+ assert.ok(e.package && e.engine && e.reason.length > 10 && e.followUp.length > 10, JSON.stringify(e));
+ }
+ });
+
+ test('an entry nothing matched is reported as stale', () => {
+ assert.equal(staleExceptions(new Set()).length, ENGINE_EXCEPTIONS.length);
+ assert.equal(staleExceptions(new Set()).every(v => v.kind === 'stale-exception'), true);
+ const all = new Set(ENGINE_EXCEPTIONS.map(e => `${e.package} -> ${e.engine}`));
+ assert.deepEqual(staleExceptions(all), []);
+ });
+});
diff --git a/scripts/ci/check-storage-owner.mjs b/scripts/ci/check-storage-owner.mjs
index 85b81c1c66..c9e1884bf7 100644
--- a/scripts/ci/check-storage-owner.mjs
+++ b/scripts/ci/check-storage-owner.mjs
@@ -8,6 +8,9 @@
// Rule 1: a first-party package (path or git source, not a registry dep)
// that is NOT a tsd crate and NOT a composition root reaches a
// forbidden engine crate through any normal or build dependency.
+// The walk stops at composition roots (what a root reaches is its
+// own), and the exact edges in ENGINE_EXCEPTIONS are excused; a
+// stale exception fails.
//
// Rule 2: a first-party package not in tsd is named `*-sqlite`,
// `*-mongodb` or `*-file`.
@@ -86,6 +89,39 @@ export const ALLOWLIST = {
tinyjuice: 'bin target, bundles engine',
};
+/**
+ * Known engine reaches that are not composition roots, each an exact
+ * (package, engine) dependency edge with a reason and its follow-up. Only that
+ * edge is excused: any other package or engine still fails, and an entry that
+ * no longer matches anything fails as stale (when checking real metadata).
+ */
+export const ENGINE_EXCEPTIONS = [
+ {
+ package: 'tinytools-std',
+ engine: 'fs2',
+ reason: 'advisory file locking for the workspace lock file',
+ followUp: 'tinytools: drop fs2 from tinytools-std',
+ },
+ {
+ package: 'tinymemory-integrations',
+ engine: 'rusqlite',
+ reason: 'reads legacy memory SQLite directly',
+ followUp: "tinymemory: route tinymemory-integrations' sqlite through the storage owner",
+ },
+];
+
+const exceptionKey = (pkg, engine) => `${pkg} -> ${engine}`;
+const EXCEPTION_KEYS = new Set(ENGINE_EXCEPTIONS.map(e => exceptionKey(e.package, e.engine)));
+
+/** One `stale-exception` violation for every exception not in `used`. */
+export function staleExceptions(used) {
+ return ENGINE_EXCEPTIONS.filter(e => !used.has(exceptionKey(e.package, e.engine))).map(e => ({
+ package: e.package,
+ kind: 'stale-exception',
+ detail: `ENGINE_EXCEPTIONS entry ${exceptionKey(e.package, e.engine)} no longer matches; remove it`,
+ }));
+}
+
export const FORBIDDEN_CRATE_NAME = /-(sqlite|mongodb|file)$/;
export const MANIFESTS = ['Cargo.toml', 'crates/openhuman-app/Cargo.toml'];
@@ -137,15 +173,18 @@ const TSD_GIT = /^git\+https?:\/\/[^?#]*\/tinystoragedrivers(?:\.git)?\?tag=([^#
// ---------------------------------------------------------------------------
/**
- * Walk the resolved normal+build dependency graph starting from `roots`
- * (composition roots — always allowed) and report every first-party non-root
- * package that reaches a forbidden engine.
+ * Walk the resolved normal+build dependency graph and report every
+ * first-party non-root package that reaches a forbidden engine. The walk does
+ * not pass through a composition root (`roots`): what a root reaches is the
+ * root's to own. An edge listed in ENGINE_EXCEPTIONS is not reported; its key
+ * is added to `used`.
*
* @param {object} metadata - cargo metadata document
* @param {string[]} roots - package names that are composition roots
+ * @param {Set<string>} [used] - collects the ENGINE_EXCEPTIONS keys that matched
* @returns {{ package: string, kind: string, engine: string, path: string[], detail: string }[]}
*/
-export function checkEngineClosure(metadata, roots) {
+export function checkEngineClosure(metadata, roots, used = new Set()) {
const packages = Object.fromEntries(
(metadata.packages ?? []).map(p => [p.id, p])
);
@@ -199,8 +238,16 @@ export function checkEngineClosure(metadata, roots) {
const dep_name = dep_pkg.name;
const new_path = [...path, dep_name];
- // Forbidden engine found — report it.
+ // A composition root owns what it reaches; do not walk past it.
+ if (roots.includes(dep_name)) continue;
+
+ // Forbidden engine found — report it, unless this exact edge is excepted.
if (isForbiddenDep(dep_name) || isForbiddenTsdEngine(dep_name)) {
+ const key = exceptionKey(current_name, dep_name);
+ if (EXCEPTION_KEYS.has(key)) {
+ used.add(key);
+ continue;
+ }
violations.push({
package: pkg.name,
kind: 'engine-reach',
@@ -311,11 +358,11 @@ export function checkVendoredOwner(metadata, root = REPO_ROOT) {
// Top-level check
// ---------------------------------------------------------------------------
-export function checkMetadata(metadata, root = REPO_ROOT) {
+export function checkMetadata(metadata, root = REPO_ROOT, used = new Set()) {
const allowlistKeys = Object.keys(ALLOWLIST);
// Rule 1: engine closure
- const closureViolations = checkEngineClosure(metadata, allowlistKeys);
+ const closureViolations = checkEngineClosure(metadata, allowlistKeys, used);
// Rule 2: crate naming
const namingViolations = checkCrateNaming(metadata);
@@ -380,12 +427,16 @@ export function main(argv) {
}
const seen = new Set();
+ const used = new Set();
const violations = docs
- .flatMap(d => checkMetadata(d, root))
+ .flatMap(d => checkMetadata(d, root, used))
.filter(v => {
const key = `${v.package}|${v.kind}|${v.detail}`;
return !seen.has(key) && seen.add(key);
});
+ // An exception must still match the workspace it was written for. Fixture
+ // runs (--metadata) check their own inputs, not this workspace.
+ if (!files.length) violations.push(...staleExceptions(used));
console.log(formatReport(violations));
return violations.length ? 1 : 0;