The `urn:atomic:triage: ` reference for a set of pins. `candidate_changes` is sorted before hashing so a triage over the same set of changes in a different order produces the same reference. The map is already canonical (BTreeMap), and JCS sorts object keys, so the reference is a pure function of the pinned facts.
(pins: &TriagePins)
| 43 | /// canonical (BTreeMap), and JCS sorts object keys, so the reference is a pure |
| 44 | /// function of the pinned facts. |
| 45 | pub fn triage_reference(pins: &TriagePins) -> String { |
| 46 | let mut canonical_pins = pins.clone(); |
| 47 | canonical_pins.candidate_changes.sort(); |
| 48 | let value = |
| 49 | serde_json::to_value(&canonical_pins).expect("TriagePins serialization is infallible"); |
| 50 | let canonical = jcs::canonicalize(&value); |
| 51 | let digest = blake3::hash(canonical.as_bytes()); |
| 52 | format!("urn:atomic:triage:{}", digest.to_hex()) |
| 53 | } |
| 54 | |
| 55 | /// Recompute the reference for `pins` and compare it to `reference`. True iff the |
| 56 | /// pins hash to exactly this reference (order-insensitive for candidate changes). |