{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://github.com/KryptosAI/mcp-observatory/schemas/run-artifact.schema.json",
  "title": "MCP Observatory Run Artifact",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "artifactType",
    "schemaVersion",
    "gate",
    "runId",
    "createdAt",
    "toolVersion",
    "target",
    "environment",
    "summary",
    "checks"
  ],
  "properties": {
    "artifactType": {
      "const": "run"
    },
    "schemaVersion": {
      "const": "1.0.0"
    },
    "gate": {
      "$ref": "#/definitions/gate"
    },
    "runId": {
      "type": "string"
    },
    "createdAt": {
      "type": "string"
    },
    "toolVersion": {
      "type": "string"
    },
    "target": {
      "$ref": "#/definitions/targetSnapshot"
    },
    "environment": {
      "$ref": "#/definitions/environmentSnapshot"
    },
    "summary": {
      "$ref": "#/definitions/runSummary"
    },
    "checks": {
      "type": "array",
      "items": {
        "$ref": "#/definitions/checkResult"
      }
    },
    "fatalError": {
      "type": "string"
    }
  },
  "definitions": {
    "gate": {
      "type": "string",
      "enum": ["pass", "fail"]
    },
    "checkStatus": {
      "type": "string",
      "enum": ["pass", "fail", "partial", "unsupported", "flaky", "skipped"]
    },
    "checkId": {
      "type": "string",
      "enum": ["tools", "prompts", "resources"]
    },
    "evidenceSummary": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "endpoint",
        "advertised",
        "responded",
        "minimalShapePresent"
      ],
      "properties": {
        "endpoint": {
          "type": "string"
        },
        "advertised": {
          "type": "boolean"
        },
        "responded": {
          "type": "boolean"
        },
        "minimalShapePresent": {
          "type": "boolean"
        },
        "itemCount": {
          "type": "integer",
          "minimum": 0
        },
        "identifiers": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "diagnostics": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      }
    },
    "checkResult": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "id",
        "capability",
        "status",
        "durationMs",
        "message",
        "evidence"
      ],
      "properties": {
        "id": {
          "$ref": "#/definitions/checkId"
        },
        "capability": {
          "$ref": "#/definitions/checkId"
        },
        "status": {
          "$ref": "#/definitions/checkStatus"
        },
        "durationMs": {
          "type": "number",
          "minimum": 0
        },
        "message": {
          "type": "string"
        },
        "evidence": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/evidenceSummary"
          }
        }
      }
    },
    "statusCounts": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "total",
        "pass",
        "fail",
        "partial",
        "unsupported",
        "flaky",
        "skipped"
      ],
      "properties": {
        "total": { "type": "integer", "minimum": 0 },
        "pass": { "type": "integer", "minimum": 0 },
        "fail": { "type": "integer", "minimum": 0 },
        "partial": { "type": "integer", "minimum": 0 },
        "unsupported": { "type": "integer", "minimum": 0 },
        "flaky": { "type": "integer", "minimum": 0 },
        "skipped": { "type": "integer", "minimum": 0 }
      }
    },
    "runSummary": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "total",
        "pass",
        "fail",
        "partial",
        "unsupported",
        "flaky",
        "skipped",
        "gate"
      ],
      "properties": {
        "total": { "type": "integer", "minimum": 0 },
        "pass": { "type": "integer", "minimum": 0 },
        "fail": { "type": "integer", "minimum": 0 },
        "partial": { "type": "integer", "minimum": 0 },
        "unsupported": { "type": "integer", "minimum": 0 },
        "flaky": { "type": "integer", "minimum": 0 },
        "skipped": { "type": "integer", "minimum": 0 },
        "gate": {
          "$ref": "#/definitions/gate"
        }
      }
    },
    "targetSnapshot": {
      "type": "object",
      "additionalProperties": false,
      "required": ["targetId", "adapter", "command", "args"],
      "properties": {
        "targetId": {
          "type": "string"
        },
        "adapter": {
          "const": "local-process"
        },
        "command": {
          "type": "string"
        },
        "args": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "cwd": {
          "type": "string"
        },
        "metadata": {
          "type": "object",
          "additionalProperties": {
            "type": "string"
          }
        },
        "serverVersion": {
          "type": "string"
        },
        "serverName": {
          "type": "string"
        }
      }
    },
    "environmentSnapshot": {
      "type": "object",
      "additionalProperties": false,
      "required": ["platform", "nodeVersion"],
      "properties": {
        "platform": {
          "type": "string"
        },
        "nodeVersion": {
          "type": "string"
        }
      }
    }
  }
}
