{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://mandateshield.com/schemas/provider-evidence-v1.json",
  "title": "MandateShield ProviderEvidence v1",
  "description": "Canonical evidence record for one provider submission. Only a VERIFIED strong evidence class with independent_verification=true can drive an autonomous terminal authorization transition.",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "id",
    "submission_id",
    "evidence_class",
    "source",
    "outcome",
    "verification_status",
    "independent_verification",
    "evidence_digest",
    "evidence",
    "provider_event_id",
    "payment_reference",
    "occurred_at",
    "verified_at",
    "created_at"
  ],
  "properties": {
    "id": {
      "type": "string",
      "pattern": "^pevd_[a-f0-9]{32}$"
    },
    "submission_id": {
      "type": "string",
      "pattern": "^psub_[a-f0-9]{32}$"
    },
    "evidence_class": {
      "type": "string",
      "enum": [
        "CALLER_ASSERTED",
        "FACILITATOR_SIGNED",
        "PROVIDER_API_VERIFIED",
        "CHAIN_FINALIZED",
        "UNRESOLVED"
      ]
    },
    "source": {
      "type": "string",
      "enum": [
        "PROCESSOR_REPORT",
        "STRIPE_WEBHOOK",
        "STRIPE_API",
        "X402_EVM_RPC",
        "FACILITATOR_SIGNATURE"
      ]
    },
    "outcome": {
      "type": "string",
      "enum": [
        "COMMITTED",
        "FAILED_CONFIRMED",
        "UNKNOWN"
      ]
    },
    "verification_status": {
      "type": "string",
      "enum": [
        "PENDING",
        "VERIFIED",
        "REJECTED",
        "CONFLICT"
      ]
    },
    "independent_verification": {
      "type": "boolean"
    },
    "evidence_digest": {
      "type": "string",
      "pattern": "^sha256:[a-f0-9]{64}$"
    },
    "evidence": {
      "type": "object",
      "description": "Canonical bounded non-secret provider projection used to compute evidence_digest."
    },
    "provider_event_id": {
      "type": [
        "string",
        "null"
      ],
      "minLength": 1,
      "maxLength": 240
    },
    "payment_reference": {
      "type": [
        "string",
        "null"
      ],
      "minLength": 1,
      "maxLength": 240
    },
    "occurred_at": {
      "type": "integer",
      "minimum": 1,
      "description": "Unix milliseconds."
    },
    "verified_at": {
      "type": [
        "integer",
        "null"
      ],
      "minimum": 1,
      "description": "Unix milliseconds when independently verified."
    },
    "created_at": {
      "type": "integer",
      "minimum": 1,
      "description": "Unix milliseconds."
    }
  },
  "allOf": [
    {
      "if": {
        "properties": {
          "independent_verification": {
            "const": true
          }
        },
        "required": [
          "independent_verification"
        ]
      },
      "then": {
        "properties": {
          "evidence_class": {
            "enum": [
              "FACILITATOR_SIGNED",
              "PROVIDER_API_VERIFIED",
              "CHAIN_FINALIZED"
            ]
          },
          "verification_status": {
            "const": "VERIFIED"
          },
          "outcome": {
            "enum": [
              "COMMITTED",
              "FAILED_CONFIRMED"
            ]
          },
          "payment_reference": {
            "type": "string",
            "minLength": 1,
            "maxLength": 240
          },
          "verified_at": {
            "type": "integer",
            "minimum": 1
          }
        }
      },
      "else": {
        "properties": {
          "verified_at": {
            "type": "null"
          }
        }
      }
    }
  ]
}
