Here's my best answer to your question...
If you are in your boat, floating in the bay, and you are boarded by San Fran cops, on their boat, then California gun laws still count. Your boat would probably count as an extention of your home and you could use deadly force to protect yourself, and others, from harm if someone tried to enter your boat and harm you. You would also be held to California law when it comes to magazine capacity (10), threaded barrels are illegal, assault weapons are illegal, etc...
If you are in your boat, floating in the bay, and you are boarded by USCG, then they would be looking to enforce federal laws: short barrel rifle, tax stamps, full auto, etc... They wouldn't necessarily be looking for high capacity mags, threaded barrels, etc like the local LEOs would be. However, like
@heavydoc said, the USCG boarding officer would be well within regulations to detain you and call local LEO to come and investigate your vessel for possible state level criminal activity. And, that all comes down to "officer's discretion". Nine times out of ten, if you are being cool the USCG boarding officer is going to be cool. The same cannot be said of the local LEOs that you might run into...
And, as
@1075tech said, the LEOs and USCG can only do so much. Once the bad guys are under arrest it's up to the district attorney and judicial system to do their part and actually try/ prosecute the scum in criminal court...