{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/predixsport-com/json-schema/predixsport-com-tennis-match-detail-schema.json",
  "title": "TennisMatchDetail",
  "x-generated": "2026-11-21",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/predixsport-com-openapi.json#/components/schemas/TennisMatchDetail",
  "properties": {
    "match_id": {
      "type": "string",
      "title": "Match Id"
    },
    "sport": {
      "type": "string",
      "enum": [
        "tennis"
      ],
      "const": "tennis",
      "title": "Sport",
      "default": "tennis"
    },
    "date": {
      "type": "string",
      "format": "date",
      "title": "Date",
      "description": "Tournament-scheduled START day, NOT the actual match day. Shared by every match of the same tournament across all rounds. Use ``tournament.round`` to gauge how far into the tournament this match falls."
    },
    "season": {
      "type": "string",
      "title": "Season"
    },
    "tournament": {
      "$ref": "#/$defs/TournamentInfo"
    },
    "player_one": {
      "$ref": "#/$defs/TennisPlayerDetail",
      "description": "First player in as-observed order from data ingestion. NOT winner-first canonicalised. All player-relative predictions (spread, exact_score, this player's aces and double faults) are aligned to this ordering."
    },
    "player_two": {
      "$ref": "#/$defs/TennisPlayerDetail"
    },
    "predicted_total_games": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "title": "Predicted Total Games",
      "description": "Rounded mean of the Poisson total-games regressor. Equivalent to `round(expected_total_games)` and aligned with the value shown on predixsport.com. Use `expected_total_games` for the un-rounded mean and `distributions.total_games` for the full PMF."
    },
    "expected_total_games": {
      "anyOf": [
        {
          "type": "number"
        },
        {
          "type": "null"
        }
      ],
      "title": "Expected Total Games",
      "description": "Mean (expected value) of the Poisson total-games regressor."
    },
    "predicted_result": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Predicted Result"
    },
    "tiebreak": {
      "anyOf": [
        {
          "$ref": "#/$defs/TennisTiebreakProjection"
        },
        {
          "type": "null"
        }
      ]
    },
    "exact_score": {
      "anyOf": [
        {
          "$ref": "#/$defs/TennisExactScoreProjection"
        },
        {
          "type": "null"
        }
      ]
    },
    "expected_aces": {
      "anyOf": [
        {
          "type": "number"
        },
        {
          "type": "null"
        }
      ],
      "title": "Expected Aces",
      "description": "Expected total aces in the match: the sum of the two per-player projections carried by `player_one` and `player_two`, with `distributions.aces` the convolution of their distributions. The per-player fields are null for matches predicted before the per-player rollout on that tour, and the total keeps the meaning it has always had either way."
    },
    "expected_double_faults": {
      "anyOf": [
        {
          "type": "number"
        },
        {
          "type": "null"
        }
      ],
      "title": "Expected Double Faults",
      "description": "Expected total double faults in the match. Same derivation as `expected_aces`, on both tours."
    },
    "expected_spread": {
      "anyOf": [
        {
          "type": "number"
        },
        {
          "type": "null"
        }
      ],
      "title": "Expected Spread",
      "description": "Expected (player_one_games - player_two_games). Sign convention follows the as-observed player order — negative means player_two is favoured."
    },
    "distributions": {
      "$ref": "#/$defs/TennisDistributions"
    },
    "cdfs": {
      "$ref": "#/$defs/TennisDistributions"
    },
    "key_factors": {
      "anyOf": [
        {
          "$ref": "#/$defs/KeyFactors"
        },
        {
          "type": "null"
        }
      ],
      "description": "Concept-level attribution of the winner prediction (positive values favour player_one, in as-observed order). Absent for rows predicted before the explainability rollout."
    },
    "actual": {
      "anyOf": [
        {
          "$ref": "#/$defs/TennisActual"
        },
        {
          "type": "null"
        }
      ],
      "description": "Realized result, present once the match has been played and reconciled. Null for upcoming / unplayed matches — the predictive fields above are identical either way."
    },
    "page_url": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Page Url",
      "description": "Canonical predixsport.com page showing these numbers in full (distributions, key factors, track record). Link it as the source when you quote this data. For a match it is the match page once that page is published, otherwise the sport's predictions page. Null only when no page exists.",
      "readOnly": true
    }
  },
  "type": "object",
  "required": [
    "match_id",
    "date",
    "season",
    "tournament",
    "player_one",
    "player_two",
    "page_url"
  ],
  "$defs": {
    "KeyFactor": {
      "properties": {
        "key": {
          "type": "string",
          "title": "Key",
          "description": "Stable identifier of the factor (e.g. 'surface', 'starting_five', 'attack')."
        },
        "label": {
          "type": "string",
          "title": "Label",
          "description": "Human-readable factor name, as shown on predixsport.com."
        },
        "prob_points": {
          "type": "number",
          "title": "Prob Points",
          "description": "How many win-probability percentage points this factor moves the prediction. Positive values favour the first side (player one / home team), negative values the second side."
        },
        "direction": {
          "type": "string",
          "title": "Direction",
          "description": "What the factor favours: 'player_one'/'player_two' for tennis, 'home'/'away' for NBA and football winner attributions, 'under'/'over' for the football under/over 2.5 attribution."
        },
        "stable": {
          "type": "boolean",
          "title": "Stable",
          "description": "True when the attribution sign is consistent across independent estimator runs. Treat unstable factors as indicative, not decisive."
        },
        "display": {
          "type": "boolean",
          "title": "Display",
          "description": "False for internal context buckets not shown on predixsport.com.",
          "default": true
        },
        "share": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "title": "Share",
          "description": "This factor's share of the total absolute attribution (0-1)."
        },
        "synthetic": {
          "anyOf": [
            {
              "type": "boolean"
            },
            {
              "type": "null"
            }
          ],
          "title": "Synthetic",
          "description": "True for fixed baseline terms (home advantage, league scoring environment) that reflect league-wide tendencies rather than this specific matchup."
        },
        "side": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Side",
          "description": "For per-team factors on outcome attributions (football under/over): which team the factor describes ('home'/'away'). Surfaces can substitute the actual team name into the label."
        }
      },
      "type": "object",
      "required": [
        "key",
        "label",
        "prob_points",
        "direction",
        "stable"
      ],
      "title": "KeyFactor",
      "description": "One concept-level driver of the winner prediction."
    },
    "KeyFactors": {
      "properties": {
        "schema_version": {
          "type": "integer",
          "title": "Schema Version",
          "description": "Contract version of this payload.",
          "default": 1
        },
        "baseline_probability": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "title": "Baseline Probability",
          "description": "Model probability for an average matchup — the reference point the factors move the prediction away from."
        },
        "factors": {
          "items": {
            "$ref": "#/$defs/KeyFactor"
          },
          "type": "array",
          "title": "Factors",
          "description": "Factors sorted by absolute impact (largest first)."
        }
      },
      "type": "object",
      "title": "KeyFactors",
      "description": "Concept-level attribution of the winner prediction.\n\nComputed with gradient-based attribution on the production neural\nnetwork and aggregated into human concepts; the factors approximately\nsum to the gap between the served win probability and an even matchup.\nFor football the factors compare the two sides directly (the draw\nprobability is modelled separately). Absent on rows predicted before\nthe explainability rollout (June 2026)."
    },
    "TennisActual": {
      "properties": {
        "winner": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Winner",
          "description": "Name of the player who actually won the match."
        },
        "total_games_played": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "title": "Total Games Played",
          "description": "Total games played across all sets. Compare with predicted_total_games."
        }
      },
      "type": "object",
      "title": "TennisActual",
      "description": "Realized result once the match has been played and reconciled\n(``{tennis|wta}_in_season_performance_frozen``). Absent until the match\nis played.\n\n``winner`` is the actual winner's NAME, aligned to the as-observed\nplayer ordering — never inferred from player position."
    },
    "TennisDistributions": {
      "properties": {
        "total_games": {
          "anyOf": [
            {
              "additionalProperties": {
                "type": "number"
              },
              "type": "object"
            },
            {
              "type": "null"
            }
          ],
          "title": "Total Games"
        },
        "spread": {
          "anyOf": [
            {
              "additionalProperties": {
                "type": "number"
              },
              "type": "object"
            },
            {
              "type": "null"
            }
          ],
          "title": "Spread"
        },
        "aces": {
          "anyOf": [
            {
              "additionalProperties": {
                "type": "number"
              },
              "type": "object"
            },
            {
              "type": "null"
            }
          ],
          "title": "Aces"
        },
        "double_faults": {
          "anyOf": [
            {
              "additionalProperties": {
                "type": "number"
              },
              "type": "object"
            },
            {
              "type": "null"
            }
          ],
          "title": "Double Faults"
        }
      },
      "type": "object",
      "title": "TennisDistributions"
    },
    "TennisExactScoreProjection": {
      "properties": {
        "predicted": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Predicted",
          "description": "Most likely set score in \"X-Y\" format relative to player_one."
        },
        "distribution": {
          "anyOf": [
            {
              "additionalProperties": {
                "type": "number"
              },
              "type": "object"
            },
            {
              "type": "null"
            }
          ],
          "title": "Distribution",
          "description": "Probability per \"X-Y\" class. Masked to feasible outcomes for the tournament format."
        }
      },
      "type": "object",
      "title": "TennisExactScoreProjection"
    },
    "TennisPlayerDetail": {
      "properties": {
        "name": {
          "type": "string",
          "title": "Name"
        },
        "win_probability": {
          "anyOf": [
            {
              "type": "number",
              "maximum": 1.0,
              "minimum": 0.0
            },
            {
              "type": "null"
            }
          ],
          "title": "Win Probability",
          "description": "Probability of this player winning the match, in [0, 1]."
        },
        "expected_aces": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "title": "Expected Aces",
          "description": "Expected aces served by THIS player. Sums with the other player's value to `expected_aces`."
        },
        "aces_distribution": {
          "anyOf": [
            {
              "additionalProperties": {
                "type": "number"
              },
              "type": "object"
            },
            {
              "type": "null"
            }
          ],
          "title": "Aces Distribution",
          "description": "Probability per ace count for this player, as {count: probability}."
        },
        "aces_cdf": {
          "anyOf": [
            {
              "additionalProperties": {
                "type": "number"
              },
              "type": "object"
            },
            {
              "type": "null"
            }
          ],
          "title": "Aces Cdf",
          "description": "Cumulative probability P(aces <= count) for this player."
        },
        "expected_double_faults": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "title": "Expected Double Faults",
          "description": "Expected double faults hit by THIS player. Sums with the other player's value to `expected_double_faults`."
        },
        "double_faults_distribution": {
          "anyOf": [
            {
              "additionalProperties": {
                "type": "number"
              },
              "type": "object"
            },
            {
              "type": "null"
            }
          ],
          "title": "Double Faults Distribution",
          "description": "Probability per double-fault count for this player, as {count: probability}."
        },
        "double_faults_cdf": {
          "anyOf": [
            {
              "additionalProperties": {
                "type": "number"
              },
              "type": "object"
            },
            {
              "type": "null"
            }
          ],
          "title": "Double Faults Cdf",
          "description": "Cumulative probability P(double faults <= count) for this player."
        },
        "actual_aces": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "title": "Actual Aces",
          "description": "Aces THIS player actually served, once the match is played and reconciled. Compare with `expected_aces` and score the call against `aces_distribution`. Null while the match is ahead, and for matches played before the per-player rollout."
        },
        "actual_double_faults": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "title": "Actual Double Faults",
          "description": "Double faults THIS player actually hit, once the match is played and reconciled. Same availability rule as `actual_aces`."
        }
      },
      "type": "object",
      "required": [
        "name"
      ],
      "title": "TennisPlayerDetail",
      "description": "The ``player_one`` / ``player_two`` object of a tennis-family match\ndetail: the win probability plus that player's OWN serve projections.\n\nThe serve fields hang off the player they describe rather than sitting\nflat on the payload as ``expected_aces_player_one``. Same rule as the\nwin probability (see ``src.models.predictions``): every player-relative\nnumber lives inside the object whose ``name`` it belongs to, so it\ncannot be mis-attributed.\n\nPopulated for ATP ``tennis`` since migration 060 and WTA since\nmigration 063. Null for matches predicted before the relevant rollout.\n\n``actual_aces`` / ``actual_double_faults`` are the realized counts of a\nplayed match (migrations 061 / 064), matched to this object by player\nNAME rather than by slot: the reconciliation record carries the\nas-observed order of the LATEST data ingestion while the prediction\ncarries the as-observed order of the day it was made, and pairing those\nby position would hand one player's serve numbers to the other whenever\nthe two disagree."
    },
    "TennisTiebreakProjection": {
      "properties": {
        "probability_yes": {
          "anyOf": [
            {
              "type": "number",
              "maximum": 1.0,
              "minimum": 0.0
            },
            {
              "type": "null"
            }
          ],
          "title": "Probability Yes"
        },
        "probability_no": {
          "anyOf": [
            {
              "type": "number",
              "maximum": 1.0,
              "minimum": 0.0
            },
            {
              "type": "null"
            }
          ],
          "title": "Probability No"
        },
        "predicted": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Predicted"
        }
      },
      "type": "object",
      "title": "TennisTiebreakProjection"
    },
    "TournamentInfo": {
      "properties": {
        "name": {
          "type": "string",
          "title": "Name"
        },
        "location": {
          "type": "string",
          "title": "Location"
        },
        "surface": {
          "type": "string",
          "title": "Surface"
        },
        "type": {
          "type": "string",
          "title": "Type",
          "description": "Tournament category (e.g. grand_slam, masters_1000, atp_250)."
        },
        "round": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "title": "Round",
          "description": "Numeric round identifier as recorded by the data pipeline (higher = later round)."
        }
      },
      "type": "object",
      "required": [
        "name",
        "location",
        "surface",
        "type"
      ],
      "title": "TournamentInfo"
    }
  }
}