“State bodies” are not required to pursue and assist with enforcing federal laws, and are generally prohibited from prosecuting under then except when states have been granted special power to do so in federal law. These are fundamental features of the “dual sovereignty” federal system in the US (and the freedom of states to decline to enforce federal law was noted as far back as in cases related to the Fugitive Slave Act prior to the Civil War.)
If the federal government wants to make laws, then it is also responsible for figuring out how to enforce them. Within certain bounds, it can bribe states to do it, but it can't command them to.
> writ of mandamus?
Yes, it exists.
No, it doesn't obligate state bodies to “pursue” or “prosecute” violations of federal law.
Hell, you can buy heroin directly in front of the Tenderloin police station. Not across the street, directly in front.
de facto, I'd say heroin is basically legal in San Francisco.