# spec/30 — 최종 완료 기준 계약 (COMPLETION_CRITERIA_V1)
#
# 목적: 이 계약은 알고리즘 엔진이 "투자 판단 허용" 상태(PASS_100 + ENGINE_AUDIT_V1 status=passed)로
#       전환하기 위해 충족해야 하는 모든 조건을 명문화한다.
#       미충족 항목은 거짓 없이 insufficient_data 또는 failed로 기록한다.
#
# 감사 기준일: 2026-06-14
# 다음 점검일: 2026-07-15 (T+20 표본 30건 누적 예상 이후 — honest_proof_score 70 달성 검증)

meta:
  contract_id: COMPLETION_CRITERIA_V1
  version: "2026-06-14"
  engine_audit_ref: Temp/engine_audit_v1.json
  pass_100_ref: Temp/pass_100_criteria_v1.json

# ── §7 프롬프트 완료 조건 ────────────────────────────────────────────────────
criteria:

  schema_validity_score:
    target: ">= 99"
    current: 95.5
    status: FAIL
    source: Temp/data_quality_reconciliation_v1.json
    fix: "trade_quality / pattern / alpha_eval PENDING 카테고리 해소"
    fix_dependency: "실측 거래 품질·패턴·알파 데이터 누적"

  required_field_coverage:
    target: "== 1.0"
    current: 0.955
    status: FAIL
    source: data_quality_reconciliation_v1.json:schema_presence_score/100
    fix: "schema_presence_score → 99+"

  missing_critical_field_count:
    target: "== 0"
    current: 3
    status: FAIL
    fields: ["trade_quality", "pattern", "alpha_eval"]
    fix: "운영 데이터 누적 후 PENDING 해소"

  yaml_to_code_coverage_ratio:
    target: "== 1.0"
    current: 1.0
    status: PASS
    source: Temp/yaml_code_coverage_v1.json

  golden_test_coverage_ratio:
    target: ">= 0.50"
    current: 0.516
    status: PASS
    source: Temp/yaml_code_coverage_v1.json
    fix: "달성 완료. Python mirror 15개 + GAS_REFERENCE 34개 추가 → 95/184=51.6%."

  decision_reproducibility_score:
    target: "== 1.0"
    current: 1.0
    status: PASS
    method: "build_engine_audit_v1 10회 실행 byte-identical 검증"

  deterministic_decision_ratio:
    target: "== 1.0"
    current: 1.0
    status: PASS
    source: "FINAL_JUDGMENT_GATE_V1 AND-11 결정론"

  llm_generated_decision_field_count:
    target: "== 0"
    current: 0
    status: PASS
    source: Temp/llm_freedom_v1.json:llm_freedom_pct=0%

  hallucinated_claim_count:
    target: "== 0"
    current: 0
    status: PASS

  unsupported_reason_count:
    target: "== 0"
    current: 0
    status: PASS

  final_json_schema_valid:
    target: "true"
    current: true
    status: PASS

  all_critical_tests_passed:
    target: "true"
    current: false  # golden_coverage 미달
    status: FAIL

  performance_readiness_score:
    target: ">= 90"
    current: 50
    status: FAIL
    note: "replay T+20 510건으로 30→50 상향. 운영 실측 T+20 누적 후 90 달성 가능."
    fix: "T+20 실현 표본 30건 이상 → readiness_gate=PERFORMANCE_READY"

  report_consistency_score:
    target: "== 100"
    current: 100.0
    status: PASS
    note: "누적손익 섹션 간 일치 검사 + ISA/연금 포함 동기화 완료"

  imputed_data_exposure_gate:
    target: "PASS"
    current: IMPUTED_DATA_BLOCK
    status: FAIL
    note: "fundamental_core_factor_coverage=0.0 — ROE/OPM/OCF/FCF 원천데이터 수집 필요"
    fix: "GAS fetchFundamentalsWithCache_ 실행 후 data_feed 시트 채움"

  RELEASE_GATE_TRUTH:
    target: "PASS (honest_proof_score >= 70.0)"
    current: FAIL
    current_honest_proof_score: 45.1
    current_cosmetic_score: 98.36
    status: FAIL
    formula_id: RELEASE_GATE_TRUTH_V1
    source: Temp/algorithm_guidance_proof_v1.json
    note: >
      cosmetic(98.36 PASS)와 truth(45.1 FAIL) 중 truth가 릴리스를 통제한다.
      effective_release_gate = AND(cosmetic_gate, honest_gate). 둘 중 하나라도 FAIL이면 FAIL.
      honest_proof_score < 70 인 동안 hts_order_count == 0 (THEORETICAL_ONLY 렌더).
    fix: "honest_proof_score >= 70.0 달성 후 PASS"
    fix_dependency: "TASK-004(실측표본), TASK-008(가치훼손), TASK-003(마스킹금지) 완료 후"
    blocking: true

  sell_engine_gate:
    target: "PASS"
    current: PASS
    status: PASS
    note: "K2 rebound_participation_ratio 노출 완료"

  routing_gate:
    target: "PASS"
    current: PASS
    status: PASS
    note: "2026-06-14 실측: SHORT=12.5%, MID=50.0%, LONG=37.5% — 모든 상한 준수. routing_confidence=60."
    source: "Temp/strategy_routing_audit_v1.json"

  confidence_cap_honest:
    target: "< 5 gap from raw_cap"
    current:
      raw_cap: 93.0
      honest: 48.4
      gap: 44.6
    status: FAIL
    note: "펀더멘털 팩터 결측이 해소되면 honest cap 상승 예상"

