{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "required": [
    "schema_version",
    "provider",
    "kind",
    "profile",
    "readiness_status",
    "lifecycle",
    "repo_aligned",
    "capabilities",
    "limitations",
    "source_read_required",
    "fallback",
    "next_actions",
    "native_interfaces",
    "first_generation",
    "steady_state",
    "usage_note"
  ],
  "properties": {
    "schema_version": { "const": "provider-readiness.v2" },
    "provider": { "type": "string" },
    "kind": { "enum": ["code-structure", "project-graph", "memory", "generic"] },
    "profile": { "enum": ["minimal", "optional", "recommended", "platform"] },
    "readiness_status": { "enum": ["fresh", "stale", "degraded", "not-run", "unknown"] },
    "lifecycle": {
      "type": "object",
      "required": [
        "installed",
        "configured",
        "initialized",
        "indexed",
        "server_reachable",
        "artifact_exists",
        "query_verified",
        "fallback_used"
      ],
      "properties": {
        "installed": { "type": "boolean" },
        "configured": { "type": "boolean" },
        "initialized": { "type": "boolean" },
        "indexed": { "type": "boolean" },
        "server_reachable": { "type": "boolean" },
        "artifact_exists": { "type": "boolean" },
        "query_verified": { "type": "boolean" },
        "fallback_used": { "type": "boolean" }
      },
      "additionalProperties": false
    },
    "repo_aligned": { "enum": ["yes", "no", "unknown", "not-applicable"] },
    "capabilities": {
      "type": "array",
      "items": { "type": "string" }
    },
    "limitations": {
      "type": "array",
      "items": { "type": "string" }
    },
    "source_read_required": { "type": "boolean" },
    "fallback": {
      "type": "object",
      "required": ["available", "methods", "reason_code"],
      "properties": {
        "available": { "type": "boolean" },
        "methods": {
          "type": "array",
          "items": { "type": "string" }
        },
        "reason_code": { "type": "string" }
      },
      "additionalProperties": false
    },
    "next_actions": {
      "type": "array",
      "items": { "type": "string" }
    },
    "native_interfaces": {
      "type": "array",
      "items": { "type": "string", "minLength": 1 }
    },
    "first_generation": {
      "type": "object",
      "required": [
        "owner",
        "status",
        "scope",
        "requires_explicit_gate",
        "requirement_workspace_path",
        "artifact_root"
      ],
      "properties": {
        "owner": { "enum": ["runtime-setup", "provider-native", "user", "none", "unknown"] },
        "status": { "enum": ["completed", "not-run", "failed", "skipped", "unknown"] },
        "scope": { "enum": ["project", "run-scoped-workspace", "user-specified", "not-applicable", "unknown"] },
        "requires_explicit_gate": { "type": "boolean" },
        "requirement_workspace_path": { "type": ["string", "null"] },
        "artifact_root": { "type": ["string", "null"] },
        "artifact_refs": {
          "type": "array",
          "items": { "type": "string", "minLength": 1 }
        },
        "next_action": { "type": ["string", "null"] }
      },
      "additionalProperties": false
    },
    "steady_state": {
      "type": "object",
      "required": ["refresh_owner", "refresh_mode", "hook_default", "usage_owner"],
      "properties": {
        "refresh_owner": { "enum": ["provider-native", "runtime-setup", "user", "none", "unknown"] },
        "refresh_mode": { "enum": ["watcher", "skill-cli-hook-on-demand", "cli-mcp-hook-on-demand", "manual-only", "none", "unknown"] },
        "hook_default": { "type": "boolean" },
        "usage_owner": { "enum": ["downstream-skill", "provider-native", "user", "none", "unknown"] },
        "hook_installed": { "type": "boolean" },
        "hook_verified": { "type": "boolean" },
        "hook_status": { "enum": ["verified", "installed", "failed", "skipped", "unknown"] },
        "hook_skipped_reason": { "type": ["string", "null"] }
      },
      "additionalProperties": false
    },
    "usage_note": {
      "type": "string"
    }
  },
  "additionalProperties": false
}
