{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "urn:awoooi:agent-market-discovery-review-v1",
  "title": "AWOOOI Agent Market Discovery Review (v1)",
  "type": "object",
  "required": [
    "schema_version",
    "generated_at",
    "inputs",
    "policy",
    "summary",
    "candidate_drafts"
  ],
  "properties": {
    "schema_version": {
      "type": "string",
      "const": "agent_market_discovery_review_v1"
    },
    "generated_at": {
      "type": "string",
      "minLength": 1
    },
    "inputs": {
      "type": "object",
      "required": [
        "watch_report_generated_at",
        "watch_report_mode",
        "candidate_registry_schema_version",
        "source_registry_schema_version"
      ],
      "properties": {
        "watch_report_generated_at": {"type": ["string", "null"]},
        "watch_report_mode": {"type": ["string", "null"]},
        "candidate_registry_schema_version": {"type": "string"},
        "source_registry_schema_version": {"type": "string"},
        "previous_review_generated_at": {"type": ["string", "null"]}
      },
      "additionalProperties": true
    },
    "policy": {
      "type": "object",
      "required": [
        "auto_registry_addition_approved",
        "sdk_installation_approved",
        "paid_api_calls_approved",
        "production_changes_approved",
        "shadow_or_canary_approved",
        "replacement_decision_allowed"
      ],
      "properties": {
        "auto_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}
      },
      "additionalProperties": true
    },
    "summary": {
      "type": "object",
      "required": [
        "discovery_sources",
        "discovered_items",
        "unique_repositories",
        "already_watched_or_registered",
        "manual_classification_required",
        "new_manual_classification_required",
        "source_failures",
        "auto_registry_additions_approved",
        "production_changes_approved",
        "shadow_or_canary_approved"
      ],
      "properties": {
        "discovery_sources": {"type": "integer", "minimum": 0},
        "discovered_items": {"type": "integer", "minimum": 0},
        "unique_repositories": {"type": "integer", "minimum": 0},
        "already_watched_or_registered": {"type": "integer", "minimum": 0},
        "manual_classification_required": {"type": "integer", "minimum": 0},
        "new_manual_classification_required": {"type": "integer", "minimum": 0},
        "source_failures": {"type": "integer", "minimum": 0},
        "auto_registry_additions_approved": {"type": "integer", "const": 0},
        "production_changes_approved": {"type": "integer", "const": 0},
        "shadow_or_canary_approved": {"type": "integer", "const": 0}
      },
      "additionalProperties": true
    },
    "candidate_drafts": {
      "type": "array",
      "items": {"$ref": "#/$defs/candidate_draft"}
    }
  },
  "$defs": {
    "candidate_draft": {
      "type": "object",
      "required": [
        "repository_full_name",
        "html_url",
        "source_ids",
        "stargazers_count_max",
        "updated_at_latest",
        "status",
        "seen_before",
        "new_since_previous_review",
        "decision",
        "recommended_next_gate",
        "approval_boundary",
        "recommended_actions"
      ],
      "properties": {
        "repository_full_name": {"type": "string", "minLength": 1},
        "html_url": {"type": "string"},
        "source_ids": {
          "type": "array",
          "items": {"type": "string"}
        },
        "stargazers_count_max": {"type": "integer", "minimum": 0},
        "updated_at_latest": {"type": ["string", "null"]},
        "status": {
          "type": "string",
          "enum": [
            "already_watched_or_registered",
            "needs_primary_source_classification"
          ]
        },
        "seen_before": {"type": "boolean"},
        "new_since_previous_review": {"type": "boolean"},
        "decision": {"type": "string"},
        "recommended_next_gate": {"type": "string"},
        "approval_boundary": {
          "type": "object",
          "required": [
            "approved_for_registry_addition",
            "approved_for_sdk_install",
            "approved_for_paid_api_calls",
            "approved_for_shadow_or_canary"
          ],
          "properties": {
            "approved_for_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_shadow_or_canary": {"type": "boolean", "const": false}
          },
          "additionalProperties": true
        },
        "recommended_actions": {
          "type": "array",
          "items": {"type": "string"}
        }
      },
      "additionalProperties": true
    }
  },
  "additionalProperties": false
}
