{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://wildflower.computer/schemas/sdk-benchmark-result.schema.json",
  "title": "Wildflower SDK loopback benchmark result",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schemaVersion",
    "benchmark",
    "description",
    "sourceCommit",
    "sourceDirty",
    "generatedAt",
    "configuration",
    "methodology",
    "environment",
    "results"
  ],
  "properties": {
    "schemaVersion": {
      "const": 1
    },
    "benchmark": {
      "const": "wildflower-sdk-loopback"
    },
    "description": {
      "type": "string"
    },
    "sourceCommit": {
      "type": "string",
      "pattern": "^[0-9a-f]{40}$"
    },
    "sourceDirty": {
      "type": "boolean"
    },
    "generatedAt": {
      "type": "string",
      "format": "date-time"
    },
    "configuration": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "coldIterations",
        "warmupIterations",
        "warmIterations",
        "languages"
      ],
      "properties": {
        "coldIterations": {
          "type": "integer",
          "minimum": 1
        },
        "warmupIterations": {
          "type": "integer",
          "minimum": 0
        },
        "warmIterations": {
          "type": "integer",
          "minimum": 1
        },
        "languages": {
          "type": "array",
          "minItems": 1,
          "uniqueItems": true,
          "items": {
            "enum": [
              "typescript",
              "python",
              "rust",
              "go",
              "zig"
            ]
          }
        }
      }
    },
    "methodology": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "target",
        "cold",
        "warm",
        "decomposition"
      ],
      "properties": {
        "target": {
          "type": "string"
        },
        "cold": {
          "type": "string"
        },
        "warm": {
          "type": "string"
        },
        "decomposition": {
          "type": "string"
        }
      }
    },
    "environment": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "platform",
        "release",
        "architecture",
        "logicalCpuCount",
        "cpuModel"
      ],
      "properties": {
        "platform": {
          "type": "string"
        },
        "release": {
          "type": "string"
        },
        "architecture": {
          "type": "string"
        },
        "logicalCpuCount": {
          "type": "integer",
          "minimum": 1
        },
        "cpuModel": {
          "type": "string"
        }
      }
    },
    "results": {
      "type": "array",
      "minItems": 1,
      "items": {
        "$ref": "#/$defs/languageResult"
      }
    }
  },
  "$defs": {
    "summary": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "min",
        "p50",
        "p95",
        "p99",
        "max",
        "mean"
      ],
      "properties": {
        "min": {
          "type": "number",
          "minimum": 0
        },
        "p50": {
          "type": "number",
          "minimum": 0
        },
        "p95": {
          "type": "number",
          "minimum": 0
        },
        "p99": {
          "type": "number",
          "minimum": 0
        },
        "max": {
          "type": "number",
          "minimum": 0
        },
        "mean": {
          "type": "number",
          "minimum": 0
        }
      }
    },
    "measurement": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "operation",
        "phase",
        "samples",
        "wallMicroseconds",
        "serverMicroseconds",
        "clientAndLoopbackEstimateMicroseconds"
      ],
      "properties": {
        "operation": {
          "enum": [
            "create",
            "get",
            "runCommand",
            "delete"
          ]
        },
        "phase": {
          "enum": [
            "cold",
            "warm"
          ]
        },
        "samples": {
          "type": "integer",
          "minimum": 1
        },
        "wallMicroseconds": {
          "$ref": "#/$defs/summary"
        },
        "serverMicroseconds": {
          "$ref": "#/$defs/summary"
        },
        "clientAndLoopbackEstimateMicroseconds": {
          "$ref": "#/$defs/summary"
        }
      }
    },
    "languageResult": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "language",
        "sdkVersion",
        "runtime",
        "measurements"
      ],
      "properties": {
        "language": {
          "enum": [
            "typescript",
            "python",
            "rust",
            "go",
            "zig"
          ]
        },
        "sdkVersion": {
          "type": "string"
        },
        "runtime": {
          "type": "string"
        },
        "measurements": {
          "type": "array",
          "minItems": 8,
          "maxItems": 8,
          "items": {
            "$ref": "#/$defs/measurement"
          }
        }
      }
    }
  }
}
