Imagine I have a code base and I'm obsessively concerned about the protection and privacy of that code. If I were to hire a freelancer to work on that code base, I'd probably have the freelancer sign a nondisclosure agreement and hopefully I'd build up a relationship with him/her over time and gain some confidence that he/she can be trusted.
However, if I wanted to collaborate with an external company, company X, what steps can I take to protect my code? I assume a nondisclosure agreement would offer some protection in the case that company X steals my code, but what could I do to protect against the code being stolen from a rogue company X employee with access to the code base? Should I require that all employees at company X sign a nondisclosure agreement?
In general, what steps can be taken by a company like company X to encourage a trusting collaboration with their clients? How can company X assure me that the code they have access to won't be stolen? Are such collaborations even possible?
I'm not really confident in the protective power of most non-disclosure agreements. In general, I believe that all I can do is work with people that I trust and hope for the best. However, for the purposes of this question I'm interested in hearing if any form of protection is available even if it isn't particularly robust.