{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://schemas.logicsrc.com/logicsrc-credential-sync-run.schema.json",
  "title": "LogicSRC Credential Sync Run",
  "type": "object",
  "required": ["type", "id", "planId", "status", "dryRun", "results", "auditEventIds", "reversible", "startedAt", "finishedAt"],
  "additionalProperties": false,
  "properties": {
    "type": { "const": "logicsrc.credential_sync_run" },
    "id": { "type": "string", "minLength": 1 },
    "planId": { "type": "string", "minLength": 1 },
    "status": { "enum": ["planned", "dry_run", "applied", "partial", "failed", "rolled_back"] },
    "dryRun": { "type": "boolean" },
    "results": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["key", "op", "applied", "dryRun"],
        "additionalProperties": false,
        "properties": {
          "key": { "type": "string", "minLength": 1 },
          "op": { "enum": ["add", "update", "remove", "unchanged", "unknown"] },
          "applied": { "type": "boolean" },
          "dryRun": { "type": "boolean" },
          "targetFingerprint": { "type": "string" },
          "error": { "type": "string" }
        }
      }
    },
    "auditEventIds": { "type": "array", "items": { "type": "string" } },
    "reversible": { "type": "boolean" },
    "startedAt": { "type": "string", "format": "date-time" },
    "finishedAt": { "type": "string", "format": "date-time" }
  }
}
