Skip to content

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

fix(scripts): stop the e2e coverage gate demanding cfg-gated methods\n\n`collectSchemaMethods` is a static text scan, so it finds every\n`ControllerSchema` literal on disk regardless of `#[cfg]`. The `test` and\n`test_support` namespaces sit behind `e2e-test-support`, which is in neither\n`[features] default` nor `scripts/ci/product-features.txt` — the two lists\n`scripts/test-rust-e2e.sh` builds its `--features` string from — so their six\ncontrollers answer `unknown method` in the very build the gate measures, while\nthe report billed them as uncovered obligations. The only ways to satisfy such\na row were a bespoke feature string or naming the method in a string literal\nthat never calls it, which is the gaming the gate's own header warns about.\n\nThe fix is gate-side and has to be: the schemas are already `#[cfg]`-correct\n(`src/openhuman/mod.rs` gates the whole `test_support` module), and a text scan\nwould find those literals even if every line were `#[cfg(never)]`.\n\nAdds `UNREACHABLE_NAMESPACES` — namespace, gating feature, and reason, the\nshape `INTENTIONALLY_NOT_FORWARDED` uses — and reports the exclusions in the\noutput rather than dropping them silently. Denominator 627 -> 621.\n\nExcluding is the dangerous direction, so each entry is checked against reality\nrather than against its own comment. The gate resolves the measured feature set\nfrom `Cargo.toml` and `product-features.txt` through the feature graph, and\nfails if a gating feature becomes reachable, if an entry names a namespace\ndiscovery cannot find, if a namespace is in both MODULES and this list, or if\nthe feature table cannot be parsed at all. Resolving the graph rather than\ntesting direct membership is what keeps `medulla` measured: it is absent from\nproduct-features.txt but present in `[features] default`, so its nine\ncontrollers are genuine obligations, not exclusions.\n\n`parseCoreFeatureGraph` and `resolveEnabledFeatures` are new exports on\n`scripts/lib/feature-forwarding.mjs`, which already owns `[features]` parsing.\nNo existing export changes.\n\nCloses #6069\n

