Try using a statically typed language, refined types, and functional programming. Your tests become limited to things that are hard or impossible to assert with the type system.
Off the top of my head, I'm guessing we're missing sparse attention. But I'll run your challenge through and see where the gaps are. I promise I'm telling the truth :)
I've had the opposite experience where we're refactoring the gnarliest shit anyone's ever seen because AI can actually understand it well enough to decompose, test, refactor, etc.