I don't know the details of proposed and actual treatment mechanisms for non-pathogen problems (though
here is an outline of the regulations surrounding levels of arsenic, cadmium, copper, lead, mercury, nickel, selenium, and zinc permitted in the US. Regulation of organic pollutants and hydrocarbon levels were considered; but dropped and don't currently apply); but my understanding is that 'composting' on a wastewater treatment scale is
not much like what people do in their back gardens, and is generally done in relatively vast hardware far from the neighbors. If anything, doing it properly probably scales up better than it scales down(amateur composters frequently fail to achieve optimal temperatures, moisture, etc. That's merely inefficient if you are dealing with grass clippings; but potentially fatal if dealing with intestinal pathogens; professionals can afford expertise, instruments, and process control, if they care).
Unfortunately, once you get past metals and pathogens(metals are at least measured, pathogens are acknowledged as a threat), you get a whole lot of 'more research needed'(the usual answer on endocrine disruptors and pharmaceutical persistence); or 'ooh, it's just a teensy bit, and we aren't required to model bioaccumulation from populations exposed to higher levels of contaminants in food producing biosolids higher in contaminants, which produce more contaminated food, and so forth..'(this is why dioxins, dibenzofurans, and similar known-nasty carbon/chlorine creations aren't covered by final regulations).
In the long run, we've obviously survived exposure to this planet, trace metals and all; and more than a few unpleasant chemicals, so I'd hope that the problems can be worked out; but the financial pressure from people who just don't want to deal with the cost of incineration or landfilling has led to some rather questionable decisions. You tell someone that if they spread the stuff over a large enough area, they get to call it 'soil treatment'; but if they bury it all in one place they need to abide by standards for non-permeable landfill construction to keep the contaminants from leaching out, you create a deeply perverse incentive.
Better separation of industrial sources is an obvious first step(it's always more expensive to un-mix things after the fact than it is to keep them separate); but I get a lot of 'more research needed' when it comes to household disposal and drug excretion.
On the bright side, we don't use
pig toilets anymore! So there is that.