Deliver BAT-003: daemon .env loading (REQ-010, minor-change)

DaemonConfig.from_env() now best-effort loads a .env file (find_dotenv
usecwd, load_dotenv override=False) so operators can manage daemon env
vars via .env, with real OS env taking precedence. Add python-dotenv
dependency, gitignore .env, ship .env.example, and add config tests
(load / OS-env precedence / absence regression / missing-DSN guard).

Verification: 78 passed, ruff clean, .env ignored + .env.example tracked,
and a .env-only DaemonConfig smoke. Processed via the minor-change fast
path: REQ-010 (Configuration) -> Implemented, BAT-003 (batch-lite,
no design) -> release-candidate.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-04 14:56:42 +09:00
co-authored by Claude Opus 4.8
parent a4e263c8e7
commit 575ba9f513
13 changed files with 346 additions and 5 deletions
@@ -0,0 +1,30 @@
# BAT-003 Planning
- Status: confirmed
- Batch: BAT-003
- Profile: batch-lite
## Included REQ
- REQ-010 (Configuration): 데몬 설정 .env 파일 로딩
## Delivery Plan
1. pyproject.toml 에 `python-dotenv` 의존성 추가.
2. `trex_core/runtime/config.py` 의 `DaemonConfig.from_env()` 시작부에서 best-effort `load_dotenv()`(미설치/부재 시 no-op, OS env override 안 함).
3. `.gitignore` 에 `.env` 추가, `.env.example` 신규(키 목록 참고용).
4. `tests/runtime/test_config_dotenv.py`: .env 로드 / OS env 우선 / .env 부재 회귀.
## Dependencies
- Internal: REQ-005(DaemonConfig) 위 확장.
- External: python-dotenv.
## Design Gate
- Design Required Before Implementation: no
- Reason: 구조/인터페이스/런타임 흐름 변경 없음. 기동 시 환경변수 소스(.env)만 추가하는 국소 설정 변경이라 batch-lite + design 생략(minor-change).
## Milestones
1. M1 — config 에 .env 로딩 + deps + gitignore/.env.example.
2. M2 — 단위테스트 green(로드/우선순위/부재).
## Risks
- R-1 (Low): .env 가 실 OS env 를 덮어쓰면 운영 사고. 대응: `load_dotenv(override=False)` 기본(실 env 우선)으로 AC-2 검증.
- R-2 (Low): dotenv 미설치 환경 회귀. 대응: best-effort import(no-op) + AC-3 회귀 테스트.