That’s an awful experience. Given CBP disagrees with the the law, USCIS policy manual, and State FAM, I wonder how you will be able to use your IR-1 visa now that CBP has you flagged. But once you find a way in, CBP won’t be able to legally prevent you from entering the U.S., though it can issue an NTA. And you will win in court. The decision from the judge will be your security blanket on subsequent returns to the U.S.
Get global entry after you become an LPR.