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
fix(scripts): check an exclusion against the #[cfg] it claims, not just the feature\n\nCodex, second round. Every check so far could pass while the Rust gate that\nmade a namespace unreachable was deleted: the feature is still declared, still\ndisabled, the namespace is still discovered and still absent from MODULES — but\nits module compiles unconditionally now and its controllers dispatch. The\nexclusion is a claim about the source, so it is checked against the source.\n\n`moduleGatesFor` walks the chain of `mod` declarations that must compile for a\ndeclaring file to exist and collects their `#[cfg(feature = …)]` gates. Every\nfile declaring an excluded namespace must sit behind one naming the claimed\ngate. The walk climbs because `#[cfg]` lives on the declaration in the PARENT,\nnever in the file itself: `test_support/schemas.rs` is reached through\n`mod schemas;` and then `pub mod test_support;`, and only the second is gated.\n\n`collectSchemaMethods` now also returns which file declared each namespace,\nwhich is what makes that check possible.\n\nTwo cases the walk has to get right, both tested: a gate on a grandparent\ndeclaration with an ungated `mod` in between (the arrangement\n`src/openhuman/test_support/` actually has), and a namespace declared in\n`mod.rs` itself — that file IS its directory's module, so its declaration sits\none level further up under the directory's name, and resolving it like an\nordinary file would look for `mod mod;`, find nothing, and report a gated\nmodule as ungated.\n
Shanud5ddb645dc01
diff --git a/scripts/__tests__/domain-e2e-coverage-gate.test.mjs b/scripts/__tests__/domain-e2e-coverage-gate.test.mjsindex ca49f456bb..bbde9f87b3 100644--- a/scripts/__tests__/domain-e2e-coverage-gate.test.mjs+++ b/scripts/__tests__/domain-e2e-coverage-gate.test.mjs@@ -72,6 +72,7 @@ function fixture(t, options = {}) {featureGraph = {},withExcludedNamespaces = true,declareExcludedFeatures = true,+ gateExcludedModule = true,} = options;const root = fs.mkdtempSync(join(tmpdir(), 'domain-e2e-gate-'));t.after(() => fs.rmSync(root, { recursive: true, force: true }));@@ -87,6 +88,16 @@ function fixture(t, options = {}) {'src/openhuman/test_support/schemas.rs',controller('test', 'reset') + controller('test_support', 'workspace_root'),);+ // The `#[cfg]` the exclusion claims. It lives on the `mod` declaration in+ // the PARENT, which is where the gate looks for it — a fixture without this+ // is a module that compiles unconditionally.+ write(+ root,+ 'src/openhuman/mod.rs',+ gateExcludedModule+ ? '#[cfg(feature = "e2e-test-support")]\npub mod test_support;\n'+ : 'pub mod test_support;\n',+ );}return root;}@@ -382,3 +393,82 @@ test('reads a single-quoted TOML feature array', (t) => {`a gate enabled through a literal string must count as enabled; got:\n${result.stderr}`,);});++// Codex, PR #6092 (second round). The last hole: delete the `#[cfg]` in Rust+// and every other check here still passes — the feature is declared, it is+// disabled, the namespace is discovered, it is not in MODULES — while the+// module now compiles unconditionally and its controllers dispatch. An+// exclusion is a claim about the source, so it is checked against the source.+test('fails when the module is no longer behind the #[cfg] the exclusion claims', (t) => {+ const root = fixture(t, { gateExcludedModule: 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 ungated module must fail the gate; got:\n${result.stdout}`);+ assert.match(+ result.stderr,+ /no longer behind the gate they claim/,+ `the failure must say the #[cfg] is gone; got:\n${result.stderr}`,+ );+ assert.match(+ result.stderr,+ /src\/openhuman\/test_support\/schemas\.rs/,+ `the file that lost its gate must be named; got:\n${result.stderr}`,+ );+});++// The positive half, and the reason the walk climbs rather than reading the+// file itself: `#[cfg]` sits on the `mod` declaration in the PARENT. Here the+// gate is two levels up from the declaring file, with an ungated `mod schemas;`+// in between — the arrangement `src/openhuman/test_support/` actually has.+test('finds the gate on an ancestor mod declaration, not just the immediate parent', (t) => {+ const root = fixture(t);+ write(root, 'src/openhuman/test_support/mod.rs', 'mod schemas;\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.doesNotMatch(+ result.stderr,+ /no longer behind the gate they claim/,+ `a gate on a grandparent mod must count; got:\n${result.stderr}`,+ );+ assert.match(+ result.stdout,+ /Excluded 2 controller\(s\)/,+ `the exclusion must still apply; got:\n${result.stdout}`,+ );+});++// A namespace can declare its controllers in `mod.rs` itself rather than in a+// `schemas.rs` sibling. That file IS its directory's module, so its own `mod`+// declaration sits one level further up and under the DIRECTORY's name —+// resolving it like an ordinary file would look for `mod mod;` and find+// nothing, silently reporting the module as ungated.+test('resolves the gate for a namespace declared in mod.rs itself', (t) => {+ const root = fixture(t, { withExcludedNamespaces: false });+ write(+ root,+ 'src/openhuman/test_support/mod.rs',+ controller('test', 'reset') + controller('test_support', 'workspace_root'),+ );+ write(root, 'src/openhuman/mod.rs', '#[cfg(feature = "e2e-test-support")]\npub mod 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.doesNotMatch(+ result.stderr,+ /no longer behind the gate they claim/,+ `a mod.rs-declared namespace must resolve its own gate; got:\n${result.stderr}`,+ );+ assert.match(+ result.stdout,+ /Excluded 2 controller\(s\)/,+ `the exclusion must still apply; got:\n${result.stdout}`,+ );+});diff --git a/scripts/check-domain-e2e-coverage.mjs b/scripts/check-domain-e2e-coverage.mjsindex d4d7e98c5d..9a5bda3141 100644--- a/scripts/check-domain-e2e-coverage.mjs+++ b/scripts/check-domain-e2e-coverage.mjs@@ -208,6 +208,9 @@ function collectInvokedMethods() {*/function collectSchemaMethods() {const methodsByNamespace = new Map();+ // Which file declared each namespace, so an exclusion can be checked against+ // the `#[cfg]` chain that actually reaches it — see `moduleGatesFor`.+ const filesByNamespace = new Map();for (const root of SCHEMA_ROOTS) {for (const file of walk(root, (f) => f.endsWith('.rs'))) {@@ -222,11 +225,57 @@ function collectSchemaMethods() {if (!namespace || !functionName || functionName === 'unknown') continue;if (!methodsByNamespace.has(namespace)) methodsByNamespace.set(namespace, new Set());methodsByNamespace.get(namespace).add(`openhuman.${namespace}_${functionName}`);+ if (!filesByNamespace.has(namespace)) filesByNamespace.set(namespace, new Set());+ filesByNamespace.get(namespace).add(file);}}}- return methodsByNamespace;+ return { methodsByNamespace, filesByNamespace };+}++/**+ * The Cargo gates on the chain of `mod` declarations that must compile for+ * `file` to exist in the build.+ *+ * `#[cfg]` sits on the `mod` declaration in the PARENT, never in the file+ * itself, so this walks upward: `src/openhuman/test_support/schemas.rs` is+ * reached through `mod schemas;` in `test_support/mod.rs` and then through+ * `pub mod test_support;` in `openhuman/mod.rs` — and only the second carries+ * the gate. A file pulled in by `include!` has no `mod` of its own and simply+ * contributes nothing at its own level, which is why a missing declaration is+ * not itself an error here.+ */+function moduleGatesFor(file) {+ const gates = new Set();+ let segments = path.relative(ROOT, file).split(path.sep);++ while (segments.length > 1) {+ const base = segments[segments.length - 1].replace(/\.rs$/, '');+ const isModFile = base === 'mod';+ // A `mod.rs` IS its directory's module, so its declaration lives one level+ // 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');++ if (fs.existsSync(declaringFile)) {+ const lines = read(declaringFile).split('\n');+ for (let i = 0; i < lines.length; i++) {+ if (!new RegExp(`^\\s*(?:pub(?:\\([^)]*\\))?\\s+)?mod\\s+${name}\\s*;`).test(lines[i])) continue;+ // Attributes stack above the declaration; read back through all of them.+ for (let j = i - 1; j >= 0 && /^\s*#\[/.test(lines[j]); j--) {+ const gate = lines[j].match(/#\[cfg\(.*?feature\s*=\s*"([a-z0-9-]+)"/)?.[1];+ if (gate) gates.add(gate);+ }+ }+ }++ segments = parentDir;+ if (segments[segments.length - 1] === 'src') break;+ }++ return gates;}/**@@ -278,7 +327,7 @@ function measuredFeatures() {* fail to measure something, it deletes a real obligation from the denominator* and reports the smaller world as success.*/-function checkExclusions(discovered, labelForNamespace) {+function checkExclusions(discovered, declaringFiles, labelForNamespace) {const { graph, enabled } = measuredFeatures();const problems = [];@@ -328,6 +377,33 @@ function checkExclusions(discovered, labelForNamespace) {);}+ // (2b) The `#[cfg]` itself is gone. Every check here can pass while the Rust+ // gate that made the namespace unreachable has been deleted: the feature is+ // still declared (0), still disabled (1), the namespace is still discovered+ // (2) and still absent from MODULES (3) — but its module now compiles+ // unconditionally and its controllers dispatch. An exclusion is a claim about+ // the source, so it is checked against the source: every file declaring the+ // namespace must sit behind a `#[cfg(feature = …)]` naming the claimed gate.+ const ungated = [];+ for (const [namespace, entry] of Object.entries(UNREACHABLE_NAMESPACES)) {+ const files = declaringFiles.get(namespace);+ if (!files) continue; // Already reported by (2); nothing to check against.+ const unguarded = [...files]+ .filter((file) => !moduleGatesFor(file).has(entry.feature))+ .map((file) => path.relative(ROOT, file))+ .sort();+ if (unguarded.length > 0) {+ ungated.push(`${namespace} — ${unguarded.join(', ')} (expected \`#[cfg(feature = "${entry.feature}")]\`)`);+ }+ }+ if (ungated.length > 0) {+ problems.push(+ `${ungated.length} excluded namespace(s) are no longer behind the gate they claim:\n ${ungated.join('\n ')}` ++ '\nThe module compiles unconditionally now, so its controllers dispatch and must be covered.' ++ '\nRestore the `#[cfg]`, or drop the UNREACHABLE_NAMESPACES entry.',+ );+ }+// (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@@ -346,7 +422,7 @@ function checkExclusions(discovered, labelForNamespace) {}const invoked = collectInvokedMethods();-const schemas = collectSchemaMethods();+const { methodsByNamespace: schemas, filesByNamespace: schemaFiles } = collectSchemaMethods();const labelForNamespace = new Map();for (const module of MODULES) {@@ -360,7 +436,7 @@ const declaredButMissing = [...labelForNamespace.keys()].filter((namespace) => !schemas.has(namespace)).sort();-const exclusionProblems = checkExclusions(schemas, labelForNamespace);+const exclusionProblems = checkExclusions(schemas, schemaFiles, 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