Merge intersecting primitives

I have a bunch of flat primitives. Some of them intersect on an edge:

I have a simple shader that renders a different color per primitive.

Goal: I want to combine primitives that touch each other so they get rendered the same color.

There was an almost-success with the surfsect SOP set to intersection, but it doesn’t seem to output any data that lets me associate the intersecting primitives with each other

BTW, I’m trying to do this procedurally, but only needs to cook once, not every frame (the incoming geometry is static, made from the trace SOP)

Did you ever figure this out? I have a similar issue.