decision · wiki/decision-chemical-rag-timeout-partial-failure.md
Decision — chemical RAG timeout partial failure
**룰 판정과 RAG 해석은 수명을 분리**한다. LLM timeout/실패는 **해당 국가 `rag_status=failed`** 로 남기고, 다른 국가 성공 해석·룰 결과를 덮지 않는다.
corpusprojectlayerjudgmenttypedecisiondomainbackendsprojectchemicalstatusactiveupdated2026-07-18originowned
Decision — chemical RAG timeout partial failure
한 줄: 룰 판정과 RAG 해석은 수명을 분리한다. LLM timeout/실패는 해당 국가 rag_status=failed 로 남기고, 다른 국가 성공 해석·룰 결과를 덮지 않는다.
결정
- 단위: RAG 후처리는 시나리오 전체가 아니라 국가 row 단위로 저장·재시도.
- timeout: LLM 요청 기본 60s (
llm_request_timeout_seconds). 초과/예외 → 그 국가 failed +rag_error(가능하면 cache fallback 우선). - 빈 성공 금지: 비어 있는 supplement를
completed로 저장하지 않음 (_apply_rag_supplementValueError). - 보존: 재시도/merge 시 이미 있는 국가 성공 문구는
_preserve_current_successful_rag로 유지. - cache: 실패 시 동일 cas/country/decision/reason 계열 과거 성공 문구 재사용 허용 (
rag_cache_source). - 시나리오 stale: pending/processing이 30분 넘으면 시나리오
status=failedsweep (해석 층과 별개의 전체 타임박스). - 제품 의미: 일부 국가만 RAG failed여도 룰 판정 페이로드는 유지 가능 — UI는 국가별 rag_status를 구분 표시해야 함 (HANDOFF 증상 수정과 정합).
- 끄기:
rag_enabled=false면 해석 층 전체 skip (룰만).
대안
| 안 | 요지 | 탈락 이유 |
|---|---|---|
| A. 한 국가 실패 시 시나리오 전체 failed | 단순 | 성공 국가 해석·재시도 UX 파괴 (HANDOFF이 막으려던 것) |
| B. timeout 무한 대기 | 완전성 | 워커 고착, stale만으로 부족 |
| C. 국가별 failed + 보존 + cache + 60s | 현 코드 | 채택 |
| D. timeout 시 묵시 completed | UX 매끄러움 | 빈/가짜 해석 법적 리스크 |
근거
- brief-chemical-simulation-config
- brief-chemical-simulation-rag-worker
- brief-chemical-llama-cpp-runbook
- brief-chemical-handoff
- concept-chemical-rule-vs-rag
폐기·재검토
- 글로벌 동기 일괄 RAG가 규제 요구로 강제될 때
- timeout/SLA를 국가·모델별로 다르게 둘 때 (설정 키 분리 decision)