@tmpfs see the thread
Of course, even if the spec doesn’t say that this information needs to be preserved (and in my view it probably shouldn’t), our implementations could preserve it.
It would be quite easy to modify commonmark.js to keep track of what character was used for emphasis, how many backticks were used in a backtick code block, what type of hard line break was used, and whether a fenced or indented code block was used (in cases where the info string is empty).
Keeping track of whether a link or image was inline or reference (and label was used for the reference) would also be relatively easy. The tricky part would be knowing where the reference goes, since this isn’t tracked in the AST. Putting them all at the end would be easy, though.
About your use case: you don’t need a CommonMark renderer for that, unless the source code blocks sometimes occur in indented contexts (blockquotes or lists). All you’d need is a preprocessor or template engine to insert the contents of the source files into specially marked code blocks.