A good solution might be to add a new license clause stipulating whether the owner is okay with their code being used to train AI models.
Part of the clause would explain that if you are okay with your code being trained on, then you're also accepting being okay with it being copied verbatim at some point down the line during code completion.
You do get a bit of tragedy of the commons where everybody wants to use the AI model but nobody wants their own code trained on.
I don't like the idea of a world where licensing and copyright law prevents us from enjoying the progress of AI. Caveat: I am not an expert on open source.
There's no need for the repo owner do anything: they already indicate the license. GitHub even shows a simple explanation of the license in the repo's main page. GitHub has all the data it needs to respect the license. If their trained model can't reproduce the license for the repo a fragment comes from, then they've failed in their social and legal responsibilities.
I do understand how ML works. I know it's probably not possible with how it's currently done. That doesn't make it legal or ethical.
It would actually be great for everyone if it showed both the license and repo. Imagine you pull up a great function with Copilot and want to explore the source for more insights. You can't with how they've done this.
It does actually ask if you want to use your code to help train it. The problem is that even when people have said no, they're still seeing their code pop up in copilot's auto-complete.
I don't mind it using my code because in my opinion, we as a software industry are way behind on where we should be and copilot is helping a lot of developers finish their projects quicker.
That said, software licenses should 100% be respected. I would hate for FOSS projects to start being sued over code. It's not in the spirit of FOSS, but neither is stealing code. Copilot should be doing a better job excluding code and none of this would be a problem.
Part of the clause would explain that if you are okay with your code being trained on, then you're also accepting being okay with it being copied verbatim at some point down the line during code completion.
You do get a bit of tragedy of the commons where everybody wants to use the AI model but nobody wants their own code trained on.
I don't like the idea of a world where licensing and copyright law prevents us from enjoying the progress of AI. Caveat: I am not an expert on open source.