{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "urn:cede:schema:exchange-check:v0",
  "title": "Craton model exchange connectivity check, v0",
  "description": "The body of POST /exchange/models/{id}/check: whether Craton can reach the provider's Oasis platform, log in with the stored credentials and find the model, step by step. A check that runs answers 200 whatever it finds; ok is true only when every step that ran passed. Nothing about the user's data is sent, and nothing is stored: the check reads the platform's health endpoint, its login and the model's own record. It says what Craton could reach at that moment and nothing about the model's results.",
  "type": "object",
  "additionalProperties": false,
  "required": ["schema_version", "model_id", "checked_at", "ok", "steps"],
  "properties": {
    "schema_version": { "type": "string", "pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+$" },
    "model_id": { "type": "string", "pattern": "^xm_[0-9a-f]{16}$" },
    "checked_at": { "type": "string", "format": "date-time", "description": "When the check ran, RFC 3339 in UTC." },
    "ok": { "type": "boolean", "description": "True when no step failed." },
    "steps": {
      "type": "array",
      "minItems": 4,
      "maxItems": 4,
      "description": "The four steps, always in this order: address, health, login, model. A step after a failure is skipped, and says so.",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["step", "outcome", "detail"],
        "properties": {
          "step": {
            "enum": ["address", "health", "login", "model"],
            "description": "address: the base URL is https and its host resolves to public addresses only. health: GET {base_url}/healthcheck/ answers 200. login: the stored credentials are accepted by POST {base_url}/access_token/, or an access token was stored. model: GET {base_url}/v2/models/{model_pk}/ answers 200 with that model."
          },
          "outcome": { "enum": ["passed", "failed", "skipped"] },
          "detail": { "type": "string", "minLength": 1, "maxLength": 1000, "description": "What happened, in a sentence. Never carries a credential." }
        }
      }
    }
  }
}
