{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://github.com/welkaim/ea-codex/schemas/v1/agent-memory-policy.json",
  "title": "AgentMemoryPolicy",
  "description": "Agent memory retention and jurisdiction policy. Decides what an agent may remember, for how long, in which jurisdiction, under which deletion rule, and with which inspection mechanism. In regulated domains, memory should be treated as a data product or controlled record. Named in Chapter 13.",
  "type": "object",
  "required": ["apiVersion", "kind", "metadata", "spec"],
  "properties": {
    "apiVersion": { "$ref": "_common.json#/$defs/apiVersion" },
    "kind": { "type": "string", "const": "AgentMemoryPolicy" },
    "metadata": { "$ref": "_common.json#/$defs/metadata" },
    "spec": {
      "type": "object",
      "required": ["agentContractRef", "retentionRules"],
      "properties": {
        "agentContractRef": { "type": "string" },
        "retentionRules": {
          "type": "array",
          "minItems": 1,
          "items": {
            "type": "object",
            "required": ["category", "retention"],
            "properties": {
              "category": {
                "type": "string",
                "examples": ["session-context", "user-preference", "task-trace", "patient-context", "secret"]
              },
              "retention": {
                "type": "string",
                "description": "Duration string (for example: '24h', '30d', 'session', 'never')."
              },
              "jurisdiction": { "type": "string" },
              "encryptionRequired": { "type": "boolean" },
              "deletionTrigger": { "type": "string" },
              "inspectableBy": {
                "type": "array",
                "items": { "type": "string" }
              }
            },
            "additionalProperties": true
          }
        },
        "prohibitedRetention": {
          "type": "array",
          "items": { "type": "string" }
        },
        "auditRequired": { "type": "boolean" }
      },
      "additionalProperties": true
    }
  },
  "additionalProperties": false
}
