{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://schemas.logicsrc.com/logicsrc-credential-audit-event.schema.json",
  "title": "LogicSRC Credential Audit Event",
  "type": "object",
  "required": ["type", "id", "provider", "action", "key", "target", "principal", "decision", "dryRun", "createdAt"],
  "additionalProperties": false,
  "properties": {
    "type": { "const": "logicsrc.credential_audit_event" },
    "id": { "type": "string", "minLength": 1 },
    "runId": { "type": "string", "minLength": 1 },
    "planId": { "type": "string", "minLength": 1 },
    "provider": { "type": "string", "pattern": "^[a-z][a-z0-9-]*$" },
    "action": { "type": "string", "pattern": "^[a-z][a-z0-9_-]*(:[a-z][a-z0-9_-]*)+$" },
    "key": { "type": "string", "minLength": 1 },
    "target": { "type": "string", "minLength": 1 },
    "fingerprint": { "type": "string" },
    "principal": {
      "type": "object",
      "required": ["type", "id"],
      "additionalProperties": false,
      "properties": {
        "type": { "enum": ["user", "agent", "workflow", "plugin"] },
        "id": { "type": "string", "minLength": 1 },
        "trusted": { "type": "boolean" }
      }
    },
    "decision": { "enum": ["allow", "approval_required", "deny"] },
    "dryRun": { "type": "boolean" },
    "createdAt": { "type": "string", "format": "date-time" }
  }
}
