{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "urn:awoooi:agent-market-discovery-classification-v1",
  "title": "AWOOOI Agent Market Discovery Classification (v1)",
  "type": "object",
  "required": [
    "schema_version",
    "generated_at",
    "inputs",
    "policy",
    "summary",
    "candidates"
  ],
  "properties": {
    "schema_version": {
      "type": "string",
      "const": "agent_market_discovery_classification_v1"
    },
    "generated_at": {
      "type": "string",
      "minLength": 1
    },
    "inputs": {
      "type": "object",
      "required": ["discovery_review_generated_at", "metadata_source"],
      "properties": {
        "discovery_review_generated_at": {"type": ["string", "null"]},
        "metadata_source": {"type": "string"}
      },
      "additionalProperties": true
    },
    "policy": {
      "type": "object",
      "required": [
        "auto_watch_registry_addition_approved",
        "sdk_installation_approved",
        "paid_api_calls_approved",
        "production_changes_approved",
        "shadow_or_canary_approved",
        "replacement_decision_allowed",
        "raw_external_pages_committed"
      ],
      "properties": {
        "auto_watch_registry_addition_approved": {"type": "boolean", "const": false},
        "sdk_installation_approved": {"type": "boolean", "const": false},
        "paid_api_calls_approved": {"type": "boolean", "const": false},
        "production_changes_approved": {"type": "boolean", "const": false},
        "shadow_or_canary_approved": {"type": "boolean", "const": false},
        "replacement_decision_allowed": {"type": "boolean", "const": false},
        "raw_external_pages_committed": {"type": "boolean", "const": false}
      },
      "additionalProperties": true
    },
    "summary": {
      "type": "object",
      "required": [
        "classified_repositories",
        "recommended_watch_additions",
        "watch_only_or_defer",
        "classification_counts",
        "recommendation_counts",
        "production_changes_approved",
        "shadow_or_canary_approved"
      ],
      "properties": {
        "classified_repositories": {"type": "integer", "minimum": 0},
        "recommended_watch_additions": {"type": "integer", "minimum": 0},
        "watch_only_or_defer": {"type": "integer", "minimum": 0},
        "classification_counts": {"type": "object", "additionalProperties": {"type": "integer"}},
        "recommendation_counts": {"type": "object", "additionalProperties": {"type": "integer"}},
        "production_changes_approved": {"type": "integer", "const": 0},
        "shadow_or_canary_approved": {"type": "integer", "const": 0}
      },
      "additionalProperties": true
    },
    "candidates": {
      "type": "array",
      "items": {"$ref": "#/$defs/classified_candidate"}
    }
  },
  "$defs": {
    "classified_candidate": {
      "type": "object",
      "required": [
        "repository_full_name",
        "html_url",
        "description",
        "topics",
        "classification",
        "recommended_role",
        "recommendation",
        "watch_addition_recommended",
        "risk_flags",
        "approval_boundary",
        "required_next_gate"
      ],
      "properties": {
        "repository_full_name": {"type": "string", "minLength": 1},
        "html_url": {"type": "string"},
        "homepage": {"type": ["string", "null"]},
        "description": {"type": ["string", "null"]},
        "topics": {
          "type": "array",
          "items": {"type": "string"}
        },
        "language": {"type": ["string", "null"]},
        "stargazers_count": {"type": "integer", "minimum": 0},
        "pushed_at": {"type": ["string", "null"]},
        "archived": {"type": "boolean"},
        "classification": {"type": "string"},
        "recommended_role": {"type": "string"},
        "recommendation": {"type": "string"},
        "watch_addition_recommended": {"type": "boolean"},
        "risk_flags": {
          "type": "array",
          "items": {"type": "string"}
        },
        "approval_boundary": {
          "type": "object",
          "required": [
            "approved_for_watch_registry_addition",
            "approved_for_sdk_install",
            "approved_for_paid_api_calls",
            "approved_for_replay",
            "approved_for_shadow_or_canary"
          ],
          "properties": {
            "approved_for_watch_registry_addition": {"type": "boolean", "const": false},
            "approved_for_sdk_install": {"type": "boolean", "const": false},
            "approved_for_paid_api_calls": {"type": "boolean", "const": false},
            "approved_for_replay": {"type": "boolean", "const": false},
            "approved_for_shadow_or_canary": {"type": "boolean", "const": false}
          },
          "additionalProperties": true
        },
        "required_next_gate": {"type": "string"}
      },
      "additionalProperties": true
    }
  },
  "additionalProperties": false
}
