I'm trying to learn to create models using non-destructive techniques, so I'm using a lot of boolean operations. For this workflow I create some primitives, and they each get the last material added to the object I most recently modified. When I boolean the primitives together, existing faces retain their materials, but new faces get a material assigned at random. Rerunning the same script several times produces otherwise-identical meshes with different materials on some faces.
Why is there random behavior with materials? And is there a way to control what material is used by booleans?