{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "urn:orbiplex:schema:proof-of-personhood-attestation:v1",
  "title": "ProofOfPersonhoodAttestation v1",
  "description": "Machine-readable schema for minimal Proof-of-Personhood attestations that support non-withdrawable UBC and limited cross-federation portability, including recognition through the minimal FIP bridge/registry.",
  "x-dia-basis": [
    "doc/normative/40-constitution/pl/CONSTITUTION.pl.md",
    "doc/normative/50-constitutional-ops/pl/UNIVERSAL-BASIC-COMPUTE.pl.md",
    "doc/normative/50-constitutional-ops/pl/UBC-LIMIT-PROFILES.pl.md"
  ],
  "type": "object",
  "additionalProperties": true,
  "required": [
    "schema/v",
    "attestation_id",
    "subject_ref",
    "issuer_scope",
    "issuer_ref",
    "attestation_method",
    "assurance_scope",
    "deanon_not_required",
    "uniqueness_scope",
    "valid_from",
    "portability_profile"
  ],
  "properties": {
    "schema/v": {
      "const": 1,
      "description": "Schema version."
    },
    "attestation_id": {
      "type": "string",
      "minLength": 1,
      "description": "Stable identifier of this attestation record.",
      "x-dia-basis": [
        "doc/normative/50-constitutional-ops/pl/UNIVERSAL-BASIC-COMPUTE.pl.md"
      ]
    },
    "subject_ref": {
      "type": "string",
      "minLength": 1,
      "description": "Stable anonymous handle for the verified person."
    },
    "issuer_scope": {
      "type": "string",
      "enum": [
        "federation",
        "fip_bridge",
        "hybrid"
      ],
      "description": "Which institutional path stands behind recognition of personhood: a federation, the minimal FIP bridge, or both together.",
      "x-dia-basis": [
        "doc/normative/50-constitutional-ops/pl/UNIVERSAL-BASIC-COMPUTE.pl.md",
        "doc/normative/50-constitutional-ops/pl/UBC-LIMIT-PROFILES.pl.md"
      ]
    },
    "issuer_ref": {
      "type": "string",
      "minLength": 1,
      "description": "Stable reference to the issuing federation, the FIP bridge, or a hybrid issuing path."
    },
    "issuer_federation_id": {
      "type": "string",
      "minLength": 1,
      "description": "Canonical federation identifier when federation-side recognition participates in issuing the attestation."
    },
    "bridge_ref": {
      "type": "string",
      "minLength": 1,
      "description": "Optional reference to the FIP bridge/registry that recognizes the attestation cross-federation."
    },
    "attestation_method": {
      "type": "string",
      "enum": [
        "cryptographic_vouching",
        "federation_attestation",
        "sealed_chambers_recognition",
        "fip_bridge_recognition",
        "hybrid"
      ],
      "description": "Recognition method used to establish Proof-of-Personhood without making de-anonymization the default path."
    },
    "assurance_scope": {
      "const": "proof_of_personhood"
    },
    "deanon_not_required": {
      "type": "boolean"
    },
    "uniqueness_scope": {
      "type": "string",
      "enum": [
        "federation",
        "trans_federation_limited",
        "trans_federation_extended"
      ],
      "description": "How far the attestation's one-person-one-presence guarantees are meant to travel across federation boundaries."
    },
    "valid_from": {
      "type": "string",
      "format": "date-time"
    },
    "valid_until": {
      "type": "string",
      "format": "date-time"
    },
    "recognition_basis_ref": {
      "type": "string",
      "minLength": 1
    },
    "evidence_ref": {
      "type": "string",
      "minLength": 1
    },
    "revocation_ref": {
      "type": "string",
      "minLength": 1
    },
    "revocation_status": {
      "type": "string",
      "enum": [
        "active",
        "revoked",
        "expired",
        "superseded"
      ]
    },
    "portability_profile": {
      "$ref": "#/$defs/portabilityProfile",
      "description": "Declared portability floor and extension capability for emergency, communication, and care access modes.",
      "x-dia-basis": [
        "doc/normative/50-constitutional-ops/pl/UBC-LIMIT-PROFILES.pl.md"
      ]
    },
    "policy_annotations": {
      "type": "object",
      "additionalProperties": true
    }
  },
  "$defs": {
    "portabilityModeMap": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "emergency",
        "communication",
        "care"
      ],
      "properties": {
        "emergency": {
          "const": "unlimited",
          "description": "Emergency access must remain available without quantitative cap at the portability floor."
        },
        "communication": {
          "type": "string",
          "enum": [
            "limited",
            "extended"
          ],
          "description": "Communication access profile when the attestation is honored outside the home federation."
        },
        "care": {
          "type": "string",
          "enum": [
            "limited",
            "extended"
          ],
          "description": "Care or mutual-aid access profile when the attestation is honored outside the home federation."
        }
      }
    },
    "portabilityProfile": {
      "type": "object",
      "additionalProperties": true,
      "required": [
        "trans_federation_default",
        "bridge_minimum_supported",
        "federation_extension_allowed"
      ],
      "properties": {
        "trans_federation_default": {
          "$ref": "#/$defs/portabilityModeMap",
          "description": "Baseline portability behavior outside the issuing federation."
        },
        "bridge_minimum_supported": {
          "type": "boolean",
          "description": "Whether the attestation is valid for the minimal FIP bridge profile."
        },
        "federation_extension_allowed": {
          "type": "boolean",
          "description": "Whether federations may lawfully expand access beyond the minimal bridge profile."
        },
        "extension_profile_refs": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          },
          "uniqueItems": true,
          "description": "Optional references to named federation profiles that extend the baseline portability floor."
        }
      }
    }
  },
  "allOf": [
    {
      "if": {
        "properties": {
          "issuer_scope": {
            "const": "federation"
          }
        },
        "required": [
          "issuer_scope"
        ]
      },
      "then": {
        "required": [
          "issuer_federation_id"
        ]
      }
    },
    {
      "if": {
        "properties": {
          "issuer_scope": {
            "const": "fip_bridge"
          }
        },
        "required": [
          "issuer_scope"
        ]
      },
      "then": {
        "required": [
          "bridge_ref"
        ],
        "properties": {
          "attestation_method": {
            "enum": [
              "sealed_chambers_recognition",
              "fip_bridge_recognition",
              "hybrid"
            ]
          },
          "portability_profile": {
            "properties": {
              "bridge_minimum_supported": {
                "const": true
              }
            }
          }
        }
      }
    },
    {
      "if": {
        "properties": {
          "issuer_scope": {
            "const": "hybrid"
          }
        },
        "required": [
          "issuer_scope"
        ]
      },
      "then": {
        "required": [
          "issuer_federation_id",
          "bridge_ref"
        ]
      }
    },
    {
      "if": {
        "properties": {
          "uniqueness_scope": {
            "const": "trans_federation_extended"
          }
        },
        "required": [
          "uniqueness_scope"
        ]
      },
      "then": {
        "properties": {
          "portability_profile": {
            "properties": {
              "extension_profile_refs": {
                "minItems": 1
              }
            }
          }
        }
      }
    }
  ]
}
