> ## Documentation Index
> Fetch the complete documentation index at: https://docs.weaveos.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Bugs introduced

> Track which commits and engineers introduced bugs that were later fixed

## Overview

The **bugs introduced** metric identifies commits that introduced bugs which were later fixed in bug-fix PRs. Unlike [bug ratio](/metrics/bug-ratio), which measures the proportion of output spent on fixes, bugs introduced traces bugs back to their source—helping you understand where bugs originate and who introduced them.

This enables powerful insights like:

* Which code changes are most likely to introduce bugs
* Patterns in when and how bugs get introduced
* Attribution of bug introductions to individuals or teams
* Correlation between AI-assisted code and bug introduction rates

## How it works

When a bug-fix PR is merged, Weave's Bug Finder traces the bug back to its source:

1. **Analyze the fix**: Parse the PR to understand what bug was fixed and which code sections changed
2. **Extract traceable lines**: Identify deleted/modified lines (not additions) that can be traced back
3. **Select sections**: Use AI to pick the one or two changed sections that most likely repaired the bug
4. **Git history**: Trace each selected section's line history (up to 30 commits per section) and keep up to 6 candidate source commits
5. **Score candidates**: AI evaluates each candidate's code changes to assess if it introduced the bug
6. **Final ranking**: Assign each candidate a confidence level and a share of the likelihood based on the evidence

If you connect [Sazabi](/integrations/sazabi), Weave also matches Sazabi issue reports to the PR that most likely introduced them, counting only medium or high confidence matches. A report that matches a bug already traced from a bug-fix PR adds evidence to that bug. A report with no match counts as its own bug, attributed to the introducing PR's author at the time that PR merged.

## Metric filtering

Only high-quality bug attributions are included in the metric. A bug introduction is counted when
the confidence level is **medium, high, or very high** and Bug Finder assigns that commit at least
70% of the likelihood among its candidates. Attributions that miss either threshold are stored but
not counted.

## Time attribution

Bugs are attributed to the time when the **buggy code was originally written** (the author date of the commit that introduced it), not when the bug was fixed. If that date is unavailable, Weave uses the time Bug Finder detected the bug. This gives you an accurate picture of when bugs are being introduced, even if they're discovered much later.

## Confidence levels

| Level | Description |
| - | - |
| **Very high** | Direct before-and-after evidence matches the exact defect and fix. |
| **High** | Clear causal evidence that the commit introduced the bug, with minor uncertainty. |
| **Medium** | Plausible causal evidence that the commit introduced the bug, but not definitive. |
| **Low** | Weak or speculative connection. Not included in the metric. |

## Relationship to bug ratio

| Metric | Measures | Attribution |
| - | - | - |
| [Bug ratio](/metrics/bug-ratio) | Proportion of output spent on bug fixes | To the person who fixed the bug |
| Bugs introduced | Number of bugs traced to their source | To the person who introduced the bug |

Both metrics are valuable: Bug ratio helps you understand how much effort goes into fixing bugs, while bugs introduced helps you understand where bugs come from.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.