{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "urn:ai.spec-kitty:schema:envelope.write.v1",
  "title": "CloudEvents envelope, write profile",
  "description": "Attribute rules for a CloudEvents 1.0 structured-JSON row a Spec Kitty producer writes (ADR 0001, write profile): upper-case ULID id, lamportclock and nodeid required. Non-normative until the cutover release. Cross-attribute rules that JSON Schema cannot state (missionid equals the id in source; subject is the aggregate only when source is project-scoped) are producer rules recorded in the registry.",
  "type": "object",
  "properties": {
    "specversion": {
      "type": "string",
      "const": "1.0"
    },
    "id": {
      "type": "string",
      "pattern": "^[0-9A-HJKMNP-TV-Z]{26}(?![\\s\\S])",
      "description": "Upper-case 26-character ULID."
    },
    "source": {
      "type": "string",
      "pattern": "^/spec-kitty/(missions|projects)/[^/\\s]+(?![\\s\\S])"
    },
    "type": {
      "type": "string",
      "pattern": "^ai\\.spec-kitty\\.[a-z0-9]+(\\.[a-z0-9]+)*\\.v[0-9]+(?![\\s\\S])"
    },
    "subject": {
      "type": "string",
      "minLength": 1
    },
    "time": {
      "type": "string",
      "format": "date-time",
      "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}[Tt][0-9]{2}:[0-9]{2}:[0-9]{2}(\\.[0-9]{1,9})?([Zz]|[+-][0-9]{2}:[0-9]{2})(?![\\s\\S])"
    },
    "datacontenttype": {
      "type": "string",
      "const": "application/json"
    },
    "dataschema": {
      "type": "string",
      "format": "uri",
      "pattern": "^urn:ai\\.spec-kitty:schema:[a-z0-9]+(\\.[a-z0-9]+)*\\.v[0-9]+(?![\\s\\S])"
    },
    "schemaversion": {
      "type": "string",
      "const": "4.0.0"
    },
    "missionid": {
      "type": "string",
      "pattern": "^[0-9A-HJKMNP-TV-Z]{26}(?![\\s\\S])"
    },
    "missionslug": {
      "type": "string",
      "minLength": 1
    },
    "actor": {
      "type": "string",
      "minLength": 1
    },
    "executionmode": {
      "type": "string",
      "minLength": 1
    },
    "lamportclock": {
      "type": "integer",
      "minimum": 0,
      "maximum": 2147483647
    },
    "nodeid": {
      "type": "string",
      "pattern": "^[0-9a-f]{12}(?![\\s\\S])"
    },
    "data": {
      "type": "object"
    }
  },
  "required": [
    "specversion",
    "id",
    "source",
    "type",
    "time",
    "datacontenttype",
    "dataschema",
    "schemaversion",
    "lamportclock",
    "nodeid",
    "data"
  ],
  "propertyNames": {
    "pattern": "^[a-z0-9]{1,20}(?![\\s\\S])"
  },
  "additionalProperties": false
}
