{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://lydiahub.online/timeline-schema.json",
  "title": "ResetPulse public timeline",
  "type": "object",
  "required": ["schema", "checkedAt", "freshness", "signalVersion", "resourceVersion", "query", "events", "boundary", "links"],
  "properties": {
    "schema": { "const": "resetpulse.timeline.v1" },
    "generatedAt": { "type": "string", "format": "date-time" },
    "checkedAt": { "type": "string", "format": "date-time" },
    "freshness": { "type": "object", "additionalProperties": true },
    "signalVersion": { "type": "string", "pattern": "^v1-[0-9a-f]{8}$", "description": "Canonical public-signal version shared with the compact and verified packets." },
    "resourceVersion": { "type": "string", "pattern": "^v1-[0-9a-f]{8}$", "description": "Query-specific response version used for ETag revalidation." },
    "query": {
      "type": "object",
      "required": ["since", "limit"],
      "properties": {
        "since": { "type": ["string", "null"], "format": "date-time" },
        "limit": { "type": "integer", "minimum": 1, "maximum": 100 }
      }
    },
    "events": { "type": "array", "items": { "$ref": "#/$defs/PublicEvent" } },
    "totalAvailable": { "type": "integer", "minimum": 0 },
    "hasMore": { "type": "boolean" },
    "boundary": { "type": "object", "required": ["credentialsRequired", "privateAccountTelemetry"], "additionalProperties": true },
    "links": { "type": "object", "additionalProperties": { "type": "string", "format": "uri" } }
  },
  "$defs": {
    "PublicEvent": {
      "type": "object",
      "required": ["id", "publishedAt", "firstObservedAt", "confirmedAt", "status", "confidence", "detectedSeconds", "title", "summary", "claimScope", "eventType", "timingQuality", "links"],
      "properties": {
        "id": { "type": "string", "pattern": "^event-[0-9]+$" },
        "publishedAt": { "type": "string", "format": "date-time" },
        "firstObservedAt": { "type": ["string", "null"], "format": "date-time" },
        "confirmedAt": { "type": ["string", "null"], "format": "date-time" },
        "status": { "enum": ["confirmed", "signal"] },
        "confidence": { "type": "number", "minimum": 0, "maximum": 100 },
        "detectedSeconds": { "type": "number", "minimum": 0 },
        "title": { "type": "string" },
        "summary": { "type": "string" },
        "claimScope": { "enum": ["broad-public", "plan-specific", "unknown"] },
        "claimScopeNote": { "type": "string" },
        "eventType": { "enum": ["full-refresh", "banked-credit", "announcement", "unknown"] },
        "eventTypeNote": { "type": "string" },
        "timingQuality": { "enum": ["measured", "historical", "migration-backfill", "external", "unknown"] },
        "sourceRole": { "type": "string" },
        "month": { "type": "string" },
        "links": { "type": "object", "required": ["evidencePage", "jsonReceipt"], "additionalProperties": { "type": "string", "format": "uri" } }
      },
      "additionalProperties": true
    }
  }
}
