{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://limecloud.github.io/agentcontext/schemas/agentcontext-context-envelope.schema.json",
  "title": "Agent Context Envelope",
  "type": "object",
  "additionalProperties": true,
  "properties": {
    "schema_version": {
      "type": "string"
    },
    "context_id": {
      "type": "string"
    },
    "scope": {
      "type": "string",
      "enum": [
        "turn",
        "task",
        "session",
        "tool_invocation",
        "review",
        "handoff",
        "custom"
      ]
    },
    "lifecycle": {
      "type": "string"
    },
    "created_at": {
      "type": "string",
      "format": "date-time"
    },
    "producer": {
      "type": [
        "object",
        "string"
      ]
    },
    "actor_refs": {
      "type": "array",
      "items": {
        "type": [
          "string",
          "object"
        ]
      }
    },
    "runtime_refs": {
      "type": "array",
      "items": {
        "type": [
          "string",
          "object"
        ]
      }
    },
    "surface_refs": {
      "type": "array",
      "items": {
        "type": [
          "string",
          "object"
        ]
      }
    },
    "item_refs": {
      "type": "array",
      "items": {
        "type": [
          "string",
          "object"
        ]
      }
    },
    "selection_refs": {
      "type": "array",
      "items": {
        "type": [
          "string",
          "object"
        ]
      }
    },
    "budget_ref": {
      "type": [
        "string",
        "object"
      ]
    },
    "assembly_refs": {
      "type": "array",
      "items": {
        "type": [
          "string",
          "object"
        ]
      }
    },
    "injection_refs": {
      "type": "array",
      "items": {
        "type": [
          "string",
          "object"
        ]
      }
    },
    "compaction_refs": {
      "type": "array",
      "items": {
        "type": [
          "string",
          "object"
        ]
      }
    },
    "missing_context_refs": {
      "type": "array",
      "items": {
        "type": [
          "string",
          "object"
        ]
      }
    },
    "policy_refs": {
      "type": "array",
      "items": {
        "type": [
          "string",
          "object"
        ]
      }
    },
    "evidence_refs": {
      "type": "array",
      "items": {
        "type": [
          "string",
          "object"
        ]
      }
    },
    "telemetry_refs": {
      "type": "array",
      "items": {
        "type": [
          "string",
          "object"
        ]
      }
    },
    "metadata": {
      "type": "object",
      "additionalProperties": true
    }
  },
  "required": [
    "schema_version",
    "context_id",
    "scope",
    "lifecycle",
    "created_at"
  ]
}
