I cannot answer your question on California law. Someone else surely will. You will probably get more answers, better answers, and faster answers if you ask in the California forum. The States are listed alphabetically on the main index.
I posted mainly because you report being stopped many times, but never detained. If you were stopped by a LEO for any reason other than he and you being citizens voluntarily chit-chatting, you WERE detained.
If you did not feel that you were free to walk away, the courts would have used an even stronger term than detained: For however briefly that the officer was requiring your presence, you were seized in the very sense that the 4A uses that word.
I will not speak to the lawfulness of such a detention in California (not being familiar with the intricacies of CA law), but I will pass along that LEOs cannot willy-nilly detain citizens. They must have a specific reason, authorized by law for the detention.
One such reason would be reasonable articulable suspicion that you have committed, are committing, or are about to commit a crime (articulable meaning that they could, at the time of the stop, put their reasonable suspicion into words). California also authorizes LEOs to stop citizens openly carrying firearms to check that the firearm is unloaded, but, IMO, that law is of questionable constitutionality.
I would suggest that you research the laws of California to determine whether detentions (even momentary ones) for the OC of a knife is lawful. Whether you choose then to challenge the next officer who violates your rights, or cooperate for the sake of expediency, would be up to you.
When I am unlawfully stopped, I take the time to educate the officers--politely. If they continue to issue orders (that are likely unlawful, but that will be determined later), I will specifically state that I do not consent, but will not resist their overt acts to enforce those orders. Make them take your ID. Make them seize your weapon. Etc. Do not hand these items over, but do not resist their taking. Have a recorder running at all times.
Just my zwei Pfennige.