From 7946e9ffc48748992f051ada15bec772b16a585d Mon Sep 17 00:00:00 2001 From: aur-build Date: Wed, 18 Nov 2026 14:47:59 +0000 Subject: hash: canonical_json is canonical now, and a serialization failure is an error MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The function behind `Identity::hash` — the digest an approval echoes back — did two things its name promised and it did not do. It did not order anything: the doc comment conceded that callers were expected to pass "already-canonical values", which is a convention, not a property, and a struct serializes in whatever order its fields were declared. And on a serialization failure it returned `"{}"`, so every value that failed to serialize hashed to one shared digest. For a system whose whole job is provenance, "two identities that could not be serialized would look identical to the approval echo" is the worst possible failure to have available. Serialization now routes through `serde_json::Value`, whose map is a `BTreeMap`, so object keys come out sorted whatever the input's construction order — the name describes what happens. A failure propagates: `canonical_json` returns `Result`, `Identity::hash` returns `Result`, and the four call sites (detect, put_world_snapshot, the world step, both enqueue paths) pass it on. There is no path left where a digest is invented for a value that could not be rendered. `tests/hash.rs` pins all three properties: an unserializable value is an error naming itself, two same-field-different-declaration-order values render identically (and to the exact compact sorted bytes), and the identity digest changes when any element of the tuple changes. --- src/watch/detect.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/watch/detect.rs') diff --git a/src/watch/detect.rs b/src/watch/detect.rs index 3134e19..71d1b29 100644 --- a/src/watch/detect.rs +++ b/src/watch/detect.rs @@ -174,7 +174,7 @@ fn analyse(cfg: &Config, db: &Db, pb: &Pkgbase, head: &str) -> Result