{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "urn:junexis:schema:platform-provenance:0.1",
  "title": "Pochodzenie artefaktu platformy Junexis 0.1",
  "description": "Oświadczenie pochodzenia dla dowolnego składnika oficjalnego wydania platformy (Instalator, Studio, kompilator, LSP, VSIX, Runtime, SDK, dostawca, Laboratorium, Mentor, Narrative).",
  "type": "object",
  "additionalProperties": false,
  "required": ["schemaVersion", "component", "version", "subjectSha256", "source", "build"],
  "properties": {
    "schemaVersion": { "const": "junexis.platform-provenance/0.1" },
    "component": { "$ref": "#/$defs/identifier" },
    "version": { "$ref": "#/$defs/semver" },
    "subjectSha256": { "$ref": "#/$defs/sha256" },
    "source": {
      "type": "object",
      "additionalProperties": false,
      "required": ["repository", "revision", "state"],
      "properties": {
        "repository": { "$ref": "#/$defs/identifier" },
        "revision": { "type": "string", "pattern": "^[0-9a-f]{40}$" },
        "state": { "enum": ["clean", "dirty"] }
      }
    },
    "build": {
      "type": "object",
      "additionalProperties": false,
      "required": ["builderId", "configuration", "startedAt", "finishedAt", "materials"],
      "properties": {
        "builderId": { "$ref": "#/$defs/identifier" },
        "configuration": { "enum": ["Debug", "Release"] },
        "startedAt": { "$ref": "#/$defs/timestamp" },
        "finishedAt": { "$ref": "#/$defs/timestamp" },
        "materials": {
          "type": "array",
          "minItems": 1,
          "maxItems": 4096,
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": ["name", "sha256"],
            "properties": {
              "name": { "$ref": "#/$defs/identifier" },
              "sha256": { "$ref": "#/$defs/sha256" }
            }
          }
        }
      }
    }
  },
  "$defs": {
    "identifier": { "type": "string", "pattern": "^[a-z0-9][a-z0-9._-]{1,127}$" },
    "semver": { "type": "string", "pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+(?:[-+][0-9A-Za-z.-]+)?$" },
    "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$" }
  }
}
