I seem to have some bad input geometry that I need to clean before processing.
The Rhino Command _RebuildEdges does what I need to clean up the trims and get correct results.
Is there a way to replicate the _RebuildEdges command via RhinoCommon?
i guess this might be possible if you can determine the faces (or edges) which need a rebuild. The BrepFace class includes a BrepFace.RebuildEdges method. You could iterate over the brep edges, check their tolerances etc. finally to detect connected faces to an edge out of tolerance you could use BrepEdge.AdjacentFaces method.