Code has been ruled as free speech by the US Supreme Court. So the First Amendment already mandates open source by virtue of it being open speech
Discussion
That’s not how it works
Free speech =/ private speech.
Unsure if you could argue “trade secret” with code, but I imagine companies keep code private for competitive edge. That’s understandable