Skip to content

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

test: attest locally built connector fixtures for confidential calls

Steven Enamakel4158bd52e0b5
diff --git a/scripts/__tests__/connector-fixture-attestation.test.mjs b/scripts/__tests__/connector-fixture-attestation.test.mjs
new file mode 100644
index 0000000000..daab0d7260
--- /dev/null
+++ b/scripts/__tests__/connector-fixture-attestation.test.mjs
@@ -0,0 +1,36 @@
+import assert from "node:assert/strict";
+import { spawnSync } from "node:child_process";
+import { createHash } from "node:crypto";
+import { mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
+import { tmpdir } from "node:os";
+import { join } from "node:path";
+import test from "node:test";
+import { fileURLToPath } from "node:url";
+
+const stage = fileURLToPath(
+ new URL("../ci/stage-connector-test-module.mjs", import.meta.url),
+);
+
+test("locally built connector fixtures carry the exact artifact digest for confidential calls", () => {
+ const root = mkdtempSync(join(tmpdir(), "connector-fixture-"));
+ try {
+ const source = join(root, "libtinyconnectors.so");
+ const destination = join(root, "fixture");
+ for (const bytes of ["first pinned build", "replacement pinned build"]) {
+ writeFileSync(source, bytes);
+ const result = spawnSync(process.execPath, [stage, source, destination], {
+ encoding: "utf8",
+ });
+ assert.equal(result.status, 0, result.stdout + result.stderr);
+ const fixture = result.stdout.trim();
+ assert.equal(readFileSync(fixture, "utf8"), bytes);
+ const digest = createHash("sha256").update(bytes).digest("hex");
+ assert.equal(
+ readFileSync(join(destination, "modules.toml"), "utf8"),
+ `"libtinyconnectors.so" = "${digest}"\n`,
+ );
+ }
+ } finally {
+ rmSync(root, { recursive: true, force: true });
+ }
+});
diff --git a/scripts/__tests__/rust-e2e-enumeration.test.mjs b/scripts/__tests__/rust-e2e-enumeration.test.mjs
index 1dba58c156..2fbf2140e2 100644
--- a/scripts/__tests__/rust-e2e-enumeration.test.mjs
+++ b/scripts/__tests__/rust-e2e-enumeration.test.mjs
@@ -224,6 +224,12 @@ test("the E2E runner builds and exports its pinned search module fixture", () =>
const end = source.indexOf('echo "[rust-e2e] Running', start);
assert.ok(start >= 0 && end > start, "module preparation block exists");
const dir = fs.mkdtempSync(path.join(os.tmpdir(), "rust-e2e-modules-"));
+ const connectorDir = path.join(dir, "vendor/tinyconnectors/target/release");
+ fs.mkdirSync(connectorDir, { recursive: true });
+ fs.writeFileSync(
+ path.join(connectorDir, "libtinyconnectors.so"),
+ "pinned connector fixture",
+ );
const runLog = path.join(dir, "runs.log");
const cargo = path.join(dir, "cargo");
fs.writeFileSync(
@@ -256,6 +262,13 @@ test("the E2E runner builds and exports its pinned search module fixture", () =>
),
output,
);
+ assert.match(
+ fs.readFileSync(
+ path.join(dir, "target/test-modules/tinyconnectors/modules.toml"),
+ "utf8",
+ ),
+ /"libtinyconnectors\.so" = "[a-f0-9]{64}"/,
+ );
assert.ok(
fs
.readFileSync(runLog, "utf8")
diff --git a/scripts/ci/self-hosted/install-test-modules.sh b/scripts/ci/self-hosted/install-test-modules.sh
index ecea194273..9b0258c541 100755
--- a/scripts/ci/self-hosted/install-test-modules.sh
+++ b/scripts/ci/self-hosted/install-test-modules.sh
@@ -79,6 +79,8 @@ fi
touch "${conn_cached}"
mkdir -p "${dest}/tinyconnectors"
cp "${conn_cached}" "${dest}/tinyconnectors/libtinyconnectors.so"
+node scripts/ci/stage-connector-test-module.mjs \
+ "${dest}/tinyconnectors/libtinyconnectors.so" "${dest}/tinyconnectors" > /dev/null
{
echo "TINYJUICE_TEST_MODULE=${dest}/tinyjuice/libtinyjuice_module.so"
diff --git a/scripts/ci/stage-connector-test-module.mjs b/scripts/ci/stage-connector-test-module.mjs
new file mode 100644
index 0000000000..92315aad8f
--- /dev/null
+++ b/scripts/ci/stage-connector-test-module.mjs
@@ -0,0 +1,26 @@
+#!/usr/bin/env node
+// The test runner builds this fixture from the pinned submodule. Record that
+// artifact's digest as operator trust; TinyBus still verifies it before loading
+// and refuses confidential delivery when the file or allowlist does not match.
+import { createHash } from "node:crypto";
+import { basename, join, resolve } from "node:path";
+import { mkdirSync, readFileSync, writeFileSync } from "node:fs";
+
+const [source, destination] = process.argv.slice(2);
+if (!source || !destination) {
+ throw new Error(
+ "usage: stage-connector-test-module.mjs <built-library> <fixture-directory>",
+ );
+}
+const bytes = readFileSync(source);
+const filename = basename(source);
+if (!/^libtinyconnectors\.(so|dylib)$|^tinyconnectors\.dll$/.test(filename)) {
+ throw new Error("expected the locally built TinyConnectors library");
+}
+const directory = resolve(destination);
+mkdirSync(directory, { recursive: true });
+const artifact = join(directory, filename);
+writeFileSync(artifact, bytes);
+const digest = createHash("sha256").update(bytes).digest("hex");
+writeFileSync(join(directory, "modules.toml"), `"${filename}" = "${digest}"\n`);
+process.stdout.write(`${artifact}\n`);
diff --git a/scripts/test-rust-e2e.sh b/scripts/test-rust-e2e.sh
index e69cf470bc..1d9e88d102 100755
--- a/scripts/test-rust-e2e.sh
+++ b/scripts/test-rust-e2e.sh
@@ -177,7 +177,9 @@ if [ -z "${TINYCONNECTORS_TEST_MODULE:-}" ]; then
connectors_module="vendor/tinyconnectors/target/release/libtinyconnectors.so"
echo "[rust-e2e] Building pinned TinyConnectors test module ..."
"$CARGO_BIN" build --release --manifest-path "$connectors_manifest"
- export TINYCONNECTORS_TEST_MODULE="$REPO_ROOT/$connectors_module"
+ connectors_module="$(node scripts/ci/stage-connector-test-module.mjs \
+ "$REPO_ROOT/$connectors_module" "$REPO_ROOT/target/test-modules/tinyconnectors")"
+ export TINYCONNECTORS_TEST_MODULE="$connectors_module"
fi
# The isolated module-admission suite requires a real native search module.
diff --git a/scripts/test-rust-with-mock.sh b/scripts/test-rust-with-mock.sh
index d34ddf82a2..df9c0bb58e 100755
--- a/scripts/test-rust-with-mock.sh
+++ b/scripts/test-rust-with-mock.sh
@@ -174,6 +174,8 @@ if [ -z "${TINYCONNECTORS_TEST_MODULE:-}" ]; then
connectors_module="$REPO_ROOT/vendor/tinyconnectors/target/release/libtinyconnectors.$module_ext"
echo "Building TinyConnectors test module from the pinned submodule ..."
cargo build --release --manifest-path "$connectors_manifest"
+ connectors_module="$(node scripts/ci/stage-connector-test-module.mjs \
+ "$connectors_module" "$REPO_ROOT/target/test-modules/tinyconnectors")"
fi
cargo_test() {