Skip to content

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

build(ci): add process statics check to rust lane

Steven Enamakel6ac802f17ce2
diff --git a/package.json b/package.json
index cb7f4938ab..8d5d5acaed 100644
--- a/package.json
+++ b/package.json
@@ -59,6 +59,7 @@
"rust:module-boundaries": "node scripts/ci/check-module-boundaries.mjs",
"rust:module-boundaries:complete": "node scripts/ci/check-module-boundaries.mjs --require-complete",
"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:process-statics": "node scripts/ci/check-process-statics.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",
diff --git a/scripts/ci/process-statics.md b/scripts/ci/process-statics.md
new file mode 100644
index 0000000000..d9e145cb2f
--- /dev/null
+++ b/scripts/ci/process-statics.md
@@ -0,0 +1,61 @@
+# Review new core process statics
+
+Run `pnpm rust:process-statics` from the repository root. The checks lane runs
+the same command's script on every change. CI must fetch the base branch and
+its history. A missing merge base fails the check.
+
+The gate compares tracked production Rust sources under
+`crates/openhuman-core/src/` with the base branch's merge base. In GitHub PRs,
+the base is `origin/$GITHUB_BASE_REF`; locally it prefers `upstream/main`, then
+`origin/main`. Supply a different base explicitly with
+`node scripts/ci/check-process-statics.mjs <base-ref>`.
+
+Every added declaration or changed declared type requires a record in
+`scripts/ci/process-statics.json`. All declared types are checked, including
+immutable statics and aliases: an alias can conceal a mutable container.
+Existing declarations are not retrospectively approved by this gate. The
+empty initial manifest does not certify their isolation.
+
+Each record has these fields:
+
+```json
+{
+ "file": "crates/openhuman-core/src/example/store.rs",
+ "name": "CACHE",
+ "type": "OnceLock<Mutex<Cache>>",
+ "count": 1,
+ "category": "B",
+ "reason": "Every key includes the authenticated profile and agent scope.",
+ "verification": "example/store_tests.rs: profiles_cannot_share_entries"
+}
+```
+
+Use the type printed by the failure message, with whitespace removed (except
+the `mut ` or `ref ` prefix). `count` is the exact number of matching
+file/name/type declarations, including declarations in nested modules.
+Duplicate records, missing fields, and records that no longer match the
+source fail. Update or remove the record when its declaration changes.
+
+Choose the ownership category and explain why it applies:
+
+| Category | Ownership |
+| --- | --- |
+| A | Process configuration or infrastructure; carries no tenant data |
+| B | Tenant data explicitly partitioned by authenticated scope |
+| C | Durable authoritative state reached through a storage driver |
+| D | A routing handle whose target enforces the ownership boundary |
+
+Reviewers must inspect the reason and verification reference. The gate
+checks their presence and the source declaration; it does not execute the
+referenced test or prove the category is correct.
+
+## Bounds
+
+This is a source declaration guard, not a Rust macro expander. It recognizes
+ordinary `static`, `static mut`, and `lazy_static!`'s `static ref`, multiline
+and qualified types, and ignores comments and string fixtures. Statics
+generated without a literal declaration by another macro need manual review.
+Sibling `*_tests.rs` files are excluded; declarations behind `cfg(test)` in
+production source files are conservatively included. Initializer edits to an
+existing declaration are subject to ordinary code review. Other crates and
+vendored repositories are outside this core-only gate.
diff --git a/scripts/ci/self-hosted/lanes-plan.mjs b/scripts/ci/self-hosted/lanes-plan.mjs
index 9dad5c2a3c..626de70b07 100644
--- a/scripts/ci/self-hosted/lanes-plan.mjs
+++ b/scripts/ci/self-hosted/lanes-plan.mjs
@@ -232,6 +232,11 @@ export function buildPlan({ profile, areas, env = {}, isPullRequest = true }) {
when: true,
run: "node scripts/ci/check-crate-chain.mjs",
},
+ {
+ name: "process-statics",
+ when: true,
+ run: "node scripts/ci/check-process-statics.mjs",
+ },
{
name: "module-boundaries",
when: rust || areas.scripts,