{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://usemakoto.dev/schema/v0.1.json",
  "title": "Makoto DBOM Schema",
  "description": "Data Bill of Materials — machine-readable provenance for data assets",
  "type": "object",
  "required": ["schema_version", "id", "created_at", "source", "signature", "lineage"],
  "properties": {
    "schema_version": {
      "type": "string",
      "const": "0.1",
      "description": "Schema version"
    },
    "id": {
      "type": "string",
      "pattern": "^dbom-",
      "description": "Unique DBOM identifier (UUID prefixed with dbom-)"
    },
    "created_at": {
      "type": "string",
      "format": "date-time",
      "description": "ISO 8601 timestamp of DBOM creation"
    },
    "source": {
      "type": "object",
      "required": ["uri", "hash", "format"],
      "properties": {
        "uri": {
          "type": "string",
          "description": "Location of the data asset (S3, GCS, GitHub, etc.)"
        },
        "hash": {
          "type": "object",
          "required": ["algorithm", "value"],
          "properties": {
            "algorithm": {
              "type": "string",
              "enum": ["sha256"],
              "description": "Hash algorithm"
            },
            "value": {
              "type": "string",
              "pattern": "^[a-f0-9]{64}$",
              "description": "Hex-encoded hash value"
            }
          }
        },
        "format": {
          "type": "string",
          "description": "Data format (csv, parquet, json, etc.)"
        }
      }
    },
    "signature": {
      "type": "object",
      "required": ["algorithm", "value", "signer"],
      "properties": {
        "algorithm": {
          "type": "string",
          "enum": ["sha256"],
          "description": "Signature algorithm"
        },
        "value": {
          "type": "string",
          "pattern": "^[a-f0-9]{64}$",
          "description": "Signature value"
        },
        "signer": {
          "type": "string",
          "description": "Identity of the signer (e.g., github:username)"
        }
      }
    },
    "lineage": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "object",
        "required": ["step", "description", "tool", "input_hash", "output_hash"],
        "properties": {
          "step": {
            "type": "integer",
            "minimum": 1,
            "description": "Sequential step number"
          },
          "description": {
            "type": "string",
            "description": "Human-readable description of this processing step"
          },
          "tool": {
            "type": "string",
            "description": "Tool and version that performed this step"
          },
          "input_hash": {
            "type": "string",
            "description": "Hash of the input to this step (n/a for first step)"
          },
          "output_hash": {
            "type": "string",
            "description": "Hash of the output from this step"
          }
        }
      }
    }
  }
}
