{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://weverlabs.com/schemas/production-write-gate.schema.json",
  "title": "Wever Labs Production Write Gate",
  "type": "object",
  "required": [
    "schema_version",
    "mode"
  ],
  "properties": {
    "schema_version": {
      "const": "production_write_gate.v1"
    },
    "mode": {
      "enum": [
        "read_gate",
        "request_production_access",
        "issue_scoped_agent_key",
        "validate_production_write",
        "record_production_write_audit",
        "rotate_scoped_agent_key",
        "read_production_write_events"
      ]
    },
    "grant_id": {
      "type": "string"
    },
    "key_id": {
      "type": "string"
    },
    "agent_id": {
      "type": "string"
    },
    "organization_name": {
      "type": "string"
    },
    "target_surface": {
      "enum": [
        "agent-use",
        "customer-production-runs",
        "production-write-gate"
      ]
    },
    "rail_key": {
      "enum": [
        "packetops",
        "diligenceops"
      ]
    },
    "idempotency_key": {
      "type": "string"
    },
    "callback_url": {
      "type": "string",
      "format": "uri"
    },
    "requested_scopes": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "allowed_rails": {
      "type": "array",
      "items": {
        "enum": [
          "packetops",
          "diligenceops"
        ]
      }
    },
    "write_decision": {
      "enum": [
        "accepted",
        "rejected",
        "accepted_with_warnings"
      ]
    },
    "production_run_id": {
      "type": "string"
    },
    "work_order_id": {
      "type": "string"
    },
    "payment_reference": {
      "type": "string"
    }
  },
  "additionalProperties": true
}
