Sub topic 5
Permissive and copyleft licenses in brief
This chapter assumes you know what an open-source license is, can use Git and code review, and have used an AI coding assistant. It is general education, not legal advice. License terms differ, so always read the actual text.
Why licenses matter for AI-assisted code
Copyright gives the author of code exclusive rights by default. An open-source license is the author's written permission to copy, change and share the code, on stated conditions. If an assistant reproduces licensed code, those conditions may come with it. To judge that risk, you first need to know what the main license families require.
Two families
Open-source licenses fall into two broad groups.
- Permissive licenses let you reuse the code in almost any project, including closed-source products. They ask for little, usually that you keep the copyright notice and license text.
- Copyleft licenses let you reuse the code too, but they require that certain derived work be shared under the same license terms.
The practical difference is what happens when your code is combined with theirs.
| License | Family | Main conditions |
|---|---|---|
| MIT | Permissive | Keep the copyright notice and license text |
| BSD (2-clause, 3-clause) | Permissive | Keep the notices. The 3-clause version also bars using the authors' names to endorse your product |
| Apache-2.0 | Permissive | Keep notices, state changes, and note that it includes a patent grant |
| LGPL | Weak copyleft | Changes to the library itself must stay under the LGPL. Linking from other code has looser rules |
| MPL-2.0 | Weak copyleft | Changes to MPL-covered files must be shared. Other files in the project can use other licenses |
| GPL | Strong copyleft | A distributed work that combines with GPL code generally must be offered under the GPL |
| AGPL | Strong copyleft | Like the GPL, and it also applies when users interact with the software over a network |
The details of what counts as a "derived work" or "combined work" depend on the license and the jurisdiction. Treat the table as a map, not a ruling.
Permissive licenses in practice
The main obligation is attribution. If a generated snippet matches MIT-licensed code, shipping it without the MIT notice breaks the license, even though the license is generous. The fix is cheap: keep the notice and the license text.
Apache-2.0 adds a patent grant and a requirement to mark files you changed. This is more to track, but still manageable.
Copyleft licenses in practice
Copyleft is a trade. You get free code, and in return, if you distribute a work that includes it, you must offer the combined work's source under the same terms. For the GPL, the trigger is generally distribution, such as shipping a binary or an app. Running GPL code privately on your own servers usually does not trigger it. The AGPL closes that gap for network services.
Here is why this matters for generated code. Suppose an assistant outputs a long function that closely matches a GPL project, and you ship it in a proprietary product. You could then face a demand to release your product's source, or have to remove and replace the code. Keeping GPL-covered code out of a closed product is much cheaper than untangling it later.
How the two families look in a repository
A common way to tell which license applies is the SPDX identifier, a short standard label placed in a file header. The identifier states the license for that file.
# SPDX-License-Identifier: Apache-2.0
# Copyright (c) 2026 Example Corp.
def clamp(value: float, low: float, high: float) -> float:
return max(low, min(value, high))This header states the license under which the project distributes the file. It does not prove that the code in the file is free of third-party material.
Common errors
- Assuming "open source" means "free of conditions." Every open-source license has conditions, even permissive ones.
- Treating copyleft as always infectious. The scope depends on the license, how the code is combined, and whether you distribute it.
- Ignoring license compatibility. Some licenses cannot be combined in one work. For example, Apache-2.0 code and GPLv2-only code are generally considered incompatible.
- Trusting a header as proof. An SPDX line states intent. It does not show where the code came from.
The next chapters cover how generated code can carry these obligations, and how to detect and record them.
Exercise
An assistant generates a 40-line function that closely matches a function in a GPL-licensed project. Your company plans to ship it inside a closed-source desktop application. Why is this riskier than if the match were an MIT-licensed function, and what would you do?
Show answer
Shipping the app distributes a combined work, which can trigger the GPL's requirement to offer the source under the GPL. The MIT license only requires keeping the copyright notice and license text. In the GPL case, I would not ship the code. I would rewrite the function independently or replace it with a permissively licensed alternative, and have it reviewed. If the match were MIT, I would keep the notice and license text with the code.
Exercise
Name one difference between the GPL and the AGPL.
Show answer
The GPL's obligations are generally triggered by distributing the software. The AGPL also applies when users interact with the software over a network, even without distribution.