Different tacks I could have taken?
Couple of ideas which may have helped (and I have used in the past).
Follow up any verbal agreement with an email, with a first line something like "This is just a quick note to confirm the recent discussions."
You can then argue (quite reasonably) that the agreement was in writing, since, if "they" don't agree, it is up to them to
replay and follow up.
Post the code regularly to somewhere public, if that is your final intention anyway.
It is too late to do this after the legal people are involved, but
if you set an early precedent, it is easy to continue.
Assuming you submit reports "up the chain of command", then you can add the one liner under achievements for the month that "Version 0.93 has been submitted to the XXX archive for
review". Again, assuming that either the report isn't read, or that the implications aren't
picked up, you have set the precedent. If the implications are
picked up, then you get an early warning of problems ahead. Either way, you get a
chance to end up with a better result, with at least a chance to have the argument early on.