{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://openfreytprotocol.example/schemas/v0/partner-relationship",
  "title": "PartnerRelationship",
  "description": "A bilateral trust relationship between two organizations on a broker, governing which resource types and operations each party may expose to the other.",
  "type": "object",
  "properties": {
    "id": {
      "type": "string",
      "format": "uuid",
      "description": "UUIDv7 resource identifier."
    },
    "resourceVersion": {
      "type": "integer",
      "minimum": 1,
      "description": "Optimistic-concurrency counter. Incremented on every mutation."
    },
    "requestingOrganizationId": {
      "type": "string",
      "description": "Opaque broker-scoped identifier of the organization that initiated the relationship."
    },
    "acceptingOrganizationId": {
      "type": "string",
      "description": "Opaque broker-scoped identifier of the organization that must accept or reject the relationship."
    },
    "status": {
      "type": "string",
      "enum": ["draft", "requested", "active", "suspended", "terminated"],
      "description": "Lifecycle state of the partner relationship."
    },
    "scopes": {
      "type": "array",
      "items": {
        "type": "string",
        "pattern": "^[a-z][a-z0-9_-]*:[a-z][a-z0-9_-]*$",
        "description": "A scope token in namespace:action format, e.g. 'capacity-offer:read'."
      },
      "uniqueItems": true,
      "description": "Set of permission scopes granted by this relationship."
    },
    "decisionPolicy": {
      "type": "string",
      "enum": ["unanimous", "majority", "any"],
      "description": "Governs how multi-party decisions are resolved within this relationship."
    },
    "effectiveFrom": {
      "type": "string",
      "format": "date",
      "description": "ISO 8601 date from which this relationship is effective."
    },
    "effectiveUntil": {
      "type": "string",
      "format": "date",
      "description": "ISO 8601 date after which this relationship expires. Omit for open-ended relationships."
    },
    "retentionPolicyRef": {
      "type": "string",
      "description": "Optional reference to a broker-defined data retention policy applied to resources shared under this relationship."
    },
    "createdAt": {
      "type": "string",
      "format": "date-time",
      "description": "ISO 8601 / RFC 3339 timestamp when the resource was first created."
    },
    "updatedAt": {
      "type": "string",
      "format": "date-time",
      "description": "ISO 8601 / RFC 3339 timestamp of the most recent mutation."
    }
  },
  "required": [
    "id",
    "resourceVersion",
    "requestingOrganizationId",
    "acceptingOrganizationId",
    "status",
    "scopes",
    "decisionPolicy",
    "effectiveFrom",
    "createdAt",
    "updatedAt"
  ]
}
