Skip to content

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

fix(module-pins): keep cfg-gated entries in the ALL list

Steven Enamakel1d6423d3f53d
diff --git a/scripts/__tests__/module-pins.test.mjs b/scripts/__tests__/module-pins.test.mjs
index 2923ffb76e..632e25f5f9 100644
--- a/scripts/__tests__/module-pins.test.mjs
+++ b/scripts/__tests__/module-pins.test.mjs
@@ -590,3 +590,16 @@ test("the submodule probe is not fooled by the superproject above it", () => {
rmSync(root, { recursive: true, force: true });
}
});
+
+test("a cfg attribute on an ALL element does not hide the record", () => {
+ const src = [
+ "pub const ALL: &[ModuleRecord] = &[",
+ " TINYCOMPUTER,",
+ ' #[cfg(feature = "documents")]',
+ " TINYDOCS,",
+ ' #[cfg(feature = "modules")] // loader only',
+ " TINYBOX,",
+ "];",
+ ].join("\n");
+ assert.deepEqual(parseAllList(src), ["TINYCOMPUTER", "TINYDOCS", "TINYBOX"]);
+});
diff --git a/scripts/lib/module-pins.mjs b/scripts/lib/module-pins.mjs
index e1c79c16c7..6b28b7e05b 100644
--- a/scripts/lib/module-pins.mjs
+++ b/scripts/lib/module-pins.mjs
@@ -49,6 +49,9 @@ export function parseAllList(src) {
if (!block) throw new Error("registry.rs: could not find `pub const ALL`");
return block[1]
.replace(/\/\/[^\n]*/g, "")
+ // `#[cfg(feature = "…")]` on an element: the record is still in `ALL` for
+ // the builds that carry its optional contract crate, so it is still pinned.
+ .replace(/#\[[^\]]*\]/g, "")
.split(",")
.map((s) => s.trim())
.filter((s) => s.length > 0);