{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://tsep-protocol.org/veille/observatoire-robots-ia/snapshot.schema.json",
  "title": "TSEP public crawler observations dashboard 1.2.0",
  "description": "Public aggregate facts and scoped interpretations. No IP, raw User-Agent, referrer or private event identifier.",
  "type": "object",
  "allOf": [
    {
      "$ref": "#/$defs/publicNode"
    }
  ],
  "required": [
    "schema_version",
    "generated_at",
    "campaign_id",
    "last_import_at",
    "analysis_plan",
    "phase_counts",
    "identities",
    "experimental",
    "passive",
    "health",
    "robots",
    "cases",
    "policies",
    "interpretation",
    "claims_breakdown",
    "operator_declarations",
    "crossover",
    "amendments"
  ],
  "properties": {
    "schema_version": {
      "const": "dashboard-1.2.0"
    },
    "generated_at": {
      "type": "string",
      "format": "date-time"
    },
    "last_import_at": {
      "type": "string",
      "format": "date-time"
    },
    "analysis_plan": {
      "type": [
        "object",
        "null"
      ]
    },
    "phase_counts": {
      "type": "object",
      "required": [
        "exploratory",
        "prospective",
        "post_phase"
      ],
      "properties": {
        "exploratory": {
          "$ref": "#/$defs/phase"
        },
        "prospective": {
          "$ref": "#/$defs/phase"
        },
        "post_phase": {
          "$ref": "#/$defs/phase"
        }
      },
      "additionalProperties": false
    },
    "cases": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/case"
      }
    },
    "claims_breakdown": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "client",
          "reason",
          "analysis_phase",
          "count"
        ],
        "properties": {
          "client": {
            "type": "string"
          },
          "reason": {
            "enum": [
              "unsupported_client",
              "no_valid_source",
              "ip_not_in_ranges",
              "invalid_ip",
              "no_client_claim",
              "ambiguous_client_claim",
              "legacy_reason_not_recorded"
            ]
          },
          "analysis_phase": {
            "$ref": "#/$defs/phaseName"
          },
          "count": {
            "$ref": "#/$defs/count"
          }
        },
        "additionalProperties": false
      }
    },
    "robots": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "client",
          "operator",
          "identity_scope",
          "operator_statement",
          "verified_requests",
          "categories",
          "arms",
          "identity_evidence_sha256"
        ],
        "properties": {
          "identity_evidence_sha256": {
            "type": "array",
            "items": {
              "$ref": "#/$defs/hash"
            }
          },
          "verified_requests": {
            "$ref": "#/$defs/count"
          }
        }
      }
    },
    "interpretation": {
      "type": "object",
      "required": [
        "operator_compliance_assessed",
        "training_use_observable",
        "pre_registered_before_collection"
      ],
      "properties": {
        "operator_compliance_assessed": {
          "const": false
        },
        "training_use_observable": {
          "const": false
        },
        "pre_registered_before_collection": {
          "const": false
        },
        "historical_identity_reverification": {
          "const": false
        }
      }
    },
    "crossover": {
      "type": "object",
      "required": [
        "metadata",
        "identities",
        "phase_counts",
        "cases",
        "claims_breakdown",
        "rejected_records",
        "included_in_original_campaign_counts",
        "causal_effect_identified",
        "compliance_rate_available"
      ],
      "properties": {
        "metadata": {
          "type": [
            "object",
            "null"
          ],
          "required": [
            "readback",
            "stopped"
          ],
          "properties": {
            "readback": {
              "type": [
                "object",
                "null"
              ],
              "additionalProperties": false,
              "required": [
                "checked_at",
                "ok"
              ],
              "properties": {
                "checked_at": {
                  "type": "string",
                  "format": "date-time"
                },
                "ok": {
                  "type": "boolean"
                }
              }
            },
            "stopped": {
              "type": "boolean"
            }
          }
        },
        "identities": {
          "type": "object"
        },
        "rejected_records": {
          "type": "integer",
          "minimum": 0
        },
        "phase_counts": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "preflight",
            "prospective",
            "post_phase"
          ],
          "properties": {
            "preflight": {
              "type": "object",
              "required": [
                "verified_requests",
                "claimed_requests",
                "unknown_requests",
                "verified_robots_requests",
                "verified_specimen_requests"
              ],
              "additionalProperties": false,
              "properties": {
                "verified_requests": {
                  "type": "integer",
                  "minimum": 0
                },
                "claimed_requests": {
                  "type": "integer",
                  "minimum": 0
                },
                "unknown_requests": {
                  "type": "integer",
                  "minimum": 0
                },
                "verified_robots_requests": {
                  "type": "integer",
                  "minimum": 0
                },
                "verified_specimen_requests": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            },
            "prospective": {
              "type": "object",
              "required": [
                "verified_requests",
                "claimed_requests",
                "unknown_requests",
                "verified_robots_requests",
                "verified_specimen_requests"
              ],
              "additionalProperties": false,
              "properties": {
                "verified_requests": {
                  "type": "integer",
                  "minimum": 0
                },
                "claimed_requests": {
                  "type": "integer",
                  "minimum": 0
                },
                "unknown_requests": {
                  "type": "integer",
                  "minimum": 0
                },
                "verified_robots_requests": {
                  "type": "integer",
                  "minimum": 0
                },
                "verified_specimen_requests": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            },
            "post_phase": {
              "type": "object",
              "required": [
                "verified_requests",
                "claimed_requests",
                "unknown_requests",
                "verified_robots_requests",
                "verified_specimen_requests"
              ],
              "additionalProperties": false,
              "properties": {
                "verified_requests": {
                  "type": "integer",
                  "minimum": 0
                },
                "claimed_requests": {
                  "type": "integer",
                  "minimum": 0
                },
                "unknown_requests": {
                  "type": "integer",
                  "minimum": 0
                },
                "verified_robots_requests": {
                  "type": "integer",
                  "minimum": 0
                },
                "verified_specimen_requests": {
                  "type": "integer",
                  "minimum": 0
                }
              }
            }
          }
        },
        "cases": {
          "type": "array",
          "items": {
            "type": "object",
            "required": [
              "client",
              "operator",
              "hour_utc",
              "path",
              "method",
              "response_status",
              "treatment",
              "identity_scope",
              "operator_statement",
              "site_rule",
              "cache_context",
              "observed_http",
              "interpretation",
              "count"
            ],
            "properties": {
              "treatment": {
                "$ref": "#/$defs/crossoverTreatment"
              },
              "count": {
                "type": "integer",
                "minimum": 1
              },
              "interpretation": {
                "type": "object",
                "properties": {
                  "causal_effect_identified": {
                    "const": false
                  },
                  "compliance_rate_available": {
                    "const": false
                  },
                  "operator_compliance_assessed": {
                    "const": false
                  },
                  "training_use_observable": {
                    "const": false
                  }
                }
              }
            }
          }
        },
        "claims_breakdown": {
          "type": "array"
        },
        "included_in_original_campaign_counts": {
          "const": false
        },
        "causal_effect_identified": {
          "const": false
        },
        "compliance_rate_available": {
          "const": false
        }
      }
    },
    "amendments": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "sha256",
          "base_plan_sha256",
          "signed_at"
        ],
        "properties": {
          "sha256": {
            "type": "string",
            "pattern": "^[a-f0-9]{64}$"
          },
          "base_plan_sha256": {
            "type": [
              "string",
              "null"
            ]
          },
          "signed_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          }
        }
      }
    }
  },
  "$defs": {
    "hash": {
      "type": "string",
      "pattern": "^[a-f0-9]{64}$"
    },
    "count": {
      "type": "integer",
      "minimum": 0
    },
    "phaseName": {
      "enum": [
        "exploratory",
        "prospective",
        "post_phase"
      ]
    },
    "phase": {
      "type": "object",
      "required": [
        "verified_requests",
        "experimental_verified_requests",
        "passive_verified_requests",
        "claimed_requests",
        "unknown_requests",
        "verified_specimens_visited"
      ],
      "additionalProperties": {
        "$ref": "#/$defs/count"
      }
    },
    "publicNode": {
      "anyOf": [
        {
          "type": [
            "string",
            "number",
            "boolean",
            "null"
          ]
        },
        {
          "type": "array",
          "items": {
            "$ref": "#/$defs/publicNode"
          }
        },
        {
          "type": "object",
          "propertyNames": {
            "not": {
              "pattern": "^(ip|user_agent|event_id|referrer|remote_addr|raw_log|raw_evidence|private_path)$"
            }
          },
          "additionalProperties": {
            "$ref": "#/$defs/publicNode"
          }
        }
      ]
    },
    "case": {
      "type": "object",
      "required": [
        "client",
        "operator",
        "hour_utc",
        "role",
        "path",
        "method",
        "response_status",
        "category",
        "count",
        "identity_scope",
        "analysis_phase",
        "site_rule",
        "operator_statement",
        "cache_context",
        "observed_http",
        "interpretation",
        "identity_evidence_sha256"
      ],
      "properties": {
        "count": {
          "$ref": "#/$defs/count"
        },
        "category": {
          "enum": [
            "discovery",
            "allowed_request",
            "restricted_request_review",
            "http_blocked",
            "http_control_review",
            "indeterminate",
            "passive",
            "declared_exception",
            "within_cache",
            "statement_unknown",
            "cache_unknown"
          ]
        },
        "analysis_phase": {
          "$ref": "#/$defs/phaseName"
        },
        "identity_scope": {
          "enum": [
            "client",
            "operator_category",
            "operator",
            "legacy_operator_ip_and_declared_token"
          ]
        },
        "identity_evidence_sha256": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/hash"
          }
        },
        "path": {
          "enum": [
            "/",
            "/robots.txt",
            "/sitemap.xml",
            "/specimens/01",
            "/specimens/02",
            "/specimens/03"
          ]
        },
        "method": {
          "enum": [
            "GET",
            "HEAD"
          ]
        },
        "response_status": {
          "type": "integer",
          "minimum": 100,
          "maximum": 599
        },
        "site_rule": {
          "type": "object",
          "required": [
            "crawl_permission",
            "policy_epoch",
            "robots_sha256",
            "policy_evidence_established"
          ],
          "properties": {
            "crawl_permission": {
              "enum": [
                "allowed",
                "disallowed",
                "unknown"
              ]
            },
            "policy_evidence_established": {
              "type": "boolean"
            }
          }
        },
        "operator_statement": {
          "type": "object",
          "required": [
            "value",
            "declaration_id",
            "text",
            "source_url",
            "reading_date",
            "evidence_sha256",
            "pinned_at",
            "applicability"
          ],
          "properties": {
            "value": {
              "enum": [
                "respects",
                "may_not_apply",
                "generally_ignores",
                "not_documented"
              ]
            },
            "applicability": {
              "const": "prospective_pin_reanalysis_for_earlier_events"
            }
          }
        },
        "cache_context": {
          "type": "object",
          "required": [
            "status",
            "policy_effective_from",
            "reason"
          ],
          "properties": {
            "status": {
              "enum": [
                "not_applicable",
                "unknown",
                "within_documented_window",
                "window_elapsed"
              ]
            }
          }
        },
        "interpretation": {
          "type": "object",
          "required": [
            "code",
            "reanalysis",
            "operator_compliance_assessed",
            "training_use_observable",
            "declaration_pinned_before_event"
          ],
          "properties": {
            "operator_compliance_assessed": {
              "const": false
            },
            "training_use_observable": {
              "const": false
            },
            "reanalysis": {
              "type": "boolean"
            },
            "declaration_pinned_before_event": {
              "type": "boolean"
            }
          }
        }
      }
    },
    "crossoverTreatment": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "experiment_id": {
          "type": "string"
        },
        "config_version": {
          "type": "string"
        },
        "config_sha256": {
          "type": "string",
          "pattern": "^[a-f0-9]{64}$"
        },
        "phase": {
          "enum": [
            "preflight",
            "prospective",
            "post_phase"
          ]
        },
        "epoch_id": {
          "type": "string"
        },
        "mode": {
          "enum": [
            "allow",
            "deny"
          ]
        },
        "scheduled_at": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time"
        },
        "scheduled_end_at": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time"
        },
        "first_response_at": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time"
        },
        "first_response_is_probe": {
          "type": [
            "boolean",
            "null"
          ]
        },
        "robots_sha256": {
          "type": "string",
          "pattern": "^[a-f0-9]{64}$"
        },
        "robots_cache_max_age_seconds": {
          "const": 300
        },
        "client_cache_state": {
          "const": "unknown"
        }
      },
      "required": [
        "experiment_id",
        "config_version",
        "config_sha256",
        "phase",
        "epoch_id",
        "mode",
        "scheduled_at",
        "scheduled_end_at",
        "first_response_at",
        "first_response_is_probe",
        "robots_sha256",
        "robots_cache_max_age_seconds",
        "client_cache_state"
      ],
      "allOf": [
        {
          "if": {
            "properties": {
              "phase": {
                "const": "preflight"
              }
            }
          },
          "then": {
            "properties": {
              "scheduled_at": {
                "type": "null"
              },
              "scheduled_end_at": {
                "type": "null"
              },
              "first_response_at": {
                "type": "null"
              },
              "first_response_is_probe": {
                "type": "null"
              }
            }
          },
          "else": {
            "properties": {
              "scheduled_at": {
                "type": "string",
                "format": "date-time"
              },
              "scheduled_end_at": {
                "type": "string",
                "format": "date-time"
              },
              "first_response_at": {
                "type": "string",
                "format": "date-time"
              },
              "first_response_is_probe": {
                "type": "boolean"
              }
            }
          }
        }
      ]
    }
  }
}
