{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://github.com/geronimo-iia/agent-foundation/schemas/taint-audit-event.json",
  "title": "Taint Audit Event",
  "description": "Schema for taint tracking audit log events",
  "oneOf": [
    {
      "type": "object",
      "title": "Ingest Event",
      "required": ["type", "timestamp", "agent", "value_id", "label"],
      "properties": {
        "type": {"const": "Ingest"},
        "timestamp": {"type": "string", "format": "date-time"},
        "agent": {"type": "string"},
        "value_id": {"type": "string"},
        "label": {"$ref": "taint-label.json"}
      },
      "additionalProperties": false
    },
    {
      "type": "object",
      "title": "SinkCheck Event",
      "required": ["type", "timestamp", "agent", "value_id", "sink", "context", "taint", "result", "violated_kinds"],
      "properties": {
        "type": {"const": "SinkCheck"},
        "timestamp": {"type": "string", "format": "date-time"},
        "agent": {"type": "string"},
        "value_id": {"type": "string"},
        "sink": {"type": "string"},
        "context": {"type": "string"},
        "taint": {"$ref": "taint-set.json"},
        "result": {"enum": ["ALLOWED", "BLOCKED"]},
        "violated_kinds": {
          "type": "array",
          "items": {"type": "string"}
        }
      },
      "additionalProperties": false
    },
    {
      "type": "object",
      "title": "Merge Event",
      "required": ["type", "timestamp", "agent", "inputs", "output"],
      "properties": {
        "type": {"const": "Merge"},
        "timestamp": {"type": "string", "format": "date-time"},
        "agent": {"type": "string"},
        "inputs": {
          "type": "array",
          "items": {"type": "string"},
          "minItems": 1
        },
        "output": {"type": "string"}
      },
      "additionalProperties": false
    },
    {
      "type": "object",
      "title": "PolicyChange Event",
      "required": ["type", "timestamp", "sink", "old_policy", "new_policy"],
      "properties": {
        "type": {"const": "PolicyChange"},
        "timestamp": {"type": "string", "format": "date-time"},
        "sink": {"type": "string"},
        "old_policy": {
          "type": "array",
          "items": {"type": "string"}
        },
        "new_policy": {
          "type": "array",
          "items": {"type": "string"}
        },
        "reason": {"type": "string"}
      },
      "additionalProperties": false
    }
  ]
}
