{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://orbiplex.ai/schemas/capability-passport-publication-status.v1.schema.json",
  "title": "Capability Passport Publication Status",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schema_version",
    "capability_id",
    "declaration_id",
    "issued_for_module_id",
    "caller_principal",
    "requested_capability_id",
    "publication",
    "observed"
  ],
  "properties": {
    "schema_version": {"const": "v1"},
    "capability_id": {"const": "capability_passport_reconcile"},
    "declaration_id": {"type": "string", "minLength": 1, "maxLength": 512},
    "issued_for_module_id": {"type": "string", "minLength": 1, "maxLength": 128},
    "caller_principal": {"type": "string", "minLength": 1, "maxLength": 256},
    "requested_capability_id": {"type": "string", "minLength": 1, "maxLength": 128},
    "publication": {
      "type": "object",
      "additionalProperties": false,
      "required": ["mode"],
      "properties": {
        "mode": {"enum": ["local-only", "seed-directory"]},
        "policy_ref": {
          "oneOf": [
            {"const": "policy:capability-passport-publication:v1"},
            {"type": "null"}
          ]
        },
        "policy_revision": {
          "oneOf": [
            {"const": "1"},
            {"type": "null"}
          ]
        }
      }
    },
    "observed": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "state",
        "attempted_endpoints",
        "accepted_endpoints",
        "failed_endpoints",
        "retry_attempt",
        "retryable",
        "updated_at"
      ],
      "properties": {
        "state": {
          "enum": [
            "local-only",
            "publish-pending",
            "published",
            "degraded",
            "revoked",
            "superseded"
          ]
        },
        "passport_id": {"type": ["string", "null"], "maxLength": 512},
        "superseded_passport_id": {"type": ["string", "null"], "maxLength": 512},
        "revocation_ref": {"type": ["string", "null"], "maxLength": 512},
        "issued_at": {"type": ["string", "null"]},
        "expires_at": {"type": ["string", "null"]},
        "attempted_endpoints": {
          "type": "array",
          "maxItems": 64,
          "items": {"type": "string", "maxLength": 2048},
          "uniqueItems": true
        },
        "accepted_endpoints": {
          "type": "array",
          "maxItems": 64,
          "items": {"type": "string", "maxLength": 2048},
          "uniqueItems": true
        },
        "failed_endpoints": {
          "type": "object",
          "maxProperties": 64,
          "propertyNames": {"maxLength": 2048},
          "additionalProperties": {"type": "string", "maxLength": 4096}
        },
        "retry_attempt": {"type": "integer", "minimum": 0, "maximum": 8},
        "retryable": {"type": "boolean"},
        "next_retry_at": {"type": ["string", "null"], "format": "date-time"},
        "retry_deadline": {"type": ["string", "null"], "format": "date-time"},
        "reason": {"type": ["string", "null"], "maxLength": 4096},
        "last_fact_ref": {"type": ["string", "null"], "maxLength": 512},
        "updated_at": {"type": "string", "format": "date-time"}
      }
    }
  }
}
