Cutting hole with Brep - Invalid Brep

I’m encountering issues with Invalid or Open Brep outputs when attempting to cut Brep 1 (terrain) with Brep 2 (parametric geometry). In many cases, when I manipulate the geometry of the model (Brep 2) or move it around within the terrain (Brep 1), I obtain a Closed Brep. However, I frequently encounter Invalid or Open Brep outputs as well. I’m struggling to identify the source of the problem and why the cut operation fails. Is there any reliable method to ensure that this cut operation works consistently? Perhaps using a dense mesh or another approach? (45.9 KB)

I have created an issue for this. The problem seems related to the sorting of the list of parametric geometry. It may be worthwhile to see if sorting by size/volume or another metric can make this more robust while the issue is under review.

There is some issue with sorting of the list, but still Closed Brep is changing to Invalid Brep after slight move transformations.

And after slight move it becomes invalid: