It's not unmaintainable if most of it is tests. Just have it write tests until it becomes safe for AI.