# Common Code Policy

Common Code policy&#x20;

The **Common Code Policy** is an optimization policy specifically designed for foundational or shared code within an application. It defines which tests should run when "common code" (shared foundations) is altered and which can be safely skipped. This empowers teams to maintain high quality while avoiding the massive test overhead typically triggered by changes to infrastructure or utility layers.

### Why It Is Useful

In most enterprise applications, approximately 30% of the codebase consists of "common code" (utility classes, logging wrappers, string formatters, or foundational infrastructure).

Without this policy, a single character change in a widely used utility would technically "touch" every test in the suite, forcing a full test run. The Common Code Policy recognizes these patterns and applies a more targeted selection logic.

<figure><img src="https://lh7-us.googleusercontent.com/OQLRDmhiQokxNOnkoVPUFrDig97pilU6FnwGDjpfPQHjkOUbkO34_FRH93fSk0yiFSQxXqxirZhVhVKvhyJSOqbUxqi9sU6k32L1AbQrmE5QmLt_QeU0KKxdY33ebdr7yFxDrAGisRltgTnmb9MotsY" alt=""><figcaption></figcaption></figure>

### How it Works?

* **Targeted Identification:** SeaLights identifies specific methods or classes that serve as common foundations.
* **Subset Selection:** When these common areas are modified, the engine does not trigger the entire suite. Instead, it identifies and recommends a smaller, highly relevant subset of tests that have the highest probability of catching a regression in that specific foundation.
* **Reduced Redundancy:** This approach ensures that quality is verified for shared code without the time-cost of running thousands of unrelated tests.

### Activation & Configuration

This policy is currently a **manually managed capability** that requires collaboration between the customer and the SeaLights team.

1. **Analysis & Discovery:** SeaLights engineers analyze your codebase and tests distribution. to generate a list of candidate methods that exhibit "common code" behavior (high fan-out and usage).
2. **Marking Methods:** Upon receiving this list, the customer reviews and formally **requests to mark specific methods** as Common Code.
3. **Defining Test Logic:** For each method marked as Common Code, the customer **defines which specific tests should run** to validate it when changes occur. This ensures that the optimization remains safe and effective.
4. **Implementation:** Once the methods and their corresponding tests are defined, the SeaLights team activates the policy for those specific sections.

***

### FAQ

<details>

<summary><strong>How do we determine what counts as "Common Code"?</strong></summary>

Typically, these are low-level utilities or infrastructure components used by hundreds of unrelated features. SeaLights provides the initial list based on analysis.

</details>

<details>

<summary><strong>Can we change the policy ourselves?</strong></summary>

Currently, configuration (including adding new methods or changing the linked tests) is handled through your SeaLights technical contact to ensure the optimization logic remains stable and accurate.

</details>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.sealights.io/knowledgebase/test-optimization/test-optimization-strategy/test-selection-policies/common-code-policy.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
