Skip to content

target-weight pilot 날짜 헬퍼 모듈 분리 (모놀리스 1차 축소) - #387

Merged
easygap merged 1 commit into
mainfrom
refactor/extract-pilot-date-helpers
Jun 1, 2026
Merged

target-weight pilot 날짜 헬퍼 모듈 분리 (모놀리스 1차 축소)#387
easygap merged 1 commit into
mainfrom
refactor/extract-pilot-date-helpers

Conversation

@easygap

@easygap easygap commented Jun 1, 2026

Copy link
Copy Markdown
Owner

개요

13,500줄 모놀리스 tools/target_weight_rotation_pilot.py를 점진적으로 분해하는 1차 작업입니다.
순수 KRX 거래일·날짜 계산 로직만 떼어 tools/pilot_calendar.py로 분리했습니다.

동작 변화 0 (behavior-preserving). _접두어 이름을 그대로 re-import해 모놀리스 내부·외부
호출이 전부 그대로 동작하고, KST/TARGET_WEIGHT_PILOT_TARGET_DAYS 상수도 새 모듈에서 가져옵니다.

변경 내용

  • tools/pilot_calendar.py (신규): split_symbols, date_range, load_kr_market_holidays,
    is_kr_market_business_day, pilot_valid_to, next_kr_market_business_day,
    coerce_kst_datetime, execution_day — 외부 상태 없이 stdlib만 쓰는 순수 함수
    (휴장일만 core.trading_hours에서 lazy load). 하위 호환용 _접두어 별칭 포함.
  • 모놀리스에서 해당 정의 제거 후 re-import. 13,521 → 13,458줄.
  • tests/test_pilot_calendar.py (신규, 18개): 분리 전 전용 테스트가 없던 헬퍼에
    커버리지 추가 — 평일/휴장일 판정, pilot 윈도우 영업일 계산, 다음 영업일, KST 변환 경계.
  • 기존 테스트 2개가 twp._load_kr_market_holidays를 패치했는데, 의존성 조회 소스가
    pilot_calendar로 이동했으므로 pc.load_kr_market_holidays 패치로 정합화(올바른 패치 지점).

모놀리스가 너무 커서 유지보수·테스트가 어렵습니다. 가장 의존성이 적고 안전한 순수 날짜
로직부터 떼어내 (a) 단독 테스트 가능하게 하고 (b) 모놀리스를 점진적으로 줄입니다. 향후 추출
후보(독립성 순): authorization-snapshot 검증, db-persistence proof, evidence repair/finalize, CLI.

검증

  • 전체 1344 테스트 통과 (회귀 없음).
  • target_weight_rotation_pilot.py --help 정상, 추출된 헬퍼 7개가 모놀리스 네임스페이스에서
    여전히 접근·동작함을 스모크로 확인.
  • 동작 변화가 없는 순수 리팩터링이라 주문/안전 로직에는 영향 없습니다.

13,500줄 모놀리스(target_weight_rotation_pilot.py)에서 순수 KRX 거래일·날짜 로직을
tools/pilot_calendar.py로 분리했다. 동작 변화 0 — _접두어 이름을 re-import해 하위
호환을 유지하고, KST/TARGET_WEIGHT_PILOT_TARGET_DAYS 상수도 거기서 가져온다.
모놀리스 13521 → 13458줄.

- pilot_calendar: split_symbols, date_range, load_kr_market_holidays,
  is_kr_market_business_day, pilot_valid_to, next_kr_market_business_day,
  coerce_kst_datetime, execution_day (+ _접두어 별칭).
- 분리 전 전용 테스트가 없던 헬퍼에 test_pilot_calendar.py 18개 추가(거래일·휴장일·
  KST 변환 경계 검증).
- 기존 테스트 2개가 twp._load_kr_market_holidays를 패치했는데, 의존성 조회 소스가
  pilot_calendar로 옮겨졌으므로 pc.load_kr_market_holidays 패치로 정합화.

검증: 전체 1344 테스트 통과. pilot --help 및 헬퍼 접근성 스모크 정상.
@easygap
easygap merged commit 5730c47 into main Jun 1, 2026
1 check passed
@easygap
easygap deleted the refactor/extract-pilot-date-helpers branch June 1, 2026 08:33
easygap added a commit that referenced this pull request Jul 6, 2026
target-weight pilot 날짜 헬퍼 모듈 분리 (모놀리스 1차 축소)
easygap added a commit that referenced this pull request Jul 6, 2026
target_weight_rotation_pilot.py 모놀리스에서 외부 의존이 없는 stdlib 전용
헬퍼 4개를 tools/pilot_util.py로 추출했다.

- stable_manifest_hash: dict 정렬·고정 직렬화 후 SHA-256
- numbers_match: 부동소수 오차 허용 비교(절대 허용오차 옵션)
- coerce_float_or_none: float 변환, NaN/Inf는 None
- coerce_int_or_zero: int 변환 실패 시 0

기존 호출부 호환을 위해 모놀리스에서 _접두어 별칭으로 re-import 하므로
동작은 100% 동일하다. 분리 전 전용 테스트가 없던 함수들이라
tests/test_pilot_util.py로 커버리지도 추가했다(15케이스).

calendar 헬퍼 분리(#387)에 이은 2차 정리. 모놀리스 13458 -> 13425줄.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant