{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://rodgui.github.io/ai-agent-governance-framework/schemas/certified-source-catalog.schema.json",
  "title": "Certified Source Catalog",
  "description": "Fontes de dados e conhecimento certificadas com ownership, finalidade, restrições, evidências e validade.",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schemaVersion",
    "catalogVersion",
    "title",
    "owner",
    "lastReviewed",
    "entries"
  ],
  "properties": {
    "schemaVersion": {
      "const": "1.0"
    },
    "catalogVersion": {
      "type": "string",
      "pattern": "^[0-9]+\\.[0-9]+(?:\\.[0-9]+)?$"
    },
    "title": {
      "type": "string",
      "minLength": 3
    },
    "owner": {
      "type": "string",
      "minLength": 3
    },
    "lastReviewed": {
      "type": "string",
      "format": "date"
    },
    "entries": {
      "type": "array",
      "minItems": 1,
      "items": {
        "$ref": "#/$defs/entry"
      }
    }
  },
  "$defs": {
    "entry": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "id",
        "name",
        "owner",
        "systemOfRecord",
        "classification",
        "status",
        "purposes",
        "allowedRiskTiers",
        "allowedRegions",
        "connectorPattern",
        "authorizationMode",
        "retention",
        "certificationEvidenceRefs",
        "reviewedAt",
        "expiresAt",
        "restrictions"
      ],
      "properties": {
        "id": {
          "type": "string",
          "pattern": "^SRC-[A-Z0-9-]{3,80}$"
        },
        "name": {
          "type": "string",
          "minLength": 3
        },
        "owner": {
          "type": "string",
          "minLength": 3
        },
        "systemOfRecord": {
          "type": "string",
          "minLength": 3
        },
        "classification": {
          "enum": [
            "public",
            "internal",
            "confidential",
            "restricted",
            "regulated"
          ]
        },
        "status": {
          "enum": [
            "certified",
            "conditional",
            "not-ready",
            "retired"
          ]
        },
        "purposes": {
          "type": "array",
          "minItems": 1,
          "uniqueItems": true,
          "items": {
            "type": "string",
            "minLength": 10
          }
        },
        "allowedRiskTiers": {
          "type": "array",
          "minItems": 1,
          "uniqueItems": true,
          "items": {
            "enum": [
              "T1",
              "T2",
              "T3",
              "T4"
            ]
          }
        },
        "allowedRegions": {
          "type": "array",
          "minItems": 1,
          "uniqueItems": true,
          "items": {
            "type": "string",
            "minLength": 2
          }
        },
        "connectorPattern": {
          "type": "string",
          "minLength": 3
        },
        "authorizationMode": {
          "enum": [
            "pre-retrieval",
            "source-enforced",
            "post-retrieval",
            "none"
          ]
        },
        "retention": {
          "type": "string",
          "minLength": 3
        },
        "certificationEvidenceRefs": {
          "type": "array",
          "minItems": 1,
          "uniqueItems": true,
          "items": {
            "type": "string",
            "minLength": 3
          }
        },
        "conditionRefs": {
          "type": "array",
          "minItems": 1,
          "uniqueItems": true,
          "items": {
            "type": "string",
            "minLength": 3
          }
        },
        "reviewedAt": {
          "type": "string",
          "format": "date"
        },
        "expiresAt": {
          "type": "string",
          "format": "date"
        },
        "restrictions": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 3
          }
        }
      },
      "allOf": [
        {
          "if": {
            "properties": {
              "status": {
                "const": "conditional"
              }
            },
            "required": [
              "status"
            ]
          },
          "then": {
            "required": [
              "conditionRefs"
            ]
          }
        }
      ]
    }
  }
}
