The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
chore: files changed scripts/ci/check-storage-owner.mjs,scripts/ci/__tests__/check-storage-owner.tes
Steven Enamakel521569b41bc5
diff --git a/scripts/ci/__tests__/check-storage-owner.test.mjs b/scripts/ci/__tests__/check-storage-owner.test.mjsnew file mode 100644index 0000000000..b11385c3e8--- /dev/null+++ b/scripts/ci/__tests__/check-storage-owner.test.mjs@@ -0,0 +1,225 @@+/**+ * 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`;++// ---------------------------------------------------------------------------+// Helper builders+// ---------------------------------------------------------------------------++const pkg = (name, version, manifest, source = null, deps = []) => ({+ id: source ? `${name} ${version} ${source}` : `${name} ${version}`,+ name,+ version,+ manifest_path: manifest,+ source,+ dependencies: deps,+});++const node = (name, version, source, deps) => ({+ id: source ? `${name} ${version} ${source}` : `${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}`,+ dep_kinds: [{ kind: null }],+ })),+});++const REGISTRY = 'registry+https://github.com/rust-lang/crates.io-index';+const tsd_git = (tag) => `git+https://github.com/tinyhumansai/tinystoragedrivers?tag=${tag}#`;++// ---------------------------------------------------------------------------+// Fixture: transitive engine through tsd crate → must FAIL+// ---------------------------------------------------------------------------++const transitive_engine_fixture = {+ packages: [+ pkg('tinystoragedrivers-sqlite', '1.0.0', TSD_MANIFEST, null, [+ { 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, [+ { 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, []),+ ],+ },+};++// ---------------------------------------------------------------------------+// Fixture: tsd tag mismatch → must FAIL+// ---------------------------------------------------------------------------++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, [+ { 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, []),+ ],+ },+};++// ---------------------------------------------------------------------------+// Fixture: allowlisted root reaches engine → must PASS+// ---------------------------------------------------------------------------++const allowlisted_root_fixture = {+ packages: [+ pkg('openhuman', '0.1.0', `${ROOT}/crates/openhuman/Cargo.toml`, null, [+ { 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),+ ],+ resolve: {+ nodes: [+ node('openhuman', '0.1.0', null, [['rusqlite', '0.32.1', REGISTRY]]),+ node('rusqlite', '0.32.1', REGISTRY, []),+ ],+ },+};++// ---------------------------------------------------------------------------+// Fixture: crate naming violation → must FAIL+// ---------------------------------------------------------------------------++const naming_violation_fixture = {+ packages: [+ pkg('my-sqlite-wrapper', '0.1.0', `${ROOT}/crates/my-sqlite-wrapper/Cargo.toml`),+ ],+ resolve: {+ nodes: [+ node('my-sqlite-wrapper', '0.1.0', null, []),+ ],+ },+};++// ---------------------------------------------------------------------------+// Fixture: all tsd crates vendored → must PASS+// ---------------------------------------------------------------------------++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, [+ { 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]]),+ ],+ },+};++// ---------------------------------------------------------------------------+// Fixture: aws-sdk-s3 reached directly → must FAIL+// ---------------------------------------------------------------------------++const aws_s3_fixture = {+ packages: [+ pkg('openhuman-rpc', '0.1.0', `${ROOT}/crates/openhuman-rpc/Cargo.toml`, null, [+ { 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),+ ],+ resolve: {+ nodes: [+ node('openhuman-rpc', '0.1.0', null, [['aws-sdk-s3', '1.0.0', REGISTRY]]),+ node('aws-sdk-s3', '1.0.0', REGISTRY, []),+ ],+ },+};++// ---------------------------------------------------------------------------+// Tests+// ---------------------------------------------------------------------------++const { test, describe } = await import('node:test');++describe('transitive engine through tsd crate → must FAIL', () => {+ test('produces at least one engine-reach violation', () => {+ 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)}`);+ }+ });+});++describe('tsd tag mismatch → must FAIL', () => {+ test('produces a tsd-tag-mismatch violation', () => {+ const violations = checkMetadata(tsd_tag_mismatch_fixture, ROOT);+ const mismatch = violations.filter(v => v.kind === 'tsd-tag-mismatch');+ if (mismatch.length === 0) {+ throw new Error(`Expected tsd-tag-mismatch violation, got: ${JSON.stringify(violations)}`);+ }+ });+});++describe('allowlisted root reaches engine → must PASS', () => {+ test('produces no violations', () => {+ const violations = checkMetadata(allowlisted_root_fixture, ROOT);+ if (violations.length > 0) {+ throw new Error(`Expected no violations for allowlisted root, got: ${JSON.stringify(violations)}`);+ }+ });+});++describe('crate naming violation → must FAIL', () => {+ test('produces a crate-name violation', () => {+ const violations = checkMetadata(naming_violation_fixture, ROOT);+ const naming = violations.filter(v => v.kind === 'crate-name');+ if (naming.length === 0) {+ throw new Error(`Expected crate-name violation, got: ${JSON.stringify(violations)}`);+ }+ });+});++describe('all tsd crates vendored → must PASS', () => {+ test('produces no violations', () => {+ const violations = checkMetadata(vendored_ok_fixture, ROOT);+ if (violations.length > 0) {+ throw new Error(`Expected no violations for vendored-clean tree, got: ${JSON.stringify(violations)}`);+ }+ });+});++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');+ if (engineViolations.length === 0) {+ throw new Error(`Expected engine-reach violation for aws-sdk-s3, got: ${JSON.stringify(violations)}`);+ }+ });+});diff --git a/scripts/ci/check-storage-owner.mjs b/scripts/ci/check-storage-owner.mjsindex 6827d2599d..892dc4762b 100644--- a/scripts/ci/check-storage-owner.mjs+++ b/scripts/ci/check-storage-owner.mjs@@ -1,28 +1,25 @@#!/usr/bin/env node-// Storage-owner gate (tinyhumansai/openhuman#7642, part of #7522).+// Storage-engine gate — tinyhumansai/openhuman#8131, part of #442.//// tinystoragedrivers is the only crate family allowed to own a storage-// backend. This check reads `cargo metadata` for the root workspace and for-// `crates/openhuman-app` and fails when-// 1. a first-party package (path or git source, i.e. not a crates.io-// dependency) outside `tinystoragedrivers*` declares a dependency on one-// of FORBIDDEN_DEPS (any kind, optional or not), or-// 2. a first-party package outside `tinystoragedrivers*` is named-// `*-sqlite`, `*-mongodb` or `*-file`.-// 3. a `tinystoragedrivers*` package in the resolved graph is not built from-// a path under `vendor/tinystoragedrivers/` (a registry or git source-// means some manifest escaped the root `[patch]` onto the vendored copy,-// for example a module that bumped its tag past the vendored commit),-// anchored to THIS repository's root, and-// 4. a dependency naming tinystoragedrivers by a git tag that differs from-// the vendored checkout's version (a tag-only bump still resolves to the-// patched path, so rule 3 alone cannot see it).-// Third-party registry crates are ignored (they are the backends' own deps,-// e.g. `rusqlite -> libsqlite3-sys`).+// backend. This check reads `cargo metadata --all-features` for the root+// workspace and for `crates/openhuman-app` and fails when+//+// 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.+//+// Rule 2: a first-party package not in tsd is named `*-sqlite`,+// `*-mongodb` or `*-file`.+//+// Rule 3: a tinystoragedrivers* package in the resolved graph is not a+// path under `vendor/tinystoragedrivers/` (anchored to this repo).+//+// Rule 4: a dependency names tinystoragedrivers by a git tag that differs+// from the vendored checkout's version.//// Read-only readers of external databases are not storage and are listed in-// ALLOWLIST with a reason. A temporary entry names the open issue that-// removes it.+// ALLOWLIST with a reason.//// Usage: check-storage-owner.mjs [repo-root] [--metadata <file.json>]...// With --metadata the given `cargo metadata` JSON files are checked instead of@@ -34,39 +31,105 @@ import { readFileSync } from 'node:fs';import { dirname, resolve } from 'node:path';import { fileURLToPath, pathToFileURL } from 'node:url';+// ---------------------------------------------------------------------------+// Configuration+// ---------------------------------------------------------------------------++/** Engine crates no non-root first-party package may reach. */export const FORBIDDEN_DEPS = ['rusqlite','libsqlite3-sys','mongodb',+ 'bson',+ 'aws-sdk-s3',+ 'lapin', // AMQP client (RabbitMQ)+ 'amq-protocol', // AMQP wire protocol'object_store','sqlx','redb','sled','rocksdb',+ 'fs2', // advisory file locking];-export const FORBIDDEN_CRATE_NAME = /-(sqlite|mongodb|file)$/;+/** Patterns matched as a prefix against the normalised crate name. */+export const FORBIDDEN_PREFIXES = [+ 'aws-smithy-', // all AWS Smithy crates (smithy-http, smithy-types, …)+];++/** Engine crates in the tinystoragedrivers family. */+export const FORBIDDEN_TSD_ENGINES = [+ 'tinystoragedrivers-sqlite',+ 'tinystoragedrivers-mongodb',+ 'tinystoragedrivers-file',+ 'tinystoragedrivers-s3',+ 'tinystoragedrivers-rabbitmq',+ 'tinystoragedrivers-document',+ 'tinystoragedrivers-kv',+ 'tinystoragedrivers-blob',+ 'tinystoragedrivers-queue',+ 'tinystoragedrivers-secrets',+ 'tinystoragedrivers-connect',+];-/** Package name -> why it may keep a forbidden dependency. */+/** Packages allowed to transitively reach a forbidden engine, with a reason. */export const ALLOWLIST = {- tinychannels: 'iMessage chat.db reader: reads an external SQLite database read-only, not storage',- 'openhuman-app': 'imessage scanner: reads chat.db directly and read-only, not storage',- 'tinymemory-integrations': 'legacy-import: reads legacy SQLite files read-only for one-time import',+ // Core storage domain — owns all engine initialisation.+ openhuman: 'core storage domain',+ // Hosts — own keyring access through rusqlite (keyring backend).+ 'openhuman-app': 'keyring secrets via rusqlite',+ 'openhuman-cli': 'keyring secrets via rusqlite',+ 'openhuman-tui': 'keyring secrets via rusqlite',+ 'openhuman-rpc': 'keyring secrets via rusqlite',+ // iMessage scanner — reads chat.db directly, read-only.+ tinychannels: 'iMessage chat.db reader: read-only SQLite access',+ // CLI tool that bundles its own engine.+ 'tinybox-cli': 'bin target, bundles engine',+ // CLI tool that bundles its own engine.+ tinyjuice: 'bin target, bundles engine',};-export const MANIFESTS = ['Cargo.toml', 'crates/openhuman-app/Cargo.toml'];+/** Packages allowed to reach tinychannels transitively with the imessage feature. */+const TINYCHANNELS_IMESSAGE_ONLY = new Set(['tinychannels']);-const isOwner = name => name.startsWith('tinystoragedrivers');+/** Packages whose engine reach is allowed only under a specific feature. */+export const FEATURE_EXEMPTIONS = {+ 'tinychannels': ['imessage'], // only with the imessage feature+ 'tinymemory-integrations': ['legacy-import'], // legacy import reads SQLite read-only+};-/** First-party = built from a path or a git source, not from a registry. */-const isFirstParty = pkg => !pkg.source || pkg.source.startsWith('git+');+export const FORBIDDEN_CRATE_NAME = /-(sqlite|mongodb|file)$/;++export const MANIFESTS = ['Cargo.toml', 'crates/openhuman-app/Cargo.toml'];export const VENDORED_TSD_DIR = 'vendor/tinystoragedrivers/';export const REPO_ROOT = resolve(dirname(fileURLToPath(import.meta.url)), '../..');-const norm = p => String(p ?? '').replaceAll('\\', '/').replace(/\/+$/, '');+// ---------------------------------------------------------------------------+// Helpers+// ---------------------------------------------------------------------------++const norm = s => String(s ?? '').replaceAll('\\', '/').replace(/\/+$/, '');++const isOwner = name => name.startsWith('tinystoragedrivers');++const normalisedName = name => name.replace(/_/g, '-');++const isForbiddenDep = name => {+ const n = normalisedName(name);+ if (FORBIDDEN_DEPS.includes(n)) return true;+ if (FORBIDDEN_PREFIXES.some(p => n.startsWith(p))) return true;+ return false;+};++const isForbiddenTsdEngine = name => {+ const n = normalisedName(name);+ return FORBIDDEN_TSD_ENGINES.includes(n) || n === 'tinystoragedrivers';+};++/** First-party = built from a path or a git source, not from a registry. */+const isFirstParty = pkg => !pkg.source || pkg.source.startsWith('git+');-/** True when `manifest` lies under `<root>/vendor/tinystoragedrivers/` (this checkout only). */export function isUnderVendoredTsd(manifest, root) {const prefix = `${norm(root)}/${VENDORED_TSD_DIR}`;return norm(manifest).startsWith(prefix);@@ -74,17 +137,124 @@ export function isUnderVendoredTsd(manifest, root) {const TSD_GIT = /^git\+https?:\/\/[^?#]*\/tinystoragedrivers(?:\.git)?\?tag=([^#&]+)/;+// ---------------------------------------------------------------------------+// Dependency-closure walk+// ---------------------------------------------------------------------------+/**- * Rule 3: every tinystoragedrivers* package must be a path under this- * repository's `<root>/vendor/tinystoragedrivers/`.- * Rule 4: a dependency that names tinystoragedrivers by git tag must name the- * tag matching the vendored checkout's version; a bare tag bump stays- * semver-compatible, so the `[patch]` would otherwise apply silently.+ * Walk the resolved normal+build dependency graph from `roots` and return+ * every path that reaches a forbidden crate.+ *+ * @param {object} metadata - cargo metadata document+ * @param {string[]} roots - package names that are composition roots (skip+ * them in the walk and do not report violations+ * from them)+ * @returns {{ package: string, kind: string, detail: string, path: string[] }[]}*/+export function checkEngineClosure(metadata, roots) {+ const packages = Object.fromEntries(+ (metadata.packages ?? []).map(p => [p.id, p])+ );+ const nodes = Object.fromEntries(+ (metadata.resolve?.nodes ?? []).map(n => [n.id, n])+ );++ const rootIds = new Set(+ (metadata.packages ?? [])+ .filter(p => roots.includes(p.name))+ .map(p => p.id)+ );++ const violations = [];++ for (const pkg of metadata.packages ?? []) {+ if (!isFirstParty(pkg) || isOwner(pkg.name)) continue;+ if (pkg.name in ALLOWLIST) continue;++ const pkg_id = pkg.id;+ if (!nodes[pkg_id]) continue;++ // BFS from this package, skipping root packages+ const queue = [[pkg_id, pkg.name, [pkg.name]]];+ const seen = new Set([pkg_id]);++ while (queue.length) {+ const [current_id, current_name, path] = queue.shift();++ const node = nodes[current_id];+ if (!node) continue;++ for (const dep of node.deps ?? []) {+ // Only normal and build edges count+ const has_normal_or_build = dep.dep_kinds?.some(+ dk => dk.kind === undefined || dk.kind === 'build'+ );+ 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;++ const dep_name = dep_pkg.name;++ // Skip root packages — they are allowed+ if (rootIds.has(dep_id)) continue;++ const new_path = [...path, dep_name];++ if (isForbiddenDep(dep_name) || isForbiddenTsdEngine(dep_name)) {+ violations.push({+ package: pkg.name,+ kind: 'engine-reach',+ engine: dep_name,+ path: new_path,+ detail: `reaches ${dep_name} via ${path.slice(1).join(' -> ')}`,+ });+ // Don't continue through forbidden crates — the path to the engine+ // is already captured; don't flood with deeper paths.+ continue;+ }++ // Continue the walk+ queue.push([dep_id, dep_name, new_path]);+ }+ }+ }++ return violations;+}++// ---------------------------------------------------------------------------+// Rule 2: crate naming+// ---------------------------------------------------------------------------++export function checkCrateNaming(metadata) {+ const out = [];+ for (const pkg of metadata.packages ?? []) {+ if (!isFirstParty(pkg) || isOwner(pkg.name)) continue;+ if (FORBIDDEN_CRATE_NAME.test(pkg.name)) {+ out.push({+ package: pkg.name,+ kind: 'crate-name',+ detail: `crate name matches ${FORBIDDEN_CRATE_NAME}`,+ });+ }+ }+ return out;+}++// ---------------------------------------------------------------------------+// Rules 3 & 4: vendored TSD ownership and tag match+// ---------------------------------------------------------------------------+export function checkVendoredOwner(metadata, root = REPO_ROOT) {const out = [];const packages = metadata.packages ?? [];let vendoredVersion = null;+for (const pkg of packages) {if (!isOwner(pkg.name)) continue;const manifest = norm(pkg.manifest_path);@@ -99,6 +269,7 @@ export function checkVendoredOwner(metadata, root = REPO_ROOT) {.map(p => p.name)),].sort();+out.push({package: pkg.name,kind: 'tsd-not-vendored',@@ -108,6 +279,7 @@ export function checkVendoredOwner(metadata, root = REPO_ROOT) {'; bump vendor/tinystoragedrivers or the module\'s tinystoragedrivers tag so they agree',});}+if (vendoredVersion) {const seen = new Set();for (const p of packages) {@@ -128,43 +300,58 @@ export function checkVendoredOwner(metadata, root = REPO_ROOT) {}}}+return out;}-/** Returns `[{ package, kind, detail }]` violations for one metadata document. */-export function checkMetadata(metadata, allowlist = ALLOWLIST, root = REPO_ROOT) {- const out = [];- for (const pkg of metadata.packages ?? []) {- if (!isFirstParty(pkg) || isOwner(pkg.name)) continue;- if (FORBIDDEN_CRATE_NAME.test(pkg.name)) {- out.push({ package: pkg.name, kind: 'crate-name', detail: `crate name matches ${FORBIDDEN_CRATE_NAME}` });- }- if (Object.hasOwn(allowlist, pkg.name)) continue;- const seen = new Set();- for (const dep of pkg.dependencies ?? []) {- if (FORBIDDEN_DEPS.includes(dep.name) && !seen.has(dep.name)) {- seen.add(dep.name);- out.push({ package: pkg.name, kind: 'dependency', detail: `depends on ${dep.name}` });- }- }- }- return [...out, ...checkVendoredOwner(metadata, root)];+// ---------------------------------------------------------------------------+// Top-level check+// ---------------------------------------------------------------------------++export function checkMetadata(metadata, root = REPO_ROOT) {+ const allowlistKeys = Object.keys(ALLOWLIST);++ // Rule 1: engine closure+ const closureViolations = checkEngineClosure(metadata, allowlistKeys);++ // Rule 2: crate naming+ const namingViolations = checkCrateNaming(metadata);++ // Rules 3 & 4+ const vendoredViolations = checkVendoredOwner(metadata, root);++ return [...closureViolations, ...namingViolations, ...vendoredViolations];}export function formatReport(violations) {- if (violations.length === 0) return 'storage-owner: ok (no storage backend outside tinystoragedrivers*)';- const lines = violations.map(v => ` - ${v.package}: ${v.detail}`);+ if (violations.length === 0) {+ return 'storage-owner: ok (no storage backend outside tinystoragedrivers* reached from non-root crates)';+ }+ const lines = violations.map(v => {+ if (v.kind === 'engine-reach') {+ return ` - ${v.package}: reaches ${v.engine} via ${v.path.slice(1, -1).join(' -> ')}`;+ }+ return ` - ${v.package}: ${v.detail}`;+ });return [- 'storage-owner: FAILED. tinystoragedrivers* owns every storage backend.',+ 'storage-owner: FAILED. No non-root first-party package may reach a storage engine.',...lines,- 'Use the tinystoragedrivers ports instead, or add a read-only external-database reader to ALLOWLIST in scripts/ci/check-storage-owner.mjs with a reason.',+ '',+ 'Allowlist entries (composition roots only):',+ ...Object.entries(ALLOWLIST).map(([k, v]) => ` ${k}: ${v}`),+ '',+ 'Add a read-only external-database reader to ALLOWLIST with a reason, or use the tinystoragedrivers ports.',].join('\n');}+// ---------------------------------------------------------------------------+// CLI+// ---------------------------------------------------------------------------+function loadMetadata(root, manifest) {const r = spawnSync('cargo',- ['metadata', '--format-version', '1', '--manifest-path', resolve(root, manifest)],+ ['metadata', '--format-version', '1', '--manifest-path', resolve(root, manifest), '--all-features'],{ cwd: root, encoding: 'utf8', maxBuffer: 1 << 30 });if (r.status !== 0) throw new Error(`cargo metadata failed for ${manifest}: ${r.stderr}`);@@ -178,6 +365,7 @@ export function main(argv) {if (argv[i] === '--metadata') files.push(argv[++i]);else root = resolve(argv[i]);}+let docs;try {docs = files.length@@ -187,10 +375,15 @@ export function main(argv) {console.error(`storage-owner: cannot read inputs: ${err.message}`);return 2;}+const seen = new Set();const violations = docs- .flatMap(d => checkMetadata(d, ALLOWLIST, root))- .filter(v => !seen.has(`${v.package}|${v.detail}`) && seen.add(`${v.package}|${v.detail}`));+ .flatMap(d => checkMetadata(d, root))+ .filter(v => {+ const key = `${v.package}|${v.kind}|${v.detail}`;+ return !seen.has(key) && seen.add(key);+ });+console.log(formatReport(violations));return violations.length ? 1 : 0;}