Since Xfoil is using potential flow theory, how is it able to predict boundary layer and separation? If I'm adding perturbation terms aren't those still made with fundamental flows?
The answer is in the resolution of the boundary layer by solving integral equation, for which a potential solution is needed (see this answer). XFoil uses Thwaites method coupled with Michel method. In particular it uses the local Reynolds number to understand if transition happened or if separation happened on the airfoil surface.