That all comes down to how you tag your outputs. You can query history if all intermediate steps are tagged with the same identifier. In the case of ordinals, I tag all with the origin outpoint, so I can search through all historical records for that origin. I'm using my wallet for my logging and history and state all in 1.