Skip to content

sharmarohit0013/reforge

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SAIGE - Self-Adaptive Intelligent GitHub Engineer

🧠 Deep Agent System for Autonomous CI/CD Healing

🔥 What Makes This Different

Most hackathon teams build: "AI that explains logs"

We built: AI that changes reality

The Architecture

┌──────────────────────┐
│      React UI        │  ← Visualization + Trigger
└──────────┬───────────┘
           │ HTTP
┌──────────▼────────────────────────┐
│   AI Backend (LangGraph System)   │  ← Deep Agent Brain
│                                   │
│  • Supervisor Agent               │
│  • Failure Detection Agent        │
│  • Root Cause Agent               │
│  • Fix Generator Agent            │
│  • Validation Agent               │
│  • Learning Agent                 │
└──────────┬────────────────────────┘
           │
┌──────────▼─────────┐
│     Postgres       │  ← Organizational Memory
│ Memory + Learning  │
└────────────────────┘

🎯 Key Concept

LangGraph = Operating System
Agents = Processes (not containers)

Agents are runtime graphs that live in the backend, not separate services.

🚀 Quick Start

Prerequisites

  • Docker & Docker Compose
  • OpenAI API Key
  • GitHub Token (optional, for webhook integration)

Setup

  1. Clone and navigate to the project:
cd reforge
  1. Configure environment variables:

Backend:

cp backend/.env.example backend/.env
# Edit backend/.env and add your OPENAI_API_KEY

UI:

cp ui/.env.example ui/.env
# Default backend URL is already set
  1. Start the system:
docker compose up --build

This will start:

  • Postgres on port 5432
  • Backend on port 8000
  • UI on port 3000
  1. Access the dashboard:
http://localhost:3000

🧠 Deep Agent System

Agent Flow

Supervisor Agent
        │
        ▼
Failure Detection Agent
        │
        ▼
Root Cause Agent
        │
        ▼
Fix Generator Agent
        │
        ▼
Validation Agent
        │
        ├── success → Learning Agent
        └── fail → Retry Reasoning Loop

What Each Agent Does

  1. Supervisor Agent: Orchestrates the entire healing process, decides next steps
  2. Failure Detection Agent: Categorizes failures and assesses severity
  3. Root Cause Agent: Performs deep analysis to find the actual root cause
  4. Fix Generator Agent: Creates specific fixes (YAML, config, code changes)
  5. Validation Agent: Validates if the fix will work before applying
  6. Learning Agent: Extracts patterns and updates knowledge base

📊 Database Schema

The system maintains organizational memory through:

  • pipeline_runs - All pipeline executions
  • failures - Detected failures with context
  • applied_fixes - Fixes that were applied
  • agent_reasoning - Complete thought process of agents
  • success_metrics - Success rates and healing metrics
  • learned_patterns - Knowledge base of patterns
  • generated_pipelines - AI-generated pipeline configs

🎮 Demo Flow

  1. Open the dashboard at http://localhost:3000
  2. Click "🔥 Trigger Test Healing"
  3. Watch the Deep Agent System:
    • Detect the failure
    • Analyze root cause
    • Generate a fix
    • Validate the solution
    • Learn from the experience
  4. Check the reasoning chain in browser console
  5. View metrics and agent status on dashboard

🔌 GitHub Integration

Webhook Setup (Optional)

  1. Go to your GitHub repository settings
  2. Add webhook: http://your-server:8000/api/webhook/github
  3. Select events: Workflow runs
  4. Add webhook secret to backend/.env

When a workflow fails:

  • GitHub sends webhook
  • SAIGE detects failure
  • Healing process starts automatically
  • Fix is applied
  • Workflow is retriggered

📁 Project Structure

reforge/
├── docker-compose.yml          # 3-container orchestration
├── backend/
│   ├── main.py                 # Deep Agent System (ONLY Python file)
│   ├── Dockerfile
│   ├── requirements.txt
│   └── .env.example
├── ui/
│   ├── src/
│   │   ├── pages/
│   │   │   └── Dashboard.tsx   # Main dashboard
│   │   ├── App.tsx
│   │   └── main.tsx
│   ├── Dockerfile
│   ├── package.json
│   └── vite.config.ts
└── db/
    └── init.sql                # Database schema

🎯 API Endpoints

Backend (Port 8000)

  • GET / - System status
  • GET /health - Health check
  • POST /api/heal - Trigger healing process
  • POST /api/webhook/github - GitHub webhook receiver
  • GET /api/pipelines - List pipeline runs
  • GET /api/failures - List failures
  • GET /api/learnings - List learned patterns
  • GET /api/metrics - Get success metrics

🧪 Testing

Manual Test

curl -X POST http://localhost:8000/api/heal \
  -H "Content-Type: application/json" \
  -d '{
    "failure": {
      "run_id": "test-123",
      "repository": "demo/test-repo",
      "branch": "main",
      "commit_sha": "abc123",
      "stage": "build",
      "error_message": "Build failed: npm install error",
      "log_snippet": "Error: Cannot find module \"express\"",
      "timestamp": "2024-01-01T00:00:00Z"
    },
    "auto_apply": true
  }'

🏆 What Makes This Hackathon-Winning

  1. Not a chatbot - It's an autonomous system that takes action
  2. Deep Agent Architecture - Real LangGraph implementation, not simple chaining
  3. Organizational Memory - Learns and improves over time
  4. Event-Driven - Webhook integration, not polling
  5. Production-Ready - Proper database, containerization, error handling

🔧 Development

Backend Development

cd backend
pip install -r requirements.txt
python main.py

UI Development

cd ui
npm install
npm run dev

Database Access

docker exec -it saige_postgres psql -U saige -d cicd_ai

📝 Environment Variables

Backend (.env)

OPENAI_API_KEY=your_key_here
GITHUB_TOKEN=your_token_here
GITHUB_WEBHOOK_SECRET=your_secret_here
DATABASE_URL=postgresql://saige:saige@postgres:5432/cicd_ai

UI (.env)

VITE_BACKEND_URL=http://localhost:8000

🎓 Key Learnings

This system demonstrates:

  • LangGraph for agent orchestration
  • Event-driven architecture with webhooks
  • Persistent memory with PostgreSQL
  • Learning systems that improve over time
  • Real-world DevOps automation

🚧 Future Enhancements

  • Multi-repository learning
  • Advanced pattern recognition with embeddings
  • Slack/Discord notifications
  • Pipeline generation from natural language
  • A/B testing of fixes
  • Cost optimization recommendations

📄 License

MIT License - See LICENSE file

🤝 Contributing

This is a hackathon project, but contributions are welcome!


Built with 🧠 by the SAIGE Team

Autonomous DevOps Intelligence - Not just explaining logs, but changing reality

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors