{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://weverlabs.com/schemas/runtime-function-auth-validation.schema.json",
  "title": "Wever Labs Runtime Function Auth Validation",
  "type": "object",
  "required": [
    "validation_id",
    "runtime_surface",
    "function_name",
    "request_context",
    "auth_checks",
    "validation_checks",
    "decision"
  ],
  "properties": {
    "validation_id": {
      "type": "string"
    },
    "runtime_surface": {
      "type": "string",
      "enum": [
        "intake",
        "work_order_dispatch",
        "execution_binding",
        "provider_activation",
        "tokenops_live_pilot",
        "callback_delivery",
        "result_persistence",
        "security_audit"
      ]
    },
    "function_name": {
      "type": "string"
    },
    "request_context": {
      "type": "object",
      "properties": {
        "agent_id": {
          "type": [
            "string",
            "null"
          ]
        },
        "client_id": {
          "type": [
            "string",
            "null"
          ]
        },
        "task_token": {
          "type": [
            "string",
            "null"
          ]
        },
        "work_order_id": {
          "type": [
            "string",
            "null"
          ]
        },
        "tool": {
          "type": [
            "string",
            "null"
          ],
          "enum": [
            "tokenops",
            "financeops",
            "energyops",
            "distributionops",
            "packetops",
            "wever_labs_os",
            null
          ]
        },
        "schema_version": {
          "type": [
            "string",
            "null"
          ]
        }
      },
      "additionalProperties": true
    },
    "auth_checks": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "check",
          "state"
        ],
        "properties": {
          "check": {
            "type": "string"
          },
          "state": {
            "type": "string",
            "enum": [
              "passed",
              "failed",
              "skipped"
            ]
          },
          "detail": {
            "type": "string"
          }
        }
      }
    },
    "validation_checks": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "check",
          "state"
        ],
        "properties": {
          "check": {
            "type": "string"
          },
          "state": {
            "type": "string",
            "enum": [
              "passed",
              "failed",
              "skipped"
            ]
          },
          "detail": {
            "type": "string"
          }
        }
      }
    },
    "decision": {
      "type": "string",
      "enum": [
        "accepted",
        "rejected",
        "accepted_with_warnings"
      ]
    },
    "response_code": {
      "type": "integer"
    },
    "audit_event_id": {
      "type": [
        "string",
        "null"
      ]
    },
    "created_at": {
      "type": "string"
    }
  },
  "additionalProperties": false
}
