I remember posting a link that discusses this in a very old thread:
The textbooks discuss the distinction between model based inference (ie. 2 sample t-test), vs design based inference (again either 2 sample t test or permutation test). The design gives justification to the calculation of a p value in an RCT.