{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://github.com/welkaim/ea-codex/schemas/v1/observability-profile.json",
  "title": "ObservabilityProfile",
  "description": "Required observability and evidence trace for an artifact. Defines which signals must be captured, where they are stored, and how long they are retained. Named in Chapter 13 as the observability counterpart to the SovereigntySpecification evidence requirement.",
  "type": "object",
  "required": ["apiVersion", "kind", "metadata", "spec"],
  "properties": {
    "apiVersion": { "$ref": "_common.json#/$defs/apiVersion" },
    "kind": { "type": "string", "const": "ObservabilityProfile" },
    "metadata": { "$ref": "_common.json#/$defs/metadata" },
    "spec": {
      "type": "object",
      "required": ["appliesTo", "signals"],
      "properties": {
        "appliesTo": {
          "type": "object",
          "properties": {
            "agentContractRef": { "type": "string" },
            "dataProductRef": { "type": "string" },
            "interactionContractRef": { "type": "string" }
          },
          "additionalProperties": true
        },
        "signals": {
          "type": "array",
          "minItems": 1,
          "items": {
            "type": "object",
            "required": ["name", "type"],
            "properties": {
              "name": { "type": "string" },
              "type": {
                "type": "string",
                "enum": ["log", "metric", "trace", "evidence-record", "decision-record"]
              },
              "store": { "type": "string" },
              "retention": { "type": "string" },
              "sampling": { "type": "string" },
              "fields": {
                "type": "array",
                "items": { "type": "string" }
              }
            },
            "additionalProperties": true
          }
        },
        "evidenceLedger": {
          "type": "object",
          "properties": {
            "store": { "type": "string" },
            "immutable": { "type": "boolean" },
            "retention": { "type": "string" }
          },
          "additionalProperties": true
        },
        "alerts": {
          "type": "array",
          "items": {
            "type": "object",
            "required": ["name", "condition", "severity"],
            "properties": {
              "name": { "type": "string" },
              "condition": { "type": "string" },
              "severity": {
                "type": "string",
                "enum": ["info", "low", "medium", "high", "critical"]
              },
              "routeTo": { "type": "string" }
            },
            "additionalProperties": true
          }
        }
      },
      "additionalProperties": true
    }
  },
  "additionalProperties": false
}
