{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "vaultfire://v3-operations/selector-policy.schema.json",
  "title": "Vaultfire V3 governance selector policy",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schemaVersion",
    "defaultAction",
    "sourceAuthorities",
    "missionBoundaryClasses",
    "allowlist",
    "denylist",
    "prohibitedInputClasses"
  ],
  "properties": {
    "schemaVersion": {"const": "1.0.0"},
    "defaultAction": {"const": "deny"},
    "sourceAuthorities": {"type": "object"},
    "missionBoundaryClasses": {"type": "array", "minItems": 4},
    "allowlist": {
      "type": "array",
      "items": {"$ref": "#/$defs/selectorRule"},
      "uniqueItems": true
    },
    "denylist": {
      "type": "array",
      "items": {"$ref": "#/$defs/denyRule"},
      "minItems": 5
    },
    "prohibitedInputClasses": {
      "type": "array",
      "items": {"enum": ["belief", "flourishing", "reputation", "trust-score", "behavioral-routing"]},
      "minItems": 5,
      "uniqueItems": true
    }
  },
  "$defs": {
    "selectorRule": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "id",
        "targetModule",
        "signature",
        "selector",
        "maxCalldataBytes",
        "maxValueWei",
        "missionBoundaryClass",
        "requiredAuthority",
        "timelockSecondsMinimum"
      ],
      "properties": {
        "id": {"type": "string"},
        "targetModule": {"type": "string"},
        "signature": {"type": "string"},
        "selector": {"type": "string", "pattern": "^0x[0-9a-f]{8}$"},
        "maxCalldataBytes": {"type": "integer", "minimum": 4, "maximum": 24576},
        "maxValueWei": {"type": "string", "pattern": "^[0-9]+$"},
        "missionBoundaryClass": {"type": "string"},
        "requiredAuthority": {"enum": ["governance-threshold-timelock"]},
        "timelockSecondsMinimum": {"type": "integer", "minimum": 86400},
        "argumentConstraints": {"type": "array", "items": {"type": "string"}}
      }
    },
    "denyRule": {
      "type": "object",
      "additionalProperties": false,
      "required": ["id", "match", "reason"],
      "properties": {
        "id": {"type": "string"},
        "match": {"type": "object"},
        "reason": {"type": "string", "minLength": 1}
      }
    }
  }
}
