Provably adaptive reinforcement learning in metric spaces