This sounds like a very cool idea. Can you make one for C++ (nudge-nudge)?
I've done something similar to this before as kind of a poor man's, humanly-supervised testing in rushed scenarios where I just outputted files from manually-executed tests outside of CI with the resulting output files submitted to version control. Then I'd inspect the file diffs to look for unanticipated changes (these were in approximation fields where the changes didn't necessarily indicate erroneous output, but should be monitored carefully).
I can only give some general suggestions without knowing the elaborate details, but my basic suggestion to start would be to favor a format that is as flat as possible.
That is, avoid something like XML here. XML can be great, but it's not necessarily the most diff-friendly or the easiest to read. There's ways to get the nested structure an XML file represents in a flat way. For example:
... might be represented in a flat way as:
y = 123
... something like this as a crude example. You can think of it kind of like a file system structure where stuff in
[...] is a directory and the stuff below are like files within that directory. It'll be easier to control that way and have everything on its own line, easy to spot differences, etc.
Next easy step is just sort the entries in the file ("directories" at the top-level and "files" within a directory). That'll give your file format a lot of stability so that it doesn't just arbitrarily rearrange the contents of the file and totally screw up the diff, tagging way more lines as changed than necessary.
I think you can actually stop at this point. If you want to go further, you can start introducing extra whitespaces to leave room for new entries to be inserted within a "directory", e.g. (kind of like a growable array container implementation which has excess memory capacity to append elements to the end without a linear-time complexity reallocation and transfer of the previous contents), and even leave "tombstone" whitespace lines behind that you can reclaim when new things are inserted. That'll result in the minimal amount of shifting changes to the file in common cases in exchange for big shifts in rare cases, though I think it's really overkill and will come with the burden on your human readers to deal with excess and seemingly-arbitrary whitespaces. It's also far more complex since you'd have to inspect the previous files you made to modify them instead of just being able to overwrite them.
The sorting and flattening of the format is the easiest way to achieve a pretty good stability of a text format IMO for diff purposes. Last but not least, this is probably just common sense and something you already know upfront, but naturally it'd be good to grab various diff tools and test your outputs against them.