{
  "$schema": "https://json-schema.org/draft-07/schema#",
  "$id": "https://local/governance/docs-publish/schemas/venue-adapter.schema.json",
  "title": "Publication Venue Adapter",
  "description": "Contract that any publication adapter (Medium, YouTube, internal docsite, etc.) must satisfy.",
  "type": "object",
  "required": ["name", "version", "auth", "capabilities", "rate_limits", "validation"],
  "additionalProperties": false,
  "properties": {
    "name": { "type": "string", "minLength": 1 },
    "version": { "type": "string" },
    "description": { "type": "string" },
    "supported_content_types": {
      "type": "array",
      "items": { "type": "string" },
      "minItems": 1
    },
    "auth": {
      "type": "object",
      "required": ["method", "credential_label"],
      "properties": {
        "method": {
          "type": "string",
          "enum": ["bearer", "api_key", "oauth2", "session_cookie", "none"]
        },
        "credential_label": {
          "type": "string",
          "description": "Label of the agent-scoped credential (SPB-02). Never the credential value."
        },
        "scope_required": { "type": "string" }
      }
    },
    "capabilities": {
      "type": "object",
      "required": ["dry_run", "publish", "unpublish"],
      "properties": {
        "dry_run": { "type": "boolean", "description": "Adapter supports a no-side-effect preflight." },
        "publish": { "type": "boolean" },
        "unpublish": { "type": "boolean" },
        "update_in_place": { "type": "boolean" },
        "schedule_publish": { "type": "boolean" }
      }
    },
    "rate_limits": {
      "type": "object",
      "properties": {
        "requests_per_minute": { "type": "integer", "minimum": 1 },
        "publish_per_day": { "type": "integer", "minimum": 1 }
      }
    },
    "retry": {
      "type": "object",
      "properties": {
        "max_attempts": { "type": "integer", "minimum": 1, "default": 3 },
        "backoff_seconds": { "type": "integer", "minimum": 1, "default": 5 }
      }
    },
    "validation": {
      "type": "object",
      "required": ["preflight"],
      "properties": {
        "preflight": {
          "type": "object",
          "description": "Required preflight checks before publish.",
          "properties": {
            "required_fields": { "type": "array", "items": { "type": "string" } },
            "max_payload_kb": { "type": "integer" },
            "policy_check": { "type": "boolean", "default": true }
          }
        }
      }
    },
    "audit": {
      "type": "object",
      "properties": {
        "emit_events": {
          "type": "array",
          "items": { "type": "string", "enum": ["dry_run", "published", "unpublished", "updated", "failed"] },
          "minItems": 1
        }
      }
    }
  }
}
