Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
42186fb
add: gh actions workflow tests
devarshishimpi May 15, 2026
5961832
Merge pull request #7 from devarshishimpi/bug/setup-codra-tests-in-gi…
devarshishimpi May 15, 2026
cf25453
feat: add resumable review queue processing
devarshishimpi May 19, 2026
35d06d5
Merge branch 'dev' into bug/fix-codra-review-taking-longer-than-expected
devarshishimpi May 19, 2026
f89d03e
add: retry mechanism for transient model provider failures
devarshishimpi May 21, 2026
e642bb6
perf: optimize review processing with prompt compaction and error rec…
devarshishimpi May 22, 2026
8556b82
Merge pull request #11 from devarshishimpi/bug/fix-codra-review-takin…
devarshishimpi May 22, 2026
d0c2ee9
add: improve job id status ui
devarshishimpi May 23, 2026
fff9b05
add: improve sonner and job status ui
devarshishimpi May 23, 2026
80de33b
refactor: improve model error handling and webhook routing
devarshishimpi May 24, 2026
92507cc
add: bump model duration for slow requests
devarshishimpi May 24, 2026
fb1ac18
fix: synthesize inconclusive reviews for cf reasoning-only responses …
devarshishimpi May 24, 2026
09ac6bf
add: improve error reporting and better date parsing and null safety …
devarshishimpi May 24, 2026
dfc6372
add: optimize job polling with etag caching, adaptive delays, and str…
devarshishimpi May 24, 2026
2b2df7d
add: improve model resilience and increase token limits
devarshishimpi May 25, 2026
cc479e3
Merge pull request #12 from devarshishimpi/bug/file-review-status-bar…
devarshishimpi May 25, 2026
e996a54
feat: implement dashboard-managed LLM provider system
devarshishimpi May 25, 2026
ff77850
refactor: label management and add provider validation
devarshishimpi May 25, 2026
0293b36
add: consolidate LLM provider management and make rate limits optional
devarshishimpi May 26, 2026
5eb8c1a
fix: db migration assistant on existing dbs
devarshishimpi May 26, 2026
04372bc
add: consolidate LLM provider management and make rate limits optional
devarshishimpi May 26, 2026
426bda0
fix: cleanup migrations, improve API robustness, and enhance settings UX
devarshishimpi May 26, 2026
1b58039
add: improve overall settings ui
devarshishimpi Jun 1, 2026
825e2f1
refactor: move job step completion to database layer
devarshishimpi Jun 2, 2026
b49a816
fix: database migrations, API methods, and label removal logic
devarshishimpi Jun 2, 2026
aa7a7d5
Merge pull request #13 from devarshishimpi/feature/support-openai-com…
devarshishimpi Jun 2, 2026
720bc18
add: automated cf setup configuration script
devarshishimpi Jun 2, 2026
6d361b5
add: redesign UI with updated design system and version display
devarshishimpi Jun 7, 2026
b5361fd
refactor: lazy load pages + redesign auth pages
devarshishimpi Jun 7, 2026
fa71068
refactor: extract page header actions and improve dark mode theming
devarshishimpi Jun 7, 2026
5379dfc
fix: handle literal \n in APP_PRIVATE_KEY and deduplicate updates-ema…
devarshishimpi Jun 7, 2026
5174d49
fix: unescape literal \n sequences when reading secrets from .dev.vars
devarshishimpi Jun 7, 2026
1aeaab2
refactor: color system, error handling, caching, and migration improv…
devarshishimpi Jun 7, 2026
bc0e435
Merge pull request #17 from devarshishimpi/feature/streamline-cloudfl…
devarshishimpi Jun 7, 2026
300c1c7
add: bump max processed files from 15 to 100
devarshishimpi Jun 7, 2026
db8e2b6
feat: enhance job processing and review configurations with severity …
devarshishimpi Jun 7, 2026
b4a98d0
fix: enhance model handling and error logging in API routes and confi…
devarshishimpi Jun 7, 2026
16dda1a
refactor: database scripts and models for improved performance and er…
devarshishimpi Jun 8, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 22 additions & 43 deletions .dev.vars.example
Original file line number Diff line number Diff line change
@@ -1,52 +1,31 @@
# ──────────────────────────────────────────────────────────────────────────────
# Codra Environment Configuration Example
# Copy this file to .dev.vars for local development: cp .dev.vars.example .dev.vars
# ──────────────────────────────────────────────────────────────────────────────
# Codra local development environment example
# Copy this file to .dev.vars for local development.
# Keep real secrets only in .dev.vars or your deployment secret store.

