{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "urn:junexis:schema:lifecycle-history:0.1",
  "title": "Historia cyklu życia Junexis 0.1",
  "type": "object",
  "additionalProperties": false,
  "required": ["schemaVersion", "rid", "generatedAt", "entries"],
  "properties": {
    "schemaVersion": { "const": "junexis.lifecycle-history/0.1" },
    "rid": { "enum": ["win-x64", "linux-x64", "osx-arm64"] },
    "generatedAt": { "$ref": "#/$defs/timestamp" },
    "entries": {
      "type": "array",
      "maxItems": 4096,
      "items": { "$ref": "#/$defs/entry" }
    }
  },
  "$defs": {
    "identifier": { "type": "string", "pattern": "^[a-z0-9][a-z0-9._-]{1,127}$" },
    "sha256": { "type": "string", "pattern": "^[0-9a-f]{64}(?![\\s\\S])" },
    "timestamp": { "type": "string", "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z$" },
    "releaseId": { "oneOf": [{ "$ref": "#/$defs/identifier" }, { "type": "null" }] },
    "optionalHash": { "oneOf": [{ "$ref": "#/$defs/sha256" }, { "type": "null" }] },
    "entry": {
      "type": "object",
      "additionalProperties": false,
      "required": ["sequence", "operationId", "operation", "startedAt", "completedAt", "result", "fromReleaseId", "toReleaseId", "planSha256", "journalSha256", "healthReportSha256", "code", "message"],
      "properties": {
        "sequence": { "type": "integer", "minimum": 1 },
        "operationId": { "$ref": "#/$defs/identifier" },
        "operation": { "enum": ["install", "update", "rollback", "repair", "uninstall", "cleanup"] },
        "startedAt": { "$ref": "#/$defs/timestamp" },
        "completedAt": { "$ref": "#/$defs/timestamp" },
        "result": { "enum": ["committed", "rolled-back", "cancelled", "failed", "recovery-required"] },
        "fromReleaseId": { "$ref": "#/$defs/releaseId" },
        "toReleaseId": { "$ref": "#/$defs/releaseId" },
        "planSha256": { "$ref": "#/$defs/sha256" },
        "journalSha256": { "$ref": "#/$defs/sha256" },
        "healthReportSha256": { "$ref": "#/$defs/optionalHash" },
        "code": { "$ref": "#/$defs/identifier" },
        "message": { "type": "string", "minLength": 1, "maxLength": 512 }
      }
    }
  }
}
