Autonomous Code Fix Pipeline

AI ↔ AI

CI fails, AI diagnoses and fixes, CI re-runs, human merges.

6 nodes · 6 edgesdevops
agentcicdcli
Visual
CI Failure Detectedevent

Webhook triggers on failed CI run with test output attached.

sequentialAI Error Diagnosis
AI Error Diagnosisagent

Analyze test output, stack trace, and recent diff to identify root cause.

sequentialAI Generate Fix
AI Generate Fixagent

Write code patch to resolve the identified failure.

sequentialApply Patch
Apply Patchcli

git apply the generated diff to the working branch.

sequentialRe-run CI
Re-run CIcicd

Execute full test suite against the patched code.

conditionalHuman Merge Approval
fallbackAI Error Diagnosis
Human Merge Approvalhuman

Engineer reviews AI-generated fix before merging to main.

uc-auto-code-fix.osop.yaml
osop_version: "1.0"
id: "auto-code-fix"
name: "Autonomous Code Fix Pipeline"
description: "CI fails, AI diagnoses and fixes, CI re-runs, human merges."

nodes:
  - id: "ci_fail"
    type: "event"
    name: "CI Failure Detected"
    description: "Webhook triggers on failed CI run with test output attached."

  - id: "diagnose"
    type: "agent"
    subtype: "llm"
    name: "AI Error Diagnosis"
    description: "Analyze test output, stack trace, and recent diff to identify root cause."

  - id: "generate_fix"
    type: "agent"
    subtype: "llm"
    name: "AI Generate Fix"
    description: "Write code patch to resolve the identified failure."
    security:
      risk_level: "medium"

  - id: "apply_fix"
    type: "cli"
    subtype: "script"
    name: "Apply Patch"
    description: "git apply the generated diff to the working branch."

  - id: "rerun_ci"
    type: "cicd"
    subtype: "test"
    name: "Re-run CI"
    description: "Execute full test suite against the patched code."
    retry_policy:
      max_attempts: 2

  - id: "human_merge"
    type: "human"
    subtype: "review"
    name: "Human Merge Approval"
    description: "Engineer reviews AI-generated fix before merging to main."
    security:
      approval_gate: true

edges:
  - from: "ci_fail"
    to: "diagnose"
    mode: "sequential"
  - from: "diagnose"
    to: "generate_fix"
    mode: "sequential"
  - from: "generate_fix"
    to: "apply_fix"
    mode: "sequential"
  - from: "apply_fix"
    to: "rerun_ci"
    mode: "sequential"
  - from: "rerun_ci"
    to: "human_merge"
    mode: "conditional"
    when: "ci.passed == true"
  - from: "rerun_ci"
    to: "diagnose"
    mode: "fallback"
    label: "Fix didn't work, try again"