Shanud311c1fd1432
diff --git a/scripts/__tests__/domain-e2e-coverage-gate.test.mjs b/scripts/__tests__/domain-e2e-coverage-gate.test.mjs
index d668b5b751..af6357b9bf 100644
--- a/scripts/__tests__/domain-e2e-coverage-gate.test.mjs
+++ b/scripts/__tests__/domain-e2e-coverage-gate.test.mjs
@@ -46,9 +46,43 @@ function runGate(root, threshold = '90') {
});
}
-function fixture(t) {
+/** A `[features]` table in the shape `parseCoreFeatureGraph` reads. */
+function cargoToml(defaultFeatures, extraFeatures) {
+ const quote = (items) => items.map((item) => `"${item}"`).join(', ');
+ const lines = ['[features]', `default = [${quote(defaultFeatures)}]`];
+ for (const [name, deps] of Object.entries(extraFeatures)) lines.push(`${name} = [${quote(deps)}]`);
+ return `${lines.join('\n')}\n`;
+}
+
+/**
+ * A fixture world.
+ *
+ * Two things every fixture needs that a bare temp dir does not have. The gate
+ * hard-requires `Cargo.toml` and `scripts/ci/product-features.txt`, because
+ * that pair is what `scripts/test-rust-e2e.sh` builds its `--features` string
+ * from and therefore the only honest answer to "which configuration is being
+ * measured". And — unless a test is proving the stale-entry guard — it needs a
+ * declaration for every `UNREACHABLE_NAMESPACES` entry, so a run is not
+ * tripping over an exclusion that names nothing in this world.
+ */
+function fixture(t, options = {}) {
+ const {
+ defaultFeatures = [],
+ productFeatures = [],
+ featureGraph = {},
+ withExcludedNamespaces = true,
+ } = options;
const root = fs.mkdtempSync(join(tmpdir(), 'domain-e2e-gate-'));
t.after(() => fs.rmSync(root, { recursive: true, force: true }));
+ write(root, 'Cargo.toml', cargoToml(defaultFeatures, featureGraph));
+ write(root, 'scripts/ci/product-features.txt', `${productFeatures.join('\n')}\n`);
+ if (withExcludedNamespaces) {
+ write(
+ root,
+ 'src/openhuman/test_support/schemas.rs',
+ controller('test', 'reset') + controller('test_support', 'workspace_root'),
+ );
+ }
return root;
}
@@ -135,3 +169,164 @@ test('measures a discovered namespace that MODULES does not name', (t) => {
`the uncovered controller must be reported as missing; got:\n${result.stdout}`,
);
});
+
+// #6069: the gate demanded coverage of methods that are not compiled into the
+// build it measures. `test` / `test_support` sit behind `e2e-test-support`,
+// which is in neither `[features] default` nor product-features.txt, so the
+// only ways to satisfy those rows were a bespoke feature string or naming the
+// method in a string literal that never calls it — the exact gaming the
+// `collectInvokedMethods` header warns about. The honest answer (0%,
+// unreachable) and the dishonest one (0%, nobody bothered) looked identical.
+test('excludes namespaces compiled out of the measured configuration', (t) => {
+ const root = fixture(t);
+ write(root, 'src/openhuman/widgets/schemas_part_01.rs', controller('widgets', 'list'));
+ write(root, 'tests/widgets_e2e.rs', 'let m = "openhuman.widgets_list";');
+
+ const result = runGate(root);
+
+ assert.doesNotMatch(
+ result.stdout,
+ /^\| test \|/m,
+ `an unreachable namespace must not be billed as an uncovered obligation; got:\n${result.stdout}`,
+ );
+ assert.doesNotMatch(
+ result.stdout,
+ /^\| test_support \|/m,
+ `an unreachable namespace must not be billed as an uncovered obligation; got:\n${result.stdout}`,
+ );
+ // The denominator must shrink with the rows. A row hidden from the table but
+ // still counted would be a worse report than the bug.
+ assert.match(
+ result.stdout,
+ /Discovered 1 controllers across 1 namespaces/,
+ `excluded controllers must leave the denominator; got:\n${result.stdout}`,
+ );
+});
+
+// Excluded is not the same as forgotten. The report has to show the claim —
+// "nothing here can be dispatched" — or nobody ever reviews it.
+test('reports what it excluded, with the gate and the reason', (t) => {
+ const root = fixture(t);
+ write(root, 'src/openhuman/widgets/schemas_part_01.rs', controller('widgets', 'list'));
+ write(root, 'tests/widgets_e2e.rs', 'let m = "openhuman.widgets_list";');
+
+ const result = runGate(root);
+
+ assert.match(
+ result.stdout,
+ /Excluded 2 controller\(s\) in 2 namespace\(s\) as unreachable/,
+ `the exclusion must be stated, not silent; got:\n${result.stdout}`,
+ );
+ assert.match(
+ result.stdout,
+ /test \(1\) — compiled out by `e2e-test-support`:/,
+ `each exclusion must name its gate; got:\n${result.stdout}`,
+ );
+ assert.match(
+ result.stdout,
+ /test_support \(1\) — compiled out by `e2e-test-support`:/,
+ `each exclusion must name its gate; got:\n${result.stdout}`,
+ );
+});
+
+// The guard that makes the list safe to keep. An exclusion is a claim about the
+// measured build, and if that build starts compiling the family in, the claim
+// deletes real obligations from the denominator and reports the smaller world
+// as success — strictly worse than the bug #6069 fixed.
+test('fails when an excluded namespace becomes reachable in the product set', (t) => {
+ const root = fixture(t, { productFeatures: ['e2e-test-support'] });
+ write(root, 'src/openhuman/widgets/schemas_part_01.rs', controller('widgets', 'list'));
+ write(root, 'tests/widgets_e2e.rs', 'let m = "openhuman.widgets_list";');
+
+ const result = runGate(root);
+
+ assert.equal(result.status, 1, `a stale exclusion must fail the gate; got:\n${result.stdout}`);
+ assert.match(
+ result.stderr,
+ /excluded namespace\(s\) are reachable in the measured configuration/,
+ `the failure must say the exclusion no longer holds; got:\n${result.stderr}`,
+ );
+ assert.match(
+ result.stderr,
+ /test \(gated on "e2e-test-support"\)/,
+ `the offending namespace and gate must be named; got:\n${result.stderr}`,
+ );
+});
+
+// Cargo features are transitive, so "is the gate in `default` or the product
+// list" is the wrong question — `documents = ["modules", …]` turns `modules` on
+// for anyone enabling `documents`. A direct-membership check passes this
+// fixture while cargo compiles the family in, which is why the gate resolves
+// the graph instead.
+test('fails when an excluded namespace is reachable only transitively', (t) => {
+ const root = fixture(t, {
+ defaultFeatures: ['bundle'],
+ featureGraph: { bundle: ['e2e-test-support'], 'e2e-test-support': [] },
+ });
+ write(root, 'src/openhuman/widgets/schemas_part_01.rs', controller('widgets', 'list'));
+ write(root, 'tests/widgets_e2e.rs', 'let m = "openhuman.widgets_list";');
+
+ const result = runGate(root);
+
+ assert.equal(result.status, 1, `a transitively-enabled gate must fail the gate; got:\n${result.stdout}`);
+ assert.match(
+ result.stderr,
+ /excluded namespace\(s\) are reachable in the measured configuration/,
+ `following the feature graph is the point of this test; got:\n${result.stderr}`,
+ );
+});
+
+// The other way the list rots: the namespace is renamed or deleted and the
+// entry silently stops referring to anything. Same failure `declaredButMissing`
+// catches for MODULES, applied to the exclusion list.
+test('fails when an excluded namespace no longer exists', (t) => {
+ const root = fixture(t, { withExcludedNamespaces: false });
+ write(root, 'src/openhuman/widgets/schemas_part_01.rs', controller('widgets', 'list'));
+ write(root, 'tests/widgets_e2e.rs', 'let m = "openhuman.widgets_list";');
+
+ const result = runGate(root);
+
+ assert.equal(result.status, 1, `an exclusion naming nothing must fail the gate; got:\n${result.stdout}`);
+ assert.match(
+ result.stderr,
+ /UNREACHABLE_NAMESPACES names 2 namespace\(s\) with no discovered controllers: test, test_support/,
+ `the stale entries must be named; got:\n${result.stderr}`,
+ );
+});
+
+// Without both files the gate cannot say which configuration it is measuring,
+// and an exclusion nothing verifies is the silent hole the list exists to
+// close. Refusing is the only honest answer — exit 2, the same usage-error
+// status as a bad threshold.
+test('refuses to run without the files the measured feature set comes from', (t) => {
+ const root = fixture(t);
+ write(root, 'src/openhuman/widgets/schemas_part_01.rs', controller('widgets', 'list'));
+ fs.rmSync(join(root, 'scripts', 'ci', 'product-features.txt'));
+
+ const result = runGate(root);
+
+ assert.equal(result.status, 2, `a world with no product feature list must be refused; got:\n${result.stdout}`);
+ assert.match(
+ result.stderr,
+ /product-features\.txt not found/,
+ `the failure must name the missing file; got:\n${result.stderr}`,
+ );
+});
+
+// Guarding the guard. A `[features]` table the parser cannot see does not fail
+// on its own — it reports every gate as OFF, which is exactly the answer that
+// makes every exclusion look earned. Silence there would undo the check.
+test('refuses to run when the feature table cannot be parsed', (t) => {
+ const root = fixture(t);
+ write(root, 'src/openhuman/widgets/schemas_part_01.rs', controller('widgets', 'list'));
+ write(root, 'Cargo.toml', '[package]\nname = "openhuman"\n');
+
+ const result = runGate(root);
+
+ assert.equal(result.status, 2, `an unparseable feature table must be refused; got:\n${result.stdout}`);
+ assert.match(
+ result.stderr,
+ /no `\[features\] default` in Cargo\.toml/,
+ `the failure must name what could not be resolved; got:\n${result.stderr}`,
+ );
+});
diff --git a/scripts/__tests__/feature-forwarding.test.mjs b/scripts/__tests__/feature-forwarding.test.mjs
index ef67de6bde..57cea484db 100644
--- a/scripts/__tests__/feature-forwarding.test.mjs
+++ b/scripts/__tests__/feature-forwarding.test.mjs
@@ -11,9 +11,11 @@ import {
diffForwarding,
INTENTIONALLY_NOT_FORWARDED,
parseCoreDefaultFeatures,
+ parseCoreFeatureGraph,
parseCoreFeatureNames,
parseProductFeatures,
parseShellForwardedFeatures,
+ resolveEnabledFeatures,
stripComments,
} from '../lib/feature-forwarding.mjs';
@@ -344,3 +346,106 @@ test('the real shell manifest forwards every real core default', () => {
);
}
});
+
+// ── feature graph ──────────────────────────────────────────────────────────
+
+test('parses the whole feature table, default included', () => {
+ const toml = `
+[features]
+default = ["media", "modules"]
+documents = ["modules", "dep:tinydocs-bus"]
+modules = ["tinybus/modules"]
+
+[dependencies]
+serde = "1"
+documents = ["not-a-feature"]
+`;
+ const graph = parseCoreFeatureGraph(toml);
+
+ assert.deepEqual(graph.get('default'), ['media', 'modules']);
+ assert.deepEqual(graph.get('documents'), ['modules', 'dep:tinydocs-bus']);
+ // Bounded at the next table header, so a `[dependencies]` key of the same
+ // name cannot overwrite a real gate's dependency list.
+ assert.equal(graph.size, 3);
+});
+
+test('resolves a gate enabled only through another gate', () => {
+ const graph = parseCoreFeatureGraph(`
+[features]
+default = ["documents"]
+documents = ["modules"]
+modules = []
+`);
+
+ const enabled = resolveEnabledFeatures(graph, ['default']);
+
+ // `modules` is nowhere in `default`; a direct membership test would read it
+ // as OFF while cargo compiles it in.
+ assert.ok(enabled.has('modules'), 'expected a transitively enabled gate to resolve as ON');
+ assert.ok(enabled.has('documents'));
+ assert.ok(!enabled.has('voice'), 'expected an unrelated gate to stay OFF');
+});
+
+test('does not mistake dependency activations for local gates', () => {
+ const graph = parseCoreFeatureGraph(`
+[features]
+default = ["modules"]
+modules = ["tinybus/modules", "dep:ureq"]
+`);
+
+ const enabled = resolveEnabledFeatures(graph, ['default']);
+
+ // `tinybus/modules` forwards a feature into a dependency and `dep:ureq` turns
+ // an optional dependency on. Neither names a gate in THIS crate, so neither
+ // can be what a local `#[cfg(feature = "…")]` reads.
+ assert.ok(!enabled.has('tinybus/modules'));
+ assert.ok(!enabled.has('dep:ureq'));
+ assert.ok(enabled.has('modules'));
+});
+
+test('seeds beyond default are followed too', () => {
+ const graph = parseCoreFeatureGraph(`
+[features]
+default = []
+documents = ["modules"]
+modules = []
+`);
+
+ // The product set is a second seed alongside `default`: the e2e runner passes
+ // `--features` WITHOUT `--no-default-features`, so the measured build is the
+ // union of the two.
+ const enabled = resolveEnabledFeatures(graph, ['default', 'documents']);
+
+ assert.ok(enabled.has('documents'));
+ assert.ok(enabled.has('modules'));
+});
+
+test('a seed the feature table does not declare resolves to itself', () => {
+ const enabled = resolveEnabledFeatures(parseCoreFeatureGraph('[features]\ndefault = []\n'), [
+ 'default',
+ 'ghost',
+ ]);
+
+ // A typo in product-features.txt is caught by `checkProductForwarding`, not
+ // here; this must not throw on the way there.
+ assert.ok(enabled.has('ghost'));
+});
+
+test('a manifest with no [features] table yields an empty graph', () => {
+ assert.equal(parseCoreFeatureGraph('[package]\nname = "openhuman"\n').size, 0);
+});
+
+test('a cycle in the feature graph terminates instead of hanging', () => {
+ // Cargo would reject this, but the gate reads the file as text and must not
+ // spin on a hand-edit that has not been through cargo yet.
+ const graph = parseCoreFeatureGraph(`
+[features]
+default = ["a"]
+a = ["b"]
+b = ["a"]
+`);
+
+ const enabled = resolveEnabledFeatures(graph, ['default']);
+
+ assert.deepEqual([...enabled].sort(), ['a', 'b', 'default']);
+});
diff --git a/scripts/check-domain-e2e-coverage.mjs b/scripts/check-domain-e2e-coverage.mjs
index 679a7e7e06..f3f9d956ac 100644
--- a/scripts/check-domain-e2e-coverage.mjs
+++ b/scripts/check-domain-e2e-coverage.mjs
@@ -2,6 +2,12 @@
import fs from 'node:fs';
import path from 'node:path';
+import {
+ parseCoreFeatureGraph,
+ parseProductFeatures,
+ resolveEnabledFeatures,
+} from './lib/feature-forwarding.mjs';
+
const ROOT = process.cwd();
function usage() {
@@ -64,6 +70,57 @@ const MODULES = [
{ label: 'threads', namespaces: ['threads'] },
];
+// Namespaces whose controllers are COMPILED OUT of the configuration this gate
+// measures, with the gate that removes them and the reason beside each — the
+// shape `INTENTIONALLY_NOT_FORWARDED` uses in scripts/lib/feature-forwarding.mjs.
+//
+// A method that cannot be dispatched cannot be reached by a `tests/**/*_e2e.rs`
+// target, so listing it as an uncovered obligation asks for something
+// impossible. The only two ways to satisfy such a row are a bespoke feature
+// string (which invalidates the shared target dir for every parallel worker) or
+// naming the method in a string literal that never calls it — the exact gaming
+// `collectInvokedMethods` warns about above. Worse, the honest answer (0%,
+// unreachable) and the dishonest one (0%, nobody bothered) look identical in
+// the report.
+//
+// This has to live HERE and not in Rust. The schemas are already `#[cfg]`-
+// correct — `src/openhuman/mod.rs` gates the whole `test_support` module — but
+// discovery reads source text off disk and would find these literals even if
+// every line were `#[cfg(never)]`. There is no Rust-side edit that changes what
+// a text scan sees.
+//
+// Excluding is the dangerous direction: a wrong entry hides real work. So each
+// one is checked against the feature set the measured build actually enables
+// (`checkExclusions` below), not merely against this comment. #6069.
+const UNREACHABLE_NAMESPACES = {
+ test: {
+ feature: 'e2e-test-support',
+ reason:
+ '`openhuman.test_reset` wipes sidecar state in place, and src/core/all.rs registers it behind ' +
+ '`#[cfg(feature = "e2e-test-support")]` precisely so a shipped binary never carries the destructive RPC. ' +
+ 'Only app/scripts/e2e-build.sh turns that gate on; under the feature string scripts/test-rust-e2e.sh ' +
+ 'builds every e2e target with, dispatching it answers `unknown method`.',
+ },
+ test_support: {
+ feature: 'e2e-test-support',
+ reason:
+ 'Same gate as `test`: src/openhuman/mod.rs declares the whole `test_support` module behind ' +
+ '`#[cfg(feature = "e2e-test-support")]`, so these workspace- and chat-introspection helpers exist only in ' +
+ 'the E2E build produced by app/scripts/e2e-build.sh.',
+ },
+};
+
+// The two files scripts/test-rust-e2e.sh derives its `--features` string from.
+//
+// It runs every suite with `--features "$(scripts/ci/product-features.sh)"` and
+// does NOT pass `--no-default-features`, so the measured configuration is
+// `default` UNION the product set — not the product set alone. The distinction
+// decides real cases: `medulla` is absent from product-features.txt but present
+// in `[features] default`, so its nine controllers ARE dispatchable in an e2e
+// build and are genuine obligations, not exclusions.
+const CORE_MANIFEST = path.join(ROOT, 'Cargo.toml');
+const PRODUCT_FEATURES_FILE = path.join(ROOT, 'scripts', 'ci', 'product-features.txt');
+
// Where `ControllerSchema` literals live.
//
// `src/openhuman` is the bulk. The second root is not optional: the `channels`
@@ -172,6 +229,103 @@ function collectSchemaMethods() {
return methodsByNamespace;
}
+/**
+ * The gates cargo has ON in the build `scripts/test-rust-e2e.sh` produces.
+ *
+ * Resolved from the same two files that script reads, and through the feature
+ * graph rather than by direct membership: a gate can be enabled transitively
+ * (`documents = ["modules", …]`), and reading such a gate as OFF would let an
+ * exclusion look earned when cargo compiles the family in.
+ *
+ * Both files are REQUIRED. Without them this gate cannot say which controllers
+ * are reachable, and an exclusion nothing verifies is precisely the silent hole
+ * `UNREACHABLE_NAMESPACES` exists to close.
+ */
+function measuredFeatures() {
+ for (const file of [CORE_MANIFEST, PRODUCT_FEATURES_FILE]) {
+ if (fs.existsSync(file)) continue;
+ console.error(
+ `check-domain-e2e-coverage: ${path.relative(ROOT, file) || file} not found under ${ROOT}.\n` +
+ 'The gate resolves which controllers are reachable in the configuration it measures from\n' +
+ 'Cargo.toml and scripts/ci/product-features.txt, so it must run from the repository root.',
+ );
+ process.exit(2);
+ }
+ const graph = parseCoreFeatureGraph(read(CORE_MANIFEST));
+ // Guard the guard. An empty graph is what a moved `[features]` table or a
+ // parser regression looks like, and it does not fail — it quietly reports
+ // every gate as OFF, which is the answer that makes every exclusion look
+ // earned. Refuse instead: this check is only worth having if it can be wrong.
+ if (!graph.has('default')) {
+ console.error(
+ `check-domain-e2e-coverage: no \`[features] default\` in ${path.relative(ROOT, CORE_MANIFEST)}.\n` +
+ 'Without it the measured feature set cannot be resolved, and every exclusion in\n' +
+ 'UNREACHABLE_NAMESPACES would be accepted unchecked.',
+ );
+ process.exit(2);
+ }
+ const product = parseProductFeatures(read(PRODUCT_FEATURES_FILE));
+ return resolveEnabledFeatures(graph, ['default', ...product]);
+}
+
+/**
+ * The three ways an `UNREACHABLE_NAMESPACES` entry can stop being true.
+ *
+ * Returns one message per problem; empty means every exclusion is still earned.
+ * This exists because the MODULES comment above is right — a list you must
+ * remember to maintain is a list that silently stops covering things — and an
+ * exclusion that rots is worse than a stale MODULES line: it does not merely
+ * fail to measure something, it deletes a real obligation from the denominator
+ * and reports the smaller world as success.
+ */
+function checkExclusions(discovered, labelForNamespace) {
+ const enabled = measuredFeatures();
+ const problems = [];
+
+ // (1) The gate came back. If the feature is enabled in the measured build,
+ // the controllers dispatch and excluding them hides work that is now real.
+ const reachable = Object.entries(UNREACHABLE_NAMESPACES)
+ .filter(([, entry]) => enabled.has(entry.feature))
+ .map(([namespace, entry]) => `${namespace} (gated on "${entry.feature}")`)
+ .sort();
+ if (reachable.length > 0) {
+ problems.push(
+ `${reachable.length} excluded namespace(s) are reachable in the measured configuration: ${reachable.join(', ')}.` +
+ '\nTheir gate is enabled by `[features] default` or scripts/ci/product-features.txt, so their controllers' +
+ '\ndo dispatch and must be covered. Drop the UNREACHABLE_NAMESPACES entry.',
+ );
+ }
+
+ // (2) The namespace is gone, or discovery stopped seeing it. Same failure
+ // `declaredButMissing` catches for MODULES, applied to the other list.
+ const missing = Object.keys(UNREACHABLE_NAMESPACES)
+ .filter((namespace) => !discovered.has(namespace))
+ .sort();
+ if (missing.length > 0) {
+ problems.push(
+ `UNREACHABLE_NAMESPACES names ${missing.length} namespace(s) with no discovered controllers: ${missing.join(', ')}.` +
+ '\nEither the namespace was removed (drop the entry) or schema discovery has stopped seeing it' +
+ '\n(fix SCHEMA_ROOTS / the match).',
+ );
+ }
+
+ // (3) Naming one namespace in both lists is a contradiction: MODULES asks for
+ // a coverage row, UNREACHABLE_NAMESPACES says there is nothing to cover.
+ // Unchecked, the exclusion wins and the namespace vanishes from the report
+ // without a word — which is how a MODULES entry stops meaning anything.
+ const contradictory = Object.keys(UNREACHABLE_NAMESPACES)
+ .filter((namespace) => labelForNamespace.has(namespace))
+ .sort();
+ if (contradictory.length > 0) {
+ problems.push(
+ `${contradictory.length} namespace(s) appear in BOTH MODULES and UNREACHABLE_NAMESPACES: ${contradictory.join(', ')}.` +
+ '\nMODULES asks for a coverage row; UNREACHABLE_NAMESPACES says there is nothing to cover. Resolve one.',
+ );
+ }
+
+ return problems;
+}
+
const invoked = collectInvokedMethods();
const schemas = collectSchemaMethods();
@@ -187,9 +341,20 @@ const declaredButMissing = [...labelForNamespace.keys()]
.filter((namespace) => !schemas.has(namespace))
.sort();
+const exclusionProblems = checkExclusions(schemas, labelForNamespace);
+
+// Reported below rather than dropped in silence: an excluded namespace is a
+// claim ("nothing here can be dispatched"), and a claim the report does not
+// show is a claim nobody reviews.
+const excluded = [...schemas]
+ .filter(([namespace]) => Object.hasOwn(UNREACHABLE_NAMESPACES, namespace))
+ .map(([namespace, methods]) => ({ namespace, count: methods.size, ...UNREACHABLE_NAMESPACES[namespace] }))
+ .sort((a, b) => a.namespace.localeCompare(b.namespace));
+
// One row per namespace that actually exists, grouped where MODULES says so.
const rows = new Map();
for (const [namespace, methods] of schemas) {
+ if (Object.hasOwn(UNREACHABLE_NAMESPACES, namespace)) continue;
const label = labelForNamespace.get(namespace) ?? namespace;
if (!rows.has(label)) rows.set(label, { label, namespaces: [], expected: new Set() });
const row = rows.get(label);
@@ -235,6 +400,23 @@ console.log(
`Discovered ${totalExpected} controllers across ${rows.size} namespaces; ${totalCovered} invoked by a tests/**/*_e2e.rs target.`,
);
+if (excluded.length > 0) {
+ const totalExcluded = excluded.reduce((sum, entry) => sum + entry.count, 0);
+ console.log('');
+ console.log(
+ `Excluded ${totalExcluded} controller(s) in ${excluded.length} namespace(s) as unreachable in the measured` +
+ ' configuration (`[features] default` + scripts/ci/product-features.txt):',
+ );
+ for (const entry of excluded) {
+ console.log(` ${entry.namespace} (${entry.count}) — compiled out by \`${entry.feature}\`: ${entry.reason}`);
+ }
+}
+
+if (exclusionProblems.length > 0) {
+ failed = true;
+ for (const problem of exclusionProblems) console.error(`\n${problem}`);
+}
+
if (declaredButMissing.length > 0) {
failed = true;
console.error(
diff --git a/scripts/lib/feature-forwarding.mjs b/scripts/lib/feature-forwarding.mjs
index 4d942fb153..3650ffe5f2 100644
--- a/scripts/lib/feature-forwarding.mjs
+++ b/scripts/lib/feature-forwarding.mjs
@@ -177,6 +177,55 @@ export function parseCoreFeatureNames(coreToml) {
return names.filter(name => name !== 'default');
}
+/**
+ * The core's whole `[features]` table as `name -> [items]`, `default` included.
+ *
+ * `parseCoreDefaultFeatures` answers "what is directly in `default`", which is
+ * not the same question as "what is ON". Cargo features are transitive:
+ * `documents = ["modules", …]` turns `modules` on for anyone who enables
+ * `documents`. A caller deciding whether some gate is compiled has to follow
+ * those edges or it will read a gate as OFF while cargo has it ON — see
+ * `resolveEnabledFeatures`.
+ */
+export function parseCoreFeatureGraph(coreToml) {
+ const text = stripComments(coreToml);
+ const header = text.match(/^[ \t]*\[features\][ \t]*$/m);
+ if (!header) return new Map();
+ const rest = text.slice(header.index + header[0].length);
+ const nextTable = rest.search(/^[ \t]*\[[^[\]]+\][ \t]*$/m);
+ const section = nextTable === -1 ? rest : rest.slice(0, nextTable);
+ const graph = new Map();
+ for (const match of section.matchAll(/^[ \t]*([A-Za-z0-9_-]+)[ \t]*=[ \t]*\[/gm)) {
+ // `match[0]` ends on the `[` that opens the array, so its last index is
+ // exactly where `readArray` must start scanning for the balanced close.
+ const open = match.index + match[0].length - 1;
+ graph.set(match[1], arrayItems(readArray(section, open)));
+ }
+ return graph;
+}
+
+/**
+ * Every gate cargo has ON once `seeds` are enabled, following the graph.
+ *
+ * Two item shapes are deliberately NOT followed. `dep:foo` turns an optional
+ * dependency on and `foo/bar` forwards a feature into a dependency; neither
+ * names a gate in THIS crate, and a `#[cfg(feature = "…")]` here can only ever
+ * read a local one. Following them would put `tinybus/modules` in the result
+ * and let a caller believe a gate by that name exists.
+ */
+export function resolveEnabledFeatures(graph, seeds) {
+ const enabled = new Set();
+ const queue = [...seeds];
+ while (queue.length > 0) {
+ const name = queue.pop();
+ if (name.startsWith('dep:') || name.includes('/')) continue;
+ if (enabled.has(name)) continue;
+ enabled.add(name);
+ for (const item of graph.get(name) ?? []) queue.push(item);
+ }
+ return enabled;
+}
+
/**
* Parse `scripts/ci/product-features.txt`: one gate per line, `#` comments and
* blank lines ignored. Mirrors `scripts/ci/product-features.sh` exactly — the