{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://aas-1.org/schemas/0.1/action-record.json",
  "title": "AAS-1 Class A Action Record",
  "description": "Schema for a single agent action record under AAS-1 v0.1.",
  "type": "object",
  "required": [
    "aas",
    "eventId",
    "class",
    "agentRef",
    "principalRef",
    "timestamp",
    "timestampServiceRef",
    "action",
    "evidence",
    "signature"
  ],
  "properties": {
    "aas": {
      "type": "string",
      "const": "0.1"
    },
    "eventId": {
      "type": "string",
      "description": "ULID or UUID, unique within the issuer.",
      "minLength": 16
    },
    "class": {
      "type": "string",
      "const": "A"
    },
    "agentRef": {
      "type": "string",
      "format": "uri",
      "description": "AIS-1 identity, typically a DID URI."
    },
    "principalRef": {
      "type": "string",
      "format": "uri",
      "description": "Legal or natural person on whose behalf the agent acted."
    },
    "delegationRef": {
      "type": "string",
      "format": "uri",
      "description": "Delegation or authorisation under which the agent acted."
    },
    "engagementRef": {
      "type": "string",
      "format": "uri",
      "description": "Reference to a Class E engagement record."
    },
    "timestamp": {
      "type": "string",
      "format": "date-time",
      "description": "RFC 3339 timestamp of the action."
    },
    "timestampServiceRef": {
      "type": "string",
      "format": "uri",
      "description": "Identifier of the timestamping authority. Mirrors AIS-1 §3.4."
    },
    "action": {
      "type": "object",
      "required": ["type", "inputsHash", "outputsHash"],
      "properties": {
        "type": {
          "type": "string",
          "enum": [
            "tool_call",
            "decision",
            "communication",
            "transaction",
            "policy_check",
            "human_handoff",
            "other"
          ]
        },
        "inputsHash": {
          "type": "string",
          "description": "Hash of canonicalised inputs."
        },
        "outputsHash": {
          "type": "string",
          "description": "Hash of canonicalised outputs."
        },
        "tools": {
          "type": "array",
          "items": {
            "type": "object",
            "required": ["name"],
            "properties": {
              "name": { "type": "string" },
              "version": { "type": "string" },
              "serverRef": { "type": "string", "format": "uri" }
            }
          }
        },
        "model": {
          "type": "object",
          "properties": {
            "id": { "type": "string" },
            "version": { "type": "string" }
          }
        },
        "summary": { "type": "string" }
      }
    },
    "policyRefs": {
      "type": "array",
      "items": { "type": "string", "format": "uri" }
    },
    "policyResult": {
      "type": "object",
      "properties": {
        "outcome": {
          "type": "string",
          "enum": ["compliant", "non_compliant", "exception", "not_evaluated"]
        },
        "details": { "type": "string" }
      }
    },
    "materiality": {
      "type": "object",
      "properties": {
        "currency": { "type": "string" },
        "amount": { "type": "number" },
        "riskScore": { "type": "number" },
        "basis": { "type": "string" }
      }
    },
    "evidence": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "required": ["type", "value"],
        "properties": {
          "type": {
            "type": "string",
            "description": "Recognised: signature, attestation, witness, log, hash_anchor, human. Implementations MAY add reverse-DNS namespaced types."
          },
          "value": {
            "description": "Evidence value, format depends on type."
          },
          "issuerRef": { "type": "string", "format": "uri" }
        }
      }
    },
    "attestations": {
      "type": "array",
      "items": { "type": "object" }
    },
    "prevHash": {
      "type": "string",
      "description": "Hash of the immediately preceding record, for chain integrity."
    },
    "signature": {
      "type": "object",
      "required": ["alg", "value"],
      "properties": {
        "alg": {
          "type": "string",
          "description": "Signature algorithm identifier (e.g. EdDSA, ES256K)."
        },
        "hashAlg": {
          "type": "string",
          "default": "SHA-256"
        },
        "canonicalisation": {
          "type": "string",
          "default": "JCS"
        },
        "keyRef": {
          "type": "string",
          "description": "Verification method identifier within the AIS-1 identity document."
        },
        "value": { "type": "string" }
      }
    },
    "notes": { "type": "string" }
  },
  "additionalProperties": false
}
