{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://oco-adam.github.io/specgraph/schemas/manifest-lock.schema.json",
  "title": "Spec Graph Manifest Lockfile",
  "description": "Optional lockfile capturing the exact graph, artifacts, and toolchain used to manifest a system. Enables reproducible re-manifestation.",
  "type": "object",
  "required": ["specgraphVersion", "graph", "manifestedAt"],
  "additionalProperties": false,
  "properties": {
    "$schema": { "type": "string" },
    "specgraphVersion": {
      "type": "string",
      "pattern": "^\\d+\\.\\d+\\.\\d+(-[0-9A-Za-z-.]+)?$"
    },
    "graph": {
      "type": "object",
      "additionalProperties": false,
      "required": ["path", "sha256"],
      "properties": {
        "path": {
          "type": "string",
          "pattern": "^(?!/)(?!.*\\.{2}/)[A-Za-z0-9._/-]+\\.json$"
        },
        "sha256": {
          "type": "string",
          "pattern": "^[A-Fa-f0-9]{64}$"
        }
      }
    },
    "manifestedAt": {
      "type": "string",
      "description": "ISO 8601 timestamp of manifestation.",
      "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z$"
    },
    "equivalenceContractId": {
      "type": "string",
      "minLength": 1,
      "maxLength": 80,
      "description": "Node ID of the equivalence_contract used to define system equivalence."
    },
    "toolchain": {
      "type": "object",
      "description": "Pinned versions of the toolchain used for manifestation.",
      "additionalProperties": { "type": "string" }
    },
    "artifacts": {
      "type": "array",
      "description": "Resolved artifacts and their content hashes at manifest time.",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["id", "sha256"],
        "properties": {
          "id": { "type": "string", "minLength": 1, "maxLength": 80 },
          "sha256": { "type": "string", "pattern": "^[A-Fa-f0-9]{64}$" },
          "source": { "type": "string" },
          "format": { "type": "string" }
        }
      }
    },
    "checks": {
      "type": "array",
      "description": "Record of verification checks executed during manifestation.",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["check", "status"],
        "properties": {
          "check": { "type": "string", "minLength": 1 },
          "status": { "type": "string", "enum": ["pass", "fail", "skipped"] },
          "outputSha256": {
            "type": "string",
            "pattern": "^[A-Fa-f0-9]{64}$"
          }
        }
      }
    }
  }
}
