{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/machina-gg/json-schema/machina-gg-backtest-response-schema.json",
  "title": "BacktestResponse",
  "x-generated": "2026-11-17",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/machina-gg-openapi.json#/components/schemas/BacktestResponse",
  "allOf": [
    {
      "$ref": "#/$defs/ResponseBase"
    },
    {
      "type": "object",
      "required": [
        "finished_fixtures",
        "status",
        "audited_count",
        "total_count",
        "included_count",
        "excluded_count",
        "exclusion_reasons",
        "sources",
        "track_record"
      ],
      "properties": {
        "finished_fixtures": {
          "type": "array",
          "minItems": 104,
          "maxItems": 104
        },
        "status": {
          "const": "available"
        },
        "audited_count": {
          "const": 98
        },
        "total_count": {
          "const": 104
        },
        "included_count": {
          "const": 98
        },
        "excluded_count": {
          "const": 6
        },
        "exclusion_reasons": {
          "type": "object",
          "required": [
            "forecast_at_or_after_kickoff"
          ]
        },
        "sources": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "track_record": {
          "type": "object",
          "required": [
            "sample_size",
            "sample_size_sufficient",
            "brier_scores",
            "accuracy",
            "calibration",
            "recommendation"
          ]
        },
        "clv_report": {
          "type": "object"
        },
        "calibration_report": {
          "type": "object"
        }
      }
    }
  ],
  "$defs": {
    "ArchiveMetadata": {
      "type": "object",
      "required": [
        "mode",
        "version",
        "status",
        "competition",
        "competition_status",
        "live",
        "snapshot_as_of",
        "capability_status",
        "provenance",
        "missing_capabilities",
        "notes"
      ],
      "properties": {
        "mode": {
          "const": "final_archive"
        },
        "version": {
          "type": "string",
          "enum": [
            "world-cup-2026-final-v2",
            "world-cup-2026-final-v3"
          ]
        },
        "status": {
          "type": "string",
          "enum": [
            "hit",
            "miss",
            "unavailable",
            "error"
          ],
          "description": "hit = an immutable archived row was served. unavailable/error = nothing was served; see coverage.reason_code. A `miss` never reaches the public surface."
        },
        "competition": {
          "const": "FIFA World Cup 2026"
        },
        "competition_status": {
          "const": "completed"
        },
        "live": {
          "const": false
        },
        "snapshot_as_of": {
          "type": [
            "string",
            "null"
          ]
        },
        "source_observed_at": {
          "type": [
            "string",
            "null"
          ]
        },
        "content_created_at": {
          "type": [
            "string",
            "null"
          ]
        },
        "timestamp_semantics": {
          "type": "string"
        },
        "capability_status": {
          "type": "string"
        },
        "provenance": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "missing_capabilities": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "notes": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "response_sha256": {
          "type": "string",
          "pattern": "^[0-9a-f]{64}$"
        },
        "source_manifest_sha256": {
          "type": "string",
          "pattern": "^[0-9a-f]{64}$"
        },
        "request_identity_sha256": {
          "type": "string",
          "pattern": "^[0-9a-f]{64}$"
        },
        "reason_code": {
          "type": "string",
          "enum": [
            "fixture_selector_required",
            "fixture_ambiguous",
            "fixture_not_found",
            "player_selector_required",
            "player_ambiguous",
            "player_not_found",
            "entity_selector_required",
            "entity_ambiguous",
            "entity_not_found",
            "unsupported_parameter",
            "archive_row_missing",
            "archive_error"
          ]
        }
      }
    },
    "Coverage": {
      "type": "object",
      "required": [
        "schema_version",
        "status",
        "reason",
        "scope",
        "mode",
        "source_provenance",
        "population_count",
        "eligible_count",
        "included_count",
        "excluded_count",
        "exclusion_reasons",
        "unsupported_fields"
      ],
      "properties": {
        "schema_version": {
          "const": "worldcup-storefront-coverage-v1"
        },
        "status": {
          "type": "string",
          "enum": [
            "complete",
            "partial",
            "unavailable",
            "error"
          ]
        },
        "reason": {
          "type": "string",
          "minLength": 1
        },
        "scope": {
          "const": "completed_tournament_archive"
        },
        "mode": {
          "const": "historical"
        },
        "source_provenance": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "population_count": {
          "type": [
            "integer",
            "null"
          ],
          "minimum": 0,
          "description": "Null means the legacy response did not record this count; null is never equivalent to zero."
        },
        "eligible_count": {
          "type": [
            "integer",
            "null"
          ],
          "minimum": 0
        },
        "included_count": {
          "type": [
            "integer",
            "null"
          ],
          "minimum": 0
        },
        "excluded_count": {
          "type": [
            "integer",
            "null"
          ],
          "minimum": 0
        },
        "exclusion_reasons": {
          "type": "object",
          "additionalProperties": {
            "type": "integer",
            "minimum": 0
          }
        },
        "unsupported_fields": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "reason_code": {
          "type": "string",
          "enum": [
            "fixture_selector_required",
            "fixture_ambiguous",
            "fixture_not_found",
            "player_selector_required",
            "player_ambiguous",
            "player_not_found",
            "entity_selector_required",
            "entity_ambiguous",
            "entity_not_found",
            "unsupported_parameter",
            "archive_row_missing",
            "archive_error"
          ],
          "description": "Machine-readable cause, present whenever status is unavailable or error. Request-side codes (fixture_*/player_*/entity_*/unsupported_parameter) mean the caller can fix the request; the gateway answers them with HTTP 400 (missing/ambiguous/unsupported) or 404 (not_found). archive_row_missing (HTTP 503) and archive_error (HTTP 502) are on our side. None of these calls is billed."
        },
        "accepted_fields": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "The request fields this endpoint accepts, echoed on unserved responses so an agent can self-correct."
        }
      }
    },
    "ResponseBase": {
      "type": "object",
      "required": [
        "archive",
        "coverage",
        "warnings"
      ],
      "properties": {
        "archive": {
          "$ref": "#/$defs/ArchiveMetadata"
        },
        "coverage": {
          "$ref": "#/$defs/Coverage"
        },
        "warnings": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      }
    }
  }
}