Skip to content

Commit 3f03b74

Browse files
author
Harmeet Singh
committed
feat: implement rag-optimize-ci MVP with CI gating and provider adapters
0 parents  commit 3f03b74

28 files changed

Lines changed: 1658 additions & 0 deletions
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
name: Bug report
3+
about: Report a defect in rag-optimize-ci
4+
title: "[bug] "
5+
labels: bug
6+
assignees: ""
7+
---
8+
9+
## Summary
10+
11+
## Steps to reproduce
12+
13+
## Expected behavior
14+
15+
## Actual behavior
16+
17+
## Environment
18+
- Python:
19+
- OS:
20+
- Command/config used:
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
name: Feature request
3+
about: Propose a new feature for rag-optimize-ci
4+
title: "[feat] "
5+
labels: enhancement
6+
assignees: ""
7+
---
8+
9+
## Problem
10+
11+
## Proposed solution
12+
13+
## Alternatives considered
14+
15+
## Acceptance criteria

.github/workflows/ci.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: ci
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
jobs:
8+
test:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v4
12+
13+
- uses: actions/setup-python@v5
14+
with:
15+
python-version: "3.11"
16+
17+
- name: Unit tests
18+
run: python -m unittest discover -s tests -p 'test_*.py'
19+
20+
sample-run:
21+
runs-on: ubuntu-latest
22+
steps:
23+
- uses: actions/checkout@v4
24+
25+
- uses: actions/setup-python@v5
26+
with:
27+
python-version: "3.11"
28+
29+
- name: Run sample
30+
run: |
31+
python -m ragopt.cli run --config examples/ragopt.yaml --report artifacts/report.md
32+
test -f artifacts/report.md

.github/workflows/release.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
jobs:
9+
verify:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
- uses: actions/setup-python@v5
14+
with:
15+
python-version: '3.11'
16+
- name: Test
17+
run: python -m unittest discover -s tests -p 'test_*.py'

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
__pycache__/
2+
.pytest_cache/
3+
.venv/
4+
artifacts/
5+
*.pyc
6+
*.pyo
7+
*.pyd
8+
.DS_Store

ARCHITECTURE.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Architecture
2+
3+
## Flow
4+
5+
1. Load `ragopt.yaml`.
6+
2. Load benchmark dataset.
7+
3. For each candidate:
8+
- run generation over each query
9+
- compute per-case metrics
10+
- aggregate metrics
11+
- apply hard constraints
12+
4. Rank candidates by weighted score.
13+
5. Persist JSON artifact + markdown report.
14+
6. Optionally post markdown to GitHub PR.
15+
16+
## Modules
17+
18+
- `ragopt/models.py`: schema and result types
19+
- `ragopt/config.py`: config and dataset loading
20+
- `ragopt/adapters.py`: generation provider abstraction
21+
- `ragopt/metrics.py`: metric and scoring functions
22+
- `ragopt/engine.py`: orchestration and comparison
23+
- `ragopt/reporting.py`: markdown outputs
24+
- `ragopt/github.py`: PR comment helper
25+
- `ragopt/cli.py`: public command interface
26+
27+
## Extension points
28+
29+
- Add providers in `adapters.py`.
30+
- Add new metrics in `metrics.py` and wire into engine.
31+
- Add policy checks in `engine.py` compare/run paths.

CASE_STUDY.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Case Study: rag-optimize-ci
2+
3+
## Problem
4+
Teams building RAG apps ship prompt/model/retrieval changes quickly but lack a practical CI gate for quality, latency, and cost tradeoffs.
5+
6+
## Solution
7+
`rag-optimize-ci` runs candidate configs against a benchmark dataset and returns:
8+
9+
- candidate scorecard
10+
- recommendation with constraints
11+
- regression verdict vs baseline
12+
13+
## Architecture
14+
15+
- `ragopt/config.py`: config + dataset loading
16+
- `ragopt/adapters.py`: provider abstraction
17+
- `ragopt/metrics.py`: quality, groundedness, citation, latency/cost scoring
18+
- `ragopt/engine.py`: run pipeline, recommendation, regression comparison
19+
- `ragopt/cli.py`: run/compare/recommend interfaces
20+
- `action.yml`: GitHub Action integration
21+
22+
## Core tradeoffs
23+
24+
- Started with deterministic metrics and mock adapter to ensure reliability and reproducibility.
25+
- Deferred complex online judge models and dashboards until CI workflow was complete.
26+
27+
## Impact goals
28+
29+
- Reduce bad RAG releases by catching regressions in PR checks.
30+
- Standardize model/prompt/retriever decisions with transparent scoring.
31+
- Enable lean teams to enforce quality without heavy platform investment.

CONTRIBUTING.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Contributing
2+
3+
## Setup
4+
5+
```bash
6+
python3 -m unittest discover -s tests -p 'test_*.py'
7+
```
8+
9+
## Development workflow
10+
11+
1. Open an issue describing the bug/feature.
12+
2. Add or update tests first where possible.
13+
3. Keep PRs focused and small.
14+
4. Ensure tests pass before opening PR.
15+
16+
## Good first issues
17+
18+
- Add real YAML parser support.
19+
- Add OpenAI adapter behind env vars.
20+
- Add richer citation matching (semantic not index-only).
21+
- Add configurable latency percentile scoring.
22+
23+
## Code style
24+
25+
- Type hints for public functions.
26+
- Keep functions small and deterministic.
27+
- Add comments only where logic is non-obvious.

DECISIONS.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Design Decisions
2+
3+
## 1. CI-first before dashboard
4+
Decision: prioritize GitHub Action + CLI over web UI.
5+
Reason: strongest immediate value for startup teams and highest hiring signal.
6+
7+
## 2. RAG-only scope
8+
Decision: optimize only RAG QA workflows in v1.
9+
Reason: clear product identity beats broad generic evaluation.
10+
11+
## 3. Weighted score + hard constraints
12+
Decision: rank with weighted score after enforcing quality/latency/cost thresholds.
13+
Reason: mirrors real shipping criteria where safety rails must be non-negotiable.
14+
15+
## 4. Mock adapter in v1
16+
Decision: include deterministic mock provider first.
17+
Reason: keeps project reproducible, low-cost, and testable in CI without external API keys.
18+
19+
## 5. JSON artifacts as source of truth
20+
Decision: persist run artifacts as JSON in `artifacts/`.
21+
Reason: easy regression diffing, reproducibility, and auditability.

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2026 Harmeet Singh
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

0 commit comments

Comments
 (0)