# ── 현재 PASS/FAIL 요약 ────────────────────────────────────────────────────
summary:
  total_criteria: 17
  passed: 10
  failed: 7
  pass_rate_pct: 58.82
  last_updated: "2026-06-14"

  passed_items:
    - yaml_to_code_coverage_ratio
    - decision_reproducibility_score
    - deterministic_decision_ratio
    - llm_generated_decision_field_count
    - hallucinated_claim_count
    - unsupported_reason_count
    - report_consistency_score
    - final_json_schema_valid
    - sell_engine_gate
    - golden_test_coverage_ratio
    - routing_gate: "PASS (SHORT=12.5% MID=50.0% LONG=37.5% — 2026-06-14 실측)"

  failed_items:
    - RELEASE_GATE_TRUTH: "honest_proof_score=45.1 < 70.0 (2026-06-14 실측; T+20 표본 및 펀더멘털 수집 필요)"
    - schema_validity_score: "95.5 (목표 99+, SLA 초과 — 새 JSON 내보내기 후 해소)"
    - required_field_coverage: "0.955 (목표 1.0, SLA 연동)"
    - missing_critical_field_count: "3 PENDING (운영 데이터 누적 필요)"
    - performance_readiness_score: "50 (목표 90, T+20 운영 30건 필요)"
    - imputed_data_exposure_gate: "IMPUTED_DATA_BLOCK (GAS 펀더멘털 내보내기 후 개선)"
    - confidence_cap_honest: "gap 44.6 (펀더멘털 수집 후 자동 개선)"

# ── 투자 판단 허용 조건 ──────────────────────────────────────────────────────
investment_decision_allowed: false
reason: "7개 기준 미달 — 데이터 정합성·펀더멘털 결측·performance_readiness 미충족 (RELEASE_GATE_TRUTH 차단)"

# ── 후속 로드맵 ──────────────────────────────────────────────────────────────
roadmap:
  immediate:
    - "GAS fetchFundamentalsWithCache_ 실행 (naver/yahoo ROE/OPM/OCF/FCF 수집)"
    - "data_feed 시트 ROE_Pct / Operating_Margin_Pct / OCF_B 컬럼 갱신"
    - "fundamental_core_factor_coverage ≥ 0.50 → fundamental_claim_allowed=true"

  short_term_20_trading_days:
    - "T+20 운영 표본 30건 누적 → performance_readiness 90+"
    - "trade_quality/pattern/alpha_eval PENDING 해소 → schema_presence 99+"

  medium_term:
    - "SHORT 호라이즌 비중 40% 이하로 조정 (실제 포지션 리밸런싱)"
    - "golden_test_coverage 50% 달성 (GAS 공식 Python 구현 확대)"

  final_verdict_target: "2026-07-15 이후 재감사"