# --- GitHub App Authentication ---
# Create at: https://github.com/settings/apps
APP_PRIVATE_KEY="-----BEGIN RSA PRIVATE KEY-----\nREPLACE_WITH_YOUR_GITHUB_APP_PRIVATE_KEY_CONTENT\n-----END RSA PRIVATE KEY-----"
GITHUB_APP_ID="REPLACE_WITH_YOUR_APP_ID"
GITHUB_APP_SLUG="REPLACE_WITH_YOUR_APP_SLUG"
GITHUB_APP_WEBHOOK_SECRET="REPLACE_WITH_YOUR_WEBHOOK_SECRET"
# --- Integration tests ---
TEST_DATABASE_URL="postgresql://user:password@localhost:5432/codra"

# --- Dashboard OAuth (GitHub) ---
# Use the same GitHub App's Client ID/Secret or a separate OAuth App
# --- LLM provider config encryption ---
LLM_CONFIG_ENCRYPTION_KEY="REPLACE_WITH_A_LONG_RANDOM_ENCRYPTION_KEY"

# --- GitHub App and OAuth ---
GITHUB_APP_WEBHOOK_SECRET="REPLACE_WITH_YOUR_WEBHOOK_SECRET"
GITHUB_APP_ID="REPLACE_WITH_YOUR_APP_ID"
GITHUB_CLIENT_ID="REPLACE_WITH_YOUR_CLIENT_ID"
GITHUB_CLIENT_SECRET="REPLACE_WITH_YOUR_CLIENT_SECRET"
AUTH_CALLBACK_URL="http://localhost:8787/auth/github/callback"

# --- Authorization ---
# Comma-separated list of GitHub usernames allowed to access the dashboard
DASHBOARD_ALLOWED_USERS="username1,username2"

# --- AI Intelligence (Gemini) ---
# Generate at: https://aistudio.google.com/app/apikey
GEMINI_API_KEY="REPLACE_WITH_YOUR_GEMINI_API_KEY"

# --- Database Connections ---

# 1. Local Development (Used by 'wrangler dev' for the HYPERDRIVE binding)
# This usually points to a local Postgres instance or a dev branch in Neon.
CLOUDFLARE_HYPERDRIVE_LOCAL_CONNECTION_STRING_HYPERDRIVE="postgresql://user:password@localhost:5432/codra_dev"

# 2. Migrations (Used by 'npm run migrate')
# This script runs via Node.js and needs a direct connection to the DB you want to migrate.
DATABASE_URL="postgresql://user:password@localhost:5432/codra_dev"

# 3. Integration Tests (Used by 'npm run test')
# MUST be a separate database to avoid data loss during test sweeps.
TEST_DATABASE_URL="postgresql://user:password@localhost:5432/codra_test"
APP_PRIVATE_KEY="-----BEGIN RSA PRIVATE KEY-----\nREPLACE_WITH_YOUR_GITHUB_APP_PRIVATE_KEY_CONTENT\n-----END RSA PRIVATE KEY-----"

# --- Cloudflare DLQ / Queue Management (Required) ---
# Required for DLQ inspection, replay, and purge via /api/dlq
# Create or identify the DLQ queue, then set CF_DLQ_ID to that queue's ID.
# Generate token at https://dash.cloudflare.com/profile/api-tokens (Queues:Edit permission)
CF_API_TOKEN="REPLACE_WITH_CLOUDFLARE_API_TOKEN"
# --- Cloudflare API ---
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Potential removal of required environment variables

