{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://hsimc.tech/rd/t736/ecosystem/schemas/work-envelope.schema.json",
  "title": "Case reference: cross-Reality work envelope",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schema_version",
    "work_ref",
    "work_revision",
    "operation_id",
    "origin_runtime_ref",
    "destination_runtime_ref",
    "actor_ref",
    "role_ref",
    "authority_ref",
    "deadline",
    "input_refs",
    "preconditions",
    "cost_ceiling",
    "idempotency_key",
    "payload_sha256",
    "requested_effect",
    "evidence_return_ref",
    "state"
  ],
  "properties": {
    "schema_version": {
      "const": "C0-001"
    },
    "work_ref": {
      "type": "string",
      "minLength": 1
    },
    "work_revision": {
      "type": "string",
      "minLength": 1
    },
    "operation_id": {
      "type": "string",
      "minLength": 1
    },
    "origin_runtime_ref": {
      "type": "string",
      "minLength": 1
    },
    "destination_runtime_ref": {
      "type": "string",
      "minLength": 1
    },
    "actor_ref": {
      "type": "string",
      "minLength": 1
    },
    "role_ref": {
      "type": "string",
      "minLength": 1
    },
    "authority_ref": {
      "type": "string",
      "minLength": 1
    },
    "deadline": {
      "type": "string",
      "format": "date-time"
    },
    "input_refs": {
      "type": "array",
      "items": {
        "type": "string",
        "minLength": 1
      }
    },
    "preconditions": {
      "type": "array",
      "items": {
        "type": "string",
        "minLength": 1
      }
    },
    "cost_ceiling": {
      "type": "object",
      "required": [
        "amount",
        "currency"
      ],
      "properties": {
        "amount": {
          "type": "number",
          "minimum": 0
        },
        "currency": {
          "type": "string",
          "pattern": "^[A-Z]{3}$"
        }
      }
    },
    "idempotency_key": {
      "type": "string",
      "minLength": 1
    },
    "payload_sha256": {
      "type": "string",
      "pattern": "^[0-9a-f]{64}$"
    },
    "requested_effect": {
      "type": "object"
    },
    "evidence_return_ref": {
      "type": "string",
      "minLength": 1
    },
    "state": {
      "enum": [
        "PROPOSED",
        "BLOCKED",
        "AUTHORIZED",
        "RESERVED",
        "DISPATCHED",
        "ATTEMPTED",
        "OBSERVED",
        "ACCEPTED",
        "REJECTED",
        "EXPIRED",
        "UNKNOWN_EFFECT"
      ]
    }
  },
  "$comment": "Reference strings must resolve to existing canonical Work/Role/Runtime records in a later binding. They are not new identities. Authenticated principal and authority are checked independently of self-reported protocol metadata. Idempotency record is durable and bound to payload hash; reconcile unknown effects instead of blind retry."
}
