This issue is a tricky one because you have discovered that the unit is illegal. However, this does not mean that you do not have rights to a live in a habitable location. This is definitely something which you should seek legal counsel for, mainly because it sounds like there are severe habitability problems at your home.
This sounds like a very involved case, one that cannot be neatly answered in the space available. However, based on the facts which you have presented, it souinds like you have a couple of options. You could sue in superior court. Alternatively, you could also bring a decreae in services petition before the San Francisco Residential Rent and Arbitration Board.
In any event you should consult with someone who is experienced in landlord-tenant law and furthermore has a good understanding of San Francisco's rent control ordinance. Also, I would strongly encourage that you consult with someone who is committed to representing tenants, especially in a situation like this.
This answer is made available by the lawyer for educational purposes only. It is also to give you general information and a general understanding of the law. This answer is not intended to give you specific legal advice. By using or participating in this site you understand that there is no attorney client privilege between you and the attorney responding. This site should not be used as a substitute for competent legal advice from a licensed professional attorney in your state. We attempt to provide quality information, but the law changes frequently and varies from jurisdiction to jurisdiction. The information and materials provided are general in nature, and may not apply to a specific factual or legal circumstance.
Every lease in California contains an implied warranty of habitability. Put differently, a landlord must take steps to keep your apartment sanitary, safe, and free from serious defects. A leaky roof that lets water in when it rains is a breach of the warranty of habitability. It sounds like you may also have claims against the landlord for breach of contract, negligence, retaliation, unfair business practices, and violation of the Rent Ordinance. Feel free to give me a call for a free initial consultation. 415-835-6777.
Disclaimer: You should discuss your situation with a local attorney, as the above statement is a general overview and does not take into account all of the factual considerations in your case. Nothing in this statement creates an attorney-client relationship.