{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://ofsclock.com/spec/ofs-envelope-v1.schema.json",
  "title": "OFS Envelope v1",
  "description": "OFS-2.1 message envelope for agent and system interoperability. ISO/UTC remains authoritative.",
  "type": "object",
  "required": ["envelope", "version", "type", "iso", "tz", "civil"],
  "properties": {
    "envelope": { "const": "ofs-envelope-v1" },
    "version": { "type": "string", "pattern": "^2\\.1$" },
    "type": {
      "type": "string",
      "enum": ["ofs.schedule.request", "ofs.schedule.result", "ofs.event.log"]
    },
    "iso": {
      "type": "string",
      "description": "ISO 8601 date-time (authoritative)",
      "format": "date-time"
    },
    "tz": {
      "type": "string",
      "description": "IANA timezone identifier"
    },
    "civil": {
      "type": "string",
      "description": "Civil display token (Φ.ψψψψψ)",
      "pattern": "^[0-9]\\.[0-9]{5}$"
    },
    "ft": {
      "type": "integer",
      "description": "Flow-Time monotonic ordering pulse (optional in static samples)",
      "minimum": 0
    },
    "mt": {
      "type": "object",
      "description": "Meaning-Time semantics (optional)",
      "properties": {
        "id": { "type": "string", "minLength": 8, "maxLength": 128 },
        "consent": { "type": "string", "enum": ["explicit", "implicit", "delegated"] },
        "privacy": { "type": "string", "enum": ["public", "restricted", "private"] },
        "causality": {
          "type": "object",
          "properties": {
            "causedBy": { "type": "array", "items": { "type": "string" } },
            "causes": { "type": "array", "items": { "type": "string" } }
          }
        }
      }
    }
  }
}
