Where/how is code pulled from storage

In 1.0 it is pretty clear that a registered flow’s code is pulled when a flow run is created, but I could not seem to find the exact code detailing when/how flow code from remote storage is pulled by the agent. Where is this defined?

Also, would the flow code be re-pulled if I recover a failed flow run?

in the agent code

yes, correct