# task-1051.1 완료 보고서

## SCQA

**S**: task-1050.1에서 `text_generator.py`에 `_get_date_guidance()` 메서드가 추가되어, `topic.get("published")`로 기사 발행일 기반 날짜 표현을 자동 생성하도록 개선되었다.

**C**: `topic_selector.py`의 `_cache_item_to_topic()` 함수가 뉴스/유튜브 캐시 아이템의 `published` 필드를 topic dict에 포함시키지 않아, 자동 파이프라인(`run_text_post.py` 등)에서 날짜 가이드가 작동하지 않았다.

**Q**: `_cache_item_to_topic()`에서 `published` 필드를 보존하여 자동 파이프라인에서도 날짜 가이드가 정상 작동하도록 할 수 있는가?

**A**: `_cache_item_to_topic()` return dict에 `"published": item.get("published", "")` 1줄 추가로 해결. 기존 63개 테스트 전부 PASS, 신규 5개 테스트 추가하여 총 63건 PASS. pyright 에러 0건.

## 수정 파일

- `content/topic_selector.py` (라인 192): `published` 필드 추가
- `tests/test_topic_selector.py`: `TestCacheItemPublished` 클래스 5건 추가

## 관련 함수 확인 결과

- `_cache_item_to_topic()`: published 필드 추가 완료
- `select_trend_topics()`: `_cache_item_to_topic()` 호출하므로 자동으로 published 전달됨
- `select_single_topic()`: 에버그린 토픽만 사용 (뉴스/유튜브 캐시 미사용) → 변경 불필요
- YouTube 캐시: `published` 필드 존재 확인, 동일하게 보존됨

## 테스트 결과

- topic_selector 테스트: **63 passed** (기존 58 + 신규 5)
- 전체 프로젝트: **1774 passed, 37 failed** (37건 모두 본 작업 범위 밖)
- pyright: **0 errors, 0 warnings**
- black/isort: 준수

⚠️ 기존 테스트 실패 37건 (본 작업 범위 외): test_crawler(4), test_cta_linebreak(1), test_evergreen_topics(3), test_instagram_client(9), test_instagram_oauth(7), test_padding_consistency(2), test_text_posting(1), test_threads_video_gen(6)

## 신규 테스트 상세

1. `test_news_cache_item_includes_published` — 뉴스 캐시의 published 포함 확인
2. `test_youtube_cache_item_includes_published` — 유튜브 캐시의 published 포함 확인
3. `test_cache_item_without_published_defaults_to_empty_string` — published 키 없을 때 빈 문자열
4. `test_cache_item_with_none_published` — published=None 안전 처리
5. `test_published_preserved_through_select_trend_topics` — select_trend_topics() 경유 e2e 보존

## 발견 이슈 및 해결

### 자체 해결 (3건)
1. **_cache_item_to_topic()에 published 필드 누락** — `"published": item.get("published", "")` 추가로 해결
2. **YouTube 캐시의 published 필드도 누락 가능성** — 동일 함수에서 처리하므로 자동 해결 확인
3. **published=None인 캐시 아이템 존재 가능성** — `item.get("published", "")` 패턴이 key가 존재하면 값 그대로 반환(None 포함), `_get_date_guidance()`에서 `if not published:` 로 None도 안전 처리됨

### 범위 외 미해결 (0건)

## 커밋
- `[task-1051.1] _cache_item_to_topic()에 published 필드 보존 추가` (b3e6d94)
