Quality gate for GitHub pull requests that checks whether the PR author understands the code they are proposing.
- receives GitHub PR webhook events (
opened,synchronize,reopened) - creates a comprehension session per PR head SHA
- fetches changed files from GitHub and normalizes diff metadata
- loads a versioned policy from YAML (
policies/generic_v1.yaml) - generates 1-2 comprehension questions from the diff
- provides a minimal answer UI (
/sessions/{id}/ui) - evaluates answers (stub evaluator by default, LiteLLM provider included)
- computes deterministic pass/fail gate decision from policy thresholds
- posts GitHub check-run + PR comment with constructive feedback and ideal answers
- stores sessions, questions, answers, evaluations, decisions in Postgres
GitHub PR Event -> /webhooks/github -> Orchestration Service
-> Diff Service
-> Policy Service
-> Question Service (LLM provider)
Author UI /sessions/{id}/ui ---------> /sessions/{id}/answers
-> Evaluation Service (LLM provider)
-> Decision Service
-> Reporting Service
-> GitHub check run + comment
-> Postgres persistence
app/
api/routes/ # HTTP routes
core/ # settings + webhook signature verification
domain/services/ # orchestration, policy, diff, q/eval, decision, reporting
integrations/github/ # github mapper/client/reporter
integrations/llm/ # provider abstraction + implementations
persistence/ # SQLAlchemy db/models
web/templates/ # minimal author UI
policies/generic_v1.yaml # versioned policy file
.github/workflows/ # sample GitHub Action trigger
- Copy environment template:
cp .env.example .env- Set required values in
.env:
GITHUB_WEBHOOK_SECRET(shared secret with GitHub Action/webhook)GITHUB_TOKEN(token with checks + PR comment permissions)- Optional (LiteLLM):
LLM_PROVIDER=litellm,LLM_MODEL=<provider/model>,LLM_API_KEY=... - Example OpenAI model:
LLM_MODEL=openai/gpt-4o-mini - Example Mistral model:
LLM_MODEL=mistral/mistral-small-latest
- Start services:
docker compose up --build- Health check:
curl http://localhost:8000/healthUse .github/workflows/pr_gate_trigger.yml in your target repository and set secrets:
PR_GATE_WEBHOOK_URL(e.g.https://your-host/webhooks/github)PR_GATE_WEBHOOK_SECRET(must match backend.env)
Then mark pr-comprehension-gate as a required status check in branch protection.
POST /webhooks/githubGET /sessions/{session_id}POST /sessions/{session_id}/answersGET /sessions/{session_id}/resultGET /sessions/{session_id}/uiGET /policiesGET /health
- Default evaluator is deterministic stub logic for local development.
- LiteLLM integration expects JSON-only outputs and is intentionally isolated behind provider methods.
- Current implementation creates DB schema at app startup (
create_all) for MVP speed.