{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://github.com/welkaim/ea-codex/schemas/v1/data-product-contract.json",
  "title": "DataProductContract",
  "description": "Federated data product contract: a contracted unit of meaning, access, quality, policy, and evidence. Extends a federated dataset with purpose, jurisdictional constraints, allowed transformations, and required proofs. Named in Chapter 13; full schema will harden as adopters report patterns.",
  "type": "object",
  "required": ["apiVersion", "kind", "metadata", "spec"],
  "properties": {
    "apiVersion": { "$ref": "_common.json#/$defs/apiVersion" },
    "kind": { "type": "string", "const": "DataProductContract" },
    "metadata": { "$ref": "_common.json#/$defs/metadata" },
    "spec": {
      "type": "object",
      "required": ["businessObject", "owner", "purposes", "jurisdiction"],
      "properties": {
        "businessObject": {
          "type": "string",
          "description": "Canonical business object the product represents (for example: GenomicCohort, PatientConsent)."
        },
        "owner": {
          "type": "object",
          "properties": {
            "domain": { "type": "string" },
            "contact": { "type": "string" }
          },
          "additionalProperties": true
        },
        "purposes": {
          "type": "array",
          "description": "Declared purposes that justify use of this product. Consumers must declare a matching purpose at access time.",
          "items": { "type": "string" },
          "minItems": 1
        },
        "allowedConsumers": {
          "type": "array",
          "items": { "type": "string" }
        },
        "jurisdiction": {
          "type": "object",
          "required": ["primary"],
          "properties": {
            "primary": { "type": "string" },
            "allowedRegions": {
              "type": "array",
              "items": { "type": "string" }
            }
          },
          "additionalProperties": true
        },
        "allowedTransformations": {
          "type": "array",
          "items": { "type": "string" }
        },
        "permittedDerivedOutputs": {
          "type": "array",
          "items": { "type": "string" }
        },
        "requiredProofs": {
          "type": "array",
          "items": { "type": "string" }
        },
        "qualityAttributes": {
          "type": "object",
          "additionalProperties": true
        },
        "interfaces": {
          "type": "array",
          "items": {
            "type": "object",
            "required": ["pattern"],
            "properties": {
              "pattern": {
                "type": "string",
                "enum": ["governed-api", "federated-query", "semantic-retrieval", "clean-room-analysis", "event-stream"]
              },
              "endpoint": { "type": "string" },
              "schemaRef": { "type": "string" }
            },
            "additionalProperties": true
          }
        }
      },
      "additionalProperties": true
    }
  },
  "additionalProperties": false
}
