It is hard to tell from what you wrote related to if he penetrated you or not. If his penis entered your anus, that is considered a risk. Albeit very low. Less than 1 percent chance and I wouldn't worry. But do test at 28 days after this occurred. If he did NOT enter your penis, then you had zero risk and don't need to test at all.
If there was no penetration there can't be any risk because hiv is dead in air, so only dead hiv hit your butt. The only way to prevent air affecting the semen is with penetration.