summaryrefslogtreecommitdiffstats
path: root/src/pkginfo.rs
diff options
context:
space:
mode:
authoraur-build <aur-build@localhost>2026-11-18 14:47:59 +0000
committeraur-build <aur-build@localhost>2026-11-18 14:47:59 +0000
commit7946e9ffc48748992f051ada15bec772b16a585d (patch)
tree96b6674efb30774647687a117759723ff3207965 /src/pkginfo.rs
parent3370a487d6e1100623ebfd982967f1223d251607 (diff)
downloadaur-build-7946e9ffc48748992f051ada15bec772b16a585d.tar.gz
aur-build-7946e9ffc48748992f051ada15bec772b16a585d.zip
hash: canonical_json is canonical now, and a serialization failure is an error
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.
Diffstat (limited to 'src/pkginfo.rs')
0 files changed, 0 insertions, 0 deletions