If both players are TEC rebels local militia won't attack either of them, the pirate base becomes useless and neither faction can put up bounty (btw, even if I use carmic retribution to put bounty on the rebel won't be attacked. No problem with me, but if the pirates won't attack their allies when they have the most bounty on their heads WHY CAN'T I PUT UP BOUNTY FOR THEM THE NORMAL WAY? It's a great incentive in FFA games to have other players attack your neighbor instead of you).
What the OP experienced was one (more likely: multiple) TEC Loyalist(s) using Insurgents (tier 8 in the civilan research, at the end of the culture string). The TEC rebel pirate and milita reinforcements are NOT neutral, they belong to the TEC rebel player and only appear in the players gravitywells, not in the wells of allies.
You cannot help your friend with cleaning his gravitywells (because the Insurgents are neutral to you), and if you want to have an envoy of your friend in your gravitywell you will have to ask him to place a Starbase there, because the neutral insurgents on your planet WILL ATTACK HIS ENVOY.
TAR still needs fixing, they need to think about a solution for envoys, insurgents clogging up your planets and a problem others experienced where some neutral factions wouldn't be neutral at all. However the insurgent attacks on your friend are not TARs fault.