A1: brand_profile fuzzy 매칭 + paper brand 가드 (None*100 폭발 차단)#195
Merged
Conversation
agents/competitor_intel.py:257 의 bench.get('closure_rate', 0) * 100 None * int
TypeError 근본 fix — 호출자 측이 아닌 데이터 소스 (brand_profile) 측에서 차단.
발견 케이스 (지앤푸드 커피 시뮬):
ftc_brand_franchise 의 듀먼카페/에이에스커피(AS COFFEE) frcsCnt=0 (paper brand)
→ closure_rate = (0) / 0 → None
→ competitor_intel.py:257 의 None * 100 → TypeError 폭발
Fix:
1. paper brand (frcsCnt=0) 매칭 시 benchmark_available=False 응답
- 호출자 (competitor_intel.py:254) 의 기존 'FTC 미등재' 분기로 자동 fallback
- franchise_count_national=0 명시 (다운스트림 KeyError 방지)
2. fuzzy prefix 매칭 (정확 매칭 실패 시 ILIKE prefix + frcsCnt > 0 우선)
- 예: '홍콩반점' → '홍콩반점0410' 자동 매칭
- 가드: brand_name 길이 ≥ 4 (false positive 방지: '파리'/'피자' 같은 2자는 차단)
3. 정확 매칭 silent tie-break 제거
- 동일 (brandNm, yr) 다 row 시 logger.warning 으로 데이터 품질 신호 노출
엔지니어링:
- _FUZZY_SQL module-level constant 분리 (text() 객체 매 호출 재생성 회피)
- f-string 외부 괄호 정리
검증 (실 DB):
- 빽다방(정상): avail=True, frcs=1449 ✓
- 홍콩반점→홍콩반점0410 (fuzzy 4자): matched, frcs=282 ✓
- 듀먼카페/에이에스커피 (paper): avail=False, frcs=0 명시 ✓
- 파리/피자 (2자 가드): 차단 ✓
- 스타벅스 (미등재): avail=False ✓
- competitor_intel.py:254 bench_block 빌드 시뮬: 폭발 안 함 ✓
- peer_brands 회귀: 통과 ✓
다른 팀원 코드 변경 0 — competitor_intel.py 의 기존 'benchmark_available' 분기로 자동 처리.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
agents/nodes/competitor_intel.py:257의bench.get('closure_rate', 0) * 100None * int TypeError 근본 fix. 호출자 (A2/agents) 변경 없이 데이터 소스 (A1/brand_profile) 측에서 차단.발견 케이스 (지앤푸드 커피 시뮬)
ftc_brand_franchise의 듀먼카페·에이에스커피(AS COFFEE) frcsCnt=0 (paper brand) →closure_rate = (0) / 0 → None→competitor_intel:257의 None * 100 → TypeError 폭발.Fix
paper brand 가드:
frcsCnt=0매칭 시benchmark_available=False응답competitor_intel.py:254) 의 기존bench.get("benchmark_available")분기로 자동 fallbackfranchise_count_national=0명시 (다운스트림 KeyError 방지)fuzzy prefix 매칭: 정확 매칭 실패 시
ILIKE prefix+frcsCnt > 0우선'홍콩반점' → '홍콩반점0410'자동 매칭len(brand_name) ≥ 4(false positive 차단:파리/피자등 2자는 막음)silent tie-break 제거: 정확 매칭에 추가했던 ORDER BY 제거 + 동일
(brandNm, yr)다 row 시logger.warning엔지니어링
_FUZZY_SQLmodule-level constant 분리 (text() 객체 매 호출 재생성 회피)검증 (실 DB)
competitor_intel.py:254bench_block 빌드 시뮬호환성
competitor_intel.py:254benchmark_available분기peer_brands함수다른 팀원 0 수정.
Test plan
DB 변경
없음. read-only fix.
🤖 Generated with Claude Code