{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://drim.waldur.com/schemas/v1beta1/capability-descriptor.schema.json",
  "title": "DRIM Target Capability Descriptor",
  "description": "What a SPECIFIC target deployment can honour. Published by the target, not hard-coded in the DR service: the same platform differs by deployment. Measured examples — one KubeVirt/Ceph lab is CephFS-only while another does RBD+CephFS; RHOSP's consistent_group_snapshot_enabled is a per-volume-type setting, not a cloud-wide fact. Modelled on CSI's ControllerGetCapabilities.",
  "type": "object",
  "required": [
    "apiVersion",
    "kind",
    "metadata",
    "capabilities"
  ],
  "additionalProperties": false,
  "properties": {
    "apiVersion": {
      "const": "drim.capability/v1"
    },
    "kind": {
      "const": "TargetDescriptor"
    },
    "metadata": {
      "type": "object",
      "required": [
        "name",
        "platform"
      ],
      "properties": {
        "name": {
          "type": "string"
        },
        "platform": {
          "type": "string"
        },
        "description": {
          "type": "string"
        },
        "evidenceBase": {
          "type": "string",
          "description": "Where the `verified` claims come from — a conformance suite, a document, a run ID."
        }
      }
    },
    "landingZones": {
      "type": "object",
      "description": "Zone name -> what kind of component it can accept. Keys are what components reference via targetRef.",
      "additionalProperties": {
        "type": "object",
        "properties": {
          "accepts": {
            "type": "array",
            "items": {
              "enum": [
                "vm",
                "k8s",
                "external"
              ]
            }
          },
          "provider": {
            "type": "string"
          },
          "reachableFrom": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Other zone names (or `dr-service`) with a network path TO this zone. Absent means no path — which makes a startupGate across the boundary unverifiable."
          }
        }
      }
    },
    "capabilities": {
      "type": "object",
      "description": "Every leaf is a claim object. A claim MUST carry `support`; `status` distinguishes a claim backed by a test from one merely asserted.",
      "additionalProperties": {
        "$ref": "#/$defs/claimGroup"
      }
    },
    "throughput": {
      "type": "object",
      "description": "Used to check declared RTO/RPO against arithmetic. Absent means the validator reports the RTO check as `unknown` rather than passing it.",
      "properties": {
        "exportMBps": {
          "$ref": "#/$defs/measuredRate"
        },
        "transferMBps": {
          "$ref": "#/$defs/measuredRate"
        },
        "importMBps": {
          "$ref": "#/$defs/measuredRate"
        },
        "fixedOverheadSeconds": {
          "type": "number"
        }
      }
    }
  },
  "$defs": {
    "claimGroup": {
      "type": "object",
      "additionalProperties": {
        "oneOf": [
          {
            "$ref": "#/$defs/claim"
          },
          {
            "$ref": "#/$defs/claimGroup"
          }
        ]
      }
    },
    "claim": {
      "type": "object",
      "required": [
        "support"
      ],
      "additionalProperties": false,
      "properties": {
        "support": {
          "enum": [
            "faithful",
            "degraded",
            "dropped",
            "unsupported"
          ],
          "description": "faithful: honoured as declared. degraded: accepted but the semantics change (e.g. a CIDR rule that can no longer match anyone). dropped: silently inexpressible — the manifest asks for it and the target cannot represent it at all. unsupported: the target REFUSES the component; this is blocking, and is the only value that should stop a restore rather than annotate it."
        },
        "status": {
          "enum": [
            "verified",
            "declared"
          ],
          "default": "declared",
          "description": "`verified` means a conformance run exercised it. A descriptor of unverified claims manufactures exactly the false confidence a validator is supposed to remove."
        },
        "values": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "note": {
          "type": "string"
        },
        "evidence": {
          "type": "string"
        }
      }
    },
    "measuredRate": {
      "type": "object",
      "required": [
        "value"
      ],
      "properties": {
        "value": {
          "type": "number"
        },
        "status": {
          "enum": [
            "verified",
            "declared"
          ],
          "default": "declared"
        },
        "evidence": {
          "type": "string"
        }
      }
    }
  }
}
