{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://mathgraph.org/schemas/resolve-bundle-v1.schema.json",
  "title": "MathGraph Resolve bundle v1",
  "description": "Strict transport envelope for the three immutable Resolve v1 members. Validation establishes structure and byte integrity, not semantic replay or publisher authenticity.",
  "type": "object",
  "additionalProperties": false,
  "required": ["schema", "members", "provenance"],
  "properties": {
    "schema": { "const": "mathgraph.resolve-bundle.v1" },
    "members": {
      "type": "object",
      "additionalProperties": false,
      "required": ["history.md", "jpl-record.json", "record.json"],
      "properties": {
        "history.md": { "$ref": "#/$defs/member" },
        "jpl-record.json": { "$ref": "#/$defs/member" },
        "record.json": { "$ref": "#/$defs/member" }
      }
    },
    "provenance": { "$ref": "#/$defs/provenance" }
  },
  "$defs": {
    "member": {
      "type": "object",
      "additionalProperties": false,
      "required": ["encoding", "data", "size", "sha256"],
      "properties": {
        "encoding": { "const": "base64" },
        "data": {
          "type": "string",
          "pattern": "^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$"
        },
        "size": { "type": "integer", "minimum": 0 },
        "sha256": { "$ref": "#/$defs/sha256" }
      }
    },
    "provenance": {
      "type": "object",
      "additionalProperties": false,
      "required": ["prior_independent_replay", "producer"],
      "properties": {
        "prior_independent_replay": {
          "type": "object",
          "additionalProperties": false,
          "required": ["actions_run", "commit", "independently_owned", "repository"],
          "properties": {
            "actions_run": { "type": "string", "pattern": "^[1-9][0-9]*$" },
            "commit": { "$ref": "#/$defs/gitSha" },
            "independently_owned": { "type": "boolean" },
            "repository": { "type": "string", "minLength": 1 }
          }
        },
        "producer": {
          "type": "object",
          "additionalProperties": false,
          "required": ["actions_run", "commit", "repository"],
          "properties": {
            "actions_run": { "type": "string", "pattern": "^[1-9][0-9]*$" },
            "commit": { "$ref": "#/$defs/gitSha" },
            "repository": { "type": "string", "minLength": 1 }
          }
        }
      }
    },
    "sha256": { "type": "string", "pattern": "^[0-9a-f]{64}$" },
    "gitSha": { "type": "string", "pattern": "^[0-9a-f]{40}$" }
  }
}
