{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://b2base.eu/schemas/1.0.0-draft.1/process/task.schema.json",
  "title": "Aufgaben",
  "$comment": "B2Base 1.0.0-draft.1. Projektentwurf, kein durch ISO oder andere Normungsgremien verabschiedeter Standard.",
  "type": "object",
  "description": "Eine Aufgabe; Teilaufgaben werden über stabile IDs verknüpft.",
  "properties": {
    "id": {
      "type": "string",
      "minLength": 1,
      "description": "Aufgabenkennung.",
      "format": "uri"
    },
    "title": {
      "type": "string",
      "minLength": 1,
      "description": "Aufgabentitel."
    },
    "description": {
      "type": "string",
      "minLength": 1,
      "description": "Optionale Arbeitsanweisung."
    },
    "status": {
      "type": "string",
      "minLength": 1,
      "description": "Bearbeitungsstatus.",
      "enum": [
        "pending",
        "inProgress",
        "completed",
        "cancelled"
      ]
    },
    "assignee": {
      "$ref": "#/$defs/PartyRef"
    },
    "parentTaskId": {
      "type": "string",
      "minLength": 1,
      "description": "Optionale übergeordnete Aufgabe.",
      "format": "uri"
    },
    "workflowInstanceId": {
      "type": "string",
      "minLength": 1,
      "description": "Zugehöriger Workflowlauf.",
      "format": "uri"
    },
    "dueAt": {
      "type": "string",
      "minLength": 1,
      "description": "Frist als Zeitpunkt mit Offset.",
      "format": "date-time"
    },
    "completedAt": {
      "type": "string",
      "minLength": 1,
      "description": "Zeitpunkt des Abschlusses.",
      "format": "date-time"
    },
    "documentRefs": {
      "type": "array",
      "description": "Zugehörige Dokumentkennungen.",
      "items": {
        "type": "string",
        "minLength": 1,
        "description": "Dokument-URI.",
        "format": "uri"
      },
      "uniqueItems": true
    },
    "extensions": {
      "type": "object",
      "description": "Vereinbarte Erweiterungen; Schlüssel als absolute URI des Herausgebers. Keine stillschweigende Änderung von Kernfeldern.",
      "properties": {},
      "additionalProperties": true,
      "propertyNames": {
        "format": "uri"
      }
    }
  },
  "required": [
    "id",
    "title",
    "status"
  ],
  "additionalProperties": false,
  "allOf": [
    {
      "if": {
        "properties": {
          "status": {
            "const": "completed"
          }
        },
        "required": [
          "status"
        ]
      },
      "then": {
        "required": [
          "completedAt"
        ]
      }
    }
  ],
  "$defs": {
    "PartyRef": {
      "type": "object",
      "description": "Verweis auf eine separat gespeicherte Person oder juristische Person; kein JSON-Schema-Verweis.",
      "properties": {
        "entityType": {
          "type": "string",
          "minLength": 1,
          "description": "Art der referenzierten Einheit.",
          "enum": [
            "person",
            "legalEntity"
          ]
        },
        "id": {
          "type": "string",
          "minLength": 1,
          "description": "Stabile absolute URI oder URN des Datensatzes, nicht dessen Name.",
          "format": "uri"
        },
        "name": {
          "type": "string",
          "minLength": 1,
          "description": "Optionale Anzeige; nicht als Identitätsschlüssel verwenden."
        }
      },
      "required": [
        "entityType",
        "id"
      ],
      "additionalProperties": false
    }
  },
  "examples": [
    {
      "id": "urn:example:task:42",
      "title": "Unterlagen prüfen",
      "status": "pending",
      "dueAt": "2026-10-01T17:00:00+02:00"
    },
    {
      "id": "urn:example:task:43",
      "title": "Daten übernommen",
      "status": "completed",
      "completedAt": "2026-09-08T08:30:00Z"
    }
  ]
}
