{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://ai-fanout.com/contracts/example-observation.schema.v1.json",
  "title": "AI Fanout published example observations",
  "type": "object",
  "additionalProperties": false,
  "required": ["schemaVersion", "publishedAt", "provider", "model", "toolVersion", "methodVersion", "protocol", "observations", "notice"],
  "properties": {
    "schemaVersion": { "const": "ai-fanout.example-observations/1.0" },
    "publishedAt": { "type": "string", "format": "date" },
    "provider": { "const": "openai" },
    "model": { "type": "string", "minLength": 1 },
    "toolVersion": { "type": "string", "minLength": 1 },
    "methodVersion": { "type": "string", "minLength": 1 },
    "protocol": {
      "type": "object",
      "additionalProperties": false,
      "required": ["tool", "searchContextSize", "maxSearches", "maxOutputTokens", "store"],
      "properties": {
        "tool": { "type": "string" }, "searchContextSize": { "type": "string" },
        "maxSearches": { "type": "integer", "minimum": 1 }, "maxOutputTokens": { "type": "integer", "minimum": 1 },
        "store": { "const": false }
      }
    },
    "observations": { "type": "array", "minItems": 1, "items": { "$ref": "#/$defs/observation" } },
    "notice": { "type": "string", "minLength": 40 }
  },
  "$defs": {
    "observation": {
      "type": "object", "additionalProperties": false,
      "required": ["id", "observedAt", "input", "providerResponseStatus", "queries", "sourceDomains", "usage"],
      "properties": {
        "id": { "type": "string", "pattern": "^[a-z0-9-]+$" },
        "observedAt": { "type": "string", "format": "date-time" },
        "input": { "type": "object", "additionalProperties": false, "required": ["keyword", "language", "country"], "properties": { "keyword": { "type": "string" }, "language": { "type": "string" }, "country": { "type": "string" } } },
        "providerResponseStatus": { "enum": ["completed", "incomplete"] },
        "queries": { "type": "array", "items": { "type": "string", "minLength": 1 } },
        "sourceDomains": { "type": "array", "items": { "type": "string", "minLength": 1 } },
        "usage": { "type": "object", "additionalProperties": false, "required": ["inputTokens", "outputTokens", "searchActions", "estimatedCostUsd"], "properties": { "inputTokens": { "type": "integer", "minimum": 0 }, "outputTokens": { "type": "integer", "minimum": 0 }, "searchActions": { "type": "integer", "minimum": 0 }, "estimatedCostUsd": { "type": "number", "minimum": 0 } } }
      }
    }
  }
}
