[fabrica] Release pin (QC round 2): verifiers build the tagged commit (flake rev and docs); the commit the pin names is kept for the record, must hold the recorded source tree when present, and is published unchecked when absent

This commit is contained in:
2026-11-22 19:29:28 +01:00
parent ea1ec11cd1
commit 5023575680
5 changed files with 41 additions and 16 deletions
+28 -6
View File
@@ -9,8 +9,12 @@
// The pin is a claim about the code it was built from, so it is refused unless the tagged commit
// holds exactly that code: its source tree (every tracked file except pin.json itself) must be
// the one the pin recorded. That is `git diff --name-only <pinned> <tag>` being empty or only
// pin.json, checked without the pinned commit's history (a runner's clone is shallow). The
// published file names the commit the hashes were built from, not the tag's.
// pin.json, checked without the pinned commit's history (a runner's clone is shallow).
//
// The build reference verifiers use is the tagged commit: it has the pinned source by that check,
// and it surely exists. The commit the pin names is kept for the record only; when its objects
// are here it must hold the recorded source tree too (a forged commit is refused), and when they
// are not (a shallow clone, or a commit rebased away) it is published unchecked.
//
// node scripts/release-pin.mjs <X.Y.Z> <tag> <commit> write target/nix/ianitor-nix.json
// node scripts/release-pin.mjs --source-tree <commit> print that commit's source-tree hash
@@ -86,15 +90,31 @@ if (here !== pin.sourceTree) {
);
}
let commitChecked = false;
try {
git("cat-file", "-e", `${pin.commit}^{commit}`);
commitChecked = true;
} catch {
// Not here: informational only.
}
if (commitChecked && sourceTree(pin.commit) !== pin.sourceTree) {
fail(
`${PIN} names ${pin.commit}, which does not hold the source tree it records: ` +
`the pin was edited by hand; run scripts/nix-pin.sh again`,
);
}
const out = {
name: "Ianitor Domi",
version,
tag,
// The commit the hashes were built from; the tag's own commit differs at most by pin.json.
commit: pin.commit,
// Build this one (docs/verify.md): the tagged commit, whose source the pin is of.
taggedCommit: commit,
flake: `git+https://gitea.marek-novak.cz/mnovak/Ianitor.git?rev=${commit}`,
// The commit nix-pin.sh ran at, for the record; checked against the source tree when present.
commit: pin.commit,
commitChecked,
sourceTree: pin.sourceTree,
flake: `git+https://gitea.marek-novak.cz/mnovak/Ianitor.git?rev=${pin.commit}`,
nixpkgs: pin.nixpkgs ?? null,
system: pin.system,
outputs: pin.outputs,
@@ -102,4 +122,6 @@ const out = {
};
mkdirSync(join(repo, "target/nix"), { recursive: true });
writeFileSync(join(repo, "target/nix/ianitor-nix.json"), JSON.stringify(out, null, 2) + "\n");
console.log(`target/nix/ianitor-nix.json: ${version}, built from ${pin.commit}, tagged at ${commit}`);
console.log(
`target/nix/ianitor-nix.json: ${version} at ${commit} (pinned at ${pin.commit}, ${commitChecked ? "checked" : "not here, unchecked"})`,
);