{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "urn:awoooi:agent-market-integration-review-v1",
  "title": "AWOOOI Agent Market Integration Review (v1)",
  "type": "object",
  "required": [
    "schema_version",
    "generated_at",
    "inputs",
    "policy",
    "summary",
    "reviews"
  ],
  "properties": {
    "schema_version": {
      "type": "string",
      "const": "agent_market_integration_review_v1"
    },
    "generated_at": {
      "type": "string",
      "minLength": 1
    },
    "inputs": {
      "type": "object",
      "required": ["watch_summary"],
      "properties": {
        "watch_report_generated_at": {"type": ["string", "null"]},
        "watch_report_mode": {"type": ["string", "null"]},
        "watch_summary": {"type": "object", "additionalProperties": true},
        "candidate_registry_schema_version": {"type": "string"},
        "scorecard_schema_version": {"type": "string"},
        "scorecard_scoring_version": {"type": "string"},
        "review_scope": {
          "type": "string",
          "enum": ["changed", "actionable", "all"]
        }
      },
      "additionalProperties": true
    },
    "policy": {
      "type": "object",
      "required": [
        "production_changes_approved",
        "replacement_decision_allowed",
        "sdk_installation_approved",
        "paid_api_calls_approved",
        "shadow_or_canary_approved",
        "raw_external_pages_committed"
      ],
      "properties": {
        "production_changes_approved": {"type": "boolean", "const": false},
        "replacement_decision_allowed": {"type": "boolean", "const": false},
        "sdk_installation_approved": {"type": "boolean", "const": false},
        "paid_api_calls_approved": {"type": "boolean", "const": false},
        "shadow_or_canary_approved": {"type": "boolean", "const": false},
        "raw_external_pages_committed": {"type": "boolean", "const": false}
      },
      "additionalProperties": true
    },
    "summary": {
      "type": "object",
      "required": [
        "reviewed_candidates",
        "blocked_from_integration",
        "requires_cost_approval",
        "requires_dependency_approval",
        "source_failures",
        "production_changes_approved",
        "shadow_or_canary_approved"
      ],
      "properties": {
        "reviewed_candidates": {"type": "integer", "minimum": 0},
        "blocked_from_integration": {"type": "integer", "minimum": 0},
        "requires_cost_approval": {"type": "integer", "minimum": 0},
        "requires_dependency_approval": {"type": "integer", "minimum": 0},
        "source_failures": {"type": "integer", "minimum": 0},
        "production_changes_approved": {"type": "integer", "const": 0},
        "shadow_or_canary_approved": {"type": "integer", "const": 0}
      },
      "additionalProperties": true
    },
    "reviews": {
      "type": "array",
      "items": {"$ref": "#/$defs/review"}
    }
  },
  "$defs": {
    "review": {
      "type": "object",
      "required": [
        "candidate_id",
        "display_name",
        "market_watch",
        "market_score",
        "registry_status",
        "approval_boundary",
        "readiness",
        "decision",
        "recommendations",
        "unblock_conditions"
      ],
      "properties": {
        "candidate_id": {"type": "string", "minLength": 1},
        "display_name": {"type": "string"},
        "market_watch": {"type": "object", "additionalProperties": true},
        "market_score": {"type": "object", "additionalProperties": true},
        "registry_status": {"type": "object", "additionalProperties": true},
        "approval_boundary": {
          "type": "object",
          "required": [
            "requires_cost_approval",
            "requires_dependency_approval",
            "approved_for_sdk_install",
            "approved_for_paid_api_calls",
            "approved_for_shadow_or_canary"
          ],
          "properties": {
            "requires_cost_approval": {"type": "boolean"},
            "requires_dependency_approval": {"type": "boolean"},
            "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
        },
        "readiness": {"type": "object", "additionalProperties": true},
        "decision": {"type": "string", "minLength": 1},
        "recommendations": {
          "type": "array",
          "items": {"type": "string"}
        },
        "unblock_conditions": {
          "type": "array",
          "items": {"type": "string"}
        }
      },
      "additionalProperties": true
    }
  },
  "additionalProperties": false
}
