Skip to content

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

feat(pins): add support for test-only source parity validation

Steven Enamakel04ebd1e32406
diff --git a/scripts/__tests__/module-pins.test.mjs b/scripts/__tests__/module-pins.test.mjs
index ba00b9a2de..6c973513a1 100644
--- a/scripts/__tests__/module-pins.test.mjs
+++ b/scripts/__tests__/module-pins.test.mjs
@@ -303,6 +303,25 @@ test("the existing exact-drift exemption is proof-checked and keeps ahead visibl
}
});
+test("TinyJuice's canonical owner merge matches its recorded release-tree attestation", () => {
+ const exemption = JSON.parse(readFileSync(join(REPO_ROOT, "scripts/ci/module-pin-exemptions.json"), "utf8"))
+ .exemptions.find((entry) => entry.id === "tinyjuice");
+ const assets = [...parseRecords(readRegistry()).values()].find((record) => record.id === "tinyjuice").assets;
+ const candidateCommit = exemption.sourceParity.candidateCommit;
+ const result = validateTestOnlySourceParity({
+ repoPath: join(REPO_ROOT, "vendor/tinyjuice"),
+ version: "0.10.8",
+ assets,
+ actualHead: candidateCommit,
+ proof: exemption.sourceParity,
+ runGit: (args) =>
+ args[0] === "rev-parse" && args[1] === "HEAD"
+ ? candidateCommit
+ : execFileSync("git", args, { cwd: join(REPO_ROOT, "vendor/tinyjuice"), encoding: "utf8" }).trim(),
+ });
+ assert.equal(result.ok, true, result.message);
+});
+
test("source parity proof rejects production, manifest, build, lock, and unknown changes", () => {
for (const changedFile of ["src/lib.rs", "Cargo.toml", "build.rs", "Cargo.lock", "unknown.txt"]) {
const fixture = sourceParityFixture();
diff --git a/scripts/ci/module-pin-exemptions.json b/scripts/ci/module-pin-exemptions.json
index 87ca3887fa..9b2c80cce2 100644
--- a/scripts/ci/module-pin-exemptions.json
+++ b/scripts/ci/module-pin-exemptions.json
@@ -21,6 +21,30 @@
"id": "tinyflows",
"expect": "v0.8.23-92-gcad43f97",
"reason": "Storage schema v2 (epic #7973): the gitlink sits past the registry's released tag on the merged upstream commit carrying the uniform storage schema. Re-pin both once a release carrying it is cut; retire this entry then."
+ },
+ {
+ "id": "tinyjuice",
+ "expect": "v0.10.8-13-g598b7d17",
+ "reason": "TinyJuice PR #102 is merged upstream at 598b7d171f4abc721b2045fbcd454974dd2bc9d0. Its only source change is the compress unit-test file; this exact attestation retains the v0.10.8 registry artifact and rejects any other tree or head.",
+ "sourceParity": {
+ "tag": "v0.10.8",
+ "releaseCommit": "7c43eedd7d7917fa41ea1bd488649fe233d00531",
+ "candidateCommit": "598b7d171f4abc721b2045fbcd454974dd2bc9d0",
+ "assetsSha256": "502797c2eccf693e5aa024afc9908b6b3cc2e94c0cacbe1ecaf498bc9c59738c",
+ "testFile": {
+ "path": "src/compress_tests.rs",
+ "releaseMode": "100644",
+ "releaseBlob": "3ea48874bb6c8af4a0573fc12cee693454ca5ce0",
+ "candidateMode": "100644",
+ "candidateBlob": "bbb10c8aa18c9c1e61a7e4f11f40159b1495e0d3"
+ },
+ "unchangedTreeSha256": "08611ddb48d72b70476230462b1853856d5af5f0af507094406faa7786feb784",
+ "binding": {
+ "modulePath": "src/compress.rs",
+ "moduleBlob": "6e9c47e86d26f299b0e8fb959839a598619ff82b",
+ "testPath": "src/compress_tests.rs"
+ }
+ }
}
]
}
diff --git a/scripts/lib/module-pin-status.mjs b/scripts/lib/module-pin-status.mjs
index 121e0c9dee..76b388f3fe 100644
--- a/scripts/lib/module-pin-status.mjs
+++ b/scripts/lib/module-pin-status.mjs
@@ -58,7 +58,9 @@ export function classifyStatus({
id,
kind: "exempt",
actual,
- message: `exempt (declared drift accepted): ${strict.reason}`,
+ message: strict.sourceParity
+ ? `exempt (verified test-only source parity at ${actual}): ${strict.reason}`
+ : `exempt (declared drift accepted): ${strict.reason}`,
};
}
const note =
@@ -66,6 +68,8 @@ export function classifyStatus({
? " (its module-pin-exemptions.json entry is stale; delete it)"
: strict.kind === "exemption-widened"
? " (the drift moved past its module-pin-exemptions.json entry)"
+ : strict.kind === "invalid-source-parity"
+ ? ` (${strict.message})`
: "";
if (strict.kind === "match" || strict.kind === "stale-exemption") {
return { id, kind: "in-sync", actual, message: `in sync${note}` };
diff --git a/scripts/lib/module-pins.mjs b/scripts/lib/module-pins.mjs
index b2dc05b16b..13ed203cd2 100644
--- a/scripts/lib/module-pins.mjs
+++ b/scripts/lib/module-pins.mjs
@@ -159,7 +159,12 @@ export function classifyPin({ id, version, submodulePath, actual, exemption, sou
};
}
}
- return { ok: true, kind: "exempt", reason: exemption.reason };
+ return {
+ ok: true,
+ kind: "exempt",
+ reason: exemption.reason,
+ sourceParity: Boolean(exemption.sourceParity),
+ };
}
return {
ok: false,
@@ -230,7 +235,8 @@ export function validateTestOnlySourceParity({
if (!file || Object.keys(file).sort().join(",") !== "candidateBlob,candidateMode,path,releaseBlob,releaseMode") {
throw new Error("test-file proof fields are missing or unknown");
}
- if (!proof.binding || file.path !== proof.binding.testPath || !/^[A-Za-z0-9_./-]+\.rs$/.test(file.path) || posix.dirname(file.path) !== posix.dirname(proof.binding.modulePath)) throw new Error("test path is not a sibling of the attested module binding");
+ const validRepoPath = (value) => typeof value === "string" && /^[A-Za-z0-9_./-]+$/.test(value) && !posix.isAbsolute(value) && !value.split("/").includes("..");
+ if (!proof.binding || !validRepoPath(file.path) || !validRepoPath(proof.binding.modulePath) || !file.path.endsWith(".rs") || file.path !== proof.binding.testPath || posix.dirname(file.path) !== posix.dirname(proof.binding.modulePath)) throw new Error("test path is not a safe sibling of the attested module binding");
if (file.releaseMode !== "100644" || file.candidateMode !== "100644") throw new Error("attested test file must remain a regular non-executable file");
if (![file.releaseBlob, file.candidateBlob].every((sha) => /^[0-9a-f]{40}$/.test(sha)) || file.releaseBlob === file.candidateBlob) throw new Error("test-file blob pair is malformed or unchanged");
const entries = (ref) => runGit(["ls-tree", "-r", "--full-tree", "-z", ref])