{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "urn:kiduna:governance:1.0.0",
  "title": "Kiduna Governance exchange profile 1.0.0",
  "type": "object",
  "properties": {
    "schema_version": {
      "const": "1.0.0"
    },
    "records": {
      "type": "array",
      "items": {
        "oneOf": [
          {
            "$ref": "#/$defs/PolicyVersion"
          },
          {
            "$ref": "#/$defs/GovernanceCycle"
          },
          {
            "$ref": "#/$defs/ProposalRevision"
          },
          {
            "$ref": "#/$defs/EligibilitySnapshot"
          },
          {
            "$ref": "#/$defs/Delegation"
          },
          {
            "$ref": "#/$defs/Ballot"
          },
          {
            "$ref": "#/$defs/CreditEntry"
          },
          {
            "$ref": "#/$defs/NegotiationEvent"
          },
          {
            "$ref": "#/$defs/Decision"
          },
          {
            "$ref": "#/$defs/Mandate"
          },
          {
            "$ref": "#/$defs/ExecutionIntent"
          },
          {
            "$ref": "#/$defs/ActionReceipt"
          },
          {
            "$ref": "#/$defs/GovernanceBinding"
          }
        ]
      },
      "minItems": 0
    }
  },
  "required": [
    "schema_version",
    "records"
  ],
  "additionalProperties": false,
  "$defs": {
    "Ref": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "minLength": 1
        },
        "revision": {
          "type": "integer",
          "minimum": 1
        }
      },
      "required": [
        "id",
        "revision"
      ],
      "additionalProperties": false
    },
    "Hash": {
      "type": "string",
      "pattern": "^[a-f0-9]{64}$"
    },
    "Time": {
      "type": "string",
      "format": "date-time"
    },
    "Money": {
      "type": "object",
      "properties": {
        "asset": {
          "const": "USDC"
        },
        "amount_minor": {
          "type": "integer",
          "minimum": 1
        },
        "decimals": {
          "const": 6
        }
      },
      "required": [
        "asset",
        "amount_minor",
        "decimals"
      ],
      "additionalProperties": false
    },
    "ResourceQuantity": {
      "type": "object",
      "properties": {
        "resource_ref": {
          "$ref": "#/$defs/Ref"
        },
        "unit": {
          "type": "string",
          "minLength": 1
        },
        "quantity": {
          "type": "integer",
          "minimum": 1
        }
      },
      "required": [
        "resource_ref",
        "unit",
        "quantity"
      ],
      "additionalProperties": false
    },
    "Payload_distribution": {
      "type": "object",
      "properties": {
        "treasury_ref": {
          "$ref": "#/$defs/Ref"
        },
        "budget_ref": {
          "anyOf": [
            {
              "$ref": "#/$defs/Ref"
            },
            {
              "type": "null"
            }
          ]
        },
        "recipient_ref": {
          "$ref": "#/$defs/Ref"
        },
        "amount": {
          "$ref": "#/$defs/Money"
        },
        "purpose": {
          "enum": [
            "compensation",
            "reimbursement",
            "purpose-benefit",
            "grant",
            "other-reviewed"
          ]
        },
        "purpose_evidence_refs": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/Ref"
          },
          "minItems": 1
        },
        "payment_obligation_ref": {
          "anyOf": [
            {
              "$ref": "#/$defs/Ref"
            },
            {
              "type": "null"
            }
          ]
        },
        "network": {
          "type": "string",
          "minLength": 1
        },
        "asset_identifier": {
          "type": "string",
          "minLength": 1
        },
        "recipient_address": {
          "type": "string",
          "minLength": 1
        }
      },
      "required": [
        "treasury_ref",
        "budget_ref",
        "recipient_ref",
        "amount",
        "purpose",
        "purpose_evidence_refs",
        "payment_obligation_ref",
        "network",
        "asset_identifier",
        "recipient_address"
      ],
      "additionalProperties": false
    },
    "Payload_appointment": {
      "type": "object",
      "properties": {
        "operation": {
          "enum": [
            "grant",
            "revoke"
          ]
        },
        "principal_ref": {
          "$ref": "#/$defs/Ref"
        },
        "role_ref": {
          "$ref": "#/$defs/Ref"
        },
        "scope_refs": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/Ref"
          },
          "minItems": 1
        },
        "starts_at": {
          "$ref": "#/$defs/Time"
        },
        "ends_at": {
          "anyOf": [
            {
              "$ref": "#/$defs/Time"
            },
            {
              "type": "null"
            }
          ]
        },
        "grant_ref": {
          "anyOf": [
            {
              "$ref": "#/$defs/Ref"
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "required": [
        "operation",
        "principal_ref",
        "role_ref",
        "scope_refs",
        "starts_at",
        "ends_at",
        "grant_ref"
      ],
      "additionalProperties": false
    },
    "Payload_membership": {
      "type": "object",
      "properties": {
        "operation": {
          "enum": [
            "admit",
            "suspend",
            "reinstate",
            "remove"
          ]
        },
        "member_ref": {
          "$ref": "#/$defs/Ref"
        },
        "membership_policy_ref": {
          "$ref": "#/$defs/Ref"
        },
        "reason": {
          "type": "string",
          "minLength": 1
        },
        "effective_at": {
          "$ref": "#/$defs/Time"
        },
        "notice_evidence_refs": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/Ref"
          },
          "minItems": 0
        }
      },
      "required": [
        "operation",
        "member_ref",
        "membership_policy_ref",
        "reason",
        "effective_at",
        "notice_evidence_refs"
      ],
      "additionalProperties": false
    },
    "Payload_budget": {
      "type": "object",
      "properties": {
        "operation": {
          "enum": [
            "establish",
            "amend",
            "close"
          ]
        },
        "budget_ref": {
          "$ref": "#/$defs/Ref"
        },
        "treasury_ref": {
          "$ref": "#/$defs/Ref"
        },
        "ceiling": {
          "$ref": "#/$defs/Money"
        },
        "starts_at": {
          "$ref": "#/$defs/Time"
        },
        "ends_at": {
          "$ref": "#/$defs/Time"
        },
        "mandate_ref": {
          "anyOf": [
            {
              "$ref": "#/$defs/Ref"
            },
            {
              "type": "null"
            }
          ]
        },
        "reservation_refs": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/Ref"
          },
          "minItems": 0
        }
      },
      "required": [
        "operation",
        "budget_ref",
        "treasury_ref",
        "ceiling",
        "starts_at",
        "ends_at",
        "mandate_ref",
        "reservation_refs"
      ],
      "additionalProperties": false
    },
    "Payload_work_authorization": {
      "type": "object",
      "properties": {
        "activity_ref": {
          "$ref": "#/$defs/Ref"
        },
        "cycle_ref": {
          "$ref": "#/$defs/Ref"
        },
        "budget_ref": {
          "anyOf": [
            {
              "$ref": "#/$defs/Ref"
            },
            {
              "type": "null"
            }
          ]
        },
        "reward": {
          "anyOf": [
            {
              "$ref": "#/$defs/Money"
            },
            {
              "type": "null"
            }
          ]
        },
        "reviewer_refs": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/Ref"
          },
          "minItems": 1
        },
        "terms_ref": {
          "$ref": "#/$defs/Ref"
        },
        "domain": {
          "enum": [
            "Technology",
            "Governance",
            "Economics",
            "Culture",
            "Ecology",
            "Care"
          ]
        }
      },
      "required": [
        "activity_ref",
        "cycle_ref",
        "budget_ref",
        "reward",
        "reviewer_refs",
        "terms_ref",
        "domain"
      ],
      "additionalProperties": false
    },
    "Payload_initiative": {
      "type": "object",
      "properties": {
        "operation": {
          "enum": [
            "create",
            "revise",
            "pause",
            "retire"
          ]
        },
        "cycle_ref": {
          "$ref": "#/$defs/Ref"
        },
        "cycle_kind": {
          "enum": [
            "Mission",
            "Campaign"
          ]
        },
        "vision_ref": {
          "$ref": "#/$defs/Ref"
        },
        "plan_ref": {
          "$ref": "#/$defs/Ref"
        },
        "metric_refs": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/Ref"
          },
          "minItems": 1
        },
        "budget_ref": {
          "anyOf": [
            {
              "$ref": "#/$defs/Ref"
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "required": [
        "operation",
        "cycle_ref",
        "cycle_kind",
        "vision_ref",
        "plan_ref",
        "metric_refs",
        "budget_ref"
      ],
      "additionalProperties": false
    },
    "Payload_agent": {
      "type": "object",
      "properties": {
        "operation": {
          "enum": [
            "configure",
            "activate",
            "restrict",
            "deactivate"
          ]
        },
        "agent_ref": {
          "$ref": "#/$defs/Ref"
        },
        "role": {
          "enum": [
            "Envoy",
            "Guide",
            "Scout",
            "Actor",
            "Realm Ally"
          ]
        },
        "mandate_ref": {
          "$ref": "#/$defs/Ref"
        },
        "tool_grant_refs": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/Ref"
          },
          "minItems": 0
        },
        "skill_refs": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/Ref"
          },
          "minItems": 0
        },
        "budget_ref": {
          "anyOf": [
            {
              "$ref": "#/$defs/Ref"
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "required": [
        "operation",
        "agent_ref",
        "role",
        "mandate_ref",
        "tool_grant_refs",
        "skill_refs",
        "budget_ref"
      ],
      "additionalProperties": false
    },
    "Payload_resource_allocation": {
      "type": "object",
      "properties": {
        "resource": {
          "$ref": "#/$defs/ResourceQuantity"
        },
        "recipient_ref": {
          "$ref": "#/$defs/Ref"
        },
        "scope_refs": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/Ref"
          },
          "minItems": 1
        },
        "starts_at": {
          "$ref": "#/$defs/Time"
        },
        "ends_at": {
          "$ref": "#/$defs/Time"
        },
        "reservation_ref": {
          "anyOf": [
            {
              "$ref": "#/$defs/Ref"
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "required": [
        "resource",
        "recipient_ref",
        "scope_refs",
        "starts_at",
        "ends_at",
        "reservation_ref"
      ],
      "additionalProperties": false
    },
    "Payload_partnership": {
      "type": "object",
      "properties": {
        "counterparty_refs": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/Ref"
          },
          "minItems": 1
        },
        "agreement_ref": {
          "$ref": "#/$defs/Ref"
        },
        "scope_refs": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/Ref"
          },
          "minItems": 1
        },
        "commitment_refs": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/Ref"
          },
          "minItems": 0
        },
        "consent_refs": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/Ref"
          },
          "minItems": 0
        }
      },
      "required": [
        "counterparty_refs",
        "agreement_ref",
        "scope_refs",
        "commitment_refs",
        "consent_refs"
      ],
      "additionalProperties": false
    },
    "Payload_policy": {
      "type": "object",
      "properties": {
        "operation": {
          "enum": [
            "adopt",
            "amend",
            "repeal"
          ]
        },
        "policy_ref": {
          "$ref": "#/$defs/Ref"
        },
        "base_policy_ref": {
          "anyOf": [
            {
              "$ref": "#/$defs/Ref"
            },
            {
              "type": "null"
            }
          ]
        },
        "effective_at": {
          "$ref": "#/$defs/Time"
        },
        "compatibility_report_ref": {
          "$ref": "#/$defs/Ref"
        }
      },
      "required": [
        "operation",
        "policy_ref",
        "base_policy_ref",
        "effective_at",
        "compatibility_report_ref"
      ],
      "additionalProperties": false
    },
    "Payload_governance_rule": {
      "type": "object",
      "properties": {
        "operation": {
          "enum": [
            "adopt",
            "amend",
            "repeal"
          ]
        },
        "policy_ref": {
          "$ref": "#/$defs/Ref"
        },
        "base_policy_ref": {
          "anyOf": [
            {
              "$ref": "#/$defs/Ref"
            },
            {
              "type": "null"
            }
          ]
        },
        "effective_at": {
          "$ref": "#/$defs/Time"
        },
        "transition_plan_ref": {
          "$ref": "#/$defs/Ref"
        },
        "bootstrap_authority_ref": {
          "anyOf": [
            {
              "$ref": "#/$defs/Ref"
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "required": [
        "operation",
        "policy_ref",
        "base_policy_ref",
        "effective_at",
        "transition_plan_ref",
        "bootstrap_authority_ref"
      ],
      "additionalProperties": false
    },
    "Payload_treasury_management": {
      "type": "object",
      "properties": {
        "treasury_ref": {
          "$ref": "#/$defs/Ref"
        },
        "operation": {
          "enum": [
            "move-pool",
            "change-reserve",
            "change-signer",
            "change-spending-limit"
          ]
        },
        "change_ref": {
          "$ref": "#/$defs/Ref"
        },
        "instruction_hash": {
          "$ref": "#/$defs/Hash"
        },
        "network": {
          "type": "string",
          "minLength": 1
        },
        "config_revision": {
          "type": "integer",
          "minimum": 1
        }
      },
      "required": [
        "treasury_ref",
        "operation",
        "change_ref",
        "instruction_hash",
        "network",
        "config_revision"
      ],
      "additionalProperties": false
    },
    "Payload_official_action": {
      "type": "object",
      "properties": {
        "artifact_ref": {
          "$ref": "#/$defs/Ref"
        },
        "artifact_hash": {
          "$ref": "#/$defs/Hash"
        },
        "destination_refs": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/Ref"
          },
          "minItems": 1
        },
        "publisher_mandate_ref": {
          "$ref": "#/$defs/Ref"
        },
        "commitment_refs": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/Ref"
          },
          "minItems": 0
        }
      },
      "required": [
        "artifact_ref",
        "artifact_hash",
        "destination_refs",
        "publisher_mandate_ref",
        "commitment_refs"
      ],
      "additionalProperties": false
    },
    "Payload_organizational_change": {
      "type": "object",
      "properties": {
        "operation": {
          "enum": [
            "purpose-amendment",
            "restructure",
            "merge",
            "dissolve"
          ]
        },
        "plan_ref": {
          "$ref": "#/$defs/Ref"
        },
        "affected_duna_refs": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/Ref"
          },
          "minItems": 1
        },
        "obligation_plan_ref": {
          "$ref": "#/$defs/Ref"
        },
        "filing_requirement_refs": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/Ref"
          },
          "minItems": 0
        },
        "legal_review_ref": {
          "$ref": "#/$defs/Ref"
        }
      },
      "required": [
        "operation",
        "plan_ref",
        "affected_duna_refs",
        "obligation_plan_ref",
        "filing_requirement_refs",
        "legal_review_ref"
      ],
      "additionalProperties": false
    },
    "GovernanceRules": {
      "type": "object",
      "properties": {
        "mechanism": {
          "anyOf": [
            {
              "enum": [
                "ballot",
                "credit-market",
                "consent",
                "custom"
              ]
            },
            {
              "type": "null"
            }
          ]
        },
        "ruleset_ref": {
          "anyOf": [
            {
              "$ref": "#/$defs/Ref"
            },
            {
              "type": "null"
            }
          ]
        },
        "electorate_rule_ref": {
          "anyOf": [
            {
              "$ref": "#/$defs/Ref"
            },
            {
              "type": "null"
            }
          ]
        },
        "quorum_rule_ref": {
          "anyOf": [
            {
              "$ref": "#/$defs/Ref"
            },
            {
              "type": "null"
            }
          ]
        },
        "approval_rule_ref": {
          "anyOf": [
            {
              "$ref": "#/$defs/Ref"
            },
            {
              "type": "null"
            }
          ]
        },
        "tie_rule_ref": {
          "anyOf": [
            {
              "$ref": "#/$defs/Ref"
            },
            {
              "type": "null"
            }
          ]
        },
        "abstention_rule_ref": {
          "anyOf": [
            {
              "$ref": "#/$defs/Ref"
            },
            {
              "type": "null"
            }
          ]
        },
        "delegation_rule_ref": {
          "anyOf": [
            {
              "$ref": "#/$defs/Ref"
            },
            {
              "type": "null"
            }
          ]
        },
        "conflict_rule_ref": {
          "anyOf": [
            {
              "$ref": "#/$defs/Ref"
            },
            {
              "type": "null"
            }
          ]
        },
        "challenge_rule_ref": {
          "anyOf": [
            {
              "$ref": "#/$defs/Ref"
            },
            {
              "type": "null"
            }
          ]
        },
        "emergency_rule_ref": {
          "anyOf": [
            {
              "$ref": "#/$defs/Ref"
            },
            {
              "type": "null"
            }
          ]
        },
        "calendar_ref": {
          "anyOf": [
            {
              "$ref": "#/$defs/Ref"
            },
            {
              "type": "null"
            }
          ]
        },
        "class_rule_refs": {
          "type": "object",
          "properties": {
            "routine": {
              "anyOf": [
                {
                  "$ref": "#/$defs/Ref"
                },
                {
                  "type": "null"
                }
              ]
            },
            "significant": {
              "anyOf": [
                {
                  "$ref": "#/$defs/Ref"
                },
                {
                  "type": "null"
                }
              ]
            },
            "foundational": {
              "anyOf": [
                {
                  "$ref": "#/$defs/Ref"
                },
                {
                  "type": "null"
                }
              ]
            }
          },
          "required": [
            "routine",
            "significant",
            "foundational"
          ],
          "additionalProperties": false
        },
        "credit_amount": {
          "anyOf": [
            {
              "type": "integer",
              "minimum": 1
            },
            {
              "type": "null"
            }
          ]
        },
        "credit_rule_ref": {
          "anyOf": [
            {
              "$ref": "#/$defs/Ref"
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "required": [
        "mechanism",
        "ruleset_ref",
        "electorate_rule_ref",
        "quorum_rule_ref",
        "approval_rule_ref",
        "tie_rule_ref",
        "abstention_rule_ref",
        "delegation_rule_ref",
        "conflict_rule_ref",
        "challenge_rule_ref",
        "emergency_rule_ref",
        "calendar_ref",
        "class_rule_refs",
        "credit_amount",
        "credit_rule_ref"
      ],
      "additionalProperties": false
    },
    "PolicyVersion": {
      "type": "object",
      "properties": {
        "kind": {
          "const": "PolicyVersion"
        },
        "id": {
          "type": "string",
          "minLength": 1
        },
        "revision": {
          "type": "integer",
          "minimum": 1
        },
        "data_class": {
          "enum": [
            "synthetic",
            "operational"
          ]
        },
        "source_refs": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          },
          "minItems": 1
        },
        "policy_kind": {
          "enum": [
            "governance",
            "membership",
            "roles",
            "treasury",
            "compensation",
            "budgets",
            "agents",
            "resources",
            "conduct",
            "procurement",
            "partnerships",
            "records"
          ]
        },
        "realm_id": {
          "type": "string",
          "minLength": 1
        },
        "status": {
          "enum": [
            "draft",
            "adopted",
            "superseded",
            "repealed"
          ]
        },
        "base_ref": {
          "anyOf": [
            {
              "$ref": "#/$defs/Ref"
            },
            {
              "type": "null"
            }
          ]
        },
        "effective_at": {
          "anyOf": [
            {
              "$ref": "#/$defs/Time"
            },
            {
              "type": "null"
            }
          ]
        },
        "adoption_decision_ref": {
          "anyOf": [
            {
              "$ref": "#/$defs/Ref"
            },
            {
              "type": "null"
            }
          ]
        },
        "body_ref": {
          "$ref": "#/$defs/Ref"
        },
        "body_hash": {
          "$ref": "#/$defs/Hash"
        },
        "governance_rules": {
          "anyOf": [
            {
              "$ref": "#/$defs/GovernanceRules"
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "required": [
        "kind",
        "id",
        "revision",
        "data_class",
        "source_refs",
        "policy_kind",
        "realm_id",
        "status",
        "base_ref",
        "effective_at",
        "adoption_decision_ref",
        "body_ref",
        "body_hash",
        "governance_rules"
      ],
      "additionalProperties": false,
      "allOf": [
        {
          "if": {
            "properties": {
              "policy_kind": {
                "const": "governance"
              }
            }
          },
          "then": {
            "properties": {
              "governance_rules": {
                "$ref": "#/$defs/GovernanceRules"
              }
            }
          }
        }
      ]
    },
    "GovernanceCycle": {
      "type": "object",
      "properties": {
        "kind": {
          "const": "GovernanceCycle"
        },
        "id": {
          "type": "string",
          "minLength": 1
        },
        "revision": {
          "type": "integer",
          "minimum": 1
        },
        "data_class": {
          "enum": [
            "synthetic",
            "operational"
          ]
        },
        "source_refs": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          },
          "minItems": 1
        },
        "realm_id": {
          "type": "string",
          "minLength": 1
        },
        "policy_ref": {
          "anyOf": [
            {
              "$ref": "#/$defs/Ref"
            },
            {
              "type": "null"
            }
          ]
        },
        "timezone": {
          "anyOf": [
            {
              "type": "string",
              "minLength": 1
            },
            {
              "type": "null"
            }
          ]
        },
        "opens_at": {
          "anyOf": [
            {
              "$ref": "#/$defs/Time"
            },
            {
              "type": "null"
            }
          ]
        },
        "closes_at": {
          "anyOf": [
            {
              "$ref": "#/$defs/Time"
            },
            {
              "type": "null"
            }
          ]
        },
        "eligibility_ref": {
          "anyOf": [
            {
              "$ref": "#/$defs/Ref"
            },
            {
              "type": "null"
            }
          ]
        },
        "configuration_status": {
          "enum": [
            "unresolved",
            "adopted"
          ]
        },
        "status": {
          "enum": [
            "draft",
            "scheduled",
            "open",
            "closed",
            "cancelled"
          ]
        }
      },
      "required": [
        "kind",
        "id",
        "revision",
        "data_class",
        "source_refs",
        "realm_id",
        "policy_ref",
        "timezone",
        "opens_at",
        "closes_at",
        "eligibility_ref",
        "configuration_status",
        "status"
      ],
      "additionalProperties": false
    },
    "ProposalRevision": {
      "type": "object",
      "properties": {
        "kind": {
          "const": "ProposalRevision"
        },
        "id": {
          "type": "string",
          "minLength": 1
        },
        "revision": {
          "type": "integer",
          "minimum": 1
        },
        "data_class": {
          "enum": [
            "synthetic",
            "operational"
          ]
        },
        "source_refs": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          },
          "minItems": 1
        },
        "duna_id": {
          "type": "string",
          "minLength": 1
        },
        "realm_id": {
          "type": "string",
          "minLength": 1
        },
        "type": {
          "enum": [
            "distribution",
            "appointment",
            "membership",
            "budget",
            "work-authorization",
            "initiative",
            "agent",
            "resource-allocation",
            "partnership",
            "policy",
            "governance-rule",
            "treasury-management",
            "official-action",
            "organizational-change"
          ]
        },
        "title": {
          "type": "string",
          "minLength": 1
        },
        "rationale": {
          "type": "string",
          "minLength": 1
        },
        "alternatives": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          },
          "minItems": 0
        },
        "affected_refs": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/Ref"
          },
          "minItems": 0
        },
        "success_criteria": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          },
          "minItems": 1
        },
        "risks": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          },
          "minItems": 0
        },
        "status": {
          "enum": [
            "draft",
            "submitted",
            "deliberating",
            "voting",
            "closed",
            "adopted",
            "rejected",
            "executable",
            "executing",
            "executed",
            "failed",
            "withdrawn",
            "expired"
          ]
        },
        "execution_class": {
          "enum": [
            "routine",
            "significant",
            "foundational"
          ]
        },
        "policy_ref": {
          "anyOf": [
            {
              "$ref": "#/$defs/Ref"
            },
            {
              "type": "null"
            }
          ]
        },
        "cycle_ref": {
          "anyOf": [
            {
              "$ref": "#/$defs/Ref"
            },
            {
              "type": "null"
            }
          ]
        },
        "eligibility_ref": {
          "anyOf": [
            {
              "$ref": "#/$defs/Ref"
            },
            {
              "type": "null"
            }
          ]
        },
        "proposer_ref": {
          "$ref": "#/$defs/Ref"
        },
        "base_ref": {
          "anyOf": [
            {
              "$ref": "#/$defs/Ref"
            },
            {
              "type": "null"
            }
          ]
        },
        "payload": {},
        "payload_hash": {
          "$ref": "#/$defs/Hash"
        },
        "revision_hash": {
          "$ref": "#/$defs/Hash"
        }
      },
      "required": [
        "kind",
        "id",
        "revision",
        "data_class",
        "source_refs",
        "duna_id",
        "realm_id",
        "type",
        "title",
        "rationale",
        "alternatives",
        "affected_refs",
        "success_criteria",
        "risks",
        "status",
        "execution_class",
        "policy_ref",
        "cycle_ref",
        "eligibility_ref",
        "proposer_ref",
        "base_ref",
        "payload",
        "payload_hash",
        "revision_hash"
      ],
      "additionalProperties": false,
      "allOf": [
        {
          "if": {
            "properties": {
              "type": {
                "const": "distribution"
              }
            }
          },
          "then": {
            "properties": {
              "payload": {
                "$ref": "#/$defs/Payload_distribution"
              }
            }
          }
        },
        {
          "if": {
            "properties": {
              "type": {
                "const": "appointment"
              }
            }
          },
          "then": {
            "properties": {
              "payload": {
                "$ref": "#/$defs/Payload_appointment"
              }
            }
          }
        },
        {
          "if": {
            "properties": {
              "type": {
                "const": "membership"
              }
            }
          },
          "then": {
            "properties": {
              "payload": {
                "$ref": "#/$defs/Payload_membership"
              }
            }
          }
        },
        {
          "if": {
            "properties": {
              "type": {
                "const": "budget"
              }
            }
          },
          "then": {
            "properties": {
              "payload": {
                "$ref": "#/$defs/Payload_budget"
              }
            }
          }
        },
        {
          "if": {
            "properties": {
              "type": {
                "const": "work-authorization"
              }
            }
          },
          "then": {
            "properties": {
              "payload": {
                "$ref": "#/$defs/Payload_work_authorization"
              }
            }
          }
        },
        {
          "if": {
            "properties": {
              "type": {
                "const": "initiative"
              }
            }
          },
          "then": {
            "properties": {
              "payload": {
                "$ref": "#/$defs/Payload_initiative"
              }
            }
          }
        },
        {
          "if": {
            "properties": {
              "type": {
                "const": "agent"
              }
            }
          },
          "then": {
            "properties": {
              "payload": {
                "$ref": "#/$defs/Payload_agent"
              }
            }
          }
        },
        {
          "if": {
            "properties": {
              "type": {
                "const": "resource-allocation"
              }
            }
          },
          "then": {
            "properties": {
              "payload": {
                "$ref": "#/$defs/Payload_resource_allocation"
              }
            }
          }
        },
        {
          "if": {
            "properties": {
              "type": {
                "const": "partnership"
              }
            }
          },
          "then": {
            "properties": {
              "payload": {
                "$ref": "#/$defs/Payload_partnership"
              }
            }
          }
        },
        {
          "if": {
            "properties": {
              "type": {
                "const": "policy"
              }
            }
          },
          "then": {
            "properties": {
              "payload": {
                "$ref": "#/$defs/Payload_policy"
              }
            }
          }
        },
        {
          "if": {
            "properties": {
              "type": {
                "const": "governance-rule"
              }
            }
          },
          "then": {
            "properties": {
              "payload": {
                "$ref": "#/$defs/Payload_governance_rule"
              }
            }
          }
        },
        {
          "if": {
            "properties": {
              "type": {
                "const": "treasury-management"
              }
            }
          },
          "then": {
            "properties": {
              "payload": {
                "$ref": "#/$defs/Payload_treasury_management"
              }
            }
          }
        },
        {
          "if": {
            "properties": {
              "type": {
                "const": "official-action"
              }
            }
          },
          "then": {
            "properties": {
              "payload": {
                "$ref": "#/$defs/Payload_official_action"
              }
            }
          }
        },
        {
          "if": {
            "properties": {
              "type": {
                "const": "organizational-change"
              }
            }
          },
          "then": {
            "properties": {
              "payload": {
                "$ref": "#/$defs/Payload_organizational_change"
              }
            }
          }
        }
      ]
    },
    "EligibilitySnapshot": {
      "type": "object",
      "properties": {
        "kind": {
          "const": "EligibilitySnapshot"
        },
        "id": {
          "type": "string",
          "minLength": 1
        },
        "revision": {
          "type": "integer",
          "minimum": 1
        },
        "data_class": {
          "enum": [
            "synthetic",
            "operational"
          ]
        },
        "source_refs": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          },
          "minItems": 1
        },
        "realm_id": {
          "type": "string",
          "minLength": 1
        },
        "policy_ref": {
          "$ref": "#/$defs/Ref"
        },
        "proposal_ref": {
          "$ref": "#/$defs/Ref"
        },
        "frozen_at": {
          "$ref": "#/$defs/Time"
        },
        "units": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "unit_id": {
                "type": "string",
                "minLength": 1
              },
              "principal_ref": {
                "$ref": "#/$defs/Ref"
              },
              "weight": {
                "type": "integer",
                "minimum": 1
              }
            },
            "required": [
              "unit_id",
              "principal_ref",
              "weight"
            ],
            "additionalProperties": false
          },
          "minItems": 1
        },
        "snapshot_hash": {
          "$ref": "#/$defs/Hash"
        }
      },
      "required": [
        "kind",
        "id",
        "revision",
        "data_class",
        "source_refs",
        "realm_id",
        "policy_ref",
        "proposal_ref",
        "frozen_at",
        "units",
        "snapshot_hash"
      ],
      "additionalProperties": false
    },
    "Delegation": {
      "type": "object",
      "properties": {
        "kind": {
          "const": "Delegation"
        },
        "id": {
          "type": "string",
          "minLength": 1
        },
        "revision": {
          "type": "integer",
          "minimum": 1
        },
        "data_class": {
          "enum": [
            "synthetic",
            "operational"
          ]
        },
        "source_refs": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          },
          "minItems": 1
        },
        "realm_id": {
          "type": "string",
          "minLength": 1
        },
        "principal_ref": {
          "$ref": "#/$defs/Ref"
        },
        "representative_ref": {
          "$ref": "#/$defs/Ref"
        },
        "proposal_refs": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/Ref"
          },
          "minItems": 1
        },
        "allowed_actions": {
          "type": "array",
          "items": {
            "enum": [
              "propose",
              "negotiate",
              "vote"
            ]
          },
          "minItems": 1
        },
        "starts_at": {
          "$ref": "#/$defs/Time"
        },
        "expires_at": {
          "$ref": "#/$defs/Time"
        },
        "revoked_at": {
          "anyOf": [
            {
              "$ref": "#/$defs/Time"
            },
            {
              "type": "null"
            }
          ]
        },
        "allow_subdelegation": {
          "type": "boolean"
        },
        "authority_ref": {
          "$ref": "#/$defs/Ref"
        }
      },
      "required": [
        "kind",
        "id",
        "revision",
        "data_class",
        "source_refs",
        "realm_id",
        "principal_ref",
        "representative_ref",
        "proposal_refs",
        "allowed_actions",
        "starts_at",
        "expires_at",
        "revoked_at",
        "allow_subdelegation",
        "authority_ref"
      ],
      "additionalProperties": false
    },
    "Ballot": {
      "type": "object",
      "properties": {
        "kind": {
          "const": "Ballot"
        },
        "id": {
          "type": "string",
          "minLength": 1
        },
        "revision": {
          "type": "integer",
          "minimum": 1
        },
        "data_class": {
          "enum": [
            "synthetic",
            "operational"
          ]
        },
        "source_refs": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          },
          "minItems": 1
        },
        "realm_id": {
          "type": "string",
          "minLength": 1
        },
        "proposal_ref": {
          "$ref": "#/$defs/Ref"
        },
        "proposal_hash": {
          "$ref": "#/$defs/Hash"
        },
        "policy_ref": {
          "$ref": "#/$defs/Ref"
        },
        "eligibility_ref": {
          "$ref": "#/$defs/Ref"
        },
        "unit_id": {
          "type": "string",
          "minLength": 1
        },
        "principal_ref": {
          "$ref": "#/$defs/Ref"
        },
        "choice": {
          "enum": [
            "yes",
            "no",
            "abstain"
          ]
        },
        "cast_at": {
          "$ref": "#/$defs/Time"
        },
        "delegation_ref": {
          "anyOf": [
            {
              "$ref": "#/$defs/Ref"
            },
            {
              "type": "null"
            }
          ]
        },
        "supersedes_ref": {
          "anyOf": [
            {
              "$ref": "#/$defs/Ref"
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "required": [
        "kind",
        "id",
        "revision",
        "data_class",
        "source_refs",
        "realm_id",
        "proposal_ref",
        "proposal_hash",
        "policy_ref",
        "eligibility_ref",
        "unit_id",
        "principal_ref",
        "choice",
        "cast_at",
        "delegation_ref",
        "supersedes_ref"
      ],
      "additionalProperties": false
    },
    "CreditEntry": {
      "type": "object",
      "properties": {
        "kind": {
          "const": "CreditEntry"
        },
        "id": {
          "type": "string",
          "minLength": 1
        },
        "revision": {
          "type": "integer",
          "minimum": 1
        },
        "data_class": {
          "enum": [
            "synthetic",
            "operational"
          ]
        },
        "source_refs": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          },
          "minItems": 1
        },
        "realm_id": {
          "type": "string",
          "minLength": 1
        },
        "proposal_ref": {
          "$ref": "#/$defs/Ref"
        },
        "policy_ref": {
          "$ref": "#/$defs/Ref"
        },
        "unit_id": {
          "type": "string",
          "minLength": 1
        },
        "entry_type": {
          "enum": [
            "issue",
            "reserve",
            "release",
            "transfer",
            "expire"
          ]
        },
        "amount": {
          "type": "integer",
          "minimum": 1
        },
        "counterparty_unit_id": {
          "anyOf": [
            {
              "type": "string",
              "minLength": 1
            },
            {
              "type": "null"
            }
          ]
        },
        "idempotency_key": {
          "type": "string",
          "minLength": 1
        },
        "occurred_at": {
          "$ref": "#/$defs/Time"
        },
        "authority_ref": {
          "$ref": "#/$defs/Ref"
        }
      },
      "required": [
        "kind",
        "id",
        "revision",
        "data_class",
        "source_refs",
        "realm_id",
        "proposal_ref",
        "policy_ref",
        "unit_id",
        "entry_type",
        "amount",
        "counterparty_unit_id",
        "idempotency_key",
        "occurred_at",
        "authority_ref"
      ],
      "additionalProperties": false
    },
    "NegotiationEvent": {
      "type": "object",
      "properties": {
        "kind": {
          "const": "NegotiationEvent"
        },
        "id": {
          "type": "string",
          "minLength": 1
        },
        "revision": {
          "type": "integer",
          "minimum": 1
        },
        "data_class": {
          "enum": [
            "synthetic",
            "operational"
          ]
        },
        "source_refs": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          },
          "minItems": 1
        },
        "realm_id": {
          "type": "string",
          "minLength": 1
        },
        "proposal_ref": {
          "$ref": "#/$defs/Ref"
        },
        "actor_ref": {
          "$ref": "#/$defs/Ref"
        },
        "delegation_ref": {
          "anyOf": [
            {
              "$ref": "#/$defs/Ref"
            },
            {
              "type": "null"
            }
          ]
        },
        "event_type": {
          "enum": [
            "offer",
            "counteroffer",
            "accept",
            "withdraw",
            "argument"
          ]
        },
        "terms_ref": {
          "anyOf": [
            {
              "$ref": "#/$defs/Ref"
            },
            {
              "type": "null"
            }
          ]
        },
        "public_reason": {
          "type": "string",
          "minLength": 1
        },
        "occurred_at": {
          "$ref": "#/$defs/Time"
        }
      },
      "required": [
        "kind",
        "id",
        "revision",
        "data_class",
        "source_refs",
        "realm_id",
        "proposal_ref",
        "actor_ref",
        "delegation_ref",
        "event_type",
        "terms_ref",
        "public_reason",
        "occurred_at"
      ],
      "additionalProperties": false
    },
    "Decision": {
      "type": "object",
      "properties": {
        "kind": {
          "const": "Decision"
        },
        "id": {
          "type": "string",
          "minLength": 1
        },
        "revision": {
          "type": "integer",
          "minimum": 1
        },
        "data_class": {
          "enum": [
            "synthetic",
            "operational"
          ]
        },
        "source_refs": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          },
          "minItems": 1
        },
        "realm_id": {
          "type": "string",
          "minLength": 1
        },
        "proposal_ref": {
          "$ref": "#/$defs/Ref"
        },
        "proposal_hash": {
          "$ref": "#/$defs/Hash"
        },
        "payload_hash": {
          "$ref": "#/$defs/Hash"
        },
        "policy_ref": {
          "$ref": "#/$defs/Ref"
        },
        "eligibility_ref": {
          "$ref": "#/$defs/Ref"
        },
        "rule_ref": {
          "$ref": "#/$defs/Ref"
        },
        "result": {
          "enum": [
            "adopted",
            "rejected",
            "blocked"
          ]
        },
        "evidence_refs": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/Ref"
          },
          "minItems": 1
        },
        "decided_at": {
          "$ref": "#/$defs/Time"
        },
        "executable_after": {
          "anyOf": [
            {
              "$ref": "#/$defs/Time"
            },
            {
              "type": "null"
            }
          ]
        },
        "challenge_status": {
          "enum": [
            "none",
            "open",
            "resolved"
          ]
        },
        "challenge_refs": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/Ref"
          },
          "minItems": 0
        },
        "reason": {
          "type": "string",
          "minLength": 1
        }
      },
      "required": [
        "kind",
        "id",
        "revision",
        "data_class",
        "source_refs",
        "realm_id",
        "proposal_ref",
        "proposal_hash",
        "payload_hash",
        "policy_ref",
        "eligibility_ref",
        "rule_ref",
        "result",
        "evidence_refs",
        "decided_at",
        "executable_after",
        "challenge_status",
        "challenge_refs",
        "reason"
      ],
      "additionalProperties": false
    },
    "Mandate": {
      "type": "object",
      "properties": {
        "kind": {
          "const": "Mandate"
        },
        "id": {
          "type": "string",
          "minLength": 1
        },
        "revision": {
          "type": "integer",
          "minimum": 1
        },
        "data_class": {
          "enum": [
            "synthetic",
            "operational"
          ]
        },
        "source_refs": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          },
          "minItems": 1
        },
        "realm_id": {
          "type": "string",
          "minLength": 1
        },
        "grantor_ref": {
          "$ref": "#/$defs/Ref"
        },
        "grantee_ref": {
          "$ref": "#/$defs/Ref"
        },
        "adoption_decision_ref": {
          "$ref": "#/$defs/Ref"
        },
        "policy_ref": {
          "$ref": "#/$defs/Ref"
        },
        "purpose": {
          "type": "string",
          "minLength": 1
        },
        "scope_refs": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/Ref"
          },
          "minItems": 1
        },
        "allowed_effects": {
          "type": "array",
          "items": {
            "enum": [
              "distribution",
              "appointment",
              "membership",
              "budget",
              "work-authorization",
              "initiative",
              "agent",
              "resource-allocation",
              "partnership",
              "policy",
              "governance-rule",
              "treasury-management",
              "official-action",
              "organizational-change"
            ]
          },
          "minItems": 1
        },
        "tool_grant_refs": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/Ref"
          },
          "minItems": 0
        },
        "budget_ref": {
          "anyOf": [
            {
              "$ref": "#/$defs/Ref"
            },
            {
              "type": "null"
            }
          ]
        },
        "per_action_limit": {
          "anyOf": [
            {
              "$ref": "#/$defs/Money"
            },
            {
              "type": "null"
            }
          ]
        },
        "total_limit": {
          "anyOf": [
            {
              "$ref": "#/$defs/Money"
            },
            {
              "type": "null"
            }
          ]
        },
        "starts_at": {
          "$ref": "#/$defs/Time"
        },
        "expires_at": {
          "$ref": "#/$defs/Time"
        },
        "revoked_at": {
          "anyOf": [
            {
              "$ref": "#/$defs/Time"
            },
            {
              "type": "null"
            }
          ]
        },
        "allow_subdelegation": {
          "type": "boolean"
        },
        "conditions_ref": {
          "$ref": "#/$defs/Ref"
        },
        "status": {
          "enum": [
            "draft",
            "active",
            "revoked",
            "expired"
          ]
        }
      },
      "required": [
        "kind",
        "id",
        "revision",
        "data_class",
        "source_refs",
        "realm_id",
        "grantor_ref",
        "grantee_ref",
        "adoption_decision_ref",
        "policy_ref",
        "purpose",
        "scope_refs",
        "allowed_effects",
        "tool_grant_refs",
        "budget_ref",
        "per_action_limit",
        "total_limit",
        "starts_at",
        "expires_at",
        "revoked_at",
        "allow_subdelegation",
        "conditions_ref",
        "status"
      ],
      "additionalProperties": false
    },
    "ExecutionIntent": {
      "type": "object",
      "properties": {
        "kind": {
          "const": "ExecutionIntent"
        },
        "id": {
          "type": "string",
          "minLength": 1
        },
        "revision": {
          "type": "integer",
          "minimum": 1
        },
        "data_class": {
          "enum": [
            "synthetic",
            "operational"
          ]
        },
        "source_refs": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          },
          "minItems": 1
        },
        "realm_id": {
          "type": "string",
          "minLength": 1
        },
        "proposal_ref": {
          "$ref": "#/$defs/Ref"
        },
        "decision_ref": {
          "$ref": "#/$defs/Ref"
        },
        "payload_hash": {
          "$ref": "#/$defs/Hash"
        },
        "policy_ref": {
          "$ref": "#/$defs/Ref"
        },
        "mandate_ref": {
          "anyOf": [
            {
              "$ref": "#/$defs/Ref"
            },
            {
              "type": "null"
            }
          ]
        },
        "adapter": {
          "type": "string",
          "minLength": 1
        },
        "idempotency_key": {
          "type": "string",
          "minLength": 1
        },
        "expires_at": {
          "$ref": "#/$defs/Time"
        },
        "status": {
          "enum": [
            "prepared",
            "blocked",
            "submitted",
            "unknown",
            "succeeded",
            "failed"
          ]
        },
        "preflight_ref": {
          "$ref": "#/$defs/Ref"
        }
      },
      "required": [
        "kind",
        "id",
        "revision",
        "data_class",
        "source_refs",
        "realm_id",
        "proposal_ref",
        "decision_ref",
        "payload_hash",
        "policy_ref",
        "mandate_ref",
        "adapter",
        "idempotency_key",
        "expires_at",
        "status",
        "preflight_ref"
      ],
      "additionalProperties": false
    },
    "ActionReceipt": {
      "type": "object",
      "properties": {
        "kind": {
          "const": "ActionReceipt"
        },
        "id": {
          "type": "string",
          "minLength": 1
        },
        "revision": {
          "type": "integer",
          "minimum": 1
        },
        "data_class": {
          "enum": [
            "synthetic",
            "operational"
          ]
        },
        "source_refs": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          },
          "minItems": 1
        },
        "realm_id": {
          "type": "string",
          "minLength": 1
        },
        "intent_ref": {
          "$ref": "#/$defs/Ref"
        },
        "payload_hash": {
          "$ref": "#/$defs/Hash"
        },
        "idempotency_key": {
          "type": "string",
          "minLength": 1
        },
        "result": {
          "enum": [
            "succeeded",
            "failed",
            "unknown",
            "external-action-required"
          ]
        },
        "provider_ref": {
          "anyOf": [
            {
              "type": "string",
              "minLength": 1
            },
            {
              "type": "null"
            }
          ]
        },
        "evidence_refs": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/Ref"
          },
          "minItems": 0
        },
        "occurred_at": {
          "$ref": "#/$defs/Time"
        },
        "reason": {
          "type": "string",
          "minLength": 1
        }
      },
      "required": [
        "kind",
        "id",
        "revision",
        "data_class",
        "source_refs",
        "realm_id",
        "intent_ref",
        "payload_hash",
        "idempotency_key",
        "result",
        "provider_ref",
        "evidence_refs",
        "occurred_at",
        "reason"
      ],
      "additionalProperties": false
    },
    "GovernanceBinding": {
      "type": "object",
      "properties": {
        "kind": {
          "const": "GovernanceBinding"
        },
        "id": {
          "type": "string",
          "minLength": 1
        },
        "revision": {
          "type": "integer",
          "minimum": 1
        },
        "data_class": {
          "enum": [
            "synthetic",
            "operational"
          ]
        },
        "source_refs": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          },
          "minItems": 1
        },
        "duna_id": {
          "type": "string",
          "minLength": 1
        },
        "realm_id": {
          "anyOf": [
            {
              "type": "string",
              "minLength": 1
            },
            {
              "type": "null"
            }
          ]
        },
        "governance_policy_ref": {
          "anyOf": [
            {
              "$ref": "#/$defs/Ref"
            },
            {
              "type": "null"
            }
          ]
        },
        "membership_policy_ref": {
          "anyOf": [
            {
              "$ref": "#/$defs/Ref"
            },
            {
              "type": "null"
            }
          ]
        },
        "treasury_policy_ref": {
          "anyOf": [
            {
              "$ref": "#/$defs/Ref"
            },
            {
              "type": "null"
            }
          ]
        },
        "proposal_process_ref": {
          "anyOf": [
            {
              "$ref": "#/$defs/Ref"
            },
            {
              "type": "null"
            }
          ]
        },
        "adoption_state": {
          "enum": [
            "not-captured",
            "proposed",
            "adopted"
          ]
        },
        "adoption_evidence_refs": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/Ref"
          },
          "minItems": 0
        }
      },
      "required": [
        "kind",
        "id",
        "revision",
        "data_class",
        "source_refs",
        "duna_id",
        "realm_id",
        "governance_policy_ref",
        "membership_policy_ref",
        "treasury_policy_ref",
        "proposal_process_ref",
        "adoption_state",
        "adoption_evidence_refs"
      ],
      "additionalProperties": false
    }
  }
}
