I reversed seven records in the test input for release-evidence, a tool I maintain for evaluating release evidence. No records added or removed. The release verdict came back the same, but two fields in the output JSON changed. Should that fail a regression test?
Start with two records and look at the bytes
Here’s a smaller example you can run from the repository root with Node.js. The first two strings have different spacing and key order. The third flips the array. The program prints the first 12 hex digits of SHA-256 alongside the exact string it hashed.
node --input-type=module <<'JS' import { canonicalize, sha256hex } from './vendor/playbook-shared/jcs.mjs'; const samples = [ '{"target":"staging","records":["a","b"]}', '{ "records": ["a","b"], "target": "staging" }', '{"records":["b","a"],"target":"staging"}', ]; for (const text of samples) { const json = canonicalize(JSON.parse(text)); console.log(sha256hex(json).slice(0, 12), json); } JS 6427b55ac09e {"records":["a","b"],"target":"staging"} 6427b55ac09e {"records":["a","b"],"target":"staging"} f8b68dad12e4 {"records":["b","a"],"target":"staging"} The first two lines match all the way across. Hashing the source file directly would pick up the extra spaces. Instead, the program parses the JSON and serializes it with the repository’s canonicalizer. It sorts object keys recursively and keeps array elements in their original order. On the third line, ["b","a"] survives that process, so SHA-256 gets different bytes. The helper implements the subset of JCS (JSON Canonicalization Scheme) used by this project. Canonicalizer source
Back to the seven records
I ran evaluate() at the merge commit for PR #8 with the lane-backed replay fixture. These seven records are synthetic. Reversing just the object keys throughout the fixture produced byte-for-byte identical serialized output. Then I went back to the original input, reversed only records, and compared the output field by field. Replay fixture
| Output field | After reversing records |
|---|---|
input_digest | 6f983451d800… → 84bdb739c00d… |
record_digest | Changed |
input_manifest | Identical |
candidate_receipt | Identical, including its receipt_id |
The first digest lets someone holding input.json check whether it matches the input to this evaluation. Preserving the array order is part of that job. The second digest covers the evaluation record, excluding its own record_digest field. Since that record includes input_digest, changing the first value also changes the second. Digest functions
The evaluator has a separate way of comparing which records are available: it orders their references by kind and digest when it builds the manifest. Reversing those same seven records gave it the same manifest and the same candidate receipt. An assertion that the entire output must stay identical would fail precisely when the evaluator had correctly recorded which input it received. Regression tests for the two kinds of reordering
The check that can pass after you’ve already lost the original
There’s a detail in the CLI I’d keep even in a much smaller program. It takes the input digest before calling the evaluator. Imagine that a future change adds input.records.reverse() inside evaluate(). In JavaScript that mutates the caller’s array, too. If the CLI waits until evaluation is over to hash the input, it can end up comparing two copies of the same mistake. Both hashes describe the reversed array.
The test substitutes an evaluator that does exactly that. The digest taken before the call still describes the original order, so the CLI catches the mismatch and exits with code 2. A caller supplying seven records in reverse order is fine. An evaluator silently reversing those seven records is a bug, even if it reaches the same verdict. Where you take the hash lets the test tell the two cases apart. CLI check · Mutation test

