{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://heartcortex.ai/schemas/1.0/evolution.schema.json",
  "title": "Evolution state",
  "type": "object",
  "required": [
    "heartVersion"
  ],
  "properties": {
    "heartVersion": {
      "type": "string",
      "x-heart-privacy": "public"
    },
    "pins": {
      "type": "array",
      "x-heart-privacy": "internal",
      "items": {
        "type": "object",
        "required": [
          "purpose",
          "provider",
          "model",
          "pinnedAt"
        ],
        "properties": {
          "purpose": {
            "type": "string"
          },
          "provider": {
            "type": "string"
          },
          "model": {
            "type": "string"
          },
          "version": {
            "type": "string"
          },
          "pinnedAt": {
            "$ref": "common.schema.json#/$defs/timestamp"
          },
          "regression": {
            "$ref": "#/$defs/regression"
          }
        }
      }
    },
    "candidates": {
      "type": "array",
      "x-heart-privacy": "internal",
      "items": {
        "type": "object",
        "required": [
          "provider",
          "model",
          "state"
        ],
        "properties": {
          "purpose": {
            "type": "string"
          },
          "provider": {
            "type": "string"
          },
          "model": {
            "type": "string"
          },
          "version": {
            "type": "string"
          },
          "state": {
            "enum": [
              "queued",
              "testing",
              "passed",
              "rejected"
            ]
          },
          "requestedAt": {
            "$ref": "common.schema.json#/$defs/timestamp"
          },
          "regression": {
            "$ref": "#/$defs/regression"
          }
        }
      }
    },
    "lessons": {
      "description": "How many lessons (rules or Playbooks learned from past incidents) exist. The lessons themselves are heart.lesson messages, from GET /evolution/lessons.",
      "type": "integer",
      "minimum": 0,
      "x-heart-privacy": "internal"
    },
    "ext": {
      "$ref": "common.schema.json#/$defs/ext",
      "x-heart-privacy": "private"
    }
  },
  "$defs": {
    "regression": {
      "type": "object",
      "required": [
        "suite",
        "passed"
      ],
      "properties": {
        "suite": {
          "type": "string"
        },
        "passed": {
          "type": "boolean"
        },
        "score": {
          "type": "number"
        },
        "ranAt": {
          "$ref": "common.schema.json#/$defs/timestamp"
        }
      }
    }
  }
}
