AD SPACE AVAILABLE · BRAND PARTNERS WELCOME

Can You Legally Use Sourcegraph Cody Code in Commercial Software? Attribution Guardrails, Copyleft Contamination, and IP Indemnity Explained

Rob Barshad · 365Finds Editorial
Indexed 88,650 Wiki articles

Put 365 Wiki to work with your AI

Copy the prompt below, paste it into the AI you already use, then ask your question.

Download full Skill

Try it with the prompt first. If you use 365 Wiki often, install the full 365Wiki Skill so you do not have to paste it again. No regular AI? Gemini or Microsoft Copilot on the web will work.

365Wiki Skill

If you are an engineering director, startup founder, or open-source compliance lead, you know the scenario that keeps enterprise legal counsel awake at night: an engineer accepts an autocomplete suggestion inside the IDE, and weeks later, a pre-IPO code audit reveals 14 lines of code lifted verbatim from a Linux kernel driver or an AGPL-3.0 database connector. Suddenly, your proprietary SaaS codebase faces copyleft contamination claims, demanding open-source disclosure or an immediate code rewrite.

At 365Finds, we look at developer tools through both operational mechanics and commercial risk. The short answer to whether you can legally use code generated by Sourcegraph Cody in commercial software is yes—provided you operate on an Enterprise tier with strict architectural and legal guardrails in place.

Relying on Sourcegraph Cody under a Free or Pro self-serve plan while assuming Sourcegraph will protect you in court is dangerous complacency. In this guide, 365Finds unpacks Sourcegraph Cody's contractual terms, dissects how its native Attribution Guardrails function under the hood, explains model-level license contamination risks, and defines how to configure an enterprise-safe AI development pipeline.


1. Ownership vs. Responsibility: What Sourcegraph's Contracts Actually Say

The first misconception many technical teams hold is that AI vendors absorb the copyright liability for whatever their models generate. Sourcegraph’s formal documentation and contracts tell a more nuanced story.

Under Section 1 of the Sourcegraph AI Terms of Use (and Section 3 of the general Terms of Service):

Sourcegraph grants you the rights to the code, but it refuses to be your de facto open-source licensing compliance officer. If Cody hallucinates or reproduces a helper function originally released under the GNU General Public License (GPL) and you bake that snippet into a closed-source enterprise product delivered to paying clients, the initial copyright infringement claim lands on your company's desk, not Sourcegraph's.

+-------------------------------------------------------------------------------+
|                       Sourcegraph Legal Risk Allocation                        |
+-------------------------------------------------------------------------------+
| Inputs & Prompts         | Customer Owns                                      |
| Generated Outputs        | Customer Owns                                      |
| License Compliance Duty  | Customer Retains Full Legal Responsibility         |
| Training on Code         | Explicit Zero-Retention / No-Training Guarantee    |
| IP Indemnification       | Enterprise Order Form ONLY (Excluded on Free/Pro)  |
+-------------------------------------------------------------------------------+

2. Technical Anatomy of Attribution Guardrails

To address the risk of open-source duplication, Sourcegraph introduced Attribution Guardrails (often referenced in documentation as copyright guardrails for public code).

How Guardrails Work Under the Hood

Attribution Guardrails operate as a real-time verification filter between Cody's inference engine and the developer's IDE:

  1. The Public Index Corpus: Sourcegraph maintains an indexed baseline corpus of approximately 290,000 public open-source code repositories spanning all license categories (permissive, weak copyleft, and strong copyleft).
  2. The 10-Line Threshold: The check triggers whenever Sourcegraph Cody generates a code snippet of ten lines or longer.
  3. Exact String Matching: The engine performs a high-performance string comparison between the generated snippet and the indexed public code database.
  4. Enforcement Behavior:
    • In standard mode, Cody may flag chat responses with an indicator showing whether the attribution check passed or failed.
    • In Enforced Mode, autocomplete suggestions that trigger a positive match are withheld entirely from the developer until the attribution check clears.

Configuring Guardrails in Sourcegraph Enterprise

To activate and enforce this protection across your organization, administrators must configure the instance's Advanced Site Configuration:

{
  "attribution.enabled": true,
  "attribution.mode": "enforced"
}

When "attribution.mode": "enforced" is configured, Cody IDE extensions (VS Code version 1.82+ or JetBrains version 7.82+) block matching code from appearing in the autocomplete feed.

The Critical Limitations 365Finds Identified

At 365Finds, we appreciate the engineering intent behind Attribution Guardrails, but treating them as an absolute legal shield is a mistake. Here is why:


3. Model Architecture: Permissive Pre-Training vs. Flagship LLMs

Your exposure to copyleft contamination is directly linked to which large language model generates your code completions. Sourcegraph Cody’s architecture allows organizations to select different underlying models for autocomplete and chat.

+-------------------+----------------------------+-----------------------------+
| Feature / Metric  | StarCoder (Permissive)     | Claude 3.5 Sonnet / GPT-4o  |
+-------------------+----------------------------+-----------------------------+
| Training Corpus   | The Stack (Permissive Only)| Web-scale, mixed licenses   |
| Copyleft Exposure | Negligible / Near Zero     | Low to Moderate             |
| Primary Strengths | Fast, license-clean code   | Complex reasoning and chat  |
| Recommended Role  | Inline IDE Autocomplete    | Architectural review & chat |
+-------------------+----------------------------+-----------------------------+

