eval scripts 자동화 가이드
ADR 0041 (두 RAG 결합) + 후속 #17·#18·#19 (한 줄 본질 자가 회귀 ship) 후속. 다음 3 eval scripts 를 Cloud Scheduler + Cloud Functions 경유로 매일/주간 자동 실행한다.
scripts/eval-rag-merge.ts— Platform RAG retrieval recall/precision (기존)scripts/eval-tenant-rag-self.ts— Tenant RAG leave-one-out 자가 회귀 (후속 #18 신설)scripts/eval-case-classification-gemini.ts— Gemini 사건 분류 정확도 (후속 #19 신설)
1. 현 상태 (2026-05-17)
- 3 스크립트 모두 수동 실행 —
NODE_PATH=apps/web/node_modules pnpm exec tsx scripts/eval-*.ts --apply - 결과는
tenants/demo-firm-memory/ragMergeQuality/{dateKey}에 저장 (dateKey suffix 로 구분) - ops dashboard 의
RagHistoryChart가 14일 시계열 자동 표시 (kind 별 분리 권장)
제약:
- 수동 실행 → 측정 간극 발생 시 학습 회귀 미감지 위험
- Vertex AI 호출 비용 — 매번 N 텍스트 임베딩 + LLM 호출 (eval-case-classification-gemini.ts)
2. 권장 cron 일정
| script | 빈도 | 비용 (회당) | cron 예 |
|---|---|---|---|
eval-rag-merge.ts | 매일 02:30 KST | Vertex AI embedding × 5 + Platform findNearest × 5 ≈ $0.01 | 30 17 * * * (UTC) |
eval-tenant-rag-self.ts | 매일 02:45 KST | embedding × 8 ≈ $0.005 | 45 17 * * * (UTC) |
eval-case-classification-gemini.ts | 주간 (월요일 03:00 KST) | Gemini 호출 × 42 ≈ $0.50 (비싼 편) | 0 18 * * 1 (UTC) |
매일 측정이 필요한 RAG retrieval 은 빠른 회귀 검출에 가치. classification 은 Gemini prompt 변경 후 측정이 핵심 — 주간이면 충분.
3. 권장 아키텍처
옵션 A: Cloud Functions scheduled (동일 패턴)
Cloud Scheduler (cron "30 17 * * *")
→ Pub/Sub topic: eval-rag-quality
→ Cloud Function: evalRagQuality (Gen2)
→ eval-rag-merge 로직 호출
→ eval-tenant-rag-self 로직 호출
장점: 한 schedule 로 두 측정 동시. 결과 dashboard 즉시 반영. 단점: Cloud Functions Gen2 메모리 (512MB+) + 타임아웃 540s. corpus 가 커지면 분할 필요.
옵션 B: GitHub Actions (간단)
# .github/workflows/eval-rag-quality.yml
on:
schedule:
- cron: "30 17 * * *" # 02:30 KST
workflow_dispatch:
jobs:
eval:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v3
- run: pnpm install
- run: NODE_PATH=apps/web/node_modules pnpm exec tsx scripts/eval-rag-merge.ts --apply
env:
GOOGLE_APPLICATION_CREDENTIALS_JSON: ${{ secrets.GCP_SA }}
- run: NODE_PATH=apps/web/node_modules pnpm exec tsx scripts/eval-tenant-rag-self.ts --apply
env:
GOOGLE_APPLICATION_CREDENTIALS_JSON: ${{ secrets.GCP_SA }}
장점: ADC/Service Account 직접 주입. 로그 GitHub Actions UI 에 즉시 노출. 실패 시 GitHub Issue 자동 생성 가능. 단점: workflow 분당 비용 (무료 한도 내).
옵션 C: 외부 cron (간단)
cron 서버 (Render · Railway · EC2) 에서 daily 실행. emulator-friendly.
4. 임계값 회귀 가드
각 script 는 --threshold 또는 --recall-threshold 옵션 + 미달 시 exit 1. Cloud Functions / GitHub Actions 가 fail 처리 → 운영자 알림.
eval-rag-merge.ts—--precision-threshold·--recall-threshold(현재 0.0 baseline)eval-tenant-rag-self.ts—--recall-threshold 0.7(mock 임계값, production 측정 후 raise)eval-case-classification-gemini.ts—--threshold 0.85(baseline)
production 측정 후 임계값 raise 권장 — 후속 PR.
5. ops dashboard 시각화
tenants/demo-firm-memory/ragMergeQuality/{dateKey} 에 저장된 모든 측정은 ops /dashboard 의 RagHistoryChart (ADR 0043 v2.68) + history list toggle (v2.73) 가 자동 표시.
dateKey suffix 로 종류 구분:
2026-05-17— eval-rag-merge (Platform RAG)2026-05-17-tenant-rag-self— eval-tenant-rag-self (Tenant RAG)2026-05-17-classification— eval-case-classification-gemini
차트는 모든 dateKey 통합 시계열. kind 별 분리 표시는 후속 PR.
6. 다음 단계
- Cloud Functions Gen2 또는 GitHub Actions 으로 옵션 A·B 선택 후 ship
- classification eval 의 임계값 baseline 측정 후 raise (Gemini 정확도 측정 후)
- ragMergeQuality kind 별 chart 분리 노출 (현재 통합)