{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://limecloud.github.io/agentapp/schemas/app-readiness.schema.json",
  "title": "Agent App Readiness Result",
  "type": "object",
  "required": [
    "ok",
    "status",
    "checks"
  ],
  "properties": {
    "ok": {
      "type": "boolean"
    },
    "status": {
      "type": "string",
      "description": "v0.5 expands the state set: ready / ready-degraded / needs-setup / blocked / unknown. v0.4 values ready / needs-setup / failed remain valid.",
      "enum": [
        "ready",
        "ready-degraded",
        "needs-setup",
        "blocked",
        "unknown",
        "failed"
      ]
    },
    "command": {
      "type": "string"
    },
    "app": {
      "type": "string"
    },
    "workspace": {
      "type": [
        "string",
        "null"
      ]
    },
    "checks": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/check"
      }
    },
    "tiers": {
      "type": "object",
      "description": "v0.5: aggregated check results by tier sourced from evals/readiness.yaml.",
      "properties": {
        "required": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/check"
          }
        },
        "recommended": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/check"
          }
        },
        "performance": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/check"
          }
        }
      },
      "additionalProperties": false
    },
    "blockers": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "warnings": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "setupActions": {
      "type": "array",
      "description": "v0.5: actionable repair steps the host can present to the user.",
      "items": {
        "$ref": "#/$defs/setupAction"
      }
    }
  },
  "$defs": {
    "check": {
      "type": "object",
      "required": [
        "severity",
        "kind",
        "key",
        "message"
      ],
      "properties": {
        "severity": {
          "type": "string",
          "enum": [
            "info",
            "warning",
            "error"
          ]
        },
        "kind": {
          "type": "string"
        },
        "key": {
          "type": "string"
        },
        "required": {
          "type": "boolean"
        },
        "version": {
          "type": "string"
        },
        "code": {
          "type": "string"
        },
        "blocking": {
          "type": "boolean"
        },
        "tier": {
          "type": "string",
          "description": "v0.5: which readiness tier the check belongs to.",
          "enum": [
            "required",
            "recommended",
            "performance"
          ]
        },
        "message": {
          "type": "string"
        },
        "remediation": {
          "type": "string"
        }
      },
      "additionalProperties": true
    },
    "setupAction": {
      "type": "object",
      "description": "v0.5: a host-actionable repair step.",
      "required": ["key", "title"],
      "properties": {
        "key": {
          "type": "string"
        },
        "title": {
          "type": "string"
        },
        "description": {
          "type": "string"
        },
        "kind": {
          "type": "string",
          "enum": [
            "bind-knowledge",
            "configure-secret",
            "grant-permission",
            "install-tool",
            "run-migration",
            "open-settings",
            "external"
          ]
        },
        "target": {
          "type": "string"
        }
      },
      "additionalProperties": true
    }
  },
  "additionalProperties": true
}
