# 자동 검수 체크리스트 스펙
# 07-자동검수-자동화-설계.md 의 audit-runner 가 소비하는 선언적 검수 항목 정의.
# method: front-crawl(A) | platform-api(B) | external-api(C) | admin-ui(D) | e2e(E)
# severity: critical | high | medium | low
# autofix: none(알림만) | proposed(변경안 생성 후 승인 대기) | auto(화이트리스트 자동 수정)

meta:
  version: 1
  mall_url: "https://REPLACE-ME.co.kr"   # 자사몰 URL로 교체
  platform: cafe24                        # cafe24 | imweb
  schedule:
    daily: "06:00"
    weekly_e2e: "MON 06:30"

checks:
  # ── 기본기 (01번 문서) ──────────────────────────────
  - id: login-kakao-button-pc
    category: fundamentals
    description: "PC 로그인 페이지에 카카오 1초 로그인 버튼이 렌더링되는가"
    method: front-crawl
    target: "/member/login.html"
    assert: "selector-exists: [class*=kakao], a[href*=kakao]"
    severity: critical
    autofix: none

  - id: login-kakao-button-mobile
    category: fundamentals
    description: "모바일 로그인 페이지에 카카오 버튼이 렌더링되는가"
    method: front-crawl
    target: "/member/login.html"
    viewport: mobile
    assert: "selector-exists: [class*=kakao], a[href*=kakao]"
    severity: critical
    autofix: none

  - id: return-request-available
    category: fundamentals
    description: "마이페이지 주문 상세에서 반품/교환 신청 버튼이 노출되는가"
    method: e2e
    scenario: "test-account-order-detail"
    severity: critical
    autofix: none

  - id: return-flow-e2e
    category: fundamentals
    description: "테스트 주문 → 반품 신청 → 접수 상태 전환까지 실동작하는가 (주 1회)"
    method: e2e
    scenario: "purchase-and-return"
    severity: critical
    autofix: none

  - id: payment-methods-active
    category: fundamentals
    description: "주문서에 설정된 전 결제수단이 노출되는가"
    method: e2e
    scenario: "checkout-payment-options"
    expect: ["card", "kakaopay", "naverpay", "bank"]
    severity: critical
    autofix: none

  - id: welcome-coupon-issued
    category: fundamentals
    description: "신규 가입 시 첫구매 쿠폰이 자동 지급되는가"
    method: e2e
    scenario: "signup-coupon-check"
    severity: high
    autofix: none

  # ── 트래킹 (02번 문서) ──────────────────────────────
  - id: ga4-script-present
    category: tracking
    description: "메인/상품/장바구니/주문서에 GA4(GTM) 스크립트가 존재하는가"
    method: front-crawl
    target: ["/", "/product/*", "/order/basket.html"]
    assert: "script-contains: googletagmanager.com"
    severity: critical
    autofix: none

  - id: meta-pixel-present
    category: tracking
    description: "Meta 픽셀이 전 주요 페이지에 존재하는가"
    method: front-crawl
    assert: "script-contains: connect.facebook.net"
    severity: high
    autofix: none

  - id: purchase-event-fires
    category: tracking
    description: "구매 완료 시 purchase 이벤트가 발화하는가 (주 1회 E2E)"
    method: e2e
    scenario: "purchase-and-return"
    assert: "network-request: google-analytics.com/g/collect?*en=purchase*"
    severity: critical
    autofix: none

  - id: utm-compliance-live-ads
    category: tracking
    description: "집행 중 광고 랜딩 URL의 UTM이 명명 규칙을 준수하는가"
    method: external-api
    source: [meta-marketing-api, naver-searchad-api]
    rule: "utm_source,utm_medium,utm_campaign,utm_content 필수 / 소문자 / 한글 금지"
    severity: high
    autofix: proposed

  - id: ga4-revenue-reconciliation
    category: tracking
    description: "GA4 매출 vs 플랫폼 주문 매출 오차 5% 이내 (주간)"
    method: external-api
    source: [ga4-data-api, platform-api]
    threshold: 0.05
    severity: high
    autofix: none

  # ── SEO / GEO (04번 문서) ──────────────────────────
  - id: meta-tags-products
    category: seo
    description: "전 상품 페이지에 title/description/OG/canonical 존재"
    method: front-crawl
    target: "/product/*"
    severity: medium
    autofix: proposed

  - id: product-jsonld-valid
    category: seo
    description: "상품 페이지 Product JSON-LD 유효 + 가격이 실제 표시가와 일치"
    method: front-crawl
    severity: medium
    autofix: proposed

  - id: robots-not-blocking
    category: seo
    description: "robots.txt가 전체 차단으로 바뀌지 않았는가 + AI 크롤러 정책 유지"
    method: front-crawl
    target: "/robots.txt"
    assert: "not-contains: 'Disallow: /' (전역)"
    severity: critical
    autofix: none

  - id: sitemap-fresh
    category: seo
    description: "sitemap.xml 접근 가능 + 서치콘솔 색인 오류 수 임계 이하"
    method: external-api
    source: [search-console-api]
    severity: medium
    autofix: none

  # ── 광고/CRO (05·06번 문서) ─────────────────────────
  - id: ad-landing-alive
    category: ads
    description: "집행 중 전 광고 랜딩 URL이 200 응답 + 품절 아님"
    method: front-crawl
    source: utm-compliance-live-ads
    severity: critical
    autofix: none

  - id: spend-anomaly
    category: ads
    description: "일 광고비가 평소 대비 ±50% 급변 시 알림"
    method: external-api
    source: [meta-marketing-api, naver-searchad-api]
    severity: high
    autofix: none

  - id: funnel-drop-alert
    category: cro
    description: "퍼널 단계별 전환율 전주 대비 -20% 이상 급락 알림 (주간)"
    method: external-api
    source: [ga4-data-api]
    severity: high
    autofix: none

  - id: mobile-lcp
    category: cro
    description: "모바일 메인/대표상품 LCP 2.5초 이내 (주간 Lighthouse)"
    method: front-crawl
    threshold_ms: 2500
    severity: medium
    autofix: none

  # ── CRM (03번 문서) ─────────────────────────────────
  - id: crm-flow-delivery-rate
    category: crm
    description: "자동화 플로우 발송 성공률 95% 이상"
    method: external-api
    source: [crm-solution-api]
    threshold: 0.95
    severity: high
    autofix: none

  - id: night-send-block
    category: crm
    description: "광고성 메시지 야간(21~08시) 발송 차단 설정 유지"
    method: admin-ui
    severity: critical
    autofix: none
