Skip to content

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

test(module-pins): add tests for provider pin classification

Steven Enamakelc5385131f2ca
diff --git a/scripts/__tests__/module-pins.test.mjs b/scripts/__tests__/module-pins.test.mjs
index f769463539..af4d1358c4 100644
--- a/scripts/__tests__/module-pins.test.mjs
+++ b/scripts/__tests__/module-pins.test.mjs
@@ -25,6 +25,7 @@ import {
checkPinMapCoverage,
classifyMove,
classifyPin,
+ classifyProviderPin,
expandRustIncludes,
parseAllList,
parseArtifactCapabilitiesPin,
@@ -185,6 +186,65 @@ test("finds ARTIFACT_CAPABILITIES_PIN and the workflow memory blocks", () => {
);
});
+// ── Provider records ──────────────────────────────────────────────────────────
+
+const SHA_A = "a".repeat(40);
+const SHA_B = "b".repeat(40);
+const provider = {
+ id: "tinyx-lang",
+ version: "0.2.4",
+ releaseUrl: "https://github.com/acme/tinyx-lang/releases/tag/v0.2.4",
+ lock: { repo: "acme/tinyx-lang", version: "0.2.4", built_against: SHA_A },
+ sourceSubmodule: "vendor/tinyx",
+ sourceHead: SHA_A,
+};
+
+test("a provider released against the host's source pin passes", () => {
+ assert.equal(classifyProviderPin(provider).ok, true);
+});
+
+test("a provider built against an older source commit fails and says to re-release", () => {
+ const v = classifyProviderPin({ ...provider, sourceHead: SHA_B });
+ assert.equal(v.ok, false);
+ assert.match(v.message, /built against vendor\/tinyx aaaaaaaa/);
+ assert.match(v.message, /Re-release/);
+});
+
+test("a provider whose registry version or url differs from its lock fails", () => {
+ const v = classifyProviderPin({
+ ...provider,
+ version: "0.2.3",
+ releaseUrl: "https://github.com/acme/tinyx-lang/releases/tag/v0.2.3",
+ });
+ assert.equal(v.ok, false);
+ assert.match(v.message, /0\.2\.3/);
+ const url = classifyProviderPin({
+ ...provider,
+ releaseUrl: "https://github.com/other/repo/releases/tag/v0.2.4",
+ });
+ assert.equal(url.ok, false);
+});
+
+test("a provider with no complete lock entry, or a short sha, fails", () => {
+ assert.equal(classifyProviderPin({ ...provider, lock: undefined }).ok, false);
+ const v = classifyProviderPin({
+ ...provider,
+ lock: { ...provider.lock, built_against: "aaaaaaaa" },
+ });
+ assert.equal(v.ok, false);
+ assert.match(v.message, /40-hex/);
+});
+
+test("parseRecords reads release_url", () => {
+ const recs = parseRecords(
+ 'const X: ModuleRecord = ModuleRecord {\n id: "x",\n version: "1.0.0",\n release_url: "https://github.com/a/b/releases/tag/v1.0.0",\n assets: &[],\n};',
+ );
+ assert.equal(
+ recs.get("X").releaseUrl,
+ "https://github.com/a/b/releases/tag/v1.0.0",
+ );
+});
+
// ── Classification ────────────────────────────────────────────────────────────
const base = { id: "tinyx", version: "1.2.3", submodulePath: "vendor/tinyx" };