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(ci): wire storage bypass check into rust layout and skip test dirs
Steven Enamakel7af9b55c2d33
diff --git a/package.json b/package.jsonindex a50e9cc5c9..12a2d7aca6 100644--- a/package.json+++ b/package.json@@ -56,10 +56,11 @@"test:install-ps1": "pwsh -NoProfile -File scripts/tests/OpenHumanWindowsInstall.Tests.ps1","rust:check": "pnpm --filter openhuman-app rust:check","rust:clippy": "cargo clippy -p openhuman -p openhuman-cli -p openhuman-tinyhumans -- -D warnings && pnpm --filter openhuman-app rust:clippy",- "rust:layout": "node scripts/ci/check-openhuman-rust-layout.mjs && node scripts/ci/check-crate-chain.mjs",+ "rust:layout": "node scripts/ci/check-openhuman-rust-layout.mjs && node scripts/ci/check-crate-chain.mjs && node scripts/ci/check-storage-bypass.mjs","rust:ignored-tests": "node scripts/ci/check-ignored-tests.mjs","dep:audit": "bash scripts/dep-audit/run.sh","agent:runtime-boundary": "node scripts/ci/check-agent-runtime-boundary.mjs",+ "storage:bypass": "node scripts/ci/check-storage-bypass.mjs","saas:ambient": "node scripts/ci/check-saas-ambient.mjs","typecheck": "pnpm --filter openhuman-app compile","tauri:ios:init": "bash scripts/ios-init.sh",diff --git a/scripts/__tests__/storage-bypass.test.mjs b/scripts/__tests__/storage-bypass.test.mjsnew file mode 100644index 0000000000..fa97110678--- /dev/null+++ b/scripts/__tests__/storage-bypass.test.mjs@@ -0,0 +1,121 @@+// Unit tests for scripts/ci/check-storage-bypass.mjs, the ratchet over state+// that is persisted behind the storage port.++import assert from "node:assert/strict";+import { spawnSync } from "node:child_process";+import fs from "node:fs";+import os from "node:os";+import path from "node:path";+import test from "node:test";+import { fileURLToPath } from "node:url";++import { ALLOW, allowed, compare, scan } from "../ci/check-storage-bypass.mjs";++const repoRoot = path.join(path.dirname(fileURLToPath(import.meta.url)), "..", "..");+const script = path.join(repoRoot, "scripts", "ci", "check-storage-bypass.mjs");+const SRC = "crates/openhuman-core/src";++function run(files, baseline, args = []) {+ const root = fs.mkdtempSync(path.join(os.tmpdir(), "openhuman-storage-bypass-"));+ for (const [rel, body] of Object.entries(files)) {+ const abs = path.join(root, rel);+ fs.mkdirSync(path.dirname(abs), { recursive: true });+ fs.writeFileSync(abs, body);+ }+ const written = path.join(root, "scripts", "ci", "storage-bypass-baseline.json");+ if (baseline) {+ fs.mkdirSync(path.dirname(written), { recursive: true });+ fs.writeFileSync(written, `${JSON.stringify(baseline, null, 2)}\n`);+ }+ const result = spawnSync(process.execPath, [script, "--root", root, ...args], {+ encoding: "utf8",+ });+ const after = fs.existsSync(written) ? JSON.parse(fs.readFileSync(written, "utf8")) : null;+ fs.rmSync(root, { recursive: true, force: true });+ return { status: result.status, out: `${result.stdout}${result.stderr}`, after };+}++test("flags a database open and a raw file write", () => {+ const found = scan(+ "x.rs",+ [+ "let c = Connection::open(&path)?;",+ "let c = rusqlite::Connection::open(path)?;",+ "std::fs::write(&p, body)?;",+ "let f = File::create(p)?;",+ "let f = OpenOptions::new().append(true).open(p)?;",+ ].join("\n"),+ );+ assert.deepEqual(+ found.map((f) => f.rule),+ ["sqlite-open", "sqlite-open", "json-write", "json-write", "json-write"],+ );+});++test("ignores comments and doc lines", () => {+ const found = scan(+ "x.rs",+ ["// Connection::open(&p)", "//! fs::write(p, b)", "let s = 1; // File::create(p)"].join("\n"),+ );+ assert.deepEqual(found, []);+});++test("compare reports added and stale sites", () => {+ const finding = { rule: "sqlite-open", path: "a.rs", line: 3, text: "x", occurrence: 1 };+ const other = { rule: "json-write", path: "b.rs", line: 4, text: "y", occurrence: 1 };+ const { added, stale } = compare([finding], [other]);+ assert.deepEqual(added, [finding]);+ assert.deepEqual(stale, [other]);+});++test("every allowlisted path carries a reason and known rules", () => {+ for (const [file, entry] of ALLOW) {+ assert.ok(file.startsWith(`${SRC}/`), file);+ assert.ok(entry.reason.length > 20, file);+ for (const rule of entry.rules) assert.ok(["sqlite-open", "json-write"].includes(rule));+ }+ assert.ok(allowed(`${SRC}/config/workspace/state.rs`, "sqlite-open"));+ assert.ok(!allowed(`${SRC}/config/workspace/state.rs`, "json-write"));+});++test("a new database open fails the check", () => {+ const { status, out } = run(+ { [`${SRC}/foo/store.rs`]: "fn f() { let c = Connection::open(p); }\n" },+ [],+ );+ assert.equal(status, 1);+ assert.match(out, /New storage-bypass sites/);+ assert.match(out, /sqlite-open: crates\/openhuman-core\/src\/foo\/store\.rs:1/);+});++test("the storage module, tests and allowlisted fallbacks are not flagged", () => {+ const { status } = run(+ {+ [`${SRC}/storage/driver.rs`]: "fn f() { let c = Connection::open(p); }\n",+ [`${SRC}/foo/store_tests.rs`]: "fn f() { std::fs::write(p, b); }\n",+ [`${SRC}/foo/tests/common.rs`]: "fn f() { File::create(p); }\n",+ [`${SRC}/cron/policy.rs`]: "fn f() { let c = Connection::open(p); }\n",+ },+ [],+ );+ assert.equal(status, 0);+});++test("a fixed site left in the baseline fails until removed", () => {+ const { status, out } = run({ [`${SRC}/foo/store.rs`]: "fn f() {}\n" }, [+ { rule: "sqlite-open", path: `${SRC}/foo/store.rs`, line: 1, text: "x", occurrence: 1 },+ ]);+ assert.equal(status, 1);+ assert.match(out, /Fixed sites still in the baseline/);+});++test("--write-baseline records the current sites", () => {+ const { status, after } = run(+ { [`${SRC}/foo/store.rs`]: "fn f() { std::fs::write(p, b); }\n" },+ null,+ ["--write-baseline"],+ );+ assert.equal(status, 0);+ assert.equal(after.length, 1);+ assert.equal(after[0].rule, "json-write");+});diff --git a/scripts/ci/check-storage-bypass.mjs b/scripts/ci/check-storage-bypass.mjsindex dba01b9f63..5d6700296b 100755--- a/scripts/ci/check-storage-bypass.mjs+++ b/scripts/ci/check-storage-bypass.mjs@@ -78,6 +78,7 @@ export function allowed(rel, rule) {function isTestFile(rel) {return (rel.startsWith("crates/openhuman-core/src/storage/") ||+ rel.includes("/tests/") ||rel.endsWith("_tests.rs") ||rel.includes(`${sep}test_support${sep}`) ||rel.includes("/test_support/")diff --git a/scripts/ci/storage-bypass-baseline.json b/scripts/ci/storage-bypass-baseline.jsonindex f9559ed6a4..6c0ddaae53 100644--- a/scripts/ci/storage-bypass-baseline.json+++ b/scripts/ci/storage-bypass-baseline.json@@ -153,69 +153,6 @@"text": "if let Err(e) = std::fs::write(&checkpoint_path, json) {","occurrence": 1},- {- "rule": "json-write",- "path": "crates/openhuman-core/src/channels/tests/common.rs",- "line": 70,- "text": "std::fs::write(tmp.path().join(\"SOUL.md\"), \"# Soul\\nBe helpful.\").unwrap();",- "occurrence": 1- },- {- "rule": "json-write",- "path": "crates/openhuman-core/src/channels/tests/common.rs",- "line": 71,- "text": "std::fs::write(",- "occurrence": 1- },- {- "rule": "json-write",- "path": "crates/openhuman-core/src/channels/tests/prompt.rs",- "line": 89,- "text": "std::fs::write(tmp.path().join(\"SOUL.md\"), \"# Soul\").unwrap();",- "occurrence": 1- },- {- "rule": "json-write",- "path": "crates/openhuman-core/src/channels/tests/prompt.rs",- "line": 90,- "text": "std::fs::write(tmp.path().join(\"IDENTITY.md\"), \"# Identity\").unwrap();",- "occurrence": 1- },- {- "rule": "json-write",- "path": "crates/openhuman-core/src/channels/tests/prompt.rs",- "line": 91,- "text": "std::fs::write(tmp.path().join(\"PROFILE.md\"), \"# User Profile\").unwrap();",- "occurrence": 1- },- {- "rule": "json-write",- "path": "crates/openhuman-core/src/channels/tests/prompt.rs",- "line": 92,- "text": "std::fs::write(tmp.path().join(\"MEMORY.md\"), \"# Memory\\nLearned bits.\").unwrap();",- "occurrence": 1- },- {- "rule": "json-write",- "path": "crates/openhuman-core/src/channels/tests/prompt.rs",- "line": 106,- "text": "std::fs::write(",- "occurrence": 1- },- {- "rule": "json-write",- "path": "crates/openhuman-core/src/channels/tests/prompt.rs",- "line": 176,- "text": "std::fs::write(ws.path().join(\"SOUL.md\"), &big_content).unwrap();",- "occurrence": 1- },- {- "rule": "json-write",- "path": "crates/openhuman-core/src/channels/tests/prompt.rs",- "line": 193,- "text": "std::fs::write(ws.path().join(\"PROFILE.md\"), \"\").unwrap();",- "occurrence": 1- },{"rule": "json-write","path": "crates/openhuman-core/src/config/migrations/phase_out_profile_md.rs",