The plumbing infrastructure of developed nations typically take in fresh water from centrally treated reservoirs. These are sourced from local rivers and lakes, and are then distributed to the residents and industrial sites as part of a municipal-wide water supply network. From a residential system's point of view, the treated water entering the households is the input. On the output side, the waste products are carried through a centralized sewage treatment network, where various methods are employed to clean the water as much as possible before it is released to a nearby sink location - typically your local sea or back into the same river downstream. Overall the system works remarkably well and it would continue to work if it weren't for problematic things aside from bio-waste ending up in the sewage. Plastics, chemicals, hormones in our stools, industrial toxins, non-biodegradable garbage are all difficult things that cannot be easily taken care of by this infrastructure. What we need is to stop these things from ending up in the output. But how?
There are expensive solutions such as reverse osmosis and distillation that do not 100% guarantee pristine water but they can be very effective. Once the soluble elements are separated, the water can be reclaimed for other uses. Alternative research avenues seem to suggest that there may be organisms or chemical processes that can break down plastics and other environmentally harmful substances. But whether those are feasible or not remains to be seen. These two broad methods however do show promise if they can be integrated with other infrastructures such as power generation. Theoretically for example, electrical power generation that rely on steam may be able to utilize some of this contaminated water (after all the large solids are removed such as through a sludging process). By boiling the sewage, the steam can be used to do work, distilled, and then the resulting water can be used for something else or released safely into the environment. The remaining toxic portion can be concentrated and undergo further processing, perhaps bio-gas reclamation or as a food source for those experimental microbes/fungi that can break them down to less toxic wastes. Maybe there can be chemical processes to create various forms of batteries from the wastes. By adding certain agents, one batch would create an anode and another a cathode. Connect a wire between them to create a toxic battery (electrical or otherwise). The remaining toxic materials that cannot be broken down completely should be concentrated, solidified and contained. Perhaps they can then be used as combustible fuel produced as part of such systems as in fecal sludge management. If not then ideally they should be disposed of in barren areas away from water sources. These can then be fed into mining operations as a recycling effort. In all cases, we must recognize that any and all potential solutions must ensure our wastes do not enter into any waters, both fresh and salty.
assert(q); // TODO: Verify assumption