Why 365Finds Recommends StarCoder for Inline Autocomplete

When ServiceNow and Hugging Face developed StarCoder under the BigCode project, they built it on "The Stack," a curated dataset restricted strictly to permissively licensed open-source code (MIT, Apache 2.0, BSD). All repositories governed by copyleft licenses (GPL, LGPL, AGPL) were filtered out prior to training.

Because StarCoder was never trained on copyleft code, its neural weights cannot memorize or regurgitate GPL expressions. When Sourcegraph Cody routes autocomplete inference through StarCoder, the risk of automated copyleft contamination drops to near zero at the parameter level.

For chat, architectural refactoring, and multi-file code understanding, models like Anthropic's Claude 3.5 Sonnet or OpenAI's GPT-4o are far superior. However, because general flagship LLMs ingested broad swathes of public internet repositories during pre-training, they require rigorous downstream compliance checking.


4. Preventing Context Leakage with cody.contextFilters

A subtle risk in enterprise software engineering is internal cross-contamination. If your company maintains internal open-source tools governed by GPL alongside closed-source proprietary products, Cody’s multi-repository context retrieval might read GPL-licensed internal utilities and feed them into prompts generating code for proprietary software.

To eliminate this vector, Sourcegraph Enterprise provides repository-level context filtering via cody.contextFilters in the site configuration.

Enterprise Context Filter Configuration

Using RE2 regular expressions, administrators can enforce strict context boundaries:

{
  "cody.contextFilters": {
    "include": [
      {
        "repoNamePattern": "^github\\.com\\/your-org\\/(proprietary-.*|core-engine)$"
      }
    ],
    "exclude": [
      {
        "repoNamePattern": ".*-internal-gpl$"
      },
      {
        "repoNamePattern": ".*-thirdparty-eval.*"
      }
    ]
  }
}

By explicitly isolating copyleft and exploratory repositories, you guarantee that Cody Gateway never injects contaminated AST context into developer chat sessions or inline suggestion buffers.


5. Sourcegraph IP Indemnification: The Conditions That Matter

When introducing AI coding tools into an enterprise that undergoes customer vendor assessments or M&A audits, legal counsel will ask: Does the AI vendor indemnify us against third-party intellectual property infringement claims?

Sourcegraph does offer IP indemnification under Section 12.2 of the Terms of Service and Section 5 of the AI Terms of Use. However, this protection is conditional:

1. Enterprise Subscription Required

Sourcegraph provides IP indemnification exclusively to customers on paid Enterprise plans with a signed Order Form. If you are using Sourcegraph Cody Free, Cody Pro ($9/month), an uncommitted trial, or a feature flagged as Beta, all software and AI outputs are provided strictly "as is", without warranty or indemnification (Section 3.7 and 3.8 of the ToS).

2. The Filter Requirement

Section 12.2(iii) contains a clause enterprise legal teams must not overlook: Sourcegraph’s defense and indemnity obligations apply only if you are using the latest version of the services, including any filters provided by the services.

If an enterprise administrator deliberately disables Attribution Guardrails or fails to update IDE client extensions, Sourcegraph's legal counsel can argue that the organization waived its indemnification rights by refusing to run the provided compliance filters.

3. Liability Limits

Under Section 9 of the AI Terms of Use, if your underlying master agreement does not provide uncapped indemnification, Sourcegraph limits liability for data security and related breaches to five times (5x) your annual license fees.


6. The 365Finds Blueprint: Zero-Contamination Production Pipeline

To safely embed Sourcegraph Cody into commercial software development, 365Finds recommends implementing a layered defensive architecture rather than relying on any single vendor promise:

+-------------------------------------------------------------------------------+
|               365Finds Enterprise AI Compliance Architecture                  |
+-------------------------------------------------------------------------------+
| Layer 1: Commercial Contract   | Formal Enterprise Order Form with Sec 12.2   |
| Layer 2: Model Routing         | StarCoder for Autocomplete; Claude for Chat  |
| Layer 3: Site Configuration    | attribution.mode: enforced & contextFilters  |
| Layer 4: IDE Standards         | Mandatory client updates (VS Code / JetBrains)|
| Layer 5: CI/CD SCA Gate        | Black Duck / Snyk / FOSSA automated PR scans |
+-------------------------------------------------------------------------------+
  1. Contractual Foundation: Execute an Enterprise Order Form confirming that Section 12.2 IP indemnification extends to AI outputs generated via Cody Gateway.
  2. Infrastructure Configuration: In Sourcegraph Advanced Site Configuration, set "attribution.enabled": true and "attribution.mode": "enforced". Apply cody.contextFilters to block all internal copyleft code from prompt ingestion.
  3. Model Selection: Configure default autocomplete to run on permissively trained models (such as StarCoder), reserving general flagship models for interactive chat and unit test creation.
  4. Automated CI/CD SCA Scanning: Never rely solely on IDE-level string matching. Enforce a mandatory Software Composition Analysis (SCA) scanner—such as Black Duck, FOSSA, or Snyk—in your continuous integration pipeline. The CI scanner analyzes pull requests against billions of open-source snippets using fuzzy token hashing, catching any sub-10-line or lightly refactored code before it merges into your release branch.

By pairing Sourcegraph's contractual indemnification with model-level permissive routing and automated SCA gating, your engineering team can accelerate delivery with Cody while presenting a pristine, defensible intellectual property posture to investors, auditors, and enterprise clients.


References