Sub topic 5
Licensing and intellectual property questions
This chapter covers the licensing and intellectual property (IP) questions that AI-assisted code raises, and how a team policy can handle them. It assumes you know the Git and pull request workflow, have done code review in a team, have used an AI coding assistant, and know roughly what a CI pipeline does. It builds on the risk overview earlier in the tutorial and feeds into the next chapter on approving tools.
This chapter is not legal advice. The law on AI-generated code is unsettled and differs by country. Your policy should set engineering rules that reduce exposure, and your legal counsel should decide the legal positions.
Why this is a policy question
A developer who pastes a suggestion into a pull request has made a licensing decision, whether or not they noticed. Three separate questions are involved:
- Inbound risk. Does the generated code copy or closely resemble code that carries license obligations, such as attribution or source disclosure?
- Ownership. Who owns the output, and can your company assert rights over it?
- Outbound risk. Does your input (prompts, files, context) give the tool vendor rights you did not intend to grant?
The third question overlaps with the data rules in the previous chapter. This chapter focuses on the first two.
Inbound risk: license contamination
Models learn from large amounts of public code, and that code has many licenses. Most of the time a model produces new code that follows common patterns. Occasionally it reproduces a recognizable passage from its training data. This is called memorization or regurgitation. It is more likely for distinctive, widely copied code such as a well-known algorithm implementation, a long boilerplate block, or a function with an unusual name.
The license of the original code matters because licenses attach conditions:
| License type | Examples | Typical condition | Why it matters for generated code |
|---|---|---|---|
| Permissive | MIT, BSD, Apache-2.0 | Keep the copyright notice and license text. Apache-2.0 also has patent and notice terms. | Copying without attribution violates the license, though the burden is light. |
| Weak copyleft | LGPL, MPL-2.0 | Changes to the licensed files must be shared under the same license. | Copied files can pull obligations into your repository. |
| Strong copyleft | GPL, AGPL | Distributing a combined work requires releasing its source under the same license. AGPL extends this to network use. | A copied block in a proprietary product can create a serious conflict. |
| Source-available or custom | BSL, SSPL, Elastic License | Restrictions on commercial or hosted use. | Copying may be forbidden outright for your use case. |
| No license | Code with no license file | All rights reserved by default. | You have no permission to copy it at all. |
The risk is not that every suggestion is tainted. The risk is that nobody checks the rare suggestion that is.
What a policy can require
A policy cannot prove that a snippet is original. It can lower the odds and make the remaining risk visible:
- Use the tool's filtering features. Some assistants can block or flag suggestions that match public code. If your approved tool offers this, the policy should require it to be turned on. Treat it as a reduction in risk, not a guarantee.
- Set a size threshold for scrutiny. A one-line suggestion is almost never a licensing issue. A large block that is not specific to your codebase deserves a closer look. A rule such as "if a generated block of more than a few lines looks like a known library or algorithm, search for its source" is easy to follow.
- Prefer a library over pasted code. If the assistant produces a long implementation of something common, such as a parser, a hashing routine, or a date library, the better engineering answer is usually to depend on a vetted package. That gives you a license you can track.
- Run license scanning on dependencies. The assistant may also suggest adding a package. Your existing dependency license checks should apply to it exactly as they apply to a human's choice.
- Use code-snippet scanning where available. Some software composition analysis tools can compare your code against a database of open source snippets. These are most useful for repositories you ship to customers.
A simple dependency license check can run in CI. The example below fails the job if a production dependency uses a license your team has not approved.
# .github/workflows/license-check.yml
name: license-check
on:
pull_request:
jobs:
licenses:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- run: npm ci
- run: >
npx --yes license-checker --production
--onlyAllow "MIT;ISC;BSD-2-Clause;BSD-3-Clause;Apache-2.0"Adjust the allowlist to the licenses your legal team approves. A package with a license outside the list causes the job to fail, which forces a human decision. This check covers declared dependencies only. It does not detect copied source code, so it complements the review steps above and does not replace them.
Ownership of AI-generated output
Two things affect who owns the output: the tool's terms of service and the law of copyright.
Terms of service. Most commercial vendors state in their terms that the customer owns the output, or that the vendor assigns its rights to the customer. Free or consumer tiers may differ. Some terms restrict using output to build competing models. Your tool approval process should read these terms and record the answer, which is one reason the policy restricts work to approved tools and plans.
Copyright law. In several jurisdictions, copyright protects works with human authorship. Material generated by a tool with little human creative input may receive weak protection or none. The practical consequence is this: if an assistant produced a module with minimal human direction and editing, you may find it harder to stop a third party from copying it. This matters most for code that is itself your product.
Engineers can do several things in response:
- Treat AI output as a draft that a person directs, edits, and combines with their own design decisions.
- Record the human contribution in the pull request description. The "How I verified it" and "AI assistance" sections of the pull request template from earlier chapters already capture this.
- Keep your most valuable proprietary logic human-designed, and use AI tools mainly on routine code.
Your lawyers may also have views on whether to register copyright for a given work, or on how to describe AI involvement in filings. Engineers should not make those calls. The policy should say who to ask.
Indemnification and its limits
Some vendors offer IP indemnification. This is a contractual promise to defend the customer against certain copyright claims over the tool's output. It sounds like a complete answer, but check the conditions, which often include:
- Applies only to specific paid plans, not free tiers.
- Requires that built-in filters for public code matches be enabled.
- Requires that you did not modify the output in a way that causes the claim.
- Excludes output you knew, or should have known, was infringing.
- May cap the amount or require prompt notice of a claim.
The engineering consequence is that indemnification can depend on how your team configures the tool. If the vendor requires the public-code filter to be on, then turning it off, even for convenience, can void the protection. Include these conditions in the tool configuration standard, and enforce them centrally where the product allows it.
Existing code and inbound contributions
Two situations are easy to overlook.
Open source contributions. If your engineers contribute to an open source project, that project may have its own rules. Some projects ban AI-generated contributions or require disclosure. Others require a Developer Certificate of Origin (DCO) sign-off, where the contributor certifies they have the right to submit the work. An engineer who signs off on AI-generated code makes that statement personally. The policy should tell engineers to read the target project's contribution guidelines before using AI on upstream work.
Client and third-party code. Contracts with customers can restrict how their code is handled, or require that deliverables be free of third-party material. If a contract forbids sending a client's code to outside services, that restriction applies to AI tools too. Treat such contracts as an input to the restricted and prohibited tiers you defined earlier.
Putting it into the policy
A short licensing section can hold most of this. Keep each rule checkable.
## Licensing and IP
1. Use only AI tools and plan tiers on the approved list. The list records
each tool's output-ownership terms and indemnification conditions.
2. Where a tool offers a public-code match filter, it must stay enabled.
3. Do not paste long generated blocks you cannot explain. If a block of
more than 10 lines resembles a known library, algorithm, or snippet,
search for the source and check its license before committing.
4. Prefer an approved dependency over generated copies of common code.
5. New dependencies, whether suggested by a tool or a person, must pass
the license check in CI.
6. Before using AI on code for an open source project or a client, read
that project's or client's rules. If the rules forbid it, do not.
7. Questions about ownership, registration, or contributions go to
[email protected]. Engineers do not decide these.The thresholds here, such as 10 lines, are examples. Choose numbers your reviewers will actually apply.
Common mistakes
- Treating the filter as proof. A filter lowers the chance of a match but does not guarantee originality. Keep the review step.
- Checking dependencies but not copied code. License scanners that read manifests will not find a function pasted into your source.
- Using personal accounts. A developer's free-tier account may have different ownership terms, different data handling, and no indemnification. This is a licensing problem as much as a data one.
- Ignoring the contract. Customer agreements and open source guidelines can be stricter than company policy.
- Letting engineers answer legal questions. Ambiguity is fine to flag. Resolving it is a job for counsel.
How a licensing concern moves through the process
When a reviewer or author suspects a match, the path should be short and the same every time.
If a match is found after merge, handle it through the incident process covered in a later chapter.
Summary
- Generated code can reproduce licensed code, so require filters, scrutiny of larger blocks, and a preference for vetted libraries.
- Scan dependencies in CI, and remember that this does not catch copied source.
- Read each tool's terms for output ownership and indemnification, and keep any filter the indemnity depends on switched on.
- Copyright protection for output with little human input is uncertain, so keep human design and editing visible.
- Check open source and client rules before using AI on their code.
- Send legal questions to counsel and record each licensing decision.
Exercise
A developer's assistant generates a 40-line function that implements a well-known compression routine. It works and passes tests. The CI license check passes. Is the licensing question settled? What should the developer do, and what is the likely better alternative?
Show answer
No. The CI license check reads declared dependencies, so it cannot detect a copied function inside your own source. The developer should search for the likely original implementation and check its license. If a source is found with an unapproved or unclear license, they should not merge it, and should ask legal if the license is unclear. The better alternative is usually to replace the generated function with a vetted, approved library, which gives a trackable license and a maintained implementation.
Exercise
Your vendor offers IP indemnification, but only if the public-code match filter is enabled. A developer proposes turning the filter off because it hides some useful suggestions. How should the policy respond, and why?
Show answer
The policy should require the filter to stay on and enforce it in the central tool configuration where possible. Turning it off could void the indemnification, which would remove the contractual protection for the whole team. The developer's convenience does not outweigh that. If the filter blocks useful suggestions too often, raise it through the policy review process or with the vendor instead of disabling it locally.