This from an anonymous correspondent:
Making data and code available for other researchers is an important tool for promoting replication, discovering errors, and advancing research agendas. However, how to handle the ownership situation? In this case, a junior scholar who worked for a long time on a tricky piece of code, using publicly available data, was asked to provide a copy of the code. A while later, an original piece of research appeared using the code, with appropriate citation to the original work. However, if the two researchers had been colleagues surely the programmer would have been a co-author on the work. What is the best way to handle this in general? Is there some way to communicate reasonable expectations at the point the code is shared, or should one reserve the right to review and join the work later, or what?