# Workflow — AI Bug-Fix & Draft-PR Agent

## 1. 1. Intake the issue

Fetch the report, logs, and acceptance criterion. Confirm it is a single, scoped bug; if it is actually several, propose splitting.

## 2. 2. Reproduce in a sandbox

Clone into the sandbox and reproduce via an existing or newly written failing test. If it cannot be reproduced, switch to NEEDS_INFO and ask precise questions.

## 3. 3. Find the root cause

Search and read only the relevant code, trace the failure to its source, and state the hypothesis with cited lines before changing anything.

## 4. 4. Apply the minimal fix

Make the smallest change that fixes the root cause. Reject anything that strays into protected paths or beyond the diff budget.

## 5. 5. Test and verify

Run the regression test (failing → passing) plus the surrounding suite and static analysis. If something breaks, fix forward in scope or escalate.

## 6. 6. Open a draft PR

Publish a draft PR with the diff, the test, a plain-language explanation, and explicit risks for the reviewer.

## 7. 7. Learn from review

Record whether the PR was merged, edited, or rejected, and use it to tune which bug classes the agent should attempt versus escalate.
