summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoraur-build <aur-build@localhost>2026-11-18 08:06:31 +0000
committeraur-build <aur-build@localhost>2026-11-18 08:06:31 +0000
commitd159ee92ec747e34846d8c3ac91c58558cb892d4 (patch)
tree60055051dbbfd00cc40c601be0646f92953fecff
parent04b40812f3366c71bf1c99779f880cc74b7f9efa (diff)
downloadaur-build-d159ee92ec747e34846d8c3ac91c58558cb892d4.tar.gz
aur-build-d159ee92ec747e34846d8c3ac91c58558cb892d4.zip
db: identity_hash is a digest of the canonical identity tuple (ยง5.1a)
The identity is the tuple an approval pins. Rendering it as raw canonical JSON made the 'hash' a blob of unescaped JSON that no form field could carry faithfully; hash the canonical form instead and keep the JSON internal.
-rw-r--r--.gitignore3
-rw-r--r--src/db/model.rs5
2 files changed, 7 insertions, 1 deletions
diff --git a/.gitignore b/.gitignore
index e86670d..09bfb8d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,3 +6,6 @@ Cargo.lock.orig
*.db-wal
*.db-shm
.DS_Store
+
+# goal-tracker state, not project source
+.pi/
diff --git a/src/db/model.rs b/src/db/model.rs
index 66674ab..07065c5 100644
--- a/src/db/model.rs
+++ b/src/db/model.rs
@@ -58,8 +58,11 @@ impl Identity {
/// The hash that makes I3 a fact: two byte-identical inputs never produce
/// two candidates, and any change to what becomes a byte in the artifact
/// produces a new one.
+ /// A digest of the canonical JSON of the identity tuple. This is the value
+ /// an approval must echo: two candidates share an `identity_hash` only if
+ /// every pin, digest and version in them is identical.
pub fn hash(&self) -> String {
- hash::canonical_json(self)
+ format!("sha256:{}", hash::hex(hash::canonical_json(self).as_bytes()))
}
}