{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/kentekenkompas-nl/json-schema/kentekenkompas-nl-knowledge-envelope-schema.json",
  "title": "KnowledgeEnvelope",
  "x-generated": "2026-11-13",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/kentekenkompas-nl-openapi.yml#/components/schemas/KnowledgeEnvelope",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schemaVersion",
    "knowledgeVersion",
    "data",
    "evidence",
    "sources",
    "freshness",
    "limitations"
  ],
  "properties": {
    "schemaVersion": {
      "const": "kk-api-v1"
    },
    "knowledgeVersion": {
      "type": "string",
      "description": "Immutable source-knowledge version."
    },
    "data": {},
    "evidence": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/Evidence"
      }
    },
    "sources": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/Source"
      }
    },
    "freshness": {
      "$ref": "#/$defs/Freshness"
    },
    "coverage": {
      "$ref": "#/$defs/Coverage"
    },
    "limitations": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/Limitation"
      }
    },
    "citationUrl": {
      "type": "string",
      "format": "uri",
      "description": "Human KentekenKompas page supporting the response's core explanation; not the same as underlying sources."
    }
  },
  "$defs": {
    "Classification": {
      "type": "string",
      "enum": [
        "OFFICIAL",
        "DERIVED",
        "EDITORIAL"
      ],
      "description": "OFFICIAL: directly stated by the identified official/primary source. DERIVED: reproducibly derived by KentekenKompas from source data. EDITORIAL: KentekenKompas interpretation or guidance; never an official RDW fact."
    },
    "Coverage": {
      "type": "object",
      "description": "Machine-readable scope and completeness boundaries supplied by the canonical bundle.",
      "additionalProperties": true
    },
    "Evidence": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "evidenceId",
        "classification",
        "sourceIds"
      ],
      "properties": {
        "evidenceId": {
          "type": "string"
        },
        "classification": {
          "$ref": "#/$defs/Classification"
        },
        "sourceIds": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "uniqueItems": true
        }
      }
    },
    "Freshness": {
      "type": "object",
      "additionalProperties": false,
      "description": "Independent content dates. generatedAt only describes bundle generation and never substitutes for dataAsOf, sourceCheckedAt or editorialReviewedAt.",
      "properties": {
        "dataAsOf": {
          "type": "string",
          "format": "date",
          "description": "Date represented by the underlying data."
        },
        "sourceCheckedAt": {
          "type": "string",
          "format": "date",
          "description": "Date the source was checked."
        },
        "editorialReviewedAt": {
          "type": "string",
          "format": "date",
          "description": "Date editorial interpretation was reviewed."
        },
        "generatedAt": {
          "type": "string",
          "format": "date-time",
          "description": "Bundle generation timestamp; not proof of source actuality."
        }
      }
    },
    "Limitation": {
      "type": "string",
      "minLength": 1,
      "description": "Explicit constraint on scope, applicability, freshness or interpretation."
    },
    "Source": {
      "oneOf": [
        {
          "$ref": "#/$defs/SourceRecord"
        },
        {
          "$ref": "#/$defs/SourceGroup"
        }
      ]
    },
    "SourceBase": {
      "type": "object",
      "additionalProperties": true,
      "required": [
        "sourceId",
        "kind",
        "visibility",
        "label",
        "category",
        "citationUrl",
        "freshness",
        "limitations"
      ],
      "properties": {
        "sourceId": {
          "type": "string"
        },
        "kind": {
          "type": "string",
          "enum": [
            "SOURCE",
            "SOURCE_GROUP"
          ]
        },
        "visibility": {
          "const": "PUBLIC"
        },
        "label": {
          "type": "string"
        },
        "category": {
          "$ref": "#/$defs/SourceCategory"
        },
        "citationUrl": {
          "type": "string",
          "format": "uri",
          "description": "Human KentekenKompas explanation target, distinct from sourceUrl."
        },
        "freshness": {
          "$ref": "#/$defs/Freshness"
        },
        "limitations": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/Limitation"
          }
        }
      }
    },
    "SourceCategory": {
      "type": "string",
      "enum": [
        "OFFICIAL_PRIMARY_DATA",
        "OFFICIAL_GUIDANCE",
        "PRIMARY_NON_GOVERNMENT",
        "REPUTABLE_EDITORIAL",
        "BACKGROUND_REFERENCE",
        "KENTEKENKOMPAS_DERIVED",
        "KENTEKENKOMPAS_EDITORIAL"
      ],
      "description": "Detailed provenance category. KENTEKENKOMPAS_DERIVED and KENTEKENKOMPAS_EDITORIAL are not official RDW sources."
    },
    "SourceGroup": {
      "allOf": [
        {
          "$ref": "#/$defs/SourceBase"
        },
        {
          "type": "object",
          "description": "Explicit KentekenKompas evidence group. The group classification cannot be interpreted as making KentekenKompas an official source.",
          "required": [
            "description",
            "memberSourceIds",
            "memberOrderMeaning",
            "citationUrls"
          ],
          "properties": {
            "kind": {
              "const": "SOURCE_GROUP"
            },
            "description": {
              "type": "string"
            },
            "memberSourceIds": {
              "type": "array",
              "minItems": 1,
              "uniqueItems": true,
              "items": {
                "type": "string"
              }
            },
            "memberOrderMeaning": {
              "type": "string"
            },
            "citationUrls": {
              "type": "array",
              "items": {
                "type": "string",
                "format": "uri"
              }
            }
          }
        }
      ]
    },
    "SourceRecord": {
      "allOf": [
        {
          "$ref": "#/$defs/SourceBase"
        },
        {
          "type": "object",
          "required": [
            "sourceUrl"
          ],
          "properties": {
            "kind": {
              "const": "SOURCE"
            },
            "sourceUrl": {
              "type": "string",
              "format": "uri",
              "description": "Underlying public evidence location."
            }
          }
        }
      ]
    }
  }
}