{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/snapvisor-io/json-schema/snapvisor-io-build-schema.json",
  "title": "Build",
  "description": "Build",
  "x-generated": "2026-11-25",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/snapvisor-io-openapi.yml#/components/schemas/Build",
  "type": "object",
  "properties": {
    "id": {
      "$ref": "#/$defs/BuildId"
    },
    "number": {
      "$ref": "#/$defs/BuildNumber"
    },
    "head": {
      "description": "The head reference of the build",
      "$ref": "#/$defs/BuildGitReference"
    },
    "base": {
      "anyOf": [
        {
          "$ref": "#/$defs/BuildGitReference"
        },
        {
          "type": "null"
        }
      ],
      "description": "The base reference of the build"
    },
    "status": {
      "anyOf": [
        {
          "type": "string",
          "enum": [
            "accepted",
            "rejected"
          ]
        },
        {
          "type": "string",
          "enum": [
            "no-changes",
            "changes-detected"
          ]
        },
        {
          "type": "string",
          "enum": [
            "expired",
            "pending",
            "progress",
            "error",
            "aborted"
          ]
        }
      ],
      "description": "The status of the build"
    },
    "conclusion": {
      "anyOf": [
        {
          "type": "string",
          "enum": [
            "no-changes",
            "changes-detected"
          ]
        },
        {
          "type": "null"
        }
      ],
      "description": "The conclusion of the build"
    },
    "autoApproved": {
      "type": "boolean",
      "description": "True when the build ran on an auto-approved branch (by default the project's default base branch): it became the new baseline by itself and needs no review, even when `status` is `changes-detected`. False until the build is processed."
    },
    "creator": {
      "anyOf": [
        {
          "$ref": "#/$defs/BuildCreator"
        },
        {
          "type": "null"
        }
      ],
      "description": "Who or what created the build, for telling an agent-created build from a CI or a person's. Null for a build created before this was recorded: it is not guessed."
    },
    "stats": {
      "anyOf": [
        {
          "type": "object",
          "properties": {
            "added": {
              "type": "number",
              "description": "Added snapshots"
            },
            "removed": {
              "type": "number",
              "description": "Removed snapshots"
            },
            "unchanged": {
              "type": "number",
              "description": "Unchanged snapshots"
            },
            "changed": {
              "type": "number",
              "description": "Changed snapshots"
            },
            "ignored": {
              "type": "number",
              "description": "Ignored snapshots"
            },
            "failure": {
              "type": "number",
              "description": "Failure screenshots"
            },
            "retryFailure": {
              "type": "number",
              "description": "Retry failure screenshots"
            },
            "total": {
              "type": "number",
              "description": "Total number of snapshots"
            }
          },
          "required": [
            "added",
            "removed",
            "unchanged",
            "changed",
            "ignored",
            "failure",
            "retryFailure",
            "total"
          ],
          "additionalProperties": false
        },
        {
          "type": "null"
        }
      ],
      "description": "Stats of the diffs present in the build"
    },
    "metadata": {
      "anyOf": [
        {
          "type": "object",
          "properties": {
            "testReport": {
              "description": "Test suite report",
              "type": "object",
              "properties": {
                "status": {
                  "type": "string",
                  "enum": [
                    "passed",
                    "failed",
                    "timedout",
                    "interrupted"
                  ],
                  "description": "Status of the test suite"
                },
                "stats": {
                  "type": "object",
                  "properties": {
                    "startTime": {
                      "description": "Date when the test suite started",
                      "type": "string"
                    },
                    "duration": {
                      "description": "Duration of the test suite in milliseconds",
                      "type": "number"
                    }
                  },
                  "additionalProperties": false
                }
              },
              "required": [
                "status"
              ],
              "additionalProperties": false
            }
          },
          "additionalProperties": false,
          "description": "Metadata associated to the build"
        },
        {
          "type": "null"
        }
      ]
    },
    "url": {
      "type": "string",
      "format": "uri",
      "description": "The URL of the build"
    },
    "notification": {
      "anyOf": [
        {
          "type": "object",
          "properties": {
            "description": {
              "type": "string"
            },
            "context": {
              "type": "string"
            },
            "github": {
              "type": "object",
              "properties": {
                "state": {
                  "type": "string",
                  "enum": [
                    "pending",
                    "success",
                    "error",
                    "failure"
                  ]
                }
              },
              "required": [
                "state"
              ],
              "additionalProperties": false
            },
            "gitlab": {
              "type": "object",
              "properties": {
                "state": {
                  "type": "string",
                  "enum": [
                    "pending",
                    "running",
                    "success",
                    "failed",
                    "canceled"
                  ]
                }
              },
              "required": [
                "state"
              ],
              "additionalProperties": false
            },
            "origin": {
              "type": "object",
              "properties": {
                "status": {
                  "type": "string",
                  "enum": [
                    "queued",
                    "in_progress",
                    "completed"
                  ]
                },
                "conclusion": {
                  "anyOf": [
                    {
                      "type": "string",
                      "enum": [
                        "success",
                        "failure"
                      ]
                    },
                    {
                      "type": "null"
                    }
                  ]
                }
              },
              "required": [
                "status",
                "conclusion"
              ],
              "additionalProperties": false
            },
            "url": {
              "type": "string",
              "format": "uri"
            }
          },
          "required": [
            "description",
            "context",
            "github",
            "gitlab",
            "origin",
            "url"
          ],
          "additionalProperties": false
        },
        {
          "type": "null"
        }
      ],
      "description": "The notification payload for the build"
    }
  },
  "required": [
    "id",
    "number",
    "head",
    "base",
    "status",
    "conclusion",
    "autoApproved",
    "creator",
    "stats",
    "metadata",
    "url",
    "notification"
  ],
  "additionalProperties": false,
  "$defs": {
    "Agent": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "description": "Stable id of the agent, e.g. `claude-code`. `unknown` when it could not be identified."
        },
        "name": {
          "description": "Name to display, e.g. `Claude Code`. Null for an agent we cannot name.",
          "type": [
            "string",
            "null"
          ]
        }
      },
      "required": [
        "id",
        "name"
      ],
      "additionalProperties": false,
      "description": "A coding agent acting on behalf of a user."
    },
    "BuildCreator": {
      "type": "object",
      "properties": {
        "kind": {
          "type": "string",
          "enum": [
            "ci",
            "agent",
            "user"
          ],
          "description": "Who created the build: `ci` (a project token: CI, tokenless or OIDC), `agent` (a coding agent, over the MCP server or reporting itself as one) or `user` (a person's own call: the web app, or a personal token with no agent marker). Self-reported by the caller, so not proof of who it was."
        },
        "agent": {
          "anyOf": [
            {
              "$ref": "#/$defs/Agent"
            },
            {
              "type": "null"
            }
          ],
          "description": "The coding agent that created the build. Set exactly when `kind` is `agent`; `unknown` as its id when the agent could not be identified."
        }
      },
      "required": [
        "kind",
        "agent"
      ],
      "additionalProperties": false,
      "description": "Who or what created a build."
    },
    "BuildGitReference": {
      "type": "object",
      "properties": {
        "sha": {
          "description": "The commit SHA",
          "$ref": "#/$defs/Sha1Hash"
        },
        "branch": {
          "type": "string",
          "description": "The branch name"
        }
      },
      "required": [
        "sha",
        "branch"
      ],
      "additionalProperties": false,
      "description": "Git reference"
    },
    "BuildId": {
      "type": "string",
      "description": "A unique identifier for the build"
    },
    "BuildNumber": {
      "type": "integer",
      "minimum": 1,
      "maximum": 9007199254740991,
      "description": "The build number"
    },
    "Sha1Hash": {
      "type": "string",
      "pattern": "^[0-9a-f]{40}$",
      "description": "SHA1 hash"
    }
  }
}