Skip to content

Auto Patch PRs

How GitWire generates full-file patches and opens pull requests to fix CI failures.

The Patch Flow

mermaid
graph TD
    A[CI Run Failed] --> B[Claude Diagnoses Failure]
    B --> C{Healable?}
    C -->|Yes| D[Identify Failing File]
    C -->|No| E[Post Diagnostic Comment]
    D --> F[Fetch File from GitHub]
    F --> G[Claude Generates Full File Fix]
    G --> H[Create Branch: gitwire/heal/runId]
    H --> I[Commit Fixed File]
    I --> J[Open Pull Request]

Full-File Generation

GitWire uses full-file generation (not search/replace):

  1. Fetch the entire failing file via GitHub Contents API
  2. Send file content + error context to Claude
  3. Claude returns the complete corrected file
  4. GitWire commits the full file, replacing the original

Why full-file?

Search/replace patches suffer from truncation issues with large files. Full-file generation is more reliable and handles whitespace changes correctly.

Branch Naming

Patch branches follow the pattern:

gitwire/heal/{github_run_id}

Example: gitwire/heal/12345678901

PR Content

The PR includes:

Title: fix(ci): resolve {failure_type} in {file_path}

Body:

  • 🔍 Root cause: The diagnosed reason for failure
  • 🛠️ Fix applied: What was changed
  • 📊 Confidence: high / medium / low
  • 🤖 Generated by GitWire CI Healing

Pre-Checks Before Committing

Before committing a fix, GitWire validates:

CheckRule
Non-emptyFile must not be empty after fix
Line deltaMust not add > 500 lines or remove > 80% of content
SyntaxBasic bracket/paren balance check

If any check fails, the heal is marked as failed and no PR is created.

Confidence Levels

LevelCriteria
highSimple fix (lint, format), single file, clear error
mediumMulti-cause, partial file fetch, medium complexity
lowComplex error, multiple files, uncertain diagnosis

Tracking

All patch PRs are tracked in the heal_prs table:

ColumnDescription
ci_run_idReference to the CI run
github_pr_numberPR number on GitHub
heal_branchBranch name used
failure_typeCategory of the failure
files_changedArray of modified file paths
statusopen, merged, or closed

Worker Reference

See CI Heal Worker for implementation details.

Heal History

Released under the MIT License.