{
  "id": "get_ivt_report",
  "mcp_tool": "get_ivt_report",
  "status": "approved",
  "source_system": "cake",
  "environment": ["staging", "prod"],
  "sharded": true,
  "shard_schema": "lucos_ro_cake",
  "shard_view_prefix": "lucos_ro_ivt_fraud",
  "connections": {
    "shorty": "cake_shorty_ro",
    "admin": "cake_admin_ro"
  },
  "objects": [
    "lucos_ro_cake.lucos_ro_ivt_fraud_*",
    "lucos_ro_cake.lucos_ro_ivt_inbound_*",
    "lucos_ro_cake.lucos_ro_ivt_amzn_*",
    "Admin.lucos_ro_affiliate_directory"
  ],
  "parameters": {
    "affiliate_id": { "type": "int", "required": false },
    "publisher_id": { "type": "string", "required": false },
    "advertiser_id": { "type": "int", "required": false },
    "min_inbound_clicks": { "type": "int", "required": false },
    "min_valid_clicks": { "type": "int", "required": false },
    "date_from": { "type": "date", "required": false },
    "date_to": { "type": "date", "required": false }
  },
  "constraints": {
    "max_window_days": 31,
    "default_window_days": 7,
    "max_rows": 5000,
    "timeout_ms": 60000
  },
  "allow_fields": [
    "level",
    "level_label",
    "affiliate",
    "valid_clicks",
    "dropped_clicks",
    "fraud_clicks",
    "inbound_clicks",
    "ivt_pct",
    "drop_pct_vs_valid",
    "fraud_pct_vs_valid",
    "total_inbound_clicks",
    "total_fraudulent_clicks",
    "ivt_level_pct",
    "ivt_overall_pct",
    "reasons"
  ],
  "deny_fields": ["click_ip", "timedate", "rpc", "errors", "referer", "postback_url"],
  "denominator_policy": "status_bucket_total",
  "amzn_advertiser_country_map": {
    "20378": "us",
    "21610": "gb"
  },
  "post_processing": [
    "Percentage arithmetic over already-aggregated counts. Nothing to bound.",
    "Emit levels 0-5 including empty ones, matching getAffClearTrustStats line 1915.",
    "Reconcile click_* affiliate NAME against amzn_* affiliate ID via Admin.lucos_ro_affiliate_directory. Cross-instance — docs/CAKE-OPEN-DECISIONS.md OD-1.",
    "affiliates[] is the affiliate leaderboard for invalid/suspicious traffic, drop% / fraud% vs valid clicks, and IVT%. Rank by ivt_pct, fraud_clicks, drop_pct_vs_valid, or fraud_pct_vs_valid. Do not use billed cake clicks from get_advertiser_report as the valid-click denominator.",
    "Optional min_inbound_clicks/min_valid_clicks suppress tiny-volume affiliates before ranking."
  ],
  "notes": "The level/reason split is bounded in SQL, not post-processed — decision and rejected alternative in docs/CAKE-IVT-AGGREGATION-BOUND.md. denominator_policy names which denominator produced the percentages; the PHP hardcodes status_bucket_total in a local with a dead else-branch (getAffClearTrustStats line 1831), so the view publishes both and the tool states its choice. amzn_advertiser_country_map holds the two Amazon special cases from lines 1582-1588, kept here so a new case is a reviewed config diff rather than a DDL change. WHEN TO CALL: invalid or suspicious traffic, drop% vs valid, fraud% vs valid, IVT%, or IVT click rank — omit affiliate_id and rank affiliates[]. Do not refuse these questions. Do not start with adhoc_explore."
}
