Skip to content

Latest commit

Β 

History

History
119 lines (91 loc) Β· 3.53 KB

File metadata and controls

119 lines (91 loc) Β· 3.53 KB

Sentinel: The AI Pull Request Reviewer

This link shows a comment made to a PR by our bot: Sentinel-PR/sentinel-sandbox#4 (review)

πŸ€– An AI-powered GitHub PR review bot using LangGraph multi-agent workflows

Sentinel automatically reviews GitHub pull requests by analyzing code changes and posting structured feedback. It behaves like a senior reviewer, focusing on correctness, security, and maintainability.

πŸ—οΈ Architecture

GitHub Webhook β†’ API Service β†’ Redis Queue β†’ Worker β†’ LangGraph β†’ GitHub Review
                     ↓              ↓           ↓
                PostgreSQL β†β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Services:

  • API Service (FastAPI) - Receives webhooks, verifies signatures, enqueues jobs
  • Worker Service - Consumes jobs, runs AI review workflow, posts reviews
  • PostgreSQL - Job tracking, idempotency, audit trail
  • Redis - Job queue, locks, SHA coalescing

πŸš€ Quick Start

Prerequisites

  • Docker & Docker Compose
  • Python 3.11+
  • GitHub App credentials
  • OpenAI API key

Setup

  1. Clone and configure:

    git clone https://github.com/your-org/sentinel.git
    cd sentinel
    cp .env.example .env
    # Edit .env with your credentials
  2. Start services:

    docker compose up -d
  3. Verify:

    curl http://localhost:8000/health

Local Development

# Install dependencies
pip install -e ".[dev]"

# Run API service
uvicorn api.main:app --reload

# Run worker (separate terminal)
python -m worker.main

# Run tests
pytest

πŸ“ Project Structure

sentinel/
β”œβ”€β”€ api/                    # FastAPI webhook service
β”‚   β”œβ”€β”€ routes/             # Endpoint handlers
β”‚   β”œβ”€β”€ services/           # Business logic
β”‚   └── models/             # Pydantic schemas
β”œβ”€β”€ worker/                 # Background worker
β”‚   β”œβ”€β”€ github/             # GitHub API client
β”‚   β”œβ”€β”€ workflow/           # LangGraph review engine
β”‚   └── output/             # Review publishing
β”œβ”€β”€ shared/                 # Shared utilities
β”‚   β”œβ”€β”€ db/                 # Database models & session
β”‚   └── queue/              # Redis client
└── tests/                  # Test suite

🧠 LangGraph Workflow

Parse Diff β†’ Classify PR β†’ Fetch Context
                              ↓
            β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
            ↓                 ↓                 ↓
   Correctness Agent   Security Agent   Maintainability Agent
            ↓                 ↓                 ↓
            β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                              ↓
                         Aggregator β†’ Guardrails β†’ Post Review

πŸ“‹ Configuration

Key environment variables (see .env.example):

Variable Description
GITHUB_APP_ID GitHub App ID
GITHUB_WEBHOOK_SECRET Webhook signature secret
OPENAI_API_KEY OpenAI API key for LLM
DATABASE_URL PostgreSQL connection string
REDIS_URL Redis connection string

πŸ“– Documentation

πŸ“œ License

MIT License - see LICENSE