{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/statshawk-ai/json-schema/statshawk-ai-api-response-person-game-log-list-schema.json",
  "title": "ApiResponsePersonGameLogList",
  "description": "Successful response envelope: resource data and request metadata.",
  "x-generated": "2026-11-26",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/statshawk-ai-openapi.json#/components/schemas/ApiResponsePersonGameLogList",
  "type": "object",
  "required": [
    "data",
    "meta"
  ],
  "properties": {
    "data": {
      "$ref": "#/$defs/PersonGameLogListResponse",
      "description": "Resource payload returned by this endpoint, inside the success envelope."
    },
    "meta": {
      "$ref": "#/$defs/ResponseMeta",
      "description": "Request identifier, source attribution, fetch timestamp and response cache state."
    }
  },
  "$defs": {
    "AppearanceId": {
      "type": "string",
      "description": "Canonical appearance identifier (`apr_…`) for one person’s participation in one contest.\nCanonical entity identifier (`apr_<base32>`). The suffix is exactly 26 Crockford base32 symbols encoding a UUID. Output uses lowercase without padding. The prefix is case-sensitive; another entity type’s prefix and bare UUID/source identifiers are rejected. Treat the full identifier as opaque."
    },
    "BaseballLineupLine": {
      "type": "object",
      "description": "A baseball appearance's as-played lineup facts:\n`batting_slot`/`batting_entry` decode MLB's 3-digit wire `battingOrder`\ncode at the adapter boundary (never stored raw) and are `None` together\nfor a player with no batting order at all (e.g. an NL pitcher with no DH),\nwho may still carry a `position`. Exposed ONLY on\n[`BoxscoreLine::baseball`] — every other sport's line never has this key.",
      "properties": {
        "batting_entry": {
          "type": [
            "integer",
            "null"
          ],
          "format": "int32",
          "description": "Substitution entry order within the slot (0 = starter); `None` iff\n`batting_slot` is `None`."
        },
        "batting_slot": {
          "type": [
            "integer",
            "null"
          ],
          "format": "int32",
          "description": "1-9 lineup slot; `None` when the person had no batting order."
        },
        "position": {
          "oneOf": [
            {
              "type": "null",
              "description": "Accepts the JSON null value."
            },
            {
              "$ref": "#/$defs/PositionCode",
              "description": "As-played fielded position (e.g. `\"SS\"`)."
            }
          ],
          "description": "As-played fielded position (e.g. `\"SS\"`)."
        }
      }
    },
    "BoxscoreLine": {
      "type": "object",
      "description": "One appearance's boxscore line: the appearance identity plus a block per\nphase the person played. Replaces the raw JSONB `stats` on the read path —\nthe blocks carry both stored base measures and computed derived measures.\n\nA single-phase sport yields one [`PhaseLine`]; a two-way player (Ohtani)\nyields a `batting` AND a `pitching` block off the same appearance.\n\n`contest` rides on the line so game-log / prop-card can attach kickoff /\nopponent context without a second appearance-spine read (the lines query\nalready joins `contests`; selecting the id is free).",
      "required": [
        "appearance",
        "person",
        "contest",
        "phases"
      ],
      "properties": {
        "appearance": {
          "$ref": "#/$defs/AppearanceId",
          "description": "Appearance identifier (`apr_...`) that anchors these phase rows."
        },
        "baseball": {
          "oneOf": [
            {
              "type": "null",
              "description": "Accepts the JSON null value."
            },
            {
              "$ref": "#/$defs/BaseballLineupLine",
              "description": "Baseball-only as-played lineup facts — `None` for every\nother sport, and skipped from the JSON entirely rather than\nserialized as `null` (sport-scoped facts never ride a universal\nshape — see CLAUDE.md)."
            }
          ],
          "description": "Baseball-only as-played lineup facts — `None` for every\nother sport, and skipped from the JSON entirely rather than\nserialized as `null` (sport-scoped facts never ride a universal\nshape — see CLAUDE.md)."
        },
        "contest": {
          "$ref": "#/$defs/ContestId",
          "description": "The contest this appearance's stats were recorded in."
        },
        "person": {
          "$ref": "#/$defs/PersonId",
          "description": "Canonical person identifier (`per_...`) whose statistics this line describes."
        },
        "person_name": {
          "type": [
            "string",
            "null"
          ],
          "description": "The person's full name, resolved server-side on the contest-boxscore\nread (one `persons` join — a consumer should never need N follow-up\nperson lookups to label a boxscore). Omitted on reads that are already\nperson-scoped (game-log), where the caller knows who the lines belong\nto."
        },
        "phases": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/PhaseLine"
          },
          "description": "One block per phase the person played, in phase order."
        },
        "team": {
          "oneOf": [
            {
              "type": "null",
              "description": "Accepts the JSON null value."
            },
            {
              "$ref": "#/$defs/TeamId",
              "description": "The team the person represented in this game when the entrant is\nteam-backed; `None` for a non-team entrant (individual/pair/animal)."
            }
          ],
          "description": "The team the person represented in this game when the entrant is\nteam-backed; `None` for a non-team entrant (individual/pair/animal)."
        }
      }
    },
    "CacheStatus": {
      "type": "string",
      "description": "Response cache status, serialized as an uppercase token.\n`HIT` means a relevant store read or handler response cache returned a cached payload; `MISS` means a cache miss or an uncached read.\n`STALE` means a cached payload passed its fresh TTL but remains inside the allowed stale interval. It does not guarantee a refresh has started. Current entity-store caching records HIT or MISS.\nComposite reads report the last store-call outcome; this does not prove every nested resource shares one fetch time.",
      "enum": [
        "HIT",
        "MISS",
        "STALE"
      ]
    },
    "ContestId": {
      "type": "string",
      "description": "Canonical contest identifier (`cst_…`) for a team match, individual match, or field event; used by public contest routes.\nCanonical entity identifier (`cst_<base32>`). The suffix is exactly 26 Crockford base32 symbols encoding a UUID. Output uses lowercase without padding. The prefix is case-sensitive; another entity type’s prefix and bare UUID/source identifiers are rejected. Treat the full identifier as opaque."
    },
    "ContestStatus": {
      "type": "string",
      "description": "Lifecycle status of a [`Contest`]. Renamed from the legacy `GameStatus`\nwith stable snake_case tokens: `scheduled` means not started; `in_progress` means play has started;\n`final` means completed; `postponed` means delayed to a later start; `cancelled` means cancelled;\n`suspended` means started play has paused.",
      "enum": [
        "scheduled",
        "in_progress",
        "final",
        "postponed",
        "cancelled",
        "suspended"
      ]
    },
    "DateRange": {
      "type": "object",
      "description": "An inclusive `[start, end]` interval over UTC instants. The temporal anchor\nof an `Edition` (`starts_at..=ends_at`).",
      "required": [
        "start",
        "end"
      ],
      "properties": {
        "end": {
          "type": "string",
          "format": "date-time",
          "description": "Inclusive end instant, encoded as an RFC 3339 UTC date-time."
        },
        "start": {
          "type": "string",
          "format": "date-time",
          "description": "Inclusive start instant, encoded as an RFC 3339 UTC date-time."
        }
      }
    },
    "EventId": {
      "type": "string",
      "description": "Intra-edition event (tournament/round/series) id (`evt_...`).\nCanonical entity identifier (`evt_<base32>`). The suffix is exactly 26 Crockford base32 symbols encoding a UUID. Output uses lowercase without padding. The prefix is case-sensitive; another entity type’s prefix and bare UUID/source identifiers are rejected. Treat the full identifier as opaque."
    },
    "EventKind": {
      "type": "string",
      "description": "The kind of intra-edition grouping an [`Event`](crate::ids::EventId)\nrepresents (spec §4.5b): a tournament/round/series/meeting within one\nedition of one competition. `tournament` is a standalone tournament; `round` is one championship round;\n`series` is a best-of-N series; `meeting` is a race or athletics meeting.",
      "enum": [
        "tournament",
        "round",
        "series",
        "meeting"
      ]
    },
    "EventLineageSlug": {
      "type": "string",
      "description": "Stable cross-edition identity of a recurring event: lowercase ASCII words joined by single underscores (e.g. `wimbledon`)."
    },
    "EventSummary": {
      "type": "object",
      "description": "The read-side summary of an intra-edition grouping attached to a contest:\ntournament, round, series, or meeting. This is source-neutral; adapters lower\nupstream-specific fields into canonical [`Event`](crate::domain::event::Event)\nrows before this view is assembled.",
      "required": [
        "id",
        "kind",
        "name",
        "span"
      ],
      "properties": {
        "id": {
          "$ref": "#/$defs/EventId",
          "description": "Canonical event identifier (`evt_` prefix), not a source identifier."
        },
        "kind": {
          "$ref": "#/$defs/EventKind",
          "description": "Grouping type within the edition: tournament, round, series, or meeting."
        },
        "lineage": {
          "oneOf": [
            {
              "type": "null",
              "description": "Accepts the JSON null value."
            },
            {
              "$ref": "#/$defs/EventLineageSlug",
              "description": "Stable recurring-event slug across editions; null when no lineage is recorded."
            }
          ],
          "description": "Stable recurring-event slug across editions; null when no lineage is recorded."
        },
        "name": {
          "type": "string",
          "description": "Display name of this event staging."
        },
        "span": {
          "$ref": "#/$defs/DateRange",
          "description": "Inclusive event start and end instants, encoded as RFC 3339 UTC timestamps."
        }
      }
    },
    "JerseyNumber": {
      "type": "string",
      "description": "Squad number a source listed the person under for one team affiliation: a label of one to three alphanumerics (\"00\" and \"0\" differ), never a quantity.",
      "pattern": "^[0-9A-Z]{1,3}$"
    },
    "PersonGameLogEntry": {
      "type": "object",
      "description": "One row of a person's game log (Workflow-1 task A4) — the game the appearance\nbelongs to plus that game's phase-derived stat line. The line is assembled\nfrom `appearances ⨝ phase tables` (base + registry-derived measures), exactly\nlike a boxscore line but keyed to the person; the `game` reference ties it to\nthe game so a consumer can tell the rows of a chronological log apart. A pure\nread — there is no `*_game_logs` table.\nThe contest-context fields (`kickoff`/`home`/`opponent`/`team`/`status`) are\nderived from the contest's [`MatchSummary`], which the read already fetches —\neach is `None` only when that contest lookup missed (or, for the team-shaped\nfields, when the line's team matches neither side / the team row is gone).",
      "required": [
        "game",
        "line"
      ],
      "properties": {
        "event": {
          "oneOf": [
            {
              "type": "null",
              "description": "Accepts the JSON null value."
            },
            {
              "$ref": "#/$defs/EventSummary",
              "description": "Tournament/round/series/meeting context, when the game belongs to one."
            }
          ],
          "description": "Tournament/round/series/meeting context, when the game belongs to one."
        },
        "game": {
          "$ref": "#/$defs/ContestId",
          "description": "The game this line was recorded in (the underlying contest id)."
        },
        "home": {
          "type": [
            "boolean",
            "null"
          ],
          "description": "Whether this person's team was the home side (`false` = away). `None`\nwhen the side can't be determined (contest lookup missed, non-team\nappearance, or a team matching neither side)."
        },
        "jersey": {
          "oneOf": [
            {
              "type": "null",
              "description": "Accepts the JSON null value."
            },
            {
              "$ref": "#/$defs/JerseyNumber",
              "description": "The squad number the person was listed under on their team for the game's edition (a label such as `\"00\"`); null when no source reported one or the contest lookup missed."
            }
          ],
          "description": "The squad number the person was listed under on their team for the game's edition (a label such as `\"00\"`); null when no source reported one or the contest lookup missed."
        },
        "kickoff": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time",
          "description": "Scheduled contest start as an RFC 3339 UTC date-time; null if the contest lookup missed."
        },
        "line": {
          "$ref": "#/$defs/BoxscoreLine",
          "description": "Per-game phase-derived stat line (base and derived measures).\nSee [CanonicalPhaseMeasureCatalog](#/components/schemas/CanonicalPhaseMeasureCatalog) for the matching per-phase game schema, names, units, and formulas."
        },
        "opponent": {
          "oneOf": [
            {
              "type": "null",
              "description": "Accepts the JSON null value."
            },
            {
              "$ref": "#/$defs/TeamRef",
              "description": "The other side of the game, with its name. `None` when the side can't\nbe determined."
            }
          ],
          "description": "The other side of the game, with its name. `None` when the side can't\nbe determined."
        },
        "status": {
          "oneOf": [
            {
              "type": "null",
              "description": "Accepts the JSON null value."
            },
            {
              "$ref": "#/$defs/ContestStatus",
              "description": "The game's status (scheduled/live/final/…). `None` only if the contest\nlookup missed."
            }
          ],
          "description": "The game's status (scheduled/live/final/…). `None` only if the contest\nlookup missed."
        },
        "team": {
          "oneOf": [
            {
              "type": "null",
              "description": "Accepts the JSON null value."
            },
            {
              "$ref": "#/$defs/TeamRef",
              "description": "The person's own team that game, with its name. `None` for a non-team\nappearance or when the team row is gone."
            }
          ],
          "description": "The person's own team that game, with its name. `None` for a non-team\nappearance or when the team row is gone."
        }
      }
    },
    "PersonGameLogListResponse": {
      "type": "object",
      "description": "List payload with returned items, a handler-supplied count, and optional page metadata.\nA limit/offset endpoint can return a bounded list without page metadata.",
      "required": [
        "items",
        "total"
      ],
      "properties": {
        "items": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/PersonGameLogEntry"
          },
          "description": "Resource items returned in this response; absent page metadata does not imply a complete collection."
        },
        "page": {
          "type": [
            "integer",
            "null"
          ],
          "format": "int32",
          "description": "Optional one-based page number; omitted when the handler supplies no page metadata.",
          "minimum": 0
        },
        "per_page": {
          "type": [
            "integer",
            "null"
          ],
          "format": "int32",
          "description": "Optional maximum items per page; omitted when the handler supplies no page metadata.",
          "minimum": 0
        },
        "total": {
          "type": "integer",
          "description": "Handler-supplied count. The default is returned items length, including limit/offset reads;\na handler can separately supply a wider match count.",
          "minimum": 0
        }
      }
    },
    "PersonId": {
      "type": "string",
      "description": "Canonical sport-agnostic person id (`per_...`).\nCanonical entity identifier (`per_<base32>`). The suffix is exactly 26 Crockford base32 symbols encoding a UUID. Output uses lowercase without padding. The prefix is case-sensitive; another entity type’s prefix and bare UUID/source identifiers are rejected. Treat the full identifier as opaque."
    },
    "PhaseLine": {
      "type": "object",
      "description": "One phase's stat block: the phase name plus its measures — stored **base**\ncolumns AND the **derived** measures the registry formulas compute. Integral\nvalues serialize as integers and fractional values as numbers. Appearance\nconstructors evaluate formulas over one row. Materialized season reads omit\nformulas that require full-row coverage because totals carry no such proof.",
      "required": [
        "phase",
        "measures"
      ],
      "properties": {
        "measures": {
          "type": "object",
          "description": "Open numeric map of canonical base and derived measures, with unqualified\nkeys inside this phase (for example `tpm` and `tov` in basketball).\nSee [CanonicalPhaseMeasureCatalog](#/components/schemas/CanonicalPhaseMeasureCatalog)\nand its game/season inventories for full names, units, formulas and keys.\nIntegral values use JSON integers; fractional values use JSON numbers.\nUnreported nullable values and undefined rates (zero denominator or missing\ninput) are absent. Nonnullable base columns can contain zero when the\nsource did not report a value; an emitted zero does not prove observation.\nMaterialized season reads also omit formulas that require full-row\ncoverage, even when all their stored totals are non-null.\nThe source-shaped legacy `*PlayerGameLine` models are parser references\nwith different keys and encodings, not this map's wire contract.\nSource coverage varies, historical coverage can be incomplete, and final\nvalues remain subject to source corrections."
        },
        "phase": {
          "type": "string",
          "description": "The phase namespace (`\"batting\"`, `\"pitching\"`, `\"basketball_player_game\"`, …)."
        }
      }
    },
    "PositionCode": {
      "type": "string",
      "description": "Source-reported sport-specific player position code."
    },
    "ResponseMeta": {
      "type": "object",
      "description": "Metadata block included in every API response envelope.\n\nReports the request identifier, read source label, response timestamp, cache outcome, and API version.\nThese fields do not report the upstream observation time or guarantee complete data coverage.",
      "required": [
        "request_id",
        "fetched_at",
        "cache",
        "version"
      ],
      "properties": {
        "cache": {
          "$ref": "#/$defs/CacheStatus",
          "description": "Uppercase response cache token: HIT (cached), MISS (uncached/cache miss), or STALE (accepted stale cache)."
        },
        "fetched_at": {
          "type": "string",
          "format": "date-time",
          "description": "RFC 3339 UTC timestamp of response assembly, or the cached store-fetch time when a read path propagates it.\nHandler caches such as the stat board retain response assembly time even on HIT or STALE.\nThis field cannot reliably measure payload age and is not the upstream observation/update time.\nComposite reads use the last store-call cache outcome unless the handler supplies its own cache status."
        },
        "request_id": {
          "type": "string",
          "format": "uuid",
          "description": "Unique identifier for this request; quote this when filing support tickets."
        },
        "source": {
          "type": [
            "string",
            "null"
          ],
          "description": "Optional label for where the handler served data, such as `postgres` or `registry`.\nNull when the handler supplied no label. This is not necessarily an upstream provider identifier."
        },
        "version": {
          "type": "string",
          "description": "API version string, currently always `\"v1\"`."
        }
      }
    },
    "TeamId": {
      "type": "string",
      "description": "Sport-scoped team id (`team_...`).\nCanonical entity identifier (`team_<base32>`). The suffix is exactly 26 Crockford base32 symbols encoding a UUID. Output uses lowercase without padding. The prefix is case-sensitive; another entity type’s prefix and bare UUID/source identifiers are rejected. Treat the full identifier as opaque."
    },
    "TeamRef": {
      "type": "object",
      "description": "The home/away team side of a [`MatchupCard`] — just enough to label the\ncard without a full [`Team`] fetch. `None` when the matchup row carries no\nresolved team for that side yet (`entity.matchups.home_team_id`/\n`away_team_id` are nullable).",
      "required": [
        "team_id",
        "name"
      ],
      "properties": {
        "name": {
          "type": "string",
          "description": "Stored canonical team display name."
        },
        "team_id": {
          "$ref": "#/$defs/TeamId",
          "description": "Canonical team ID (`team_...`) for this card side."
        }
      }
    }
  }
}