{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://hormuz.meme/schemas/integration-guild.schema.json",
  "title": "HORMUZ integration guild registry",
  "type": "object",
  "additionalProperties": false,
  "required": ["schemaVersion", "documentType", "subject", "reviewedAt", "policy", "items"],
  "properties": {
    "schemaVersion": { "const": 1 },
    "documentType": { "const": "integration_guild" },
    "subject": { "const": "eip155:8453/erc20:0xf912a4A0c374a33f192d0657719cE107194573F1" },
    "reviewedAt": { "type": "string", "format": "date-time" },
    "policy": { "$ref": "#/$defs/policy" },
    "items": {
      "type": "array", "minItems": 7, "maxItems": 7, "uniqueItems": true,
      "items": { "$ref": "#/$defs/item" },
      "allOf": [
        { "contains": { "type": "object", "properties": { "id": { "const": "farcaster-mini-app" } }, "required": ["id"] } },
        { "contains": { "type": "object", "properties": { "id": { "const": "base-ecosystem" } }, "required": ["id"] } },
        { "contains": { "type": "object", "properties": { "id": { "const": "basescan-token-metadata" } }, "required": ["id"] } },
        { "contains": { "type": "object", "properties": { "id": { "const": "dex-screener" } }, "required": ["id"] } },
        { "contains": { "type": "object", "properties": { "id": { "const": "coingecko" } }, "required": ["id"] } },
        { "contains": { "type": "object", "properties": { "id": { "const": "coinmarketcap" } }, "required": ["id"] } },
        { "contains": { "type": "object", "properties": { "id": { "const": "upstream-caip-passport-consumer" } }, "required": ["id"] } }
      ]
    }
  },
  "$defs": {
    "policy": {
      "type": "object", "additionalProperties": false,
      "required": ["statusSemantics", "financialRewards", "apiDisclaimer"],
      "properties": {
        "statusSemantics": { "const": "availability_submission_review_and_approval_are_independent" },
        "financialRewards": { "const": "none_promised" },
        "apiDisclaimer": { "const": "API observation only; not an approval, endorsement, application, trade, or evidence of liquidity quality." }
      }
    },
    "asset": {
      "type": "object", "additionalProperties": false,
      "required": ["chain", "chainId", "symbol", "caip19"],
      "properties": {
        "chain": { "const": "Base" }, "chainId": { "const": 8453 }, "symbol": { "const": "HORMUZ" },
        "caip19": { "const": "eip155:8453/erc20:0xf912a4A0c374a33f192d0657719cE107194573F1" }
      }
    },
    "axes": {
      "type": "object", "additionalProperties": false,
      "required": ["availability", "submission", "review", "approval"],
      "properties": {
        "availability": { "enum": ["available", "api_observed", "api_not_observed", "implementation_ready", "blocked", "unknown"] },
        "submission": { "enum": ["not_applicable", "not_submitted", "manual_action_required", "submitted"] },
        "review": { "enum": ["not_applicable", "not_started", "pending", "unknown", "blocked"] },
        "approval": { "enum": ["not_applicable", "not_approved", "approved"] }
      }
    },
    "evidence": {
      "type": "object", "additionalProperties": false, "required": ["label", "url"],
      "properties": { "label": { "type": "string", "minLength": 1, "maxLength": 80 }, "url": { "type": "string", "format": "uri", "pattern": "^https://" } }
    },
    "ownerAction": {
      "type": "object", "additionalProperties": false, "required": ["label", "url"],
      "properties": { "label": { "type": "string", "minLength": 1, "maxLength": 120 }, "url": { "type": "string", "format": "uri", "pattern": "^https://" } }
    },
    "observationRef": {
      "type": "object", "additionalProperties": false,
      "required": ["id", "kind", "platform", "stateAxis", "expectedState"],
      "properties": {
        "id": { "type": "string", "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$" },
        "kind": { "enum": ["market", "listing", "listing_group"] },
        "platform": { "type": "string", "minLength": 1 },
        "stateAxis": { "enum": ["availability", "submission", "review", "approval"] },
        "expectedState": { "enum": ["available", "api_observed", "api_not_observed", "implementation_ready", "blocked", "unknown", "not_applicable", "not_submitted", "manual_action_required", "submitted", "not_started", "pending", "not_approved", "approved"] }
      },
      "allOf": [
        { "if": { "properties": { "stateAxis": { "const": "availability" } }, "required": ["stateAxis"] }, "then": { "properties": { "expectedState": { "enum": ["available", "api_observed", "api_not_observed", "implementation_ready", "blocked", "unknown"] } } } },
        { "if": { "properties": { "stateAxis": { "const": "submission" } }, "required": ["stateAxis"] }, "then": { "properties": { "expectedState": { "enum": ["not_applicable", "not_submitted", "manual_action_required", "submitted"] } } } },
        { "if": { "properties": { "stateAxis": { "const": "review" } }, "required": ["stateAxis"] }, "then": { "properties": { "expectedState": { "enum": ["not_applicable", "not_started", "pending", "unknown", "blocked"] } } } },
        { "if": { "properties": { "stateAxis": { "const": "approval" } }, "required": ["stateAxis"] }, "then": { "properties": { "expectedState": { "enum": ["not_applicable", "not_approved", "approved"] } } } }
      ]
    },
    "outcome": {
      "type": "object", "additionalProperties": false,
      "required": ["subject", "passportUrl", "requiredArtifact", "reviewRequired"],
      "properties": {
        "subject": { "const": "eip155:8453/erc20:0xf912a4A0c374a33f192d0657719cE107194573F1" },
        "passportUrl": { "const": "https://hormuz.meme/token-passport.json" },
        "requiredArtifact": { "const": "public_integration_consuming_caip_identity_and_passport" },
        "reviewRequired": { "const": true }
      }
    },
    "reward": {
      "type": "object", "additionalProperties": false, "required": ["kind", "promised", "statement"],
      "properties": { "kind": { "const": "none" }, "promised": { "const": false }, "statement": { "const": "No financial reward is offered or promised." } }
    },
    "contributor": {
      "type": "object", "additionalProperties": false, "required": ["status"],
      "properties": { "status": { "const": "unclaimed_until_reviewed" } }
    },
    "item": {
      "type": "object", "additionalProperties": false,
      "required": ["id", "type", "platform", "summary", "state", "axes", "asset", "submissionPerformed", "observationRefs", "evidence", "ownerAction"],
      "properties": {
        "id": { "type": "string", "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$" },
        "type": { "enum": ["platform", "upstream_integration"] },
        "platform": { "type": "string", "minLength": 1, "maxLength": 80 },
        "summary": { "type": "string", "minLength": 1, "maxLength": 280 },
        "state": { "enum": ["manual_action_required", "api_observed", "api_not_observed", "implementation_ready", "submitted", "blocked"] },
        "axes": { "$ref": "#/$defs/axes" }, "asset": { "$ref": "#/$defs/asset" },
        "submissionPerformed": { "type": "boolean" },
        "observationRefs": { "type": "array", "uniqueItems": true, "items": { "$ref": "#/$defs/observationRef" } },
        "evidence": { "type": "array", "uniqueItems": true, "items": { "$ref": "#/$defs/evidence" } },
        "ownerAction": { "$ref": "#/$defs/ownerAction" }, "outcome": { "$ref": "#/$defs/outcome" },
        "reward": { "$ref": "#/$defs/reward" }, "contributor": { "$ref": "#/$defs/contributor" },
        "prohibitedActivity": { "type": "array", "minItems": 6, "maxItems": 6, "uniqueItems": true, "items": { "enum": ["applications", "votes", "volume", "trading", "social_activity", "unverifiable_claims"] } }
      },
      "allOf": [
        {
          "if": { "properties": { "type": { "const": "upstream_integration" } }, "required": ["type"] },
          "then": { "type": "object", "properties": { "outcome": true, "reward": true, "contributor": true, "prohibitedActivity": true }, "required": ["outcome", "reward", "contributor", "prohibitedActivity"] },
          "else": { "not": { "anyOf": [
            { "type": "object", "properties": { "outcome": true }, "required": ["outcome"] },
            { "type": "object", "properties": { "reward": true }, "required": ["reward"] },
            { "type": "object", "properties": { "contributor": true }, "required": ["contributor"] },
            { "type": "object", "properties": { "prohibitedActivity": true }, "required": ["prohibitedActivity"] }
          ] } }
        },
        {
          "if": { "type": "object", "properties": { "state": { "const": "api_observed" } }, "required": ["state"] },
          "then": { "type": "object", "properties": { "axes": { "type": "object", "properties": { "availability": { "const": "api_observed" } } }, "evidence": { "type": "array", "minItems": 1 } } }
        },
        {
          "if": { "type": "object", "properties": { "state": { "const": "api_not_observed" } }, "required": ["state"] },
          "then": { "type": "object", "properties": { "axes": { "type": "object", "properties": { "availability": { "const": "api_not_observed" } } } } }
        },
        {
          "if": { "type": "object", "properties": { "state": { "const": "implementation_ready" } }, "required": ["state"] },
          "then": { "type": "object", "properties": { "axes": { "type": "object", "properties": { "availability": { "const": "implementation_ready" } } }, "evidence": { "type": "array", "minItems": 1 } } }
        },
        {
          "if": { "type": "object", "properties": { "state": { "const": "manual_action_required" } }, "required": ["state"] },
          "then": { "type": "object", "properties": { "axes": { "type": "object", "properties": { "submission": { "const": "manual_action_required" } } } } }
        },
        {
          "if": { "type": "object", "properties": { "state": { "const": "submitted" } }, "required": ["state"] },
          "then": { "type": "object", "properties": { "axes": { "type": "object", "properties": { "submission": { "const": "submitted" } } }, "submissionPerformed": { "const": true }, "evidence": { "type": "array", "minItems": 1 } } }
        },
        {
          "if": { "type": "object", "properties": { "state": { "const": "blocked" } }, "required": ["state"] },
          "then": { "type": "object", "properties": { "axes": { "type": "object", "anyOf": [{ "properties": { "availability": { "const": "blocked" } } }, { "properties": { "review": { "const": "blocked" } } }] } } }
        },
        {
          "if": { "type": "object", "properties": { "axes": { "type": "object", "properties": { "approval": { "const": "approved" } }, "required": ["approval"] } }, "required": ["axes"] },
          "then": { "type": "object", "properties": { "axes": { "type": "object", "properties": { "submission": { "const": "submitted" } } } } }
        },
        {
          "if": { "type": "object", "properties": { "axes": { "type": "object", "properties": { "submission": { "const": "submitted" } }, "required": ["submission"] } }, "required": ["axes"] },
          "then": { "type": "object", "properties": { "submissionPerformed": { "const": true } } },
          "else": { "type": "object", "properties": { "submissionPerformed": { "const": false } } }
        },
        {
          "if": { "type": "object", "properties": { "axes": { "type": "object", "properties": { "review": { "const": "pending" } }, "required": ["review"] } }, "required": ["axes"] },
          "then": { "type": "object", "properties": { "axes": { "type": "object", "properties": { "submission": { "const": "submitted" } } } } }
        },
        {
          "if": { "type": "object", "properties": { "axes": { "type": "object", "properties": { "availability": { "enum": ["api_observed", "api_not_observed"] } }, "required": ["availability"] } }, "required": ["axes"] },
          "then": { "type": "object", "properties": { "observationRefs": { "type": "array", "minItems": 1 } } }
        }
      ]
    }
  }
}
