As a former long-term tenant in San Francisco and now a landlord, I can tell you that sub-tenants absolutely have rights, and it would be highly illegal for your master tenant to "pack up your belongings, put them outside, change the locks and you are hereby evicted!" However, it is possible for a master tenant to evict a subtenant in 14 "just cause" situations, so it pays to do some research.
The two organizations that Jed mentions are the same two that I refer people to, though I would add the caveat that the Tenants Union can be extreme in their approaches -- it seems to me that they care far more about pro-tenant law and precedent than they care about any actual person, so be careful to consider whether their recommendations actually fit who you want to be as a person. Here are the links:
Go to the "Documents and Resources" section, and get ready to do your homework.
And the Tenants Union:
If you get mail there and it is your legal address, you can't get thrown out for no reason. Talk to a tenants' right s group because if you have been there longer than 30 days in San Francisco, you do have rights.
However, if there are problems with the master tenant, is this a place you really want to continue to live? I'd be paranoid about my stuff if someone didn't want me there. Cut your losses and get out before it gets ugly. In the meantime, learn your rights. This is San Francisco, you have some.
P.S. Another example of why you can't be kicked out. A friend of mine had a fight with her boyfriend--her house, he lived there. The police came but wouldn't do anything--as in make him leave--as it was his legal address.
Rebecca is correct. Contact the tenants union or the the rent control board and find out your rights. I would also agree that you probably want to start looking for another place before this one gets uglier. It never hurts to know what your right are even if you don't intend on standing on them and making a bigger issue. Lifes too short. If you are not on the lease you will not have recourse with the landlord nor will you likely be able to get the roommate to move out.
If your name was not on the lease and you did not sign the contract, then you do not have any rights or if you do, it is very limited. If I were you, I will start looking for a new place and if you will have some roommates, make sure your name is on the lease agreement.