{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://fullsend.ai/normative/entity-context-snapshot/v1/entity.schema.json",
  "title": "EntityMetadata",
  "type": "object",
  "required": ["kind", "id", "number", "title", "state", "author_id", "author", "created_at", "updated_at", "labels"],
  "properties": {
    "kind": { "enum": ["work_item", "change_proposal"] },
    "id": {
      "$ref": "common.schema.json#/$defs/structural_id",
      "description": "Immutable opaque forge object ID used for record keys; distinct from normalized-event v1 entity.id."
    },
    "number": {
      "type": "integer",
      "minimum": 1,
      "description": "Positive forge display number projected into normalized-event v1 entity.id."
    },
    "title": { "type": "string", "minLength": 1 },
    "state": { "enum": ["open", "closed", "merged"] },
    "author_id": {
      "oneOf": [
        { "$ref": "common.schema.json#/$defs/structural_id" },
        { "type": "null" }
      ]
    },
    "author": { "type": ["string", "null"], "minLength": 1 },
    "created_at": { "$ref": "common.schema.json#/$defs/timestamp" },
    "updated_at": { "$ref": "common.schema.json#/$defs/timestamp" },
    "labels": {
      "type": "array",
      "items": { "type": "string" },
      "uniqueItems": true,
      "description": "Filtered label strings sorted by UTF-8 byte order."
    }
  },
  "allOf": [
    {
      "if": { "properties": { "kind": { "const": "work_item" } }, "required": ["kind"] },
      "then": { "properties": { "state": { "enum": ["open", "closed"] } } }
    }
  ],
  "additionalProperties": false
}
