This is close to what Nim pre version 1.0 tried, tracking all the original ASTs before template/macro expansions. It caused exponential memory consumption and was abandoned. Clever schemes don't help with exponentials.
Also, what problem does this solve? > So when designing transformations, we need to take into account that the > transformation should be possible to reverse using info. Sounds like even more mental burden when doing these transformations.