{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://tiergauge.com/api/scrape-runs.schema.json",
  "title": "TierGauge scrape-runs feed",
  "description": "Schema for /api/scrape-runs.json. One row per tracked tool, surfacing the most-recent scrape-attempt event (run_at, outcome, plans_found, warnings, error) plus cumulative attempt count. Pairs with freshness.json (verified-data staleness) and coverage.json (missing alternatives) to give external monitors three independent data-health signals.",
  "type": "object",
  "required": [
    "feed_version",
    "generated_at",
    "site",
    "license",
    "tools_tracked",
    "tools_with_runs",
    "total_warnings_last_run",
    "last_run_outcome_counts",
    "orphan_run_files",
    "runs"
  ],
  "properties": {
    "$schema": { "type": "string", "format": "uri" },
    "feed_version": { "type": "string" },
    "generated_at": { "type": "string", "format": "date-time" },
    "site": { "type": "string", "format": "uri" },
    "license": { "type": "string" },
    "tools_tracked": { "type": "integer", "minimum": 0 },
    "tools_with_runs": { "type": "integer", "minimum": 0 },
    "total_warnings_last_run": { "type": "integer", "minimum": 0 },
    "last_run_outcome_counts": {
      "type": "object",
      "additionalProperties": { "type": "integer", "minimum": 0 }
    },
    "orphan_run_files": { "type": "integer", "minimum": 0 },
    "runs": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["slug", "name", "attempts", "latest"],
        "properties": {
          "slug": { "type": "string", "minLength": 1 },
          "name": { "type": "string", "minLength": 1 },
          "attempts": { "type": "integer", "minimum": 0 },
          "latest": {
            "oneOf": [
              { "type": "null" },
              {
                "type": "object",
                "required": ["run_at", "tool_slug", "outcome"],
                "properties": {
                  "run_at": { "type": "string", "format": "date-time" },
                  "tool_slug": { "type": "string", "minLength": 1 },
                  "outcome": {
                    "type": "string",
                    "enum": [
                      "ok",
                      "stale-preserved",
                      "no-extractor",
                      "no-tool-json",
                      "extractor-threw",
                      "validation-failed"
                    ]
                  },
                  "plans_found": { "type": "integer", "minimum": 0 },
                  "warnings": {
                    "type": "array",
                    "items": { "type": "string" }
                  },
                  "error": { "type": "string" }
                }
              }
            ]
          }
        }
      }
    }
  }
}
