{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "title": "ExtractieContract",
  "description": "Contract voor gestructureerde extractie uit een brondocument. Veldvolgorde is causaal: broncitaat en bron_offset komen vóór elke interpretatie (oorzaak, verplichting, bedrag, datum), zodat de interpretatie geconditioneerd wordt op het citaat en niet andersom. Epistemische status is een afgedwongen enum, geen lege-string-conventie.",
  "type": "object",
  "required": ["document_id", "feiten"],
  "additionalProperties": false,
  "properties": {
    "document_id": { "type": "string", "minLength": 1 },
    "feiten": {
      "type": "array",
      "items": { "$ref": "#/definitions/feit" }
    }
  },
  "definitions": {
    "epistemischeStatus": {
      "type": "string",
      "enum": ["vastgesteld", "vermoed", "onbekend"]
    },
    "feit": {
      "type": "object",
      "required": ["broncitaat", "bron_offset", "oorzaak"],
      "additionalProperties": false,
      "properties": {
        "broncitaat": {
          "type": "string",
          "minLength": 1,
          "description": "Exact citaat uit de bron; moet terugvindbaar zijn (grounding)."
        },
        "bron_offset": {
          "type": "array",
          "items": { "type": "integer" },
          "minItems": 2,
          "maxItems": 2,
          "description": "[start, end] character-offsets van broncitaat in de brontekst (data lineage)."
        },
        "oorzaak": {
          "type": "object",
          "required": ["status"],
          "additionalProperties": false,
          "properties": {
            "status": { "$ref": "#/definitions/epistemischeStatus" },
            "tekst": { "type": "string" }
          }
        },
        "verplichting": {
          "type": "object",
          "required": ["status"],
          "additionalProperties": false,
          "properties": {
            "status": { "$ref": "#/definitions/epistemischeStatus" },
            "tekst": { "type": "string" }
          }
        },
        "bedrag": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "waarde": { "type": "number" },
            "valuta": { "type": "string", "enum": ["EUR"] },
            "status": { "$ref": "#/definitions/epistemischeStatus" }
          },
          "required": ["status"]
        },
        "datum": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "waarde": { "type": "string" },
            "status": { "$ref": "#/definitions/epistemischeStatus" }
          },
          "required": ["status"]
        }
      }
    }
  }
}