Several variables previously marked as required or used for configuration have been removed from the example file: 'CF_DLQ_ID', 'BOT_USERNAME', and 'GITHUB_APP_SLUG'. Specifically, the comments on lines 19-20 still mention 'DLQ actions', but 'CF_DLQ_ID' (previously described as 'Required for DLQ inspection') is missing. If these are still needed by the application, their removal from the template will hinder local development setup.

Suggested change
# --- Cloudflare API ---
Keep CF_DLQ_ID="REPLACE_WITH_YOUR_DLQ_QUEUE_ID" in the Cloudflare API section if it is still required for DLQ functionality.

# Required permissions: Queues Edit for DLQ actions, Workers AI Read for
# Cloudflare model catalog discovery.
CF_ACCOUNT_ID="REPLACE_WITH_YOUR_CLOUDFLARE_ACCOUNT_ID"
CF_DLQ_ID="REPLACE_WITH_YOUR_DLQ_QUEUE_ID"
CF_API_TOKEN="REPLACE_WITH_CLOUDFLARE_API_TOKEN"

# --- Application Settings ---
# --- Application URLs and mode ---
APP_URL="http://localhost:8787"
BOT_USERNAME="codra-app-dev"
AUTH_CALLBACK_URL="http://localhost:8787/auth/github/callback"
ENVIRONMENT="development"

# --- Database connections ---
DATABASE_URL="postgresql://user:password@localhost:5432/codra_dev"
CLOUDFLARE_HYPERDRIVE_LOCAL_CONNECTION_STRING_HYPERDRIVE="postgresql://user:password@localhost:5432/codra_dev"
20 changes: 20 additions & 0 deletions .env.test.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Codra test environment example.
# Copy to .env.test for local tests. These values are fake and must not be
# reused for production, staging, or any real external service.

GITHUB_APP_SLUG="codra-test-app"
GITHUB_APP_WEBHOOK_SECRET="fake-webhook-secret"

GITHUB_CLIENT_ID="fake-dashboard-client-id"
GITHUB_CLIENT_SECRET="fake-dashboard-client-secret"
AUTH_CALLBACK_URL="https://codra.test/auth/github/callback"
DASHBOARD_ALLOWED_USERS="devarshishimpi"

APP_URL="https://codra.test"
BOT_USERNAME="codra-test-app"
LLM_CONFIG_ENCRYPTION_KEY="fake-local-llm-config-encryption-key"

# Required. Must point at a disposable Postgres database because tests reset and
# write data while running.
DATABASE_URL="postgresql://postgres:postgres@127.0.0.1:5432/codra_test"
TEST_DATABASE_URL="postgresql://postgres:postgres@127.0.0.1:5432/codra_test"
35 changes: 31 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
name: Code Quality

on:
workflow_dispatch:
push:
branches:
- main
pull_request:
branches:
- main
types:
- opened
- synchronize
- reopened
- ready_for_review

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand All @@ -16,6 +18,31 @@ jobs:
verify:
name: Verify Stability
runs-on: ubuntu-latest
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Potential race condition during service initialization

Since the official Postgres Docker image does not include a built-in HEALTHCHECK instruction and the provided 'options' are invalid, GitHub Actions will consider the service 'started' as soon as the container is created. This creates a race condition where the 'verify' job steps may begin executing and attempt to connect to the database before the Postgres engine has finished initializing, leading to 'connection refused' errors.

services:
postgres:
image: postgres:16
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: codra_test
ports:
- 5432:5432
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Invalid Docker run options in service configuration

The 'options' field in GitHub Actions services passes arguments directly to the 'docker run' command. The flags '--health-cmd', '--health-interval', '--health-timeout', and '--health-retries' are not valid arguments for 'docker run'. These flags are used in Dockerfiles or Docker Compose files, but not via the 'docker run' CLI. This configuration will likely cause the Postgres service to fail to start or result in the flags being ignored.

Suggested change
- 5432:5432
# Remove the options block and instead add a 'Wait for DB' step in the steps section:
- name: Wait for database
run: while ! pg_isready -h localhost -p 5432 -U postgres; do sleep 2; done

