Mind if I shift the discussion a little bit? Still on topic, but thinking about the output a little differently.
I'd prefer us moving away from the mindset of having an all-encompassing
writer that accommodates whatever output we want to throw at it. I think that's what is making this a difficult problem.
Instead, we can think about once we select an algorithm, we know what will be produced. Coupled with the data, we know the output down to the sizes. We should find a way to describe that. One extreme way to encode this is to have a different type of writer for each piece, like a writer for draws, a writer for the adaptation parameters, a writer for the elapsed time, etc. We can imagine there's some fixed C++ structure that holds everything. Then it's a matter of serializing and deserializing that. Or we can build some sort of schema that describes it. But we should be describing that, not the message-level information. (btw, this applies to optimization and ADVI too.)
The only complication here is that we consider not serializing everything. And I think that's fine. We just have to know what's minimal or what we can do with pieces.
Anyway, that's how I'm thinking about it. Thoughts? (I don't care if the implementation is done through a class that can handle everything, but trying to piece together structured output with individual key-value pairs seem like we're making the problem a lot harder on ourselves.)