Courts are of course have a certain degree of interpretive freedom, but the process should result in a machinery that implements intent faithfully, and legislators change laws to change intent (and to patch holes, but in common law that usually happens through the courts too).
Legislation, laws, and law enforcement as technologies have always had these trade offs, and they have progressed tremendously over the centuries (or millennias).
From the Roman veto of the tribune of the plebs, to current constitutional review there are many checks and balances. But legislation as a process doesn't have inherent loopholes.
Currently for every piece of law proposed many official and civil groups warn of the potential unintended side effects of it. But then the majority usually disregards those concerns.
AI might be best put to use for finding loopholes. In formal specifications, in legal documents, in laws... you name it.
The required process change is reasonably straightforward; instead of presuming an answer given by AI is useful as a solution to the given problem, take it as an indicator of a loophole in problem specification and see if one can be closed up.