Skip to content

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

fix(scripts): close two ways an exclusion could read as safely disabled

Shanuf95100cd497e
diff --git a/scripts/__tests__/domain-e2e-coverage-gate.test.mjs b/scripts/__tests__/domain-e2e-coverage-gate.test.mjs
index af6357b9bf..ca49f456bb 100644
--- a/scripts/__tests__/domain-e2e-coverage-gate.test.mjs
+++ b/scripts/__tests__/domain-e2e-coverage-gate.test.mjs
@@ -71,10 +71,15 @@ function fixture(t, options = {}) {
productFeatures = [],
featureGraph = {},
withExcludedNamespaces = true,
+ declareExcludedFeatures = 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));
+ // The manifest must DECLARE each exclusion's gate even when nothing enables
+ // it — an undeclared gate is a rename the table missed, not a disabled one,
+ // and the gate refuses it.
+ const features = declareExcludedFeatures ? { 'e2e-test-support': [], ...featureGraph } : featureGraph;
+ write(root, 'Cargo.toml', cargoToml(defaultFeatures, features));
write(root, 'scripts/ci/product-features.txt', `${productFeatures.join('\n')}\n`);
if (withExcludedNamespaces) {
write(
@@ -330,3 +335,50 @@ test('refuses to run when the feature table cannot be parsed', (t) => {
`the failure must name what could not be resolved; got:\n${result.stderr}`,
);
});
+
+// Codex, PR #6092. The subtlest way this list rots: a gate is renamed, every
+// `#[cfg]` site is updated, and only this table is missed. The old name is then
+// absent from the feature graph — so it is absent from the enabled set too, and
+// the reachability check reads that as "safely disabled". The namespace still
+// exists and is not in MODULES, so nothing else fires, and a reachable family
+// leaves the denominator without a word. "Not enabled" and "not a gate at all"
+// must be different answers.
+test('fails when an excluded namespace names a gate the manifest does not declare', (t) => {
+ const root = fixture(t, { declareExcludedFeatures: 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 undeclared gate must fail the gate; got:\n${result.stdout}`);
+ assert.match(
+ result.stderr,
+ /name a feature the `\[features\]` table does not declare/,
+ `the failure must distinguish a renamed gate from a disabled one; got:\n${result.stderr}`,
+ );
+ assert.match(
+ result.stderr,
+ /test \(gated on "e2e-test-support"\)/,
+ `the offending entry must be named; got:\n${result.stderr}`,
+ );
+});
+
+// CodeRabbit, PR #6092. TOML has two single-line string forms and cargo accepts
+// both. Reading only `"…"` made `default = ['e2e-test-support']` parse as an
+// empty array, so the gate saw the feature as OFF and accepted the exclusion
+// for controllers the measured build actually compiles in.
+test('reads a single-quoted TOML feature array', (t) => {
+ const root = fixture(t);
+ write(root, 'Cargo.toml', "[features]\ndefault = ['e2e-test-support']\ne2e-test-support = []\n");
+ 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 literal-string default list must still be read; got:\n${result.stdout}`);
+ assert.match(
+ result.stderr,
+ /excluded namespace\(s\) are reachable in the measured configuration/,
+ `a gate enabled through a literal string must count as enabled; got:\n${result.stderr}`,
+ );
+});
diff --git a/scripts/__tests__/feature-forwarding.test.mjs b/scripts/__tests__/feature-forwarding.test.mjs
index 57cea484db..355801c6e1 100644
--- a/scripts/__tests__/feature-forwarding.test.mjs
+++ b/scripts/__tests__/feature-forwarding.test.mjs
@@ -449,3 +449,30 @@ b = ["a"]
assert.deepEqual([...enabled].sort(), ['a', 'b', 'default']);
});
+
+test('reads TOML literal strings, not just basic strings', () => {
+ // Both forms are valid TOML and cargo accepts either. Matching only `"…"`
+ // reported these arrays as EMPTY, and empty is the answer that makes every
+ // consumer here pass vacuously. (CodeRabbit, PR #6092.)
+ assert.deepEqual(parseCoreDefaultFeatures("[features]\ndefault = ['voice', \"media\"]\n"), [
+ 'voice',
+ 'media',
+ ]);
+ assert.deepEqual(parseCoreFeatureGraph("[features]\ndefault = ['documents']\ndocuments = ['modules']\n").get('documents'), ['modules']);
+ assert.deepEqual(
+ parseShellForwardedFeatures(
+ "openhuman_core = { path = \"../..\", default-features = false, features = ['voice'] }\n",
+ ).features,
+ ['voice'],
+ );
+});
+
+test('an apostrophe inside a basic string does not open a literal string', () => {
+ // Alternation order is load-bearing: `"…"` is tried first at each position,
+ // so the `'` in `don't` is consumed as part of the basic string rather than
+ // starting a literal one and swallowing the rest of the array.
+ assert.deepEqual(parseCoreDefaultFeatures('[features]\ndefault = ["don\'t", "media"]\n'), [
+ "don't",
+ 'media',
+ ]);
+});
diff --git a/scripts/check-domain-e2e-coverage.mjs b/scripts/check-domain-e2e-coverage.mjs
index f3f9d956ac..d4d7e98c5d 100644
--- a/scripts/check-domain-e2e-coverage.mjs
+++ b/scripts/check-domain-e2e-coverage.mjs
@@ -265,7 +265,7 @@ function measuredFeatures() {
process.exit(2);
}
const product = parseProductFeatures(read(PRODUCT_FEATURES_FILE));
- return resolveEnabledFeatures(graph, ['default', ...product]);
+ return { graph, enabled: resolveEnabledFeatures(graph, ['default', ...product]) };
}
/**
@@ -279,9 +279,28 @@ function measuredFeatures() {
* and reports the smaller world as success.
*/
function checkExclusions(discovered, labelForNamespace) {
- const enabled = measuredFeatures();
+ const { graph, enabled } = measuredFeatures();
const problems = [];
+ // (0) The gate no longer exists. A rename that updated the `#[cfg]` sites but
+ // missed this table leaves a feature name no `[features]` entry declares —
+ // absent from the graph, so absent from `enabled`, which check (1) below
+ // reads as "safely disabled". The namespace still exists and is not in
+ // MODULES, so neither of the other checks fires either, and the renamed
+ // family's controllers leave the denominator in silence. "Not enabled" and
+ // "not a gate at all" have to be different answers.
+ const undeclared = Object.entries(UNREACHABLE_NAMESPACES)
+ .filter(([, entry]) => !graph.has(entry.feature))
+ .map(([namespace, entry]) => `${namespace} (gated on "${entry.feature}")`)
+ .sort();
+ if (undeclared.length > 0) {
+ problems.push(
+ `${undeclared.length} excluded namespace(s) name a feature the \`[features]\` table does not declare: ${undeclared.join(', ')}.` +
+ '\nA renamed or deleted gate reads as disabled here, which would accept the exclusion unchecked.' +
+ '\nPoint the UNREACHABLE_NAMESPACES entry at the current gate name, or drop it.',
+ );
+ }
+
// (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)
diff --git a/scripts/lib/feature-forwarding.mjs b/scripts/lib/feature-forwarding.mjs
index 3650ffe5f2..aa5c146446 100644
--- a/scripts/lib/feature-forwarding.mjs
+++ b/scripts/lib/feature-forwarding.mjs
@@ -96,10 +96,21 @@ function readArray(text, open) {
return null;
}
-/** Pull the quoted string items out of a raw TOML array body. */
+/**
+ * Pull the quoted string items out of a raw TOML array body.
+ *
+ * TOML has two single-line string forms and both are valid in a manifest:
+ * basic `"voice"` and literal `'voice'`. Matching only the first reported
+ * `default = ['voice']` as an EMPTY array — and empty is the answer that makes
+ * every caller here pass vacuously, which is the failure mode this module
+ * exists to prevent (`checkProductForwarding` has nothing to compare, and the
+ * e2e coverage gate reads every feature as OFF and accepts its exclusions
+ * unchecked). Basic strings are tried first at each position, so an apostrophe
+ * inside `"don't"` cannot be mistaken for the start of a literal string.
+ */
function arrayItems(raw) {
if (raw === null) return [];
- return [...raw.matchAll(/"([^"]+)"/g)].map(m => m[1]);
+ return [...raw.matchAll(/"([^"]+)"|'([^']+)'/g)].map(m => m[1] ?? m[2]);
}
/**