A golden file is useful only when its expected differences mean something. If the contract permits the order of an unordered collection to vary, a byte-for-byte golden can turn a harmless permutation into a regression. If the contract requires sorting by priority, applying the exact same normalization can hide a real defect.
Pick one case and run a pinned reference implementation against the same input several times with the relevant environment and seed policy recorded. Inspect the differences before normalizing them. Equality across that finite sample means no variation was observed in the sample; it cannot prove determinism. Preserve a sanitized trace of the raw discrepancy when needed, subject to the same data-retention limits as other test artifacts.
Give each normalization rule a counterexample
Suppose the output is an array of labels with order unspecified but duplicates meaningful. Sorting both arrays before comparing them should accept [red, blue] versus [blue, red] .…