{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://forgevena.dev/schemas/credential-slot/v1",
  "title": "Forgevena Credential Slot Metadata v1",
  "type": "object",
  "required": ["schemaVersion", "credential", "activeKeyId", "slots", "audit"],
  "properties": {
    "schemaVersion": { "const": 1 },
    "credential": { "type": "string", "pattern": "^[a-z][a-z0-9-]*$" },
    "activeKeyId": { "type": ["string", "null"], "pattern": "^(primary|[a-z][a-z0-9-]{0,31})$" },
    "slots": {
      "type": "object",
      "additionalProperties": {
        "type": "object",
        "required": ["keyId", "status"],
        "properties": {
          "keyId": { "type": "string", "pattern": "^(primary|[a-z][a-z0-9-]{0,31})$" },
          "storage": { "enum": ["local", "encrypted"] },
          "status": { "enum": ["active", "quarantined", "purged"] },
          "createdAt": { "type": ["string", "null"], "format": "date-time" },
          "rotatedAt": { "type": ["string", "null"], "format": "date-time" },
          "validatedAt": { "type": ["string", "null"], "format": "date-time" },
          "removedAt": { "type": ["string", "null"], "format": "date-time" },
          "recoveryExpiresAt": { "type": ["string", "null"], "format": "date-time" }
        },
        "additionalProperties": false
      }
    },
    "audit": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["action", "at"],
        "properties": {
          "action": { "enum": ["configured", "activated", "rotated", "validated", "quarantined", "recovered", "quarantine-expired"] },
          "keyId": { "type": ["string", "null"] },
          "storage": { "type": ["string", "null"], "enum": ["local", "encrypted", null] },
          "at": { "type": "string", "format": "date-time" }
        },
        "additionalProperties": false
      }
    }
  },
  "additionalProperties": false
}
