{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://weverlabs.com/schemas/agent-exception-ticket.schema.json",
  "title": "Wever Labs Agent Exception Ticket",
  "description": "Public-safe contract for recording a paid agent task exception, including evidence gaps, callback failures, credit issues, or tool execution pauses.",
  "type": "object",
  "required": [
    "object_type",
    "exception_id",
    "agent_task_run_id",
    "requested_tool",
    "exception_type",
    "severity",
    "status",
    "created_at"
  ],
  "properties": {
    "object_type": {
      "const": "agent_exception_ticket"
    },
    "exception_id": {
      "type": "string"
    },
    "agent_task_run_id": {
      "type": "string"
    },
    "work_order_id": {
      "type": "string"
    },
    "requested_tool": {
      "type": "string",
      "enum": [
        "packetops",
        "distributionops",
        "tokenops",
        "wever_labs_os"
      ]
    },
    "exception_type": {
      "type": "string",
      "enum": [
        "evidence_gap",
        "callback_failure",
        "credit_hold",
        "tool_execution_pause",
        "result_quality_review",
        "settlement_mismatch",
        "manual_review_required"
      ]
    },
    "severity": {
      "type": "string",
      "enum": [
        "low",
        "medium",
        "high",
        "blocked"
      ]
    },
    "status": {
      "type": "string",
      "enum": [
        "open",
        "under_review",
        "waiting_on_requesting_agent",
        "recovery_requested",
        "replay_ready",
        "resolved",
        "closed"
      ]
    },
    "summary": {
      "type": "string"
    },
    "evidence_status": {
      "type": "string",
      "enum": [
        "sufficient",
        "partial",
        "insufficient",
        "not_applicable"
      ]
    },
    "missing_items": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "safe_to_replay": {
      "type": "boolean"
    },
    "recovery_request_url": {
      "type": "string",
      "format": "uri"
    },
    "replay_package_url": {
      "type": "string",
      "format": "uri"
    },
    "ledger_url": {
      "type": "string",
      "format": "uri"
    },
    "result_attestation_url": {
      "type": "string",
      "format": "uri"
    },
    "created_at": {
      "type": "string",
      "format": "date-time"
    },
    "updated_at": {
      "type": "string",
      "format": "date-time"
    },
    "handshake_id": {
      "type": "string",
      "description": "Optional upstream agent handshake ID."
    },
    "preflight_id": {
      "type": "string",
      "description": "Optional upstream preflight check ID."
    },
    "contract_id": {
      "type": "string",
      "description": "Optional upstream run contract ID."
    },
    "run_contract_url": {
      "type": "string",
      "format": "uri",
      "description": "Optional URL for the run contract object."
    }
  },
  "additionalProperties": true
}
