Interesting - I would be interested in chatting with you too. I am a lawyer at a Big law firm. One of the things that I have been doing (which clients love) is writing software to automate or enhance parts of what I do.
I made an arrangement immediately when I started. I told them I do code on the side, and that I had other people that I worked with on that code.
They agreed that they pay me for legal work, not for code. Thus, the tools I build are mine, but the analysis and output of those tools may be theirs if I am using the tools for their benefit.