{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://go165.github.io/bounty-radar/feed/schema.json",
  "title": "Bounty Radar Feed",
  "type": "object",
  "required": ["generated_at", "source", "demo", "methodology", "count", "items"],
  "properties": {
    "generated_at": {
      "type": "string",
      "format": "date-time"
    },
    "source": {
      "type": "string",
      "format": "uri"
    },
    "demo": {
      "type": "string",
      "format": "uri"
    },
    "manifest": {
      "type": "string",
      "format": "uri"
    },
    "schema": {
      "type": "string",
      "format": "uri"
    },
    "methodology": {
      "type": "string"
    },
    "count": {
      "type": "integer",
      "minimum": 0
    },
    "items": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/item"
      }
    },
    "errors": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/feed_error"
      }
    }
  },
  "$defs": {
    "feed_error": {
      "type": "object",
      "required": ["preset", "status", "message"],
      "properties": {
        "preset": {
          "type": "string"
        },
        "status": {
          "type": "integer"
        },
        "message": {
          "type": "string"
        }
      }
    },
    "item": {
      "type": "object",
      "required": ["score", "raw_score", "risk_score", "opportunity_class", "effort_score", "effort_signals", "decision_notes", "risk_flags", "manual_friction", "preset", "preset_name", "repo", "title", "url", "updated_at", "labels", "signals", "addresses"],
      "properties": {
        "score": {
          "type": "number",
          "minimum": 0
        },
        "raw_score": {
          "type": "number",
          "minimum": 0
        },
        "risk_score": {
          "type": "number",
          "minimum": 0
        },
        "opportunity_class": {
          "type": "string",
          "enum": ["quick-win", "high-value", "rail-watch", "standard", "manual-review", "avoid"]
        },
        "effort_score": {
          "type": "number",
          "minimum": 0,
          "maximum": 100
        },
        "effort_signals": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "decision_notes": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "risk_flags": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/risk_flag"
          }
        },
        "manual_friction": {
          "type": "boolean"
        },
        "preset": {
          "type": "string"
        },
        "preset_name": {
          "type": "string"
        },
        "repo": {
          "type": "string",
          "pattern": "^[^/]+/[^/]+$"
        },
        "title": {
          "type": "string"
        },
        "url": {
          "type": "string",
          "format": "uri"
        },
        "updated_at": {
          "type": "string",
          "format": "date-time"
        },
        "labels": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "signals": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "addresses": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/address"
          }
        }
      }
    },
    "risk_flag": {
      "type": "object",
      "required": ["label", "severity", "penalty"],
      "properties": {
        "label": {
          "type": "string"
        },
        "severity": {
          "type": "string",
          "enum": ["blocker", "manual", "high"]
        },
        "penalty": {
          "type": "number",
          "minimum": 0
        }
      }
    },
    "address": {
      "type": "object",
      "required": ["type", "value"],
      "properties": {
        "type": {
          "type": "string",
          "enum": ["EVM", "Stellar", "MRWK"]
        },
        "value": {
          "type": "string"
        }
      }
    }
  }
}
