{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "urn:awoooi:agent-market-watch-report-v1",
  "title": "AWOOOI Agent Market Watch Report (v1)",
  "type": "object",
  "required": [
    "schema_version",
    "generated_at",
    "mode",
    "registry",
    "cadence",
    "policy",
    "summary",
    "candidates",
    "integration_queue",
    "failures"
  ],
  "properties": {
    "schema_version": {
      "type": "string",
      "const": "agent_market_watch_report_v1"
    },
    "generated_at": {
      "type": "string",
      "minLength": 1
    },
    "mode": {
      "type": "string",
      "enum": ["offline", "live"]
    },
    "registry": {
      "type": "object",
      "required": ["path", "schema_version"],
      "properties": {
        "path": {"type": "string"},
        "schema_version": {"type": "string"},
        "updated_at": {"type": "string"}
      },
      "additionalProperties": true
    },
    "cadence": {
      "type": "object",
      "required": ["weekly_market_watch", "monthly_integration_review", "trigger_on_major_version"],
      "properties": {
        "weekly_market_watch": {"type": "string"},
        "monthly_integration_review": {"type": "string"},
        "trigger_on_major_version": {"type": "boolean"}
      },
      "additionalProperties": true
    },
    "policy": {
      "type": "object",
      "required": [
        "replacement_decision_allowed",
        "integration_requires_replay",
        "paid_provider_requires_approval",
        "new_dependency_requires_approval"
      ],
      "properties": {
        "replacement_decision_allowed": {"type": "boolean"},
        "integration_requires_replay": {"type": "boolean"},
        "paid_provider_requires_approval": {"type": "boolean"},
        "new_dependency_requires_approval": {"type": "boolean"}
      },
      "additionalProperties": true
    },
    "summary": {
      "type": "object",
      "required": [
        "candidate_count",
        "source_count",
        "changed_candidates",
        "watch_only_candidates",
        "integration_queue_count",
        "failure_count"
      ],
      "properties": {
        "candidate_count": {"type": "integer", "minimum": 0},
        "source_count": {"type": "integer", "minimum": 0},
        "changed_candidates": {"type": "integer", "minimum": 0},
        "watch_only_candidates": {"type": "integer", "minimum": 0},
        "integration_queue_count": {"type": "integer", "minimum": 0},
        "failure_count": {"type": "integer", "minimum": 0}
      },
      "additionalProperties": true
    },
    "candidates": {
      "type": "array",
      "items": {"$ref": "#/$defs/candidate"}
    },
    "integration_queue": {
      "type": "array",
      "items": {"$ref": "#/$defs/integration_queue_item"}
    },
    "new_candidate_discovery": {
      "type": "array",
      "items": {"type": "object", "additionalProperties": true}
    },
    "failures": {
      "type": "array",
      "items": {"type": "string"}
    }
  },
  "$defs": {
    "candidate": {
      "type": "object",
      "required": [
        "candidate_id",
        "display_name",
        "evaluation_priority",
        "recommended_role",
        "sources",
        "changed",
        "decision",
        "recommended_actions"
      ],
      "properties": {
        "candidate_id": {"type": "string", "minLength": 1},
        "display_name": {"type": "string"},
        "evaluation_priority": {"type": "string"},
        "recommended_role": {"type": "string"},
        "sources": {
          "type": "array",
          "items": {"$ref": "#/$defs/source_result"}
        },
        "changed": {"type": "boolean"},
        "decision": {"type": "string"},
        "recommended_actions": {
          "type": "array",
          "items": {"type": "string"}
        }
      },
      "additionalProperties": true
    },
    "source_result": {
      "type": "object",
      "required": ["source_id", "type", "url", "status"],
      "properties": {
        "source_id": {"type": "string"},
        "type": {"type": "string"},
        "url": {"type": "string"},
        "status": {"type": "string"},
        "http_status": {"type": ["integer", "null"]},
        "version": {"type": ["string", "null"]},
        "published_at": {"type": ["string", "null"]},
        "content_hash": {"type": ["string", "null"]},
        "changed_since_reference": {"type": "boolean"},
        "reference_version": {"type": ["string", "null"]},
        "error": {"type": ["string", "null"]}
      },
      "additionalProperties": true
    },
    "integration_queue_item": {
      "type": "object",
      "required": ["candidate_id", "reason", "required_next_gate"],
      "properties": {
        "candidate_id": {"type": "string"},
        "reason": {"type": "string"},
        "required_next_gate": {"type": "string"},
        "requires_cost_approval": {"type": "boolean"},
        "requires_dependency_approval": {"type": "boolean"}
      },
      "additionalProperties": true
    }
  },
  "additionalProperties": false
}
