# CHANGELOG — DMCausalTriangulate-Kor

## [2026-05-29]

### 수행 내용
- DMCausalTriangulate-Kor MVP 1회차 빌드. 5-design causal triangulation 도구 (T2DM
  약물 × outcome 격자, RCT · observational · target-MR · ex vivo · within-subject).
- `triangulation/` 패키지 7개 모듈 (ontology · grid · lawlor · bias · designs · report · __init__).
- `main.py` CLI (--grid · --pair · --discordant · --report{,-md,-docx}).
- `app.py` Streamlit UI (heatmap · 쌍 분석 탭 · discordance 랭킹 · 리포트 export).
- `data/effects_sample.csv` 52행 (RCT 25 · observational 13 · target-MR 10 · ex vivo 4;
  SGLT2i · GLP-1RA · DPP-4i · metformin · tirzepatide × 17 약물-outcome 쌍 격자).
- `data/drug_ontology.csv` 19행 ATC × target, `data/outcome_ontology.csv` 25행 MeSH × 카테고리.
- README.md (디스클레이머 + 실행법 + 한계 + 참고문헌), QA.md (검수 로그), data/README.md (출처).
- 검수 11개 항목 모두 통과 (AST · CSV · CLI · streamlit headless 기동 · 리포트 export · 디스클레이머).

### 주요 결정 사항
- **stdlib-only core**: pandas·numpy·scipy 미사용 — `csv` 모듈만으로 triangulation 패키지 구현.
  CLI는 streamlit/plotly 없이도 동작 (사용자 spec 요구). requirements.txt에는 명시하되 lazy import.
- **Streamlit 우선 + CLI fallback**: 사용자 spec이 Streamlit 명시이지만 검증 안정성을
  위해 동일 기능 CLI 제공. plotly 미설치 환경에서는 dataframe-only로 graceful degradation.
- **bias 진단 sample-size weighted majority**: textbook 케이스(DPP-4i × pancreatitis,
  metformin × cancer)에서 올바른 진단(detection_bias, healthy_user_bias)이 top에
  오도록 `_design_direction`을 sample-size 가중으로 보정.
- **7 design 카드 전부 표시**: bias hit이 없어도 `recommend_designs`는 7개를 모두
  반환하되 match_score 기준 정렬 — 사용자가 항상 전체 design deck을 보도록.
- **공개 자료만 사용**: 모든 effect 추정치는 PubMed/NEJM/Lancet/Diabetes Care/CT.gov
  공개 출처. EMR·환자식별정보 0. LLM API 호출 0. 외부 API 호출 0.

### 변경된 파일
- `app.py` — Streamlit UI (신규)
- `main.py` — CLI (신규)
- `requirements.txt` — Python 의존성 (신규)
- `triangulation/__init__.py` — 패키지 진입점 (신규)
- `triangulation/ontology.py` — 약물·outcome 온톨로지 로더 (신규)
- `triangulation/grid.py` — 5-design grid + concordance metric (신규)
- `triangulation/lawlor.py` — Lawlor 2016 5-criterion 채점 (신규)
- `triangulation/bias.py` — bias direction taxonomy + 진단 rule (신규)
- `triangulation/designs.py` — 7 design 카드 (신규)
- `triangulation/report.py` — markdown/docx 리포트 (신규)
- `data/effects_sample.csv` — 52행 sample (신규)
- `data/drug_ontology.csv` — 19행 ATC × target (신규)
- `data/outcome_ontology.csv` — 25행 MeSH × 카테고리 (신규)
- `data/README.md` — 데이터 출처 (신규)
- `README.md` — 프로젝트 readme (신규)
- `QA.md` — 검수 로그 (신규)

### 재현 방법
```bash
cd projects/2026-05-29-1-dm-causal-triangulate-kor/

# CLI (의존성 없음 — Python 3 stdlib만)
python3 main.py --help
python3 main.py --grid
python3 main.py --pair "SGLT2i" "CV death"
python3 main.py --pair "DPP-4i" "pancreatitis"
python3 main.py --pair "metformin" "cancer" --report-docx /tmp/met_cancer.docx
python3 main.py --discordant --top 5

# Streamlit UI (streamlit · plotly · pandas 설치 필요)
pip install -r requirements.txt
python3 -m streamlit run app.py
```
