feat(#67): IMP-38 V4 max_rank policy formalization (u1~u3, 4 round consensus)

- u1: separate templates/phase_z2/catalog/v4_fallback_policy.yaml + load_v4_fallback_policy() loader
  (catalog pollution prevention — Codex #1 correction)
- u2: dynamic effective max_rank in lookup_v4_match_with_fallback (3-variable ceiling min,
  Codex #2 correction: min(configured, len(judgments_full32))) + 3-tier usable predicate
  (status + catalog + optional capacity) + trace 8 fields (requested/default/configured_extended/
  judgments_count/effective_extended_ceiling/effective_max_rank/usable_count/policy_applied)
- u3: 2 production call site cleanup (max_rank=3 removed, HEAD baseline) + tracked
  Front/vite.config.ts PHASE_Z_MAX_RANK env retired + 4 regression scenarios

verified: 32 passed (IMP-38 focused scope) — IMP-05 L4 dedup / L2 schema preserved,
IMP-30 allow_provisional byte-identical, caller_override backward compat (tests)

Stage cycle (#67, 7 round Claude + 5 round Codex):
- Stage 1: Claude #1 -> Codex #1 YES + 5 corrections
- Stage 2 r1+r2: Claude #2-#4 -> Codex #2 Q2 -> Codex #3 YES (4 round consensus LOCK 23195)
- Stage 3 U1+U2+U3: Claude #5-#9 -> Codex #6 NO 4to3 correction -> Codex #7 YES -> Codex #8 YES
- Stage 4: Claude #11 -> Codex #9 (anchor attribution nuance) -> Codex #10 readiness -> Codex #11

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-05-21 22:14:05 +09:00
parent dceb10129f
commit 90503cadd6
7 changed files with 576 additions and 15 deletions

View File

@@ -0,0 +1,45 @@
# IMP-38 V4 max_rank 정책 — separate yaml (catalog 오염 방지)
#
# 도입 배경:
# 기존 `lookup_v4_match_with_fallback(max_rank=3)` hardcoded → rank 4~32 의 등록 frame 도달 못함
# mdx05-2 같이 V4 rank 1~9 가 catalog 미등록 + rank 10~ 등록 case → chain_exhausted → unit 생성 X
#
# 4 round 합의 (IMP-38 #67):
# - Codex #1: frame_contracts.yaml 오염 회피 → 별 yaml 파일 (이 파일)
# - Codex #2: 3 변수 분리 (configured / judgments / catalog count)
# - Codex #3: effective_extended_ceiling = min(configured, len(judgments_full32))
#
# 적용 path: src/phase_z2_mapper.py 의 load_v4_fallback_policy() loader
# + src/phase_z2_pipeline.py 의 lookup_v4_match_with_fallback() 동적 max_rank logic
policy_type: dynamic_usable_count_based
# usable_threshold N:
# rank 1~default_max_rank 중 "usable" predicate 충족 frame 수 >= N → default_max_rank 유지
# < N → extended_max_rank 로 확장
usable_threshold: 1
# default_max_rank:
# normal case (usable_count >= threshold) 의 fallback chain 길이
# mdx03 같이 rank 1 use_as_is 매칭 잘 되는 case 보호
default_max_rank: 3
# extended_max_rank:
# usable_count < threshold case 의 확장 ceiling
# mdx05-2 같이 rank 1~9 미등록 case 처리
# ★ 실제 effective_extended_ceiling = min(extended_max_rank, len(judgments_full32))
# (Codex #2 정정: yaml ceiling 무력화 방지 + V4 schema 범위 초과 방지)
extended_max_rank: 32
# usable predicate (3-tier):
# (a) phase_z_status in MVP1_ALLOWED_STATUSES (matched_zone / adapt_matched_zone)
# (b) get_contract(template_id) is not None (catalog 등록)
# (c) capacity_fit ok (raw_content 제공 시만 — optional)
# 의미 신뢰 vs catalog presence trade-off:
# N=1 = 가장 보수 (rank 1 usable 시 확장 X — mdx03 정상 case 보호)
# default_max_rank=3 = 의미 신뢰 범위 (V4 rank 1~3)
# extended_max_rank=32 = catalog presence fallback (rank 4~32)
# graceful fallback (yaml 없을 시):
# loader 가 default {default_max_rank: 3, extended_max_rank: 3} 로 fall through (backward compat)