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 domain e2e gate crediting compiled-out coverage

M3gA-Mind8460ce9d8057
diff --git a/scripts/__tests__/domain-e2e-coverage-gate.test.mjs b/scripts/__tests__/domain-e2e-coverage-gate.test.mjs
index 89c86e84e6..4fec19ffbf 100644
--- a/scripts/__tests__/domain-e2e-coverage-gate.test.mjs
+++ b/scripts/__tests__/domain-e2e-coverage-gate.test.mjs
@@ -94,10 +94,19 @@ function fixture(t, options = {}) {
// the exclusion claims lives on the SECOND of those — which is the whole
// reason the gate walks the chain instead of reading the file it found the
// controller in.
+ //
+ // That second declaration goes in **`lib.rs`**, because that is where it
+ // goes in the crate. This fixture used to write `src/mod.rs`, which Rust
+ // cannot have: a crate root is `lib.rs` or `main.rs`, never `mod.rs`. The
+ // walk only looked for `mod.rs`, so against the fixture it found the gate
+ // and against the real tree it fell off the end — and every test here
+ // passed while the gate told `openhuman` to "restore" a `#[cfg]` that was
+ // never removed. A fixture that models an impossible world proves nothing
+ // about the real one.
write(root, 'crates/openhuman-core/src/test_support/mod.rs', 'mod schemas;\n');
write(
root,
- 'crates/openhuman-core/src/mod.rs',
+ 'crates/openhuman-core/src/lib.rs',
`${excludedModuleCfg ? `${excludedModuleCfg}\n` : ''}pub mod test_support;\n`,
);
}
@@ -604,3 +613,208 @@ test('accepts repeated declarations when every one of them requires the gate', (
`the exclusion must still apply; got:\n${result.stdout}`,
);
});
+
+// ---------------------------------------------------------------------------
+// #6382 quarantine: crediting coverage to files that compile to nothing.
+//
+// 52 of the repo's 115 `tests/**/*_e2e.rs` files open with `#![cfg(any())]` —
+// `any()` with no branches is unsatisfiable, so the whole module is thrown
+// away. The scan is textual and credited them anyway: 176 distinct controllers
+// sat in the covered column without a single compiled line behind them. That
+// is not a weaker signal than a real test, it is the absence of one wearing a
+// real one's clothes.
+test('credits nothing from a file whose own cfg can never be satisfied', (t) => {
+ const root = fixture(t);
+ write(root, 'crates/openhuman-core/src/widgets/schemas.rs', controller('widgets', 'list'));
+ write(root, 'tests/widgets_e2e.rs', '#![cfg(any())]\nlet m = "openhuman.widgets_list";');
+
+ const result = runGate(root);
+
+ assert.match(
+ result.stdout,
+ /\| widgets \| widgets \| 0\/1 \| 0\.0% \|/,
+ `a quarantined file must credit nothing; got:\n${result.stdout}`,
+ );
+ assert.match(
+ result.stdout,
+ /openhuman\.widgets_list/,
+ `the controller must be reported missing, not covered; got:\n${result.stdout}`,
+ );
+});
+
+// The negative control for the test above, and the reason this is not just a
+// "does the file mention cfg" check. `#![cfg(feature = "mcp")]` is how
+// `tests/mcp_registry_e2e.rs` keeps the slim build compiling; it is a real
+// conditional, it IS built in the measured configuration, and treating it like
+// the quarantine would delete genuine coverage — the direction that hides work.
+test('still credits a file gated on a real feature', (t) => {
+ const root = fixture(t);
+ write(root, 'crates/openhuman-core/src/widgets/schemas.rs', controller('widgets', 'list'));
+ write(root, 'tests/widgets_e2e.rs', '#![cfg(feature = "mcp")]\nlet m = "openhuman.widgets_list";');
+
+ const result = runGate(root);
+
+ assert.match(
+ result.stdout,
+ /\| widgets \| widgets \| 1\/1 \| 100\.0% \|/,
+ `a feature-gated file must still count; got:\n${result.stdout}`,
+ );
+});
+
+// A namespace that outgrows one file splits the same way every time: the
+// `const NAMESPACE` stays with the aggregate and the `ControllerSchema`
+// literals move into siblings reaching it through `use super::*`. Per-file
+// lookup found no const, resolved the namespace to undefined, and skipped
+// every controller in the file. 43 controllers went that way — and 26 of them
+// were `memory_tree`, which kept the five declared in the file that still had
+// a local const and reported 5/5, 100%.
+test('resolves const NAMESPACE from the aggregate file beside the split', (t) => {
+ const root = fixture(t);
+ write(
+ root,
+ 'crates/openhuman-core/src/widgets/schemas.rs',
+ 'const NAMESPACE: &str = "widgets";\nmod list_schemas;\n',
+ );
+ write(
+ root,
+ 'crates/openhuman-core/src/widgets/schemas/list_schemas.rs',
+ `
+pub const SCHEMA: ControllerSchema = ControllerSchema {
+ namespace: NAMESPACE,
+ function: "list",
+};
+`,
+ );
+ write(root, 'tests/widgets_e2e.rs', 'let m = "openhuman.widgets_list";');
+
+ const result = runGate(root);
+
+ assert.match(
+ result.stdout,
+ /\| widgets \| widgets \| 1\/1 \| 100\.0% \|/,
+ `a controller in a split file must resolve its namespace; got:\n${result.stdout}`,
+ );
+});
+
+// The `memory_tree` shape specifically: the const is in a SIBLING of the file
+// holding the literals, not in the parent. Directory-scoped resolution covers
+// both; parent-only resolution would not.
+test('resolves const NAMESPACE from a sibling in the same module directory', (t) => {
+ const root = fixture(t);
+ write(root, 'crates/openhuman-core/src/widgets/definitions.rs', 'const NAMESPACE: &str = "widgets";\n');
+ write(
+ root,
+ 'crates/openhuman-core/src/widgets/tree_schema.rs',
+ `
+pub const SCHEMA: ControllerSchema = ControllerSchema {
+ namespace: NAMESPACE,
+ function: "ingest",
+};
+`,
+ );
+ write(root, 'tests/widgets_e2e.rs', 'let m = "openhuman.widgets_ingest";');
+
+ const result = runGate(root);
+
+ assert.match(
+ result.stdout,
+ /\| widgets \| widgets \| 1\/1 \| 100\.0% \|/,
+ `a sibling const must resolve the namespace; got:\n${result.stdout}`,
+ );
+});
+
+// `openhuman.a_b` was a `ControllerSchema` fixture inside
+// `core/core_mod_tests.rs`, invented by discovery and then failing the lane as
+// its own 0/1 row. Two more (`test_echo`, `test_configure`) inflated the `test`
+// exclusion from 1 real controller to 3. A `*_tests.rs` file is never a
+// registration site.
+test('ignores ControllerSchema fixtures declared in a *_tests.rs file', (t) => {
+ const root = fixture(t);
+ write(root, 'crates/openhuman-core/src/widgets/schemas.rs', controller('widgets', 'list'));
+ write(root, 'tests/widgets_e2e.rs', 'let m = "openhuman.widgets_list";');
+ // The shape that invented `openhuman.a_b`: a fixture in a unit-test file.
+ write(root, 'crates/openhuman-core/src/core/core_mod_tests.rs', controller('a', 'b'));
+
+ const result = runGate(root);
+
+ assert.doesNotMatch(
+ result.stdout,
+ /openhuman\.a_b/,
+ `a unit-test fixture must not become a controller; got:\n${result.stdout}`,
+ );
+ // `widgets` only. `test` / `test_support` are reported on the Excluded line,
+ // and `a` must not appear at all — before the fix it was its own 0/1 row.
+ assert.match(
+ result.stdout,
+ /Discovered 1 controllers across 1 namespaces/,
+ `the fixture namespace must not gain a phantom; got:\n${result.stdout}`,
+ );
+ assert.doesNotMatch(
+ result.stdout,
+ /^\| a \|/m,
+ `the fixture namespace must not become a table row; got:\n${result.stdout}`,
+ );
+});
+
+// `[a-z_]+` rejected every namespace carrying a digit, so `web3_swap`,
+// `web3_bridge`, `web3_dapp` and `x402` — ten controllers, including every
+// wallet swap and bridge entry point — were never measured.
+test('discovers a namespace whose name contains a digit', (t) => {
+ const root = fixture(t);
+ write(root, 'crates/openhuman-core/src/web3/swap/schemas.rs', controller('web3_swap', 'quote'));
+ write(root, 'tests/web3_e2e.rs', 'let m = "openhuman.web3_swap_quote";');
+
+ const result = runGate(root);
+
+ assert.match(
+ result.stdout,
+ /\| web3_swap \| web3_swap \| 1\/1 \| 100\.0% \|/,
+ `a namespace with a digit must be measured; got:\n${result.stdout}`,
+ );
+});
+
+// The exclusion check walks upward for the `#[cfg]` that makes a namespace
+// unreachable. `#[cfg] pub mod test_support;` lives in the crate ROOT, which is
+// `lib.rs` — `crates/openhuman-core/src/mod.rs` is not a file Rust can have.
+// Looking only for `mod.rs` meant the walk fell off the end and reported the
+// gate missing while `lib.rs:86` carried it the whole time.
+test('resolves an exclusion gate declared in the crate root lib.rs', (t) => {
+ const root = fixture(t);
+ write(root, 'crates/openhuman-core/src/widgets/schemas.rs', controller('widgets', 'list'));
+ write(root, 'tests/widgets_e2e.rs', 'let m = "openhuman.widgets_list";');
+
+ const result = runGate(root);
+
+ assert.doesNotMatch(
+ result.stderr,
+ /no longer behind the gate they claim/,
+ `a gate in lib.rs must be found; got:\n${result.stderr}`,
+ );
+});
+
+// `crates/openhuman-tinyhumans` registers `billing`, `team`, `referral` and
+// `announcements` into the same registry at runtime through
+// `register_controller_extension`, so they dispatch exactly like a built-in
+// controller. SCHEMA_ROOTS named only the core and the vendored channels bus,
+// so those 34 were exempt from the threshold entirely — the family most likely
+// to move money was the one family nothing measured.
+test('discovers controllers declared in the hosted tinyhumans crate', (t) => {
+ const root = fixture(t);
+ write(root, 'crates/openhuman-tinyhumans/src/hosted/billing/schemas.rs', controller('billing', 'get_balance'));
+ // Named by no e2e target: it must show up as a real, uncovered obligation
+ // rather than not show up at all.
+ write(root, 'tests/widgets_e2e.rs', 'let m = "openhuman.nothing_here";');
+
+ const result = runGate(root);
+
+ assert.match(
+ result.stdout,
+ /\| billing \| billing \| 0\/1 \| 0\.0% \|/,
+ `a hosted-crate controller must be measured; got:\n${result.stdout}`,
+ );
+ assert.match(
+ result.stdout,
+ /openhuman\.billing_get_balance/,
+ `the hosted controller must be named as missing; got:\n${result.stdout}`,
+ );
+});
diff --git a/scripts/check-domain-e2e-coverage.mjs b/scripts/check-domain-e2e-coverage.mjs
index 9ab6b37cb4..c194040fd3 100644
--- a/scripts/check-domain-e2e-coverage.mjs
+++ b/scripts/check-domain-e2e-coverage.mjs
@@ -133,8 +133,18 @@ const PRODUCT_FEATURES_FILE = path.join(ROOT, 'scripts', 'ci', 'product-features
//
// `app/src/services/__tests__/rpcMethods.test.ts` already reaches into the same
// vendored crate for the same reason.
+//
+// The third root is the hosted TinyHumans surface. `crates/openhuman-tinyhumans`
+// registers `billing`, `team`, `referral` and `announcements` into the same
+// registry at runtime through `register_controller_extension`
+// (`crates/openhuman-core/src/core/all.rs`), so those 34 controllers dispatch
+// exactly like a built-in one — but they are declared in a crate this list did
+// not name, so the gate could not see them and they were exempt from the
+// threshold entirely. The family most likely to move money was the one family
+// nothing measured.
const SCHEMA_ROOTS = [
path.join(ROOT, 'crates', 'openhuman-core', 'src'),
+ path.join(ROOT, 'crates', 'openhuman-tinyhumans', 'src'),
path.join(ROOT, 'vendor', 'tinychannels', 'crates', 'tinychannels-bus', 'src', 'controllers'),
];
@@ -183,6 +193,12 @@ function collectInvokedMethods() {
for (const file of files) {
const text = read(file);
+ // A file the compiler throws away cannot invoke anything. 52 of the 115
+ // e2e files open with `#![cfg(any())]` pending the #6382 migration, and
+ // crediting them put 176 controllers in the covered column that no build
+ // has compiled since the day they were switched off — the largest single
+ // source of false coverage this gate had.
+ if (fileIsCompiledOut(text)) continue;
for (const match of text.matchAll(/"((?:openhuman)\.[A-Za-z0-9_]+)"/g)) {
methods.add(match[1]);
}
@@ -191,6 +207,36 @@ function collectInvokedMethods() {
return methods;
}
+/**
+ * Is this file's own `#![cfg(...)]` unsatisfiable, whatever the feature set?
+ *
+ * Only ever answers true for a predicate that is false by construction, never
+ * for one that merely happens to be off here — `#![cfg(feature = "mcp")]` on
+ * `tests/mcp_registry_e2e.rs` is a real conditional and its methods stay
+ * credited. Deliberately narrow: this gate has no business deciding whether
+ * `unix` or `target_os` holds, and a wrong "always false" silently deletes
+ * real coverage, which is the direction that hides work.
+ *
+ * - `any()` with no branches can never be satisfied. That is the literal
+ * shape the #6382 quarantine uses.
+ * - `all(...)` is unsatisfiable as soon as ONE branch is.
+ * - everything else, including any `not(...)`, is treated as satisfiable.
+ */
+function cfgIsAlwaysFalse(node) {
+ if (!node) return false;
+ if (node.kind === 'any') return node.children.length === 0;
+ if (node.kind === 'all') return node.children.some(cfgIsAlwaysFalse);
+ return false;
+}
+
+/** File-level `#![cfg(...)]` inner attributes, which gate the whole module. */
+function fileIsCompiledOut(text) {
+ for (const match of text.matchAll(/^#!\[\s*cfg\s*\(([\s\S]*?)\)\s*\]/gm)) {
+ if (cfgIsAlwaysFalse(parseCfgPredicate(match[1]))) return true;
+ }
+ return false;
+}
+
/**
* Every controller declared anywhere under `SCHEMA_ROOTS`, keyed by namespace.
*
@@ -214,12 +260,23 @@ function collectSchemaMethods() {
for (const root of SCHEMA_ROOTS) {
for (const file of walk(root, (f) => f.endsWith('.rs'))) {
+ // A `*_tests.rs` file is unit-test scaffolding, never a registration
+ // site. Reading them invented three controllers that do not exist as
+ // RPCs — `openhuman.a_b` (`core/core_mod_tests.rs`), `openhuman.test_echo`
+ // and `openhuman.test_configure` (`core/cli_tests.rs`, fixtures for
+ // `parse_function_params`) — and `a_b` was its own 0/1 row, failing the
+ // lane over a method nothing can dispatch.
+ if (path.basename(file).endsWith('_tests.rs')) continue;
const text = read(file);
- const constNamespace = text.match(/const\s+NAMESPACE:\s*&str\s*=\s*"([a-z_]+)"/)?.[1];
+ const constNamespace = namespaceConstFor(file, text);
// `ChannelControllerSchema` is the vendored bus crate's equivalent shape.
for (const match of text.matchAll(/(?:Channel)?ControllerSchema\s*\{([\s\S]*?)\n\s*\}/g)) {
const block = match[1];
- const namespaceToken = block.match(/namespace:\s*(?:NAMESPACE|"([a-z_]+)")/);
+ // `[a-z0-9_]`, not `[a-z_]`: a digit in the name is not exotic, and
+ // excluding it silently dropped `web3_swap`, `web3_bridge`,
+ // `web3_dapp` and `x402` — ten controllers, including every wallet
+ // swap and bridge entry point.
+ const namespaceToken = block.match(/namespace:\s*(?:NAMESPACE|"([a-z0-9_]+)")/);
const functionName = block.match(/function:\s*"([A-Za-z0-9_]+)"/)?.[1];
const namespace = namespaceToken?.[1] ?? (namespaceToken ? constNamespace : undefined);
if (!namespace || !functionName || functionName === 'unknown') continue;
@@ -234,6 +291,56 @@ function collectSchemaMethods() {
return { methodsByNamespace, filesByNamespace };
}
+const NAMESPACE_CONST = /const\s+NAMESPACE:\s*&str\s*=\s*"([a-z0-9_]+)"/;
+
+/**
+ * The `const NAMESPACE` a file's `namespace: NAMESPACE` literals resolve to.
+ *
+ * Reading only the file itself was the second instance of the bug the comment
+ * on `collectSchemaMethods` describes. When a namespace outgrows one file the
+ * split is always the same: the `const` stays with the aggregate
+ * (`memory/sources/schemas.rs`, `memory/schema/definitions.rs`) and the
+ * `ControllerSchema` literals move into siblings that reach it through
+ * `use super::*`. Per-file lookup then finds no const, resolves the namespace
+ * to `undefined`, and `continue`s past every controller in the file — silently.
+ *
+ * That cost 43 controllers. Seventeen of them were `memory_sources`, which at
+ * least failed loudly because MODULES names it and the gate noticed it had
+ * measured nothing. The other 26 were `memory_tree`, which is not in MODULES:
+ * it kept the five controllers declared in the one file that still had a local
+ * const and reported **5/5, 100%** for a namespace with 31 — fail-open, with a
+ * green tick on it.
+ *
+ * So resolution is scoped to the module directory: the file, then its
+ * siblings, then the file that defines the directory as a module (`mod.rs`, or
+ * `<dir>.rs` beside it). Verified unambiguous — no directory in the tree
+ * declares two different values.
+ */
+function namespaceConstFor(file, text) {
+ const local = text.match(NAMESPACE_CONST)?.[1];
+ if (local) return local;
+
+ const dir = path.dirname(file);
+ const candidates = [];
+ for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
+ if (entry.isFile() && entry.name.endsWith('.rs')) candidates.push(path.join(dir, entry.name));
+ }
+ candidates.push(path.join(dir, 'mod.rs'), `${dir}.rs`);
+
+ const found = new Set();
+ for (const candidate of candidates) {
+ if (!fs.existsSync(candidate)) continue;
+ const value = read(candidate).match(NAMESPACE_CONST)?.[1];
+ if (value) found.add(value);
+ }
+ // Two different answers is not a namespace this function can name. Returning
+ // nothing drops the controllers, which is the same silent loss as before —
+ // but it is also not a case that exists today, and inventing a tie-break for
+ // it would be untested code. If it ever fires, the MODULES/discovery guards
+ // are what surface it.
+ return found.size === 1 ? [...found][0] : undefined;
+}
+
/**
* Parse the inside of a `cfg(...)` predicate into `all` / `any` / `not` / atom.
*
@@ -388,9 +495,21 @@ function moduleGateProves(file, feature) {
// further up and under the directory's name.
const name = isModFile ? segments[segments.length - 2] : base;
const parentDir = isModFile ? segments.slice(0, -2) : segments.slice(0, -1);
- const declaringFile = path.join(ROOT, ...parentDir, 'mod.rs');
+ // `mod.rs` is only the declaring file for a module nested inside another.
+ // At the top of a crate the declaration lives in the crate ROOT, which is
+ // `lib.rs` (or `main.rs`) and never `mod.rs` — `crates/openhuman-core/src/mod.rs`
+ // is not a file Rust can have. Looking only for `mod.rs` meant this walk
+ // fell off the end for every top-level `pub mod`, returned false, and the
+ // exclusion check then reported `test` / `test_support` as "no longer
+ // behind the gate they claim" while `lib.rs:86` carried the `#[cfg]` the
+ // whole time. The gate's own fixture hid it by writing a `src/mod.rs`.
+ const declaringFiles = [path.join(ROOT, ...parentDir, 'mod.rs')];
+ if (parentDir[parentDir.length - 1] === 'src') {
+ declaringFiles.push(path.join(ROOT, ...parentDir, 'lib.rs'), path.join(ROOT, ...parentDir, 'main.rs'));
+ }
- if (fs.existsSync(declaringFile)) {
+ for (const declaringFile of declaringFiles) {
+ if (!fs.existsSync(declaringFile)) continue;
const text = read(declaringFile);
const declaration = new RegExp(`^[ \\t]*(?:pub(?:\\([^)]*\\))?[ \\t]+)?mod[ \\t]+${name}[ \\t]*;`, 'gm');
// EVERY declaration has to imply the feature, not merely the first one.
diff --git a/scripts/test-rust-e2e.sh b/scripts/test-rust-e2e.sh
index 92298a089d..b37c139ea4 100755
--- a/scripts/test-rust-e2e.sh
+++ b/scripts/test-rust-e2e.sh
@@ -30,28 +30,53 @@ REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
# serially so CI does not link several large integration binaries at once.
# Tests guarded by `#[ignore]` stay skipped unless the caller passes
# `-- --ignored`.
-ALL_E2E_SUITES=(
- agent_approval_memory_coverage_e2e
- calendar_grounding_e2e
- config_auth_app_state_connectivity_e2e
- composio_post_oauth_retry_e2e
- cwd_jail_e2e
- domain_modules_e2e
- embeddings_rpc_e2e
- inference_provider_e2e
- json_rpc_e2e
- keyring_secretstore_fresh_e2e
- keyring_secretstore_e2e
- linux_cef_deb_runtime_e2e
- live_routing_e2e
- mcp_registry_e2e
- memory_roundtrip_e2e
- memory_sources_e2e
- observability_wallet_expected_e2e
- skill_registry_e2e
- worker_b_domain_e2e
- worker_c_modules_e2e
-)
+# The suite list is DERIVED from `tests/*_e2e.rs`, not hand-maintained.
+#
+# It used to be a literal list of 20 names while 29 `tests/*_e2e.rs` targets
+# existed, so nine were silently absent from this runner — including
+# `transcript_search_e2e`, which a coverage matrix cited as existing coverage.
+# CI never had the gap: `test-reusable.yml`, `scripts/ci/rust-coverage.sh` and
+# `scripts/test-rust-with-mock.sh` all discover targets with the same `find`
+# used below. Only the documented LOCAL command was short, which made a local
+# green weaker than it read.
+#
+# Polarity matters here. An include list fails UNSAFE: a new target is omitted
+# until someone remembers to add it. The exclude list below fails SAFE: a new
+# target runs by default and must be deliberately opted out, with a cause. Keep
+# it that way, and keep it empty if you can — a target that needs an external
+# service should gate itself with `#[ignore]` or an env check, which costs
+# nothing here because the target still runs and simply reports zero tests.
+E2E_SUITE_EXCLUDE=()
+
+_discover_e2e_suites() {
+ local name
+ while IFS= read -r name; do
+ local skip=0
+ local excluded
+ for excluded in ${E2E_SUITE_EXCLUDE[@]+"${E2E_SUITE_EXCLUDE[@]}"}; do
+ [ "$name" = "$excluded" ] && skip=1 && break
+ done
+ [ $skip -eq 0 ] && printf '%s\n' "$name"
+ done < <(
+ find "$REPO_ROOT/tests" -maxdepth 1 -type f -name '*_e2e.rs' -print |
+ sed -e 's#.*/##' -e 's#\.rs$##' |
+ sort
+ )
+}
+
+ALL_E2E_SUITES=()
+while IFS= read -r _suite; do
+ ALL_E2E_SUITES+=("$_suite")
+done < <(_discover_e2e_suites)
+
+# Refuse to run on an empty discovery rather than reporting a vacuous success.
+# `SUITES` falling back to an empty `ALL_E2E_SUITES` would run nothing and exit
+# 0, which reads exactly like a passing suite.
+if [ "${#ALL_E2E_SUITES[@]}" -eq 0 ]; then
+ echo "[rust-e2e] ERROR: discovered 0 e2e suites under $REPO_ROOT/tests." >&2
+ echo " Expected tests/*_e2e.rs targets; refusing to report success." >&2
+ exit 2
+fi
# Parse args: --suite <name> can be passed multiple times to filter.
# Everything after `--` is forwarded to cargo test as test-binary args.