{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://rjlsol.com/schemas/data-product.v1.json",
  "title": "RJL data product manifest (data-product.yaml), version 1",
  "description": "Illustrative reference schema from the RJL Data Product Certification Standard. Not a vendor schema or an external accreditation. Adopt and version it through your own governance.",
  "type": "object",
  "additionalProperties": false,
  "properties": {
    "schema_version": {
      "const": "rjl.data-product.v1"
    },
    "id": {
      "type": "string",
      "pattern": "^[a-z0-9][a-z0-9._-]*$"
    },
    "version": {
      "type": "string",
      "pattern": "^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)$"
    },
    "domain": {
      "type": "string",
      "pattern": "^[a-z0-9][a-z0-9._-]*$"
    },
    "type": {
      "enum": [
        "operational",
        "analytical",
        "knowledge"
      ]
    },
    "lifecycle": {
      "enum": [
        "sandbox",
        "managed_sandbox",
        "certified",
        "degraded",
        "deprecated",
        "retired"
      ]
    },
    "owners": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "product": {
          "type": "string",
          "minLength": 1
        },
        "steward": {
          "type": "string",
          "minLength": 1
        },
        "service": {
          "type": "string",
          "minLength": 1
        },
        "support_ref": {
          "type": "string",
          "minLength": 1
        }
      },
      "required": [
        "product",
        "steward",
        "service",
        "support_ref"
      ]
    },
    "scope": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "purpose": {
          "type": "string",
          "minLength": 1
        },
        "consumers": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          },
          "minItems": 1
        },
        "excluded": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          }
        }
      },
      "required": [
        "purpose",
        "consumers",
        "excluded"
      ]
    },
    "sources_ref": {
      "type": "string",
      "minLength": 1
    },
    "interfaces": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^[a-z0-9][a-z0-9._-]*$"
          },
          "kind": {
            "enum": [
              "read_api",
              "event_stream",
              "change_feed",
              "table",
              "view",
              "serving_store",
              "index",
              "file"
            ]
          },
          "contract_ref": {
            "type": "string",
            "minLength": 1
          },
          "compatibility_ref": {
            "type": "string",
            "minLength": 1
          }
        },
        "required": [
          "id",
          "kind",
          "contract_ref",
          "compatibility_ref"
        ]
      }
    },
    "semantics_ref": {
      "type": "string",
      "minLength": 1
    },
    "policy_ref": {
      "type": "string",
      "minLength": 1
    },
    "quality_ref": {
      "type": "string",
      "minLength": 1
    },
    "service": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "slo_ref": {
          "type": "string",
          "minLength": 1
        },
        "recovery_ref": {
          "type": "string",
          "minLength": 1
        },
        "runbook_ref": {
          "type": "string",
          "minLength": 1
        }
      },
      "required": [
        "slo_ref",
        "recovery_ref",
        "runbook_ref"
      ]
    },
    "evidence": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "lineage_ref": {
          "type": "string",
          "minLength": 1
        },
        "test_pack_ref": {
          "type": "string",
          "minLength": 1
        },
        "results_ref": {
          "type": "string",
          "minLength": 1
        },
        "deployment_ref": {
          "type": "string",
          "minLength": 1
        },
        "audit_ref": {
          "type": "string",
          "minLength": 1
        },
        "decision_ref": {
          "type": "string",
          "minLength": 1
        }
      },
      "required": [
        "lineage_ref",
        "test_pack_ref",
        "results_ref",
        "deployment_ref",
        "audit_ref",
        "decision_ref"
      ]
    },
    "decision": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "decided_at": {
          "type": "string",
          "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
        },
        "review_by": {
          "type": "string",
          "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
        }
      },
      "required": [
        "decided_at",
        "review_by"
      ]
    },
    "cost": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "workload_ref": {
          "type": "string",
          "minLength": 1
        },
        "limits_ref": {
          "type": "string",
          "minLength": 1
        },
        "escalation_owner": {
          "type": "string",
          "minLength": 1
        }
      },
      "required": [
        "workload_ref",
        "limits_ref",
        "escalation_owner"
      ]
    }
  },
  "required": [
    "schema_version",
    "id",
    "version",
    "domain",
    "type",
    "lifecycle",
    "owners",
    "scope",
    "sources_ref",
    "interfaces",
    "semantics_ref",
    "policy_ref",
    "quality_ref",
    "service",
    "evidence",
    "decision",
    "cost"
  ],
  "allOf": [
    {
      "if": {
        "properties": {
          "lifecycle": {
            "const": "certified"
          }
        }
      },
      "then": {
        "properties": {
          "version": {
            "pattern": "^[1-9]\\d*\\.\\d+\\.\\d+$"
          }
        }
      }
    }
  ]
}
