{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://aiwg.io/schemas/dataset/dataset-standards-exchange.v1.schema.json",
  "title": "AIWG Dataset Standards Exchange v1",
  "type": "object",
  "required": ["schemaVersion", "profile", "value", "loss"],
  "properties": {
    "schemaVersion": { "const": "aiwg.dataset-standards-exchange/v1" },
    "profile": {
      "type": "object", "required": ["id", "version"], "additionalProperties": false,
      "properties": { "id": { "type": "string", "minLength": 1 }, "version": { "type": "string", "minLength": 1 } }
    },
    "value": {},
    "loss": { "$ref": "#/$defs/lossReport" }
  },
  "additionalProperties": false,
  "$defs": {
    "schemaReference": {
      "type": "object", "required": ["id", "version"], "additionalProperties": false,
      "properties": { "id": { "type": "string", "format": "uri" }, "version": { "type": "string", "minLength": 1 } }
    },
    "profileDescriptor": {
      "type": "object",
      "required": ["id", "standard", "version", "direction", "inputSchema", "outputSchema", "mappingImplementation", "supportedFeatures", "roundTripFields", "extensionNamespace", "unknownExtensionPolicy", "maturity", "useCases", "coverageBoundary"],
      "additionalProperties": false,
      "properties": {
        "id": { "type": "string", "minLength": 1 },
        "standard": { "enum": ["w3c-prov-json", "openlineage", "dcat", "croissant", "data-package", "ro-crate"] },
        "version": { "type": "string", "minLength": 1 },
        "direction": { "enum": ["import", "export", "round-trip"] },
        "inputSchema": { "$ref": "#/$defs/schemaReference" }, "outputSchema": { "$ref": "#/$defs/schemaReference" },
        "mappingImplementation": { "type": "string", "minLength": 1 },
        "supportedFeatures": { "type": "array", "items": { "type": "string" }, "uniqueItems": true },
        "roundTripFields": { "type": "array", "items": { "type": "string" }, "uniqueItems": true },
        "extensionNamespace": { "type": "string", "format": "uri", "pattern": "/$" },
        "unknownExtensionPolicy": { "enum": ["preserve", "report", "reject"] },
        "maturity": { "enum": ["stable", "candidate", "descriptor-only"] },
        "useCases": { "type": "array", "minItems": 1, "items": { "type": "string", "minLength": 1 } },
        "coverageBoundary": { "type": "string", "minLength": 1 }
      }
    },
    "lossItem": {
      "type": "object", "required": ["category", "reason"], "additionalProperties": false,
      "properties": {
        "category": { "enum": ["mapped", "omitted", "synthesized", "unsupported", "extension-carried"] },
        "sourcePath": { "type": "string" }, "targetPath": { "type": "string" }, "reason": { "type": "string", "minLength": 1 }, "extensionNamespace": { "type": "string", "format": "uri" }
      }
    },
    "lossReport": {
      "type": "object", "required": ["schemaVersion", "profileId", "profileVersion", "direction", "sourceDigest", "items", "counts"], "additionalProperties": false,
      "properties": {
        "schemaVersion": { "const": "aiwg.dataset-standards-exchange/v1" }, "profileId": { "type": "string" }, "profileVersion": { "type": "string" }, "direction": { "enum": ["import", "export"] },
        "sourceDigest": { "type": "object", "required": ["algorithm", "value"], "additionalProperties": false, "properties": { "algorithm": { "const": "sha256" }, "value": { "type": "string", "pattern": "^[a-f0-9]{64}$" } } },
        "items": { "type": "array", "items": { "$ref": "#/$defs/lossItem" } },
        "counts": { "type": "object", "required": ["mapped", "omitted", "synthesized", "unsupported", "extension-carried"], "additionalProperties": false, "properties": { "mapped": { "type": "integer", "minimum": 0 }, "omitted": { "type": "integer", "minimum": 0 }, "synthesized": { "type": "integer", "minimum": 0 }, "unsupported": { "type": "integer", "minimum": 0 }, "extension-carried": { "type": "integer", "minimum": 0 } } }
      }
    }
  }
}
