# req-010: 데몬 설정 .env 파일 로딩 - Status: Implemented - Type: Configuration - Priority: Medium - Owner: project maintainers ## Intent - 운영자가 데몬 환경변수(`TREX_POSTGRESQL_DSN` 등)를 `.env` 파일로 관리할 수 있도록, 데몬 기동 시 `.env` 를 로드한다. 실제 OS 환경변수는 `.env` 보다 우선한다(12-factor 호환). ## Requirement - `DaemonConfig.from_env()` 가 `os.environ` 을 읽기 전에 `.env`(있으면)를 로드한다. python-dotenv 를 의존성에 추가하고, `.env` 는 `.gitignore` 에 등록해 커밋되지 않게 하며, `.env.example` 를 참고용으로 제공한다. `.env` 가 없거나 dotenv 미설치여도 기존 동작(os.environ 단독)을 유지한다(회귀 없음). ## Acceptance Criteria 1. Given CWD 에 `.env`(`TREX_POSTGRESQL_DSN=...`)가 있고 해당 OS env 가 미설정, When `DaemonConfig.from_env()`, Then `.env` 값이 로드되어 `dsn` 에 반영된다. 2. Given OS env 와 `.env` 에 같은 키가 다른 값으로 존재, When `from_env()`, Then OS env 값이 우선한다(.env 가 덮어쓰지 않음). 3. Given `.env` 가 없음, When `from_env()`, Then 기존처럼 `os.environ` 만으로 동작한다(회귀 없음). 4. Given 저장소, When `.gitignore` 확인, Then `.env` 가 무시 대상이며 `.env.example` 은 추적된다. ## Impacted Area - Docs: 없음(baseline 구조/인터페이스/런타임 흐름 변경 없음 — minor-change) - Modules: pyproject.toml(python-dotenv), trex_core/runtime/config.py(load_dotenv), .gitignore, .env.example(신규) - Tests: tests/runtime/test_config_dotenv.py (로드/우선순위/부재 회귀) ## Notes - minor-change fast path: 단일 저위험 Configuration REQ, 구조/인터페이스/런타임 흐름 영향 없음(기동 시 env 소스 추가뿐). batch-lite 로 처리, design 불요. - dotenv 로드는 best-effort(미설치 시 graceful no-op) — 도메인/테스트 경로에 영향 없음. - 맥락: dcy-002 데몬(REQ-005)의 설정 편의 개선. trex-orbit 도 `.env` 사용. ## Change Log ### CHG-20260604-01 - Date: 2026-06-04 - Author: Justin Ko #### Change Summary - 최초 생성(Proposed) — 데몬 `.env` 로딩 Configuration 요구사항. #### Intent - 환경변수의 파일 기반 관리(.env) 지원을 backlog 로 정규화. #### Acceptance Criteria Delta - Added: - .env 로드, OS env 우선, 부재 회귀, gitignore 4개 기준 - Updated: - 없음 - Removed: - 없음 #### Impacted Area Delta - Docs: - 없음 - Modules: - pyproject.toml, runtime/config.py, .gitignore, .env.example - Tests: - tests/runtime/test_config_dotenv.py #### Delivery Trace Delta - Batches: - none - Releases: - none #### Revalidation Impact - Reverification Needed: no - Existing Implementation Invalidated: no - Status Recommendation: keep-current - Follow-up Action: minor-change batch-lite 편성 #### Validation Plan - 설정 로드/우선순위/부재 회귀 단위테스트로 검증. ### CHG-20260604-02 - Date: 2026-06-04 - Author: Justin Ko #### Change Summary - Status Proposed → Approved (minor-change 저위험 단일 REQ, 구조/인터페이스/런타임 흐름 영향 없음). #### Intent - 승인 게이트 충족(필수 필드·구체 AC·blocker 없음). batch-lite 로 즉시 delivery 가능. #### Acceptance Criteria Delta - Added: - 없음 - Updated: - 없음 - Removed: - 없음 #### Impacted Area Delta - Docs: - docs/srs/index.md (Register Approved) - Modules: - 없음 - Tests: - 없음 #### Delivery Trace Delta - Batches: - none (batch-lite 편성 예정) - Releases: - none #### Revalidation Impact - Reverification Needed: no - Existing Implementation Invalidated: no - Status Recommendation: keep-current - Follow-up Action: draft-batch 로 batch-lite 생성 #### Validation Plan - batch-lite verification 에서 AC 검증. ### CHG-20260604-03 - Date: 2026-06-04 - Author: Justin Ko #### Change Summary - Status Approved → Implemented (confirm-req-implemented, 근거 batch BAT-003 release-candidate). #### Intent - BAT-003 verification.md 의 AC↔evidence(로드/우선순위/부재 회귀/gitignore, 78 pass)로 모든 AC 충족 → 구현 완료. #### Acceptance Criteria Delta - Added: - 없음 - Updated: - 없음 - Removed: - 없음 #### Impacted Area Delta - Docs: - docs/srs/index.md (Register Implemented) - Modules: - 없음 - Tests: - 없음 #### Delivery Trace Delta - Batches: - BAT-003 (release-candidate) - Releases: - none #### Revalidation Impact - Reverification Needed: no - Existing Implementation Invalidated: no - Status Recommendation: keep-current - Follow-up Action: draft-release 로 release 편성(BAT-001~003) #### Validation Plan - BAT-003 verification evidence 재참조로 충분.