Skip to content

A1+ABM+Legal: 전수조사 4 HIGH + 다수 MED fix (NULL/매핑/RAG/검증)#196

Merged
bat1120 merged 1 commit into
devfrom
IM3-abm-legal-db-null-mapping-fix
May 5, 2026
Merged

A1+ABM+Legal: 전수조사 4 HIGH + 다수 MED fix (NULL/매핑/RAG/검증)#196
bat1120 merged 1 commit into
devfrom
IM3-abm-legal-db-null-mapping-fix

Conversation

@bat1120

@bat1120 bat1120 commented May 5, 2026

Copy link
Copy Markdown
Contributor

Summary

전수조사 (2026-05-05) 결과 4 영역 (DB / 업종 / ABM / 법률) 발견 문제 일괄 fix. 3 병렬 sub-agent 작업 통합.

Fix 내역

ABM 시뮬 (simulation/)

ID 위치 Fix
C1 HIGH profile_builder.py:99-167 male/female_70_74 100% NULL 회피 + COALESCE 가드
C2 HIGH profile_builder.py:201-282 apt_trade_real ILIKE 강화 (망원2/성산2 명시 + neighbor_groups 인접 fallback)
C3 HIGH world.py + world_loader.py + runner.py brand_name NULL 시 cannibalization 명시 skip + skipped_no_brand 카운터
C4 HIGH world_loader.py + runner.py _TIME_ZONE_TO_HOURS 6구간 → 24h 확장 (daily boost dict swap 정합)

법률 (agents/legal/, agents/nodes/legal.py)

ID 위치 Fix
D1 HIGH specialists.py (4종) RAG 0-row → caution floor 강제 (silent safe 오판 차단)
D2 HIGH legal.py:461 FTC frcsCnt=NULL 시 churn_rate=None + caution 메시지
D3 MED rules.py school_zone mock 5개 위험 docstring (보류)
D4 MED specialists.py territory_radius_m 50~1500m 검증 (false positive 차단)
D5 LOW legal.py cache key brand_name 정규화

DB / dong_resolver / schemas

ID 위치 Fix
E2 HIGH dong_resolver/population_api/demographic_depth dong_resolver SoT 통합 (3곳 분산 hardcode → 1곳)
E3 MED dong_resolver.py resolve_dong_code(default=None) 시그니처 + helper 추가
E4 MED commercial_intelligence.py get_dong_centroid 마포 한정 docstring
B1 HIGH simulation_input.py Pydantic 검증 (business_type 화이트리스트 + lat/lon 마포 bbox)

검증

  • ruff check/format 수정 파일 통과
  • 모든 모듈 import OK
  • test_legal_orchestrator 12 PASS
  • test_runner_day_loop_boost 3 PASS
  • test_living_pop_loader 3 PASS
  • test_vacancy_pse_brand 4 PASS
  • MAPO_DONG_CODES dict id 동일 (6 모듈 backward compat)

보류 (별 PR)

항목 사유
E1 dong_code String(8)/(10) 통일 alembic 마이그레이션 + ORM 8+ 곳 변경, 별 PR IM3-dong-code-string-unify
C6 새벽 4시 강제 휴식 영업시간 정책 결정 필요
B2 corp_brand_resolver 재도입 팀 합의 후

DB 변경

없음. 코드 fix + Pydantic 검증 강화만.

🤖 Generated with Claude Code

전수조사 (2026-05-05) 4 영역 (DB/업종/ABM/법률) 발견 문제 fix.
3 병렬 sub-agent 작업 통합.

## ABM 시뮬 (simulation/)

- C1 male/female_70_74 NULL 컬럼 회피 + COALESCE 가드 (profile_builder.py)
  → AGE_BUCKETS '70_plus' 단일 사용, NULL 회귀 방지 주석 고정
- C2 apt_trade_real ILIKE 매핑 강화 (profile_builder.py:201-282)
  → 망원2동/성산2동 명시 + neighbor_groups 인접 동 평균 fallback (income default 0.5 silent fail 차단)
- C3 kakao_store.brand_name NULL 72.8% → cannibalization brand 매칭 명시 skip
  → Store.brand_name field 추가, skipped_no_brand 카운터로 silent 0 가시화
- C4 living_population_grid vs legacy fallback key 형식 통일 (world_loader/runner)
  → _TIME_ZONE_TO_HOURS 매핑으로 6구간 → 24h 확장, daily boost dict swap 정합

## 법률 (agents/legal/)

- D1 RAG 0-row 폭발 차단 (4 specialist)
  → rag_empty 플래그 + LLM prompt 에 caution 강제 directive + post-LLM safe→caution floor
- D2 FTC churn_rate frcsCnt=NULL 의미 손상 fix (legal.py)
  → max(0,1) 트릭 제거, frcsCnt is None or store_count<=0 시 churn_rate=None
  → 소비자 코드: None → caution + summary "데이터 부족" 명시
- D3 school_zone mock 5개 위험 docstring 알림 (rules.py)
- D4 territory_radius_m 50~1500m 범위 검증 (specialists.py)
  → 범위 외/파싱 실패 시 None fallback + warning 로그
- D5 cache key brand_name 정규화 (legal.py)
  → 공백/대소문자/lower 통합 (Starbucks/starbucks/STARBUCKS 동일 키)

## DB / dong_resolver / schemas

- E2 dong_resolver SoT 통합 (services/dong_resolver.py)
  → MAPO_DONG_MAP 단일 source. population_api / demographic_depth 가 import 하도록
- E3 resolve_dong_code(name, default=None) 시그니처 + resolve_dong_code_or_default helper
- E4 get_dong_centroid 마포 한정 docstring 명시 (commercial_intelligence)
- B1 SimulationInput Pydantic 검증 강화 (simulation_input.py)
  → business_type 28종 화이트리스트 (silent fail 차단 1단계, 강격 strict Literal 은 별 PR)
  → lat/lon 마포 bbox 범위 (37.50~37.65, 126.85~126.95)
  → 빈 business_type 차단

## 검증

- ruff check/format 통과 (수정 파일 한정)
- 모든 모듈 import OK
- 기존 테스트 통과 (test_legal_orchestrator 12 + test_runner_day_loop_boost 3 + test_living_pop_loader 3 + test_vacancy_pse_brand 4)
- 호출자 backward compat 검증 (MAPO_DONG_CODES dict id 동일 — 6 모듈)

## 보류 (별 PR)

- E1 dong_code String(8)/(10) 통일 — alembic 마이그레이션 + ORM 8+ 곳 변경 (별 PR `IM3-dong-code-string-unify`)
- C5 SimulationInput 처리 (이번 PR 에 통합됨)
- C6 새벽 4시 강제 휴식 — 정책 결정 필요
- B2 corp_brand_resolver 재도입 — 팀 합의 후

## DB 변경
없음. 코드 fix + Pydantic 검증 강화만.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@bat1120 bat1120 merged commit b944b17 into dev May 5, 2026
@bat1120 bat1120 deleted the IM3-abm-legal-db-null-mapping-fix branch May 5, 2026 03:19
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