{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "urn:uaix:uai-1:schema:uai.intent.request.v1",
  "title": "UAI Intent Request v1",
  "description": "Schema for explicit intent requests in the richer UAI-1 public exchange envelope.",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "uai_version",
    "profile",
    "message_id",
    "source",
    "target",
    "conversation",
    "delivery",
    "trust",
    "body",
    "provenance",
    "integrity",
    "extensions"
  ],
  "properties": {
    "uai_version": {
      "type": "string",
      "const": "1.0"
    },
    "profile": {
      "type": "string",
      "const": "uai.intent.request.v1"
    },
    "message_id": {
      "type": "string",
      "minLength": 1
    },
    "source": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "type",
        "id"
      ],
      "properties": {
        "type": {
          "type": "string",
          "minLength": 1
        },
        "id": {
          "type": "string",
          "minLength": 1
        },
        "label": {
          "type": "string"
        },
        "uri": {
          "type": "string",
          "format": "uri"
        },
        "did": {
          "type": "string",
          "minLength": 1
        },
        "role": {
          "type": "string"
        },
        "implementation": {
          "type": "string"
        }
      }
    },
    "target": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "type",
        "id"
      ],
      "properties": {
        "type": {
          "type": "string",
          "minLength": 1
        },
        "id": {
          "type": "string",
          "minLength": 1
        },
        "label": {
          "type": "string"
        },
        "uri": {
          "type": "string",
          "format": "uri"
        },
        "did": {
          "type": "string",
          "minLength": 1
        },
        "role": {
          "type": "string"
        },
        "implementation": {
          "type": "string"
        }
      }
    },
    "conversation": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "conversation_id",
        "turn_id",
        "sequence"
      ],
      "properties": {
        "conversation_id": {
          "type": "string",
          "minLength": 1
        },
        "turn_id": {
          "type": "string",
          "minLength": 1
        },
        "parent_message_id": {
          "type": "string",
          "minLength": 1
        },
        "traceparent": {
          "type": "string",
          "minLength": 1
        },
        "sequence": {
          "type": "integer",
          "minimum": 1
        }
      }
    },
    "delivery": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "mode",
        "priority",
        "expires_at",
        "reply_requested",
        "ack_required"
      ],
      "properties": {
        "mode": {
          "type": "string",
          "enum": [
            "sync",
            "async",
            "event"
          ]
        },
        "priority": {
          "type": "string",
          "enum": [
            "routine",
            "interactive",
            "urgent"
          ]
        },
        "expires_at": {
          "type": "string",
          "format": "date-time"
        },
        "reply_requested": {
          "type": "boolean"
        },
        "ack_required": {
          "type": "boolean"
        },
        "task_ref": {
          "type": "string",
          "minLength": 1
        }
      }
    },
    "trust": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "channel",
        "auth_scheme",
        "principal"
      ],
      "properties": {
        "channel": {
          "type": "string",
          "enum": [
            "public-web",
            "private-api",
            "mtls",
            "signed-envelope",
            "credentialed"
          ]
        },
        "auth_scheme": {
          "type": "string",
          "minLength": 1
        },
        "principal": {
          "type": "string",
          "minLength": 1
        },
        "credential_ref": {
          "type": "string",
          "format": "uri"
        },
        "signature_ref": {
          "type": "string",
          "format": "uri"
        },
        "replay_window_id": {
          "type": "string",
          "minLength": 1
        },
        "trust_profile": {
          "type": "string",
          "minLength": 1,
          "description": "Profile or policy label for interpreting trust metadata; not required for compact trust readers and not a mandatory credential stack."
        },
        "verification_status": {
          "type": "string",
          "enum": [
            "not_verified",
            "verified",
            "failed",
            "expired",
            "revoked",
            "unknown"
          ]
        },
        "credential_status": {
          "type": "string",
          "enum": [
            "not_checked",
            "valid",
            "invalid",
            "expired",
            "revoked",
            "unknown"
          ]
        },
        "verifier_ref": {
          "type": "string",
          "format": "uri"
        },
        "trust_root_ref": {
          "type": "string",
          "format": "uri"
        },
        "proof_ref": {
          "type": "string",
          "format": "uri"
        },
        "replay_policy_ref": {
          "type": "string",
          "format": "uri"
        },
        "verification_checked_at": {
          "type": "string",
          "format": "date-time"
        },
        "verification_expires_at": {
          "type": "string",
          "format": "date-time"
        },
        "assurance_level": {
          "type": "string",
          "enum": [
            "self_asserted",
            "reference_only",
            "transport_authenticated",
            "signed_reference",
            "credential_verified",
            "local_policy_verified"
          ]
        }
      }
    },
    "body": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "intent",
        "subject",
        "requested_profile",
        "parameters",
        "constraints",
        "response_profile"
      ],
      "properties": {
        "intent": {
          "type": "string",
          "minLength": 1
        },
        "subject": {
          "type": "string",
          "minLength": 1
        },
        "requested_profile": {
          "type": "string",
          "minLength": 1
        },
        "parameters": {
          "type": "object"
        },
        "constraints": {
          "type": "array",
          "minItems": 1,
          "items": {
            "type": "string",
            "minLength": 1
          }
        },
        "response_profile": {
          "type": "string",
          "minLength": 1
        }
      }
    },
    "provenance": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "trace_id",
        "issued_at",
        "log_ref",
        "agent_id",
        "model_id",
        "confidence"
      ],
      "properties": {
        "trace_id": {
          "type": "string",
          "minLength": 1
        },
        "parent_trace_id": {
          "type": "string",
          "minLength": 1
        },
        "issued_at": {
          "type": "string",
          "format": "date-time"
        },
        "log_ref": {
          "type": "string",
          "minLength": 1
        },
        "agent_id": {
          "type": "string",
          "minLength": 1
        },
        "model_id": {
          "type": "string",
          "minLength": 1
        },
        "confidence": {
          "type": "number",
          "minimum": 0,
          "maximum": 1
        },
        "lineage": {
          "type": "array",
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "stage",
              "actor_id"
            ],
            "properties": {
              "stage": {
                "type": "string",
                "minLength": 1
              },
              "actor_id": {
                "type": "string",
                "minLength": 1
              },
              "model_id": {
                "type": "string",
                "minLength": 1
              },
              "note": {
                "type": "string"
              }
            }
          }
        }
      }
    },
    "integrity": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "version",
        "algorithm",
        "canonicalization",
        "checksum"
      ],
      "properties": {
        "version": {
          "type": "integer",
          "minimum": 1
        },
        "algorithm": {
          "type": "string",
          "minLength": 1
        },
        "canonicalization": {
          "type": "string",
          "minLength": 1
        },
        "checksum": {
          "type": "string",
          "minLength": 1
        }
      }
    },
    "extensions": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "namespace",
          "purpose",
          "critical"
        ],
        "properties": {
          "namespace": {
            "type": "string",
            "minLength": 1
          },
          "purpose": {
            "type": "string",
            "minLength": 1
          },
          "critical": {
            "type": "boolean"
          }
        }
      }
    }
  }
}
