{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://www.rxrelay.ai/skills/rxrelay-readiness.schema.json",
  "title": "RxRelay integration readiness report",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schemaVersion",
    "generatedAt",
    "status",
    "integration",
    "source",
    "summary",
    "checks",
    "sandbox",
    "secrets",
    "liveSafety"
  ],
  "properties": {
    "schemaVersion": { "const": "1.0" },
    "generatedAt": { "type": "string", "format": "date-time" },
    "status": {
      "enum": ["ready", "ready_with_warnings", "blocked"]
    },
    "integration": {
      "type": "object",
      "additionalProperties": false,
      "required": ["repository", "commit", "framework", "environment"],
      "properties": {
        "repository": { "type": "string", "minLength": 1 },
        "commit": { "type": ["string", "null"] },
        "framework": { "type": "string", "minLength": 1 },
        "environment": {
          "enum": ["local", "sandbox", "preview", "production", "multiple"]
        }
      }
    },
    "source": {
      "type": "object",
      "additionalProperties": false,
      "required": ["docsUrl", "openApiUrl", "openApiSha256", "retrievedAt"],
      "properties": {
        "docsUrl": { "type": "string", "format": "uri" },
        "openApiUrl": { "type": "string", "format": "uri" },
        "openApiSha256": {
          "type": ["string", "null"],
          "pattern": "^[a-f0-9]{64}$"
        },
        "retrievedAt": { "type": ["string", "null"], "format": "date-time" },
        "fallbackDescription": { "type": ["string", "null"] }
      }
    },
    "summary": {
      "type": "object",
      "additionalProperties": false,
      "required": ["pass", "warn", "fail", "notVerified", "notApplicable"],
      "properties": {
        "pass": { "type": "integer", "minimum": 0 },
        "warn": { "type": "integer", "minimum": 0 },
        "fail": { "type": "integer", "minimum": 0 },
        "notVerified": { "type": "integer", "minimum": 0 },
        "notApplicable": { "type": "integer", "minimum": 0 }
      }
    },
    "checks": {
      "type": "array",
      "minItems": 1,
      "items": { "$ref": "#/$defs/check" }
    },
    "sandbox": {
      "type": "object",
      "additionalProperties": false,
      "required": ["attempted", "mutationPerformed", "requestIds"],
      "properties": {
        "attempted": { "type": "boolean" },
        "mutationPerformed": { "type": "boolean" },
        "requestIds": {
          "type": "array",
          "items": { "type": "string", "pattern": "^req_[A-Za-z0-9_-]+$" }
        },
        "notes": { "type": "array", "items": { "type": "string" } }
      }
    },
    "secrets": {
      "type": "object",
      "additionalProperties": false,
      "required": ["valuesCaptured"],
      "properties": {
        "valuesCaptured": { "const": false },
        "exposureFindings": {
          "type": "array",
          "items": { "type": "string" }
        }
      }
    },
    "liveSafety": {
      "type": "object",
      "additionalProperties": false,
      "required": ["liveMutationPerformed"],
      "properties": {
        "liveMutationPerformed": { "const": false },
        "notes": { "type": "array", "items": { "type": "string" } }
      }
    }
  },
  "$defs": {
    "check": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "id",
        "area",
        "status",
        "severity",
        "title",
        "evidence",
        "remediation"
      ],
      "properties": {
        "id": {
          "enum": [
            "contract.current",
            "secrets.server-only",
            "secrets.environment-isolation",
            "auth.scope",
            "catalog.runtime-source",
            "order.payload",
            "order.idempotency",
            "order.retry-safety",
            "errors.problem-details",
            "webhook.signature",
            "webhook.deduplication",
            "tests.local",
            "tests.sandbox-order",
            "tests.webhook",
            "live.no-live-mutations"
          ]
        },
        "area": {
          "enum": [
            "contract",
            "secrets",
            "authentication",
            "catalog",
            "orders",
            "errors",
            "webhooks",
            "tests",
            "live-safety"
          ]
        },
        "status": {
          "enum": ["pass", "warn", "fail", "not_verified", "not_applicable"]
        },
        "severity": { "enum": ["blocker", "warning", "info"] },
        "title": { "type": "string", "minLength": 1 },
        "evidence": {
          "type": "array",
          "items": { "type": "string" }
        },
        "remediation": {
          "type": "array",
          "items": { "type": "string" }
        },
        "files": {
          "type": "array",
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": ["path"],
            "properties": {
              "path": { "type": "string", "minLength": 1 },
              "line": { "type": ["integer", "null"], "minimum": 1 }
            }
          }
        }
      }
    }
  }
}