options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
env:
DATABASE_URL: postgresql://postgres:postgres@127.0.0.1:5432/codra_test
TEST_DATABASE_URL: postgresql://postgres:postgres@127.0.0.1:5432/codra_test
GITHUB_APP_SLUG: codra-test-app
GITHUB_APP_WEBHOOK_SECRET: fake-webhook-secret
GITHUB_CLIENT_ID: fake-dashboard-client-id
GITHUB_CLIENT_SECRET: fake-dashboard-client-secret
AUTH_CALLBACK_URL: https://codra.test/auth/github/callback
APP_URL: https://codra.test
DASHBOARD_ALLOWED_USERS: devarshishimpi
BOT_USERNAME: codra-test-app

steps:
- name: Checkout repository
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ web_modules/
.env
.env.*
!.env.example
!.env.test.example

# parcel-bundler cache (https://parceljs.org/)
.cache
Expand Down
9 changes: 6 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ cp .dev.vars.example .dev.vars
You will need to set up:
- A GitHub App (for webhooks/checks).
- A GitHub OAuth App (for dashboard authentication).
- A Gemini API Key.
- `LLM_CONFIG_ENCRYPTION_KEY` for encrypting dashboard-managed provider API keys.
- LLM providers and model credentials from the Settings dashboard.
- A Hyperdrive local connection string for `wrangler dev`.
- A direct `DATABASE_URL` for migrations.

Expand All @@ -52,10 +53,12 @@ npm run dev

## 🧪 Testing

We use **Vitest** for unit and integration testing. `npm test` runs the non-database tests by default and automatically enables DB integration tests when `TEST_DATABASE_URL` points at a disposable Postgres database.
We use **Vitest** for unit and integration testing. `npm test` requires a disposable Postgres database, runs migrations against it, and then runs the full test suite.

The test runner loads `.env.test`, `.env.local`, `.env`, `.dev.vars`, and then `.env.test.example`. Override `TEST_DATABASE_URL` in one of the private env files when your local test database does not match the example URL.

```bash
# Run all tests
# Run the full test suite
npm test

# Run tests in watch mode
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@

Codra listens to GitHub pull request events, runs AI-powered review jobs, posts inline findings back to the PR, and gives you a dashboard to inspect jobs, repositories, model routing, review history, and failed queue runs.

> **Beta** -- Codra is under active development. Expect rough edges, missing features, and breaking changes between releases. Feedback and bug reports are welcome via [GitHub Issues](https://github.com/devarshishimpi/codra/issues).

## Why Codra

- **Own the whole review loop**: Run the GitHub App, Cloudflare Worker, queue, database, model credentials, and dashboard under your own control.
Expand All @@ -47,7 +49,7 @@ Codra listens to GitHub pull request events, runs AI-powered review jobs, posts
- Dead letter queue inspection, replay, and purge workflows
- GitHub OAuth dashboard authentication
- External PostgreSQL storage through Cloudflare Hyperdrive
- Google Gemini and Cloudflare Workers AI model providers
- Dashboard-managed LLM providers for OpenAI, OpenRouter, Anthropic, Google, and Cloudflare models
- Repository settings for labels, skipped globs, custom rules, and model routing

## How It Works
Expand All @@ -65,7 +67,7 @@ Codra listens to GitHub pull request events, runs AI-powered review jobs, posts
- **Dashboard**: React, Vite, Tailwind CSS, Radix UI, Recharts
- **Data**: PostgreSQL, Cloudflare Hyperdrive, Cloudflare KV
- **Queues**: Cloudflare Queues with DLQ workflows
- **Models**: Google Gemini and Cloudflare Workers AI
- **Models**: OpenAI, OpenRouter, Anthropic, Google, and Cloudflare providers
- **GitHub**: GitHub App webhooks, checks, reviews, and OAuth
- **Quality**: TypeScript, Zod, Vitest, Playwright browser tests

Expand Down
Loading
Loading