{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://real-life.org/rltp/v1/schemas/rltp-delivery-document.schema.json",
  "title": "RLTP Delivery Document Profile (rltp-delivery@0.17)",
  "description": "Outer-member profile per Delivery Contract section 3 for Trust Task documents (target framework 0.4) of RLTP task types. Payload content is governed by the type's payload schema, whose $id is the Type URI. proof is REQUIRED on delivery-ack and MUST be absent on the other types of this casting (enforced in prose; this schema admits both shapes). Offline rule: all $refs resolve from the local registry; network resolution is forbidden.",
  "type": "object",
  "required": ["id", "type", "issuer", "recipient", "threadId", "issuedAt", "payload"],
  "additionalProperties": false,
  "properties": {
    "id": { "$ref": "#/$defs/uuid" },
    "type": {
      "type": "string",
      "pattern": "^https://real-life\\.org/trust-tasks/[a-z0-9-]+/[0-9]+\\.[0-9]+$"
    },
    "issuer": { "$ref": "#/$defs/didKey" },
    "recipient": { "$ref": "#/$defs/didKey" },
    "threadId": { "$ref": "#/$defs/uuid" },
    "ceremony": {
      "type": "object",
      "description": "OPTIONAL and structurally unconstrained per Trust Tasks 4.11.1: this schema imposes NOTHING on its members — every framework field (enactment, step, round, terminal, prev, ...) passes through unrejected, in any shape. The single RLTP profile rule lives in prose (Contract section 3): a present enactment value MUST recompute against enclosed material; it grants no authority."
    },
    "issuedAt": { "$ref": "#/$defs/rfc3339utc" },
    "payload": { "type": "object" },
    "proof": {
      "type": "object",
      "required": ["type", "cryptosuite", "created", "verificationMethod", "proofPurpose", "proofValue"],
      "properties": {
        "type": { "const": "DataIntegrityProof" },
        "cryptosuite": { "const": "eddsa-jcs-2022" },
        "created": { "$ref": "#/$defs/rfc3339utc" },
        "verificationMethod": {
          "type": "string",
          "pattern": "^did:key:z6Mk[1-9A-HJ-NP-Za-km-z]{44}#z6Mk[1-9A-HJ-NP-Za-km-z]{44}$"
        },
        "proofPurpose": { "const": "assertionMethod" },
        "proofValue": { "type": "string", "pattern": "^z[1-9A-HJ-NP-Za-km-z]+$" }
      }
    }
  },
  "$defs": {
    "uuid": {
      "type": "string",
      "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
    },
    "didKey": {
      "type": "string",
      "pattern": "^did:key:z6Mk[1-9A-HJ-NP-Za-km-z]{44}$"
    },
    "rfc3339utc": {
      "type": "string",
      "pattern": "^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])T([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](\\.[0-9]+)?Z$"
    }
  }
}
