{
  "openapi": "3.1.0",
  "info": {
    "title": "Gauss API",
    "version": "2026-10-29",
    "description": "Host Amp repositories, set channel policies, submit merges, inspect failed checks, and publish artifacts. The `motor gauss` commands are built on this API."
  },
  "servers": [
    {
      "url": "https://www.motor.dev"
    }
  ],
  "security": [
    {
      "bearer": []
    },
    {
      "dpop": []
    }
  ],
  "tags": [
    {
      "name": "Using this API",
      "description": "To host a project on Gauss:\n\n- Create a repository with `POST /api/gauss/repos`. New repositories are private.\n- Set who can read and change it with the access endpoints.\n- Record, pull, and push changes with Amp, at the repository's address: `https://gauss.motor.dev/<handle>/<repo>`. A Git repository (`vcs_kind` `git`) is Git's instead, at `https://gauss.motor.dev/<handle>/<repo>.git`: `motor auth git-setup` lets Git sign in there.\n- To publish files, such as a release, reserve an artifact's version, upload its files, and publish it with `.../finalize`.\n\nPass the team's handle as `team` when you create or list repositories: in the request body to create, and in the query string to list. Other requests name the repository in the path, as `<handle>/<repo>`.\n\nErrors use Gauss's own codes, such as `repository_not_found`, as well as Motor's. See https://www.motor.dev/docs/apis#api_conventions for the credentials, errors, and lists that every Motor API shares."
    },
    {
      "name": "Permissions",
      "description": "Access to a repository is set by its scopes:\n\n- `read`: the repository, its channels and changes, merges, and artifacts.\n- `write`: push, apply, and tag. Includes `read`.\n- `publish`: reserve, upload, finalize, and delete artifacts. Includes `read`.\n- `manage`: change the repository's visibility and access. Includes all of the above.\n\nMembers of the repository's team get its `team_scopes` and any scopes granted to them, and team admins can manage every repository in their team. A team key works only in its own team. It gets each repository's `team_scopes`, limited to the key's own scopes: `gauss:read`, `gauss:write`, `gauss:publish` (which can also list artifacts), or `gauss:*` for all three, or one of them for one repository, `gauss:<action>:<repository>`, such as `gauss:publish:site`, still within that repository's `team_scopes`. A team key can't manage a repository; that takes a person's session. A repository's `effective_scopes` shows what you can do with it."
    },
    {
      "name": "Hosting addresses",
      "description": "Amp's protocol, Git's Smart HTTP (`/<handle>/<repo>.git`), Go modules (`/api/go/...`), and artifact downloads are served from Gauss's own address, which `GET /api` returns as `gauss`. A repository's published artifacts are listed at `/<handle>/<repo>/artifacts/index.json` there, with each version's files at `/<handle>/<repo>/artifacts/<version>/<file>`. Artifact files upload directly to storage, using the presigned request from `.../uploads`, which needs no credential."
    },
    {
      "name": "Repositories",
      "description": "Amp repositories, each in a team, at `https://gauss.motor.dev/<handle>/<repo>`."
    },
    {
      "name": "Access",
      "description": "Repository permissions for team members and individual users."
    },
    {
      "name": "Artifacts",
      "description": "Versioned releases containing files and the source tag and state they were built from."
    },
    {
      "name": "Hooks",
      "description": "What a repository's `.gauss/hooks.star` declares: the events that each hook subscribes to, its filters, and what it runs. Hooks are files of the repository: no API makes or deletes them."
    },
    {
      "name": "Events",
      "description": "The events of a repository, and the hooks that each runs."
    },
    {
      "name": "Invocations",
      "description": "The runs of a repository's hooks: each event's matching hooks, and those invoked by hand. Each invocation is one hook's, with its attempts, each a Piston run."
    },
    {
      "name": "Policies",
      "description": "Channel policies, which managers set through the API: the checks that a merge into a channel needs, and whether the channel takes direct pushes or only merges. A repository's files can't change them."
    },
    {
      "name": "Merges",
      "description": "Merges of a source channel into a target channel. Every merge goes through its target's queue: opening it pins a snapshot of the source, which the queue batches with others, checks on exactly the candidate's state, and lands once the checks that the target's policy requires pass. A failed batch splits until the merges that fail are found, and rejected; a target that fails its own checks makes the queue try each merge alone until one lands. Nothing in the queue waits for a person."
    },
    {
      "name": "Secrets",
      "description": "A repository's secrets: values that its runs get, which nobody reads back. A team's administrators set and delete them; the repository's writers use them in `motor piston run`, through grants that Piston redeems as each task starts."
    },
    {
      "name": "Profiles",
      "description": "A repository's profiles: what its hooks' privileged tasks, such as deploys, use. A profile's rules say which events and channels or tags may use it, and its bindings what its tasks get: its own values, or the repository's secrets, explicitly inherited."
    }
  ],
  "paths": {
    "/api/gauss/repos": {
      "post": {
        "operationId": "create_repository",
        "summary": "Create a repository",
        "description": "Creates a repository in the explicitly specified `team`. Requires team membership; creating a public repository also requires a team admin. Team keys cannot create repositories (`user_required`).\n\nNew repositories have no default team scopes. The creator receives `manage`, and team admins can also manage the repository. Use the access endpoints to grant access to other members.\n\nRetry with the same `Idempotency-Key` to resume creation and return the same repository. Reusing the key for a different request returns `409`. If provisioning is incomplete, the response is `503`; retry with the same key, or wait for Gauss’s automatic retry.\n\nA repository is Amp's unless `vcs_kind` is `git`. Gauss makes Git repositories only where its configuration enables them (`git_disabled` otherwise).",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 255
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "team",
                  "name"
                ],
                "properties": {
                  "team": {
                    "type": "string",
                    "description": "The handle of the team that the repository is for, such as `ada` or `lighthouse`. Required."
                  },
                  "name": {
                    "type": "string",
                    "description": "1 to 100 lowercase letters, digits, and single underscores between words, starting with a letter."
                  },
                  "main_channel": {
                    "type": "string",
                    "description": "The main channel. Pushes that add changes to it create merge records. Defaults to `main` and cannot be changed."
                  },
                  "visibility": {
                    "type": "string",
                    "enum": [
                      "private",
                      "public"
                    ],
                    "description": "Default: private. Anybody can read a public repository, with all its channels and changes."
                  },
                  "vcs_kind": {
                    "type": "string",
                    "enum": [
                      "amp",
                      "git"
                    ],
                    "description": "The repository's version control: `amp` (the default) or `git`. It can't change later."
                  }
                }
              },
              "example": {
                "team": "ada",
                "name": "web"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "A retry with the same Idempotency-Key: the repository.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Repository"
                },
                "example": {
                  "id": "repo_1BbA6sXxyUWHYvKqN5T3dM",
                  "handle": "ada",
                  "name": "web",
                  "main_channel": "main",
                  "visibility": "private",
                  "status": "ready",
                  "provisioning_error": "",
                  "url": "https://gauss.motor.dev/ada/web",
                  "created_at": "2026-10-22T09:00:00Z",
                  "updated_at": "2026-10-22T09:00:00Z",
                  "effective_scopes": [
                    "read",
                    "write",
                    "publish",
                    "manage"
                  ],
                  "vcs_kind": "amp"
                }
              }
            }
          },
          "201": {
            "description": "The repository.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Repository"
                },
                "example": {
                  "id": "repo_1BbA6sXxyUWHYvKqN5T3dM",
                  "handle": "ada",
                  "name": "web",
                  "main_channel": "main",
                  "visibility": "private",
                  "status": "ready",
                  "provisioning_error": "",
                  "url": "https://gauss.motor.dev/ada/web",
                  "created_at": "2026-10-22T09:00:00Z",
                  "updated_at": "2026-10-22T09:00:00Z",
                  "effective_scopes": [
                    "read",
                    "write",
                    "publish",
                    "manage"
                  ],
                  "vcs_kind": "amp"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "Not a member of the team (`not_a_member`), a team key (`user_required`), a team key of another team (`wrong_team`), a public repository by someone who isn't a team admin (`admin_required`), or a suspended team (`suspended`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "not_a_member",
                    "message": "you aren't a member of lab",
                    "retryable": false
                  }
                }
              }
            }
          },
          "404": {
            "description": "No team has the handle (`team_not_found`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "team_not_found",
                    "message": "no team has the handle lab",
                    "retryable": false
                  }
                }
              }
            }
          },
          "409": {
            "description": "A repository with the name exists (`repository_exists`), or the Idempotency-Key made another one (`idempotency_conflict`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "repository_exists",
                    "message": "ada/web exists",
                    "retryable": false
                  }
                }
              }
            }
          },
          "412": {
            "description": "A Git repository, where Gauss doesn't host Git yet (`git_disabled`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "git_disabled",
                    "message": "Gauss doesn't host Git repositories yet; make an Amp repository (vcs_kind \"amp\")",
                    "retryable": false
                  }
                }
              }
            }
          },
          "413": {
            "$ref": "#/components/responses/TooLarge"
          },
          "422": {
            "description": "No team (`team_required`), or an invalid name, main channel, or visibility (`invalid_name`, `invalid_main_channel`, `invalid_visibility`), or a version control that isn't `amp` or `git` (`invalid_vcs_kind`); or a field of the wrong type, or an unknown one (`invalid_field`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "team_required",
                    "message": "name the team, by its handle: \"team\" in the body, or ?team=<handle>",
                    "retryable": false
                  }
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "503": {
            "description": "Repository provisioning is incomplete or a required service is temporarily unavailable. Wait for the retry delay indicated by `Retry-After` or `retry_after_seconds`, then repeat the request with the same `Idempotency-Key`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "temporarily_unavailable",
                    "message": "Gauss can't answer now. Try again in a moment.",
                    "retryable": true,
                    "retry_after_seconds": 1
                  }
                }
              }
            }
          }
        },
        "tags": [
          "Repositories"
        ]
      },
      "get": {
        "operationId": "list_repositories",
        "summary": "List repositories",
        "description": "Lists readable repositories in the specified team, sorted by name. Results include public repositories and private repositories the caller can access. A team key can list only its own team’s repositories.",
        "parameters": [
          {
            "name": "team",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The handle of the team. Required."
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 1000
            },
            "description": "Maximum results per page. Range: 1–1,000. Defaults to 100."
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "The previous response’s `next_cursor`. Omit for the first page."
          }
        ],
        "responses": {
          "200": {
            "description": "A page of repositories.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RepositoryPage"
                },
                "example": {
                  "data": [
                    {
                      "id": "repo_1BbA6sXxyUWHYvKqN5T3dM",
                      "handle": "ada",
                      "name": "web",
                      "main_channel": "main",
                      "visibility": "private",
                      "status": "ready",
                      "provisioning_error": "",
                      "url": "https://gauss.motor.dev/ada/web",
                      "created_at": "2026-10-22T09:00:00Z",
                      "updated_at": "2026-10-22T09:00:00Z",
                      "effective_scopes": [
                        "read",
                        "write",
                        "publish",
                        "manage"
                      ],
                      "vcs_kind": "amp"
                    }
                  ],
                  "next_cursor": null
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "A team key of another team (`wrong_team`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "wrong_team",
                    "message": "the team key works in ada, not in lab",
                    "retryable": false
                  }
                }
              }
            }
          },
          "404": {
            "description": "No team has the handle (`team_not_found`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "team_not_found",
                    "message": "no team has the handle lab",
                    "retryable": false
                  }
                }
              }
            }
          },
          "422": {
            "description": "No team (`team_required`), or an invalid limit (`invalid_limit`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "team_required",
                    "message": "name the team, by its handle: \"team\" in the body, or ?team=<handle>",
                    "retryable": false
                  }
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "503": {
            "description": "Gauss or a required service is temporarily unavailable (`motor_unavailable`, `unavailable`, `temporarily_unavailable`). Wait for the retry delay indicated by `Retry-After` or `retry_after_seconds` before retrying.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "temporarily_unavailable",
                    "message": "Gauss can't answer now. Try again in a moment.",
                    "retryable": true,
                    "retry_after_seconds": 1
                  }
                }
              }
            }
          }
        },
        "tags": [
          "Repositories"
        ]
      }
    },
    "/api/gauss/repos/{handle}/{repo}": {
      "get": {
        "operationId": "get_repository",
        "summary": "Get a repository",
        "description": "Returns repository details and the caller’s `effective_scopes`. Public repositories are readable by anyone. Private repositories require `read` access.",
        "responses": {
          "200": {
            "description": "The repository.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Repository"
                },
                "example": {
                  "id": "repo_1BbA6sXxyUWHYvKqN5T3dM",
                  "handle": "ada",
                  "name": "web",
                  "main_channel": "main",
                  "visibility": "private",
                  "status": "ready",
                  "provisioning_error": "",
                  "url": "https://gauss.motor.dev/ada/web",
                  "created_at": "2026-10-22T09:00:00Z",
                  "updated_at": "2026-10-22T09:00:00Z",
                  "effective_scopes": [
                    "read",
                    "write",
                    "publish",
                    "manage"
                  ],
                  "vcs_kind": "amp"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "The caller lacks a required repository or team-key scope (`insufficient_scope`), or the account or team is suspended (`suspended`, `account_suspended`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "insufficient_scope",
                    "message": "you need the manage scope of ada/web; ask someone who manages it",
                    "retryable": false
                  }
                }
              }
            }
          },
          "404": {
            "description": "The repository does not exist or is not visible to the caller (`repository_not_found`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "repository_not_found",
                    "message": "no repository ada/web, or it's private to another account",
                    "retryable": false
                  }
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "503": {
            "description": "Gauss or a required service is temporarily unavailable (`motor_unavailable`, `unavailable`, `temporarily_unavailable`). Wait for the retry delay indicated by `Retry-After` or `retry_after_seconds` before retrying.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "temporarily_unavailable",
                    "message": "Gauss can't answer now. Try again in a moment.",
                    "retryable": true,
                    "retry_after_seconds": 1
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "handle",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The handle of the team that owns the repository, including a user’s personal team."
          },
          {
            "name": "repo",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The repository's name."
          }
        ],
        "tags": [
          "Repositories"
        ]
      },
      "patch": {
        "operationId": "update_repository",
        "summary": "Change a repository's visibility",
        "description": "Changes a repository's `visibility`. Requires `manage` access. Making a repository private immediately restricts access to authorized users; it does not remove copies previously downloaded.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "visibility": {
                    "type": "string",
                    "enum": [
                      "private",
                      "public"
                    ]
                  }
                },
                "required": [
                  "visibility"
                ]
              },
              "example": {
                "visibility": "private"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The repository.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Repository"
                },
                "example": {
                  "id": "repo_1BbA6sXxyUWHYvKqN5T3dM",
                  "handle": "ada",
                  "name": "web",
                  "main_channel": "main",
                  "visibility": "private",
                  "status": "ready",
                  "provisioning_error": "",
                  "url": "https://gauss.motor.dev/ada/web",
                  "created_at": "2026-10-22T09:00:00Z",
                  "updated_at": "2026-10-22T09:00:00Z",
                  "effective_scopes": [
                    "read",
                    "write",
                    "publish",
                    "manage"
                  ],
                  "vcs_kind": "amp"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "The caller lacks a required repository or team-key scope (`insufficient_scope`), or the account or team is suspended (`suspended`, `account_suspended`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "insufficient_scope",
                    "message": "you need the manage scope of ada/web; ask someone who manages it",
                    "retryable": false
                  }
                }
              }
            }
          },
          "404": {
            "description": "The repository does not exist or is not visible to the caller (`repository_not_found`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "repository_not_found",
                    "message": "no repository ada/web, or it's private to another account",
                    "retryable": false
                  }
                }
              }
            }
          },
          "413": {
            "$ref": "#/components/responses/TooLarge"
          },
          "422": {
            "description": "No visibility (`invalid_update`), an invalid visibility (`invalid_visibility`); or a field of the wrong type, or an unknown one (`invalid_field`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "invalid_visibility",
                    "message": "visibility is private or public",
                    "retryable": false
                  }
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "503": {
            "description": "Gauss or a required service is temporarily unavailable (`motor_unavailable`, `unavailable`, `temporarily_unavailable`). Wait for the retry delay indicated by `Retry-After` or `retry_after_seconds` before retrying.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "temporarily_unavailable",
                    "message": "Gauss can't answer now. Try again in a moment.",
                    "retryable": true,
                    "retry_after_seconds": 1
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "handle",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The handle of the team that owns the repository, including a user’s personal team."
          },
          {
            "name": "repo",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The repository's name."
          }
        ],
        "tags": [
          "Repositories"
        ]
      }
    },
    "/api/gauss/repos/{handle}/{repo}/artifacts": {
      "post": {
        "operationId": "reserve_artifact",
        "summary": "Reserve an artifact's version",
        "description": "Reserves a version for an artifact and links it to the repository tag and recorded state it was built from. Requires `publish` access. Gauss verifies the tag and its state against the repository.\n\nSpecify `version`, or omit it to allocate the next automatic version. Automatic versions require a body `idempotency_key`. Retrying the same publication returns its existing reservation.\n\nUpload the files, then finalize the artifact to publish it.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "source_tag",
                  "source_state"
                ],
                "properties": {
                  "version": {
                    "type": "string",
                    "description": "1 to 64 letters, digits, '.', '_', '+' and '-'. Versions compare naturally: runs of digits as numbers. Leave it out for the next `YYYY_MM_NNNN` (UTC), which needs `idempotency_key`."
                  },
                  "source_tag": {
                    "type": "string",
                    "description": "Repository tag identifying the source."
                  },
                  "source_state": {
                    "type": "string",
                    "description": "Recorded state identified by the source tag."
                  },
                  "idempotency_key": {
                    "type": "string",
                    "description": "Unique key for this publication, up to 200 bytes. Retrying with this key returns the same artifact, including its allocated version."
                  }
                }
              },
              "example": {
                "version": "2026_10_0001",
                "source_tag": "2026_10_0001",
                "source_state": "MZ4XKH"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Returns the existing artifact when retrying a reservation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Artifact"
                },
                "example": {
                  "id": "artifact_1BbA6sXxyUWHYvKqN5T3dM",
                  "version": "2026_10_0001",
                  "source_tag": "2026_10_0001",
                  "source_state": "MZ4XKH",
                  "status": "published",
                  "files": [
                    {
                      "name": "amp-darwin-arm64.gz",
                      "size": 9416704,
                      "sha256": "4d3c7f2b4f5a9e0e8b1c2d3e4f5a6b7c8d9e0f1a2b3c4d5e6f7a8b9c0d1e2f3a",
                      "content_type": "application/gzip"
                    }
                  ],
                  "url": "https://gauss.motor.dev/motor/amp/artifacts/2026_10_0001",
                  "created_at": "2026-10-22T09:00:00Z",
                  "published_at": "2026-10-22T09:05:00Z"
                }
              }
            }
          },
          "201": {
            "description": "The reserved artifact.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Artifact"
                },
                "example": {
                  "id": "artifact_1BbA6sXxyUWHYvKqN5T3dM",
                  "version": "2026_10_0001",
                  "source_tag": "2026_10_0001",
                  "source_state": "MZ4XKH",
                  "status": "uploading",
                  "files": [],
                  "url": "https://gauss.motor.dev/motor/amp/artifacts/2026_10_0001",
                  "created_at": "2026-10-22T09:00:00Z",
                  "published_at": null
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "description": "New storage is blocked because the team needs a payment card (`billing_required`) or reached its monthly spending limit (`over_limit`). Existing files remain stored and continue to incur charges.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "billing_required",
                    "message": "the team needs a payment card to store artifacts; add one in Motor's console",
                    "retryable": false
                  }
                }
              }
            }
          },
          "403": {
            "description": "The caller lacks a required repository or team-key scope (`insufficient_scope`), or the account or team is suspended (`suspended`, `account_suspended`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "insufficient_scope",
                    "message": "you need the manage scope of ada/web; ask someone who manages it",
                    "retryable": false
                  }
                }
              }
            }
          },
          "404": {
            "description": "The repository does not exist or is not visible to the caller (`repository_not_found`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "repository_not_found",
                    "message": "no repository ada/web, or it's private to another account",
                    "retryable": false
                  }
                }
              }
            }
          },
          "409": {
            "description": "The version belongs to another source (`version_exists`) or was previously published and deleted. Published versions cannot be reused.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "version_exists",
                    "message": "2026_10_0001 is the version of another source (the tag v1); choose another version",
                    "retryable": false
                  }
                }
              }
            }
          },
          "413": {
            "$ref": "#/components/responses/TooLarge"
          },
          "422": {
            "description": "An invalid version (`invalid_version`) or source (`invalid_source`), a missing tag (`tag_not_found`), or a tag of another state (`tag_mismatch`); or a field of the wrong type, or an unknown one (`invalid_field`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "invalid_version",
                    "message": "a version is 1 to 64 letters, digits, '.', '_', '+' and '-', starting with a letter or a digit, such as 2026_10_0001",
                    "retryable": false
                  }
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "503": {
            "description": "Gauss or a required service is temporarily unavailable (`artifacts_unavailable`, `temporarily_unavailable`). Wait for the retry delay indicated by `Retry-After` or `retry_after_seconds` before retrying.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "temporarily_unavailable",
                    "message": "Gauss can't answer now. Try again in a moment.",
                    "retryable": true,
                    "retry_after_seconds": 1
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "handle",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The handle of the team that owns the repository, including a user’s personal team."
          },
          {
            "name": "repo",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The repository's name."
          }
        ],
        "tags": [
          "Artifacts"
        ]
      },
      "get": {
        "operationId": "list_artifacts",
        "summary": "List a repository's artifacts",
        "description": "Lists artifacts by version, newest first. Requires `read` access. Team members can also see artifacts whose uploads are still in progress.",
        "responses": {
          "200": {
            "description": "The artifacts.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ArtifactList"
                },
                "example": {
                  "data": [
                    {
                      "id": "artifact_1BbA6sXxyUWHYvKqN5T3dM",
                      "version": "2026_10_0001",
                      "source_tag": "2026_10_0001",
                      "source_state": "MZ4XKH",
                      "status": "published",
                      "files": [
                        {
                          "name": "amp-darwin-arm64.gz",
                          "size": 9416704,
                          "sha256": "4d3c7f2b4f5a9e0e8b1c2d3e4f5a6b7c8d9e0f1a2b3c4d5e6f7a8b9c0d1e2f3a",
                          "content_type": "application/gzip"
                        }
                      ],
                      "url": "https://gauss.motor.dev/motor/amp/artifacts/2026_10_0001",
                      "created_at": "2026-10-22T09:00:00Z",
                      "published_at": "2026-10-22T09:05:00Z"
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "The caller lacks a required repository or team-key scope (`insufficient_scope`), or the account or team is suspended (`suspended`, `account_suspended`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "insufficient_scope",
                    "message": "you need the manage scope of ada/web; ask someone who manages it",
                    "retryable": false
                  }
                }
              }
            }
          },
          "404": {
            "description": "The repository does not exist or is not visible to the caller (`repository_not_found`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "repository_not_found",
                    "message": "no repository ada/web, or it's private to another account",
                    "retryable": false
                  }
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "503": {
            "description": "Gauss or a required service is temporarily unavailable (`motor_unavailable`, `unavailable`, `temporarily_unavailable`). Wait for the retry delay indicated by `Retry-After` or `retry_after_seconds` before retrying.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "temporarily_unavailable",
                    "message": "Gauss can't answer now. Try again in a moment.",
                    "retryable": true,
                    "retry_after_seconds": 1
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "handle",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The handle of the team that owns the repository, including a user’s personal team."
          },
          {
            "name": "repo",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The repository's name."
          }
        ],
        "tags": [
          "Artifacts"
        ]
      }
    },
    "/api/gauss/repos/{handle}/{repo}/artifacts/check": {
      "post": {
        "operationId": "check_publication",
        "summary": "Check a publication",
        "description": "Checks publishing access, version availability, and the source tag’s state without changing the repository. Requires `publish` access. Use this before a build to detect publication problems early.",
        "tags": [
          "Artifacts"
        ],
        "parameters": [
          {
            "name": "handle",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The handle of the team that owns the repository, including a user’s personal team."
          },
          {
            "name": "repo",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The repository's name."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "version": {
                    "type": "string",
                    "description": "The version to check, or leave it out for an automatic one."
                  },
                  "source_tag": {
                    "type": "string",
                    "description": "A tag of the repository, or leave it out."
                  },
                  "source_state": {
                    "type": "string",
                    "description": "The state that `source_tag` must name, or leave it out for any."
                  }
                }
              },
              "example": {
                "source_tag": "2026_10_0001"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Publication checks passed.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "source_state",
                    "artifacts_url"
                  ],
                  "properties": {
                    "source_state": {
                      "type": "string",
                      "description": "Resolved state of `source_tag`, or an empty string if no tag was supplied."
                    },
                    "artifacts_url": {
                      "type": "string",
                      "description": "Repository artifact listing."
                    }
                  }
                },
                "example": {
                  "source_state": "MZ4XKH",
                  "artifacts_url": "https://gauss.motor.dev/motor/amp/artifacts"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "description": "New storage is blocked because the team needs a payment card (`billing_required`) or reached its monthly spending limit (`over_limit`). Existing files remain stored and continue to incur charges.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "billing_required",
                    "message": "the team needs a payment card to store artifacts; add one in Motor's console",
                    "retryable": false
                  }
                }
              }
            }
          },
          "403": {
            "description": "The caller lacks a required repository or team-key scope (`insufficient_scope`), or the account or team is suspended (`suspended`, `account_suspended`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "insufficient_scope",
                    "message": "you need the manage scope of ada/web; ask someone who manages it",
                    "retryable": false
                  }
                }
              }
            }
          },
          "404": {
            "description": "The repository does not exist or is not visible to the caller (`repository_not_found`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "repository_not_found",
                    "message": "no repository ada/web, or it's private to another account",
                    "retryable": false
                  }
                }
              }
            }
          },
          "409": {
            "description": "The version belongs to another source (`version_exists`) or was previously published and deleted. Published versions cannot be reused.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "version_exists",
                    "message": "2026_10_0001 is the version of another source (the tag v1); choose another version",
                    "retryable": false
                  }
                }
              }
            }
          },
          "422": {
            "description": "An invalid version (`invalid_version`) or source (`invalid_source`), a missing tag (`tag_not_found`), or a tag of another state (`tag_mismatch`); or a field of the wrong type, or an unknown one (`invalid_field`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "invalid_version",
                    "message": "a version is 1 to 64 letters, digits, '.', '_', '+' and '-', starting with a letter or a digit, such as 2026_10_0001",
                    "retryable": false
                  }
                }
              }
            }
          },
          "503": {
            "description": "Gauss or a required service is temporarily unavailable (`artifacts_unavailable`, `temporarily_unavailable`). Wait for the retry delay indicated by `Retry-After` or `retry_after_seconds` before retrying.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "temporarily_unavailable",
                    "message": "Gauss can't answer now. Try again in a moment.",
                    "retryable": true,
                    "retry_after_seconds": 1
                  }
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/api/gauss/repos/{handle}/{repo}/artifacts/{version}": {
      "get": {
        "operationId": "get_artifact",
        "summary": "Get an artifact",
        "description": "Returns an artifact and its files. Requires `read` access. Team members can also inspect artifacts whose uploads are still in progress.",
        "responses": {
          "200": {
            "description": "The artifact.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Artifact"
                },
                "example": {
                  "id": "artifact_1BbA6sXxyUWHYvKqN5T3dM",
                  "version": "2026_10_0001",
                  "source_tag": "2026_10_0001",
                  "source_state": "MZ4XKH",
                  "status": "published",
                  "files": [
                    {
                      "name": "amp-darwin-arm64.gz",
                      "size": 9416704,
                      "sha256": "4d3c7f2b4f5a9e0e8b1c2d3e4f5a6b7c8d9e0f1a2b3c4d5e6f7a8b9c0d1e2f3a",
                      "content_type": "application/gzip"
                    }
                  ],
                  "url": "https://gauss.motor.dev/motor/amp/artifacts/2026_10_0001",
                  "created_at": "2026-10-22T09:00:00Z",
                  "published_at": "2026-10-22T09:05:00Z"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "The caller lacks a required repository or team-key scope (`insufficient_scope`), or the account or team is suspended (`suspended`, `account_suspended`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "insufficient_scope",
                    "message": "you need the manage scope of ada/web; ask someone who manages it",
                    "retryable": false
                  }
                }
              }
            }
          },
          "404": {
            "description": "No such repository or artifact (`repository_not_found`, `artifact_not_found`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "repository_not_found",
                    "message": "no repository ada/web, or it's private to another account",
                    "retryable": false
                  }
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "503": {
            "description": "Gauss or a required service is temporarily unavailable (`motor_unavailable`, `unavailable`, `temporarily_unavailable`). Wait for the retry delay indicated by `Retry-After` or `retry_after_seconds` before retrying.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "temporarily_unavailable",
                    "message": "Gauss can't answer now. Try again in a moment.",
                    "retryable": true,
                    "retry_after_seconds": 1
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "handle",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The handle of the team that owns the repository, including a user’s personal team."
          },
          {
            "name": "repo",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The repository's name."
          },
          {
            "name": "version",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The artifact's version, such as 2026_10_0001."
          }
        ],
        "tags": [
          "Artifacts"
        ]
      },
      "delete": {
        "operationId": "delete_artifact",
        "summary": "Delete an artifact",
        "description": "Deletes an artifact’s files and stops their storage charges. Requires `publish` access.\n\nDeleting an unpublished artifact removes its reservation, allowing the version to be reused. Deleting a published artifact retains a `deleted` record and permanently reserves its version. Repository tags are retained. Repeating a deletion of an artifact already marked `deleted` has no effect.",
        "tags": [
          "Artifacts"
        ],
        "responses": {
          "204": {
            "description": "Deleted."
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "The caller lacks a required repository or team-key scope (`insufficient_scope`), or the account or team is suspended (`suspended`, `account_suspended`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "insufficient_scope",
                    "message": "you need the manage scope of ada/web; ask someone who manages it",
                    "retryable": false
                  }
                }
              }
            }
          },
          "404": {
            "description": "No such repository or artifact (`repository_not_found`, `artifact_not_found`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "repository_not_found",
                    "message": "no repository ada/web, or it's private to another account",
                    "retryable": false
                  }
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "503": {
            "description": "Gauss or a required service is temporarily unavailable (`motor_unavailable`, `unavailable`, `temporarily_unavailable`). Wait for the retry delay indicated by `Retry-After` or `retry_after_seconds` before retrying.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "temporarily_unavailable",
                    "message": "Gauss can't answer now. Try again in a moment.",
                    "retryable": true,
                    "retry_after_seconds": 1
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "handle",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The handle of the team that owns the repository, including a user’s personal team."
          },
          {
            "name": "repo",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The repository's name."
          },
          {
            "name": "version",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The artifact's version, such as 2026_10_0001."
          }
        ]
      }
    },
    "/api/gauss/repos/{handle}/{repo}/artifacts/{version}/finalize": {
      "post": {
        "operationId": "finalize_artifact",
        "summary": "Publish an artifact",
        "description": "Publishes an artifact with the specified files. Requires `publish` access. Supply either `files` in a body of at most 16 MiB, or `files_sha256`, a digest of the complete file list.\n\nGauss verifies each uploaded file’s size and digest. Publication makes the artifact visible and immutable. Concurrent finalizations publish only once. Retrying with the same files returns the published artifact; a different file list returns `409`.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "files": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "additionalProperties": false,
                      "required": [
                        "name",
                        "sha256"
                      ],
                      "properties": {
                        "name": {
                          "type": "string"
                        },
                        "sha256": {
                          "type": "string"
                        }
                      }
                    }
                  },
                  "files_sha256": {
                    "type": "string",
                    "description": "Instead of `files`, for any number of files: the SHA-256, in hex, of a line `<name>\\u0000<sha256>\\n` for each file, sorted by name."
                  }
                }
              },
              "example": {
                "files": [
                  {
                    "name": "amp-darwin-arm64.gz",
                    "sha256": "4d3c7f2b"
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The published artifact.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Artifact"
                },
                "example": {
                  "id": "artifact_1BbA6sXxyUWHYvKqN5T3dM",
                  "version": "2026_10_0001",
                  "source_tag": "2026_10_0001",
                  "source_state": "MZ4XKH",
                  "status": "published",
                  "files": [
                    {
                      "name": "amp-darwin-arm64.gz",
                      "size": 9416704,
                      "sha256": "4d3c7f2b4f5a9e0e8b1c2d3e4f5a6b7c8d9e0f1a2b3c4d5e6f7a8b9c0d1e2f3a",
                      "content_type": "application/gzip"
                    }
                  ],
                  "url": "https://gauss.motor.dev/motor/amp/artifacts/2026_10_0001",
                  "created_at": "2026-10-22T09:00:00Z",
                  "published_at": "2026-10-22T09:05:00Z"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "The caller lacks a required repository or team-key scope (`insufficient_scope`), or the account or team is suspended (`suspended`, `account_suspended`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "insufficient_scope",
                    "message": "you need the manage scope of ada/web; ask someone who manages it",
                    "retryable": false
                  }
                }
              }
            }
          },
          "404": {
            "description": "No such repository or artifact (`repository_not_found`, `artifact_not_found`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "repository_not_found",
                    "message": "no repository ada/web, or it's private to another account",
                    "retryable": false
                  }
                }
              }
            }
          },
          "409": {
            "description": "The uploaded files aren't the named ones, or changed during the finalization (`files_mismatch`); a file whose upload the storage doesn't have (`file_not_uploaded`); or the artifact is published with other files (`artifact_published`); or the artifact was deleted (`artifact_deleted`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "files_mismatch",
                    "message": "the artifact's files changed during the finalization; finalize again",
                    "retryable": false
                  }
                }
              }
            }
          },
          "413": {
            "description": "A body larger than 16 MiB (`too_large`): name the files by `files_sha256`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "too_large",
                    "message": "a file is at most 5368709120 bytes, the most that the storage takes in one upload",
                    "retryable": false
                  }
                }
              }
            }
          },
          "422": {
            "description": "No files (`no_files`), or a file listed twice (`duplicate_file`); or a field of the wrong type, or an unknown one (`invalid_field`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "no_files",
                    "message": "list the artifact's files, or give their files_sha256, not both",
                    "retryable": false
                  }
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "503": {
            "description": "Gauss or a required service is temporarily unavailable (`artifacts_unavailable`, `temporarily_unavailable`). Wait for the retry delay indicated by `Retry-After` or `retry_after_seconds` before retrying.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "temporarily_unavailable",
                    "message": "Gauss can't answer now. Try again in a moment.",
                    "retryable": true,
                    "retry_after_seconds": 1
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "handle",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The handle of the team that owns the repository, including a user’s personal team."
          },
          {
            "name": "repo",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The repository's name."
          },
          {
            "name": "version",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The artifact's version, such as 2026_10_0001."
          }
        ],
        "tags": [
          "Artifacts"
        ]
      }
    },
    "/api/gauss/repos/{handle}/{repo}/artifacts/{version}/uploads": {
      "post": {
        "operationId": "create_artifact_upload",
        "summary": "Upload a file of an artifact",
        "description": "Returns a presigned request for uploading a file directly to storage. Requires `publish` access and an unpublished artifact. Storage verifies the file’s size, SHA-256 digest, and content type.\n\nRequesting another upload for the same name replaces its pending upload metadata. If the identical file is already uploaded, `upload` is null and no upload is needed.\n\nEach file can be at most 5 GiB. Storage charges begin when the file reaches storage.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "name",
                  "size",
                  "sha256"
                ],
                "properties": {
                  "name": {
                    "type": "string",
                    "description": "File name: 1–128 letters, digits, periods, underscores, plus signs, or hyphens. `manifest.json` and `index.json` are reserved."
                  },
                  "size": {
                    "type": "integer",
                    "format": "int64",
                    "description": "The file's size, in bytes."
                  },
                  "sha256": {
                    "type": "string",
                    "description": "The file's SHA-256, in hex."
                  },
                  "content_type": {
                    "type": "string",
                    "description": "File media type. Defaults to `application/octet-stream`."
                  }
                }
              },
              "example": {
                "name": "amp-darwin-arm64.tar.gz",
                "size": 18874368,
                "sha256": "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08",
                "content_type": "application/gzip"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "File metadata and presigned upload request.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Upload"
                },
                "example": {
                  "name": "amp-darwin-arm64.gz",
                  "size": 9416704,
                  "sha256": "4d3c7f2b4f5a9e0e8b1c2d3e4f5a6b7c8d9e0f1a2b3c4d5e6f7a8b9c0d1e2f3a",
                  "content_type": "application/gzip",
                  "upload": {
                    "url": "https://gauss-artifacts.s3.us-east-1.amazonaws.com/artifacts/…?X-Amz-Signature=…",
                    "method": "PUT",
                    "headers": {
                      "Content-Length": "9416704",
                      "Content-Type": "application/gzip",
                      "If-None-Match": "*",
                      "X-Amz-Checksum-Sha256": "TTx/K09anu..."
                    },
                    "expires_at": "2026-10-22T09:15:00Z"
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "description": "New storage is blocked because the team needs a payment card (`billing_required`) or reached its monthly spending limit (`over_limit`). Existing files remain stored and continue to incur charges.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "billing_required",
                    "message": "the team needs a payment card to store artifacts; add one in Motor's console",
                    "retryable": false
                  }
                }
              }
            }
          },
          "403": {
            "description": "The caller lacks a required repository or team-key scope (`insufficient_scope`), or the account or team is suspended (`suspended`, `account_suspended`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "insufficient_scope",
                    "message": "you need the manage scope of ada/web; ask someone who manages it",
                    "retryable": false
                  }
                }
              }
            }
          },
          "404": {
            "description": "No such repository or artifact (`repository_not_found`, `artifact_not_found`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "repository_not_found",
                    "message": "no repository ada/web, or it's private to another account",
                    "retryable": false
                  }
                }
              }
            }
          },
          "409": {
            "description": "The artifact is published, and doesn't change (`artifact_published`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "artifact_published",
                    "message": "2026_10_0001 is published, and doesn't change",
                    "retryable": false
                  }
                }
              }
            }
          },
          "413": {
            "description": "A file larger than one upload takes (`too_large`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "too_large",
                    "message": "a file is at most 5368709120 bytes, the most that the storage takes in one upload",
                    "retryable": false
                  }
                }
              }
            }
          },
          "422": {
            "description": "An invalid name, digest, size or content type (`invalid_file_name`, `invalid_sha256`, `invalid_size`, `invalid_content_type`); or a field of the wrong type, or an unknown one (`invalid_field`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "invalid_file_name",
                    "message": "a file's name is 1 to 128 letters, digits, '.', '_', '+' and '-', starting with a letter or a digit, without '..', and not manifest.json or index.json",
                    "retryable": false
                  }
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "503": {
            "description": "Gauss or a required service is temporarily unavailable (`artifacts_unavailable`, `temporarily_unavailable`). Wait for the retry delay indicated by `Retry-After` or `retry_after_seconds` before retrying.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "temporarily_unavailable",
                    "message": "Gauss can't answer now. Try again in a moment.",
                    "retryable": true,
                    "retry_after_seconds": 1
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "handle",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The handle of the team that owns the repository, including a user’s personal team."
          },
          {
            "name": "repo",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The repository's name."
          },
          {
            "name": "version",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The artifact's version, such as 2026_10_0001."
          }
        ],
        "tags": [
          "Artifacts"
        ]
      }
    },
    "/api/gauss/repos/{handle}/{repo}/access": {
      "get": {
        "operationId": "get_repository_access",
        "summary": "Show a repository's access",
        "description": "Returns default team scopes, admin scopes, and explicit user grants, including each user’s effective scopes and their sources. Requires `manage` access.",
        "responses": {
          "200": {
            "description": "The repository's access.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Access"
                },
                "example": {
                  "repository_id": "repo_1BbA6sXxyUWHYvKqN5T3dM",
                  "handle": "lighthouse",
                  "repository": "web",
                  "team_scopes": [
                    "read"
                  ],
                  "admin_scopes": [
                    "read",
                    "write",
                    "publish",
                    "manage"
                  ],
                  "grants": [
                    {
                      "user_id": "user_1BbA6sXxyUWHYvKqN5T3dN",
                      "scopes": [
                        "manage"
                      ],
                      "granted_by": "user_1BbA6sXxyUWHYvKqN5T3dN",
                      "updated_at": "2026-10-22T09:00:00Z",
                      "active": true,
                      "effective_scopes": [
                        "read",
                        "write",
                        "publish",
                        "manage"
                      ],
                      "sources": [
                        "grant",
                        "team"
                      ]
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "The caller lacks `manage` access (`insufficient_scope`), used a team key (`device_credential_required`), or belongs to a suspended team (`suspended`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "insufficient_scope",
                    "message": "you need the manage scope of ada/web; ask someone who manages it",
                    "retryable": false
                  }
                }
              }
            }
          },
          "404": {
            "description": "The repository does not exist or is not visible to the caller (`repository_not_found`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "repository_not_found",
                    "message": "no repository ada/web, or it's private to another account",
                    "retryable": false
                  }
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "503": {
            "description": "Gauss or a required service is temporarily unavailable (`motor_unavailable`, `unavailable`, `temporarily_unavailable`). Wait for the retry delay indicated by `Retry-After` or `retry_after_seconds` before retrying.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "temporarily_unavailable",
                    "message": "Gauss can't answer now. Try again in a moment.",
                    "retryable": true,
                    "retry_after_seconds": 1
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "handle",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The handle of the team that owns the repository, including a user’s personal team."
          },
          {
            "name": "repo",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The repository's name."
          }
        ],
        "tags": [
          "Access"
        ]
      }
    },
    "/api/gauss/repos/{handle}/{repo}/access/team": {
      "put": {
        "operationId": "set_repository_team_access",
        "summary": "Set the team's scopes",
        "description": "Replaces the repository’s default team scopes and returns the updated access configuration. Requires `manage` access. Changes apply immediately; explicit user grants remain unchanged. An empty `scopes` array removes all default team scopes. Emits `gauss.repository.access_changed`.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "scopes"
                ],
                "properties": {
                  "scopes": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "enum": [
                        "read",
                        "write",
                        "publish",
                        "manage"
                      ]
                    },
                    "description": "The complete replacement set of scopes. An empty array removes all scopes in this set."
                  }
                }
              },
              "example": {
                "scopes": [
                  "read",
                  "write"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The repository's access.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Access"
                },
                "example": {
                  "repository_id": "repo_1BbA6sXxyUWHYvKqN5T3dM",
                  "handle": "lighthouse",
                  "repository": "web",
                  "team_scopes": [
                    "read"
                  ],
                  "admin_scopes": [
                    "read",
                    "write",
                    "publish",
                    "manage"
                  ],
                  "grants": [
                    {
                      "user_id": "user_1BbA6sXxyUWHYvKqN5T3dN",
                      "scopes": [
                        "manage"
                      ],
                      "granted_by": "user_1BbA6sXxyUWHYvKqN5T3dN",
                      "updated_at": "2026-10-22T09:00:00Z",
                      "active": true,
                      "effective_scopes": [
                        "read",
                        "write",
                        "publish",
                        "manage"
                      ],
                      "sources": [
                        "grant",
                        "team"
                      ]
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "The caller lacks `manage` access (`insufficient_scope`), used a team key (`device_credential_required`), or belongs to a suspended team (`suspended`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "insufficient_scope",
                    "message": "you need the manage scope of ada/web; ask someone who manages it",
                    "retryable": false
                  }
                }
              }
            }
          },
          "404": {
            "description": "The repository does not exist or is not visible to the caller (`repository_not_found`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "repository_not_found",
                    "message": "no repository ada/web, or it's private to another account",
                    "retryable": false
                  }
                }
              }
            }
          },
          "413": {
            "$ref": "#/components/responses/TooLarge"
          },
          "422": {
            "description": "An unknown scope, or no `scopes` (`invalid_scope`); or a field of the wrong type, or an unknown one (`invalid_field`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "invalid_scope",
                    "message": "\"own\" is no scope; the scopes are read, write, publish, and manage",
                    "retryable": false
                  }
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "503": {
            "description": "Gauss or a required service is temporarily unavailable (`motor_unavailable`, `unavailable`, `temporarily_unavailable`). Wait for the retry delay indicated by `Retry-After` or `retry_after_seconds` before retrying.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "temporarily_unavailable",
                    "message": "Gauss can't answer now. Try again in a moment.",
                    "retryable": true,
                    "retry_after_seconds": 1
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "handle",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The handle of the team that owns the repository, including a user’s personal team."
          },
          {
            "name": "repo",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The repository's name."
          }
        ],
        "tags": [
          "Access"
        ]
      }
    },
    "/api/gauss/repos/{handle}/{repo}/access/users/{user_id}": {
      "put": {
        "operationId": "set_repository_user_access",
        "summary": "Set a member's grant",
        "description": "Replaces a member’s explicit repository scopes and returns the updated access configuration. Requires `manage` access. The user must currently belong to the repository’s team.\n\nAn empty `scopes` array removes the explicit grant; access from team defaults or an admin role remains. The grant expires if the user leaves the team and is not restored if they rejoin. Changes apply immediately and emit `gauss.repository.access_changed`.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "scopes"
                ],
                "properties": {
                  "scopes": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "enum": [
                        "read",
                        "write",
                        "publish",
                        "manage"
                      ]
                    },
                    "description": "The complete replacement set of scopes. An empty array removes all scopes in this set."
                  }
                }
              },
              "example": {
                "scopes": [
                  "read",
                  "write"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The repository's access.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Access"
                },
                "example": {
                  "repository_id": "repo_1BbA6sXxyUWHYvKqN5T3dM",
                  "handle": "lighthouse",
                  "repository": "web",
                  "team_scopes": [
                    "read"
                  ],
                  "admin_scopes": [
                    "read",
                    "write",
                    "publish",
                    "manage"
                  ],
                  "grants": [
                    {
                      "user_id": "user_1BbA6sXxyUWHYvKqN5T3dN",
                      "scopes": [
                        "manage"
                      ],
                      "granted_by": "user_1BbA6sXxyUWHYvKqN5T3dN",
                      "updated_at": "2026-10-22T09:00:00Z",
                      "active": true,
                      "effective_scopes": [
                        "read",
                        "write",
                        "publish",
                        "manage"
                      ],
                      "sources": [
                        "grant",
                        "team"
                      ]
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "The caller lacks `manage` access (`insufficient_scope`), used a team key (`device_credential_required`), or belongs to a suspended team (`suspended`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "insufficient_scope",
                    "message": "you need the manage scope of ada/web; ask someone who manages it",
                    "retryable": false
                  }
                }
              }
            }
          },
          "404": {
            "description": "The repository does not exist or is not visible to the caller (`repository_not_found`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "repository_not_found",
                    "message": "no repository ada/web, or it's private to another account",
                    "retryable": false
                  }
                }
              }
            }
          },
          "413": {
            "$ref": "#/components/responses/TooLarge"
          },
          "422": {
            "description": "An unknown scope, or no `scopes` (`invalid_scope`), or a user who isn't a member of the repository's team (`not_a_member`); or a field of the wrong type, or an unknown one (`invalid_field`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "invalid_scope",
                    "message": "\"own\" is no scope; the scopes are read, write, publish, and manage",
                    "retryable": false
                  }
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "503": {
            "description": "Gauss or a required service is temporarily unavailable (`motor_unavailable`, `unavailable`, `temporarily_unavailable`). Wait for the retry delay indicated by `Retry-After` or `retry_after_seconds` before retrying.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "temporarily_unavailable",
                    "message": "Gauss can't answer now. Try again in a moment.",
                    "retryable": true,
                    "retry_after_seconds": 1
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "handle",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The handle of the team that owns the repository, including a user’s personal team."
          },
          {
            "name": "repo",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The repository's name."
          },
          {
            "name": "user_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The Motor user's ID, `user_…`."
          }
        ],
        "tags": [
          "Access"
        ]
      }
    },
    "/api/gauss/repos/{handle}/{repo}/hooks": {
      "get": {
        "operationId": "list_hooks",
        "summary": "List the hooks of a state",
        "description": "Returns the hooks that a state of the repository declares in `.gauss/hooks.star`, with `read`: the state of `channel`, of `tag`, or `state`, or, without any of them, the main channel's, which `evaluation.selected_by` says. A hook runs when an event that it subscribes to happens and matches its filters; each event runs the hooks of its own state (see the events). Nothing registers hooks: changing the file changes them. An `invalid` file declares no hooks, and its `diagnostics` say why; so does one whose evaluation exceeded a limit of Starlark, such as its steps (`limit_exceeded`). The hooks come a page at a time, in the order of their declarations; the pages after the first are of the first page's state, whatever the channel or the tag does meanwhile.",
        "tags": [
          "Hooks"
        ],
        "parameters": [
          {
            "name": "handle",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The handle of the repository's account: a user, for their personal account, or a team."
          },
          {
            "name": "repo",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The repository's name."
          },
          {
            "name": "state",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "An exact state of the repository."
          },
          {
            "name": "channel",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "A channel, whose current state counts."
          },
          {
            "name": "tag",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "A tag, whose state counts."
          },
          {
            "name": "event",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "channel.updated",
                "tag.created",
                "merge.candidate_updated",
                "schedule"
              ]
            },
            "description": "Only the hooks that subscribe to this event."
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 500
            },
            "description": "At most this many. Default: 100."
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "The `next_cursor` of the last page."
          }
        ],
        "responses": {
          "200": {
            "description": "The hooks.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HookList"
                },
                "example": {
                  "evaluation": {
                    "selected_by": "default_channel",
                    "selected_name": "main",
                    "state": "QW3YPL…",
                    "path": ".gauss/hooks.star",
                    "status": "valid",
                    "version": 1,
                    "digest": "sha256:9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08",
                    "diagnostics": []
                  },
                  "hooks": [
                    {
                      "name": "deploy_staging",
                      "events": [
                        "channel.updated"
                      ],
                      "channels": [
                        "main"
                      ],
                      "tags": [],
                      "action": {
                        "type": "piston",
                        "piston": {
                          "config": "piston.star",
                          "targets": [
                            "deploy_staging"
                          ],
                          "inputs": {},
                          "profile": "staging"
                        }
                      },
                      "location": {
                        "file": ".gauss/hooks.star",
                        "line": 2,
                        "column": 5
                      },
                      "check": "",
                      "schedules": [],
                      "paths": [],
                      "paths_ignore": []
                    }
                  ],
                  "next_cursor": null
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "A scope of the repository that the caller doesn't have, or a team key without the scope (`insufficient_scope`), or a suspended team (`suspended`, `account_suspended`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "insufficient_scope",
                    "message": "you need the manage scope of ada/web; ask someone who manages it",
                    "retryable": false
                  }
                }
              }
            }
          },
          "404": {
            "description": "No such repository, or a private one of another account (`repository_not_found`); no such channel, tag or state (`channel_not_found`, `tag_not_found`, `state_not_found`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "channel_not_found",
                    "message": "the repository has no channel \"dev\"",
                    "retryable": false
                  }
                }
              }
            }
          },
          "422": {
            "description": "More than one of `state`, `channel` and `tag` (`invalid_selector`), a `state` that isn't one (`invalid_state`), an event that hooks can't subscribe to (`invalid_event`), or an invalid limit or cursor (`invalid_limit`, `invalid_cursor`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "invalid_selector",
                    "message": "name one of state, channel and tag",
                    "retryable": false
                  }
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "503": {
            "description": "Motor, the database, or the engine is unavailable for a moment (`motor_unavailable`, `unavailable`). Retry after Retry-After, or Gauss can't answer now (`temporarily_unavailable`). Retry after `retry_after_seconds`, with the same Idempotency-Key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "temporarily_unavailable",
                    "message": "Gauss can't answer now. Try again in a moment.",
                    "retryable": true,
                    "retry_after_seconds": 1
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/gauss/repos/{handle}/{repo}/hooks/{hook}": {
      "get": {
        "operationId": "get_hook",
        "summary": "Get a hook of a state",
        "description": "Returns a hook that a state declares, chosen as for listing hooks, with `read`, and where it's declared.",
        "tags": [
          "Hooks"
        ],
        "parameters": [
          {
            "name": "handle",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The handle of the repository's account: a user, for their personal account, or a team."
          },
          {
            "name": "repo",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The repository's name."
          },
          {
            "name": "hook",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The hook's name."
          },
          {
            "name": "state",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "An exact state of the repository."
          },
          {
            "name": "channel",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "A channel, whose current state counts."
          },
          {
            "name": "tag",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "A tag, whose state counts."
          }
        ],
        "responses": {
          "200": {
            "description": "The hook.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HookDetail"
                },
                "example": {
                  "evaluation": {
                    "selected_by": "default_channel",
                    "selected_name": "main",
                    "state": "QW3YPL…",
                    "path": ".gauss/hooks.star",
                    "status": "valid",
                    "version": 1,
                    "digest": "sha256:9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08",
                    "diagnostics": []
                  },
                  "hook": {
                    "name": "deploy_staging",
                    "events": [
                      "channel.updated"
                    ],
                    "channels": [
                      "main"
                    ],
                    "tags": [],
                    "action": {
                      "type": "piston",
                      "piston": {
                        "config": "piston.star",
                        "targets": [
                          "deploy_staging"
                        ],
                        "inputs": {},
                        "profile": "staging"
                      }
                    },
                    "location": {
                      "file": ".gauss/hooks.star",
                      "line": 2,
                      "column": 5
                    },
                    "check": "",
                    "schedules": [],
                    "paths": [],
                    "paths_ignore": []
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "A scope of the repository that the caller doesn't have, or a team key without the scope (`insufficient_scope`), or a suspended team (`suspended`, `account_suspended`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "insufficient_scope",
                    "message": "you need the manage scope of ada/web; ask someone who manages it",
                    "retryable": false
                  }
                }
              }
            }
          },
          "404": {
            "description": "No such repository, channel, tag or state, as for listing hooks, or the state declares no such hook (`hook_not_found`), which the message explains, such as a state without `.gauss/hooks.star`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "hook_not_found",
                    "message": "the state QW3YPL… declares no hook \"deploy\"",
                    "retryable": false
                  }
                }
              }
            }
          },
          "422": {
            "description": "More than one of `state`, `channel` and `tag` (`invalid_selector`), a `state` that isn't one (`invalid_state`), or an event that hooks can't subscribe to (`invalid_event`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "invalid_selector",
                    "message": "name one of state, channel and tag",
                    "retryable": false
                  }
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "503": {
            "description": "Motor, the database, or the engine is unavailable for a moment (`motor_unavailable`, `unavailable`). Retry after Retry-After, or Gauss can't answer now (`temporarily_unavailable`). Retry after `retry_after_seconds`, with the same Idempotency-Key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "temporarily_unavailable",
                    "message": "Gauss can't answer now. Try again in a moment.",
                    "retryable": true,
                    "retry_after_seconds": 1
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/gauss/repos/{handle}/{repo}/hooks/validate": {
      "post": {
        "operationId": "validate_hooks",
        "summary": "Validate hooks",
        "description": "Evaluates the hooks of a state, chosen as for listing hooks, or of proposed files of `.gauss/` (`files`), with `read`, and matches them against a sample `event`. It runs nothing, and installs nothing: proposed files count only when a change records them and reaches the repository. Use it to check `.gauss/hooks.star` before pushing it.",
        "tags": [
          "Hooks"
        ],
        "parameters": [
          {
            "name": "handle",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The handle of the repository's account: a user, for their personal account, or a team."
          },
          {
            "name": "repo",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The repository's name."
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "state": {
                    "type": "string",
                    "description": "An exact state."
                  },
                  "channel": {
                    "type": "string",
                    "description": "A channel, whose current state counts."
                  },
                  "tag": {
                    "type": "string",
                    "description": "A tag, whose state counts."
                  },
                  "files": {
                    "type": "object",
                    "description": "Proposed files of `.gauss/`, by their paths from the repository's root, such as `.gauss/hooks.star`, instead of a state's: at most 100.",
                    "additionalProperties": {
                      "type": "string"
                    }
                  },
                  "event": {
                    "type": "object",
                    "description": "A sample event to match the hooks against: its type, and its channel or its tag, or a `schedule`'s channel and cron expression.",
                    "additionalProperties": false,
                    "required": [
                      "type"
                    ],
                    "properties": {
                      "type": {
                        "type": "string",
                        "enum": [
                          "channel.updated",
                          "tag.created",
                          "merge.candidate_updated",
                          "schedule"
                        ]
                      },
                      "channel": {
                        "type": "string"
                      },
                      "tag": {
                        "type": "string"
                      },
                      "schedule": {
                        "type": "string",
                        "description": "The cron expression of a `schedule` event, such as `0 6 * * *`."
                      },
                      "changed_paths": {
                        "type": "object",
                        "description": "The paths that a sample `channel.updated` or `merge.candidate_updated` changed, for the hooks' path filters: at most 1,000. An object with no `paths` is an event that changed no path. Without it, path filters don't apply, and the hooks that have them match with `paths` `bypassed`.",
                        "additionalProperties": false,
                        "properties": {
                          "paths": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          }
                        }
                      }
                    }
                  }
                }
              },
              "example": {
                "files": {
                  ".gauss/hooks.star": "hook(\n    name = \"deploy_staging\",\n    events = [\"channel.updated\"],\n    channels = [\"main\"],\n    action = piston(config = \"piston.star\", targets = [\"deploy_staging\"], profile = \"staging\"),\n)\n"
                },
                "event": {
                  "type": "channel.updated",
                  "channel": "main"
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The evaluation: `evaluation.status` is `invalid`, with diagnostics, for files with problems.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HookValidation"
                },
                "example": {
                  "evaluation": {
                    "selected_by": "files",
                    "selected_name": "",
                    "state": "",
                    "path": ".gauss/hooks.star",
                    "status": "valid",
                    "version": 1,
                    "digest": "sha256:9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08",
                    "diagnostics": []
                  },
                  "hooks": [
                    {
                      "name": "deploy_staging",
                      "events": [
                        "channel.updated"
                      ],
                      "channels": [
                        "main"
                      ],
                      "tags": [],
                      "action": {
                        "type": "piston",
                        "piston": {
                          "config": "piston.star",
                          "targets": [
                            "deploy_staging"
                          ],
                          "inputs": {},
                          "profile": "staging"
                        }
                      },
                      "location": {
                        "file": ".gauss/hooks.star",
                        "line": 2,
                        "column": 5
                      },
                      "check": "",
                      "schedules": [],
                      "paths": [],
                      "paths_ignore": []
                    }
                  ],
                  "matches": [
                    {
                      "hook": {
                        "name": "deploy_staging",
                        "events": [
                          "channel.updated"
                        ],
                        "channels": [
                          "main"
                        ],
                        "tags": [],
                        "action": {
                          "type": "piston",
                          "piston": {
                            "config": "piston.star",
                            "targets": [
                              "deploy_staging"
                            ],
                            "inputs": {},
                            "profile": "staging"
                          }
                        },
                        "location": {
                          "file": ".gauss/hooks.star",
                          "line": 2,
                          "column": 5
                        },
                        "check": "",
                        "schedules": [],
                        "paths": [],
                        "paths_ignore": []
                      },
                      "matched": true,
                      "reason": "",
                      "paths": "",
                      "path": "",
                      "paths_detail": ""
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "A scope of the repository that the caller doesn't have, or a team key without the scope (`insufficient_scope`), or a suspended team (`suspended`, `account_suspended`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "insufficient_scope",
                    "message": "you need the manage scope of ada/web; ask someone who manages it",
                    "retryable": false
                  }
                }
              }
            }
          },
          "404": {
            "description": "No such repository, or a private one of another account (`repository_not_found`); no such channel, tag or state (`channel_not_found`, `tag_not_found`, `state_not_found`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "channel_not_found",
                    "message": "the repository has no channel \"dev\"",
                    "retryable": false
                  }
                }
              }
            }
          },
          "422": {
            "description": "Both files and a state, more than one of `state`, `channel` and `tag` (`invalid_selector`), a `state` that isn't one (`invalid_state`), a file outside `.gauss/` or too many (`invalid_files`), or a sample event without its channel or tag (`invalid_event`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "invalid_files",
                    "message": "\"piston.star\" isn't a path of .gauss/, from the repository's root, such as \".gauss/hooks.star\"",
                    "retryable": false
                  }
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "503": {
            "description": "Motor, the database, or the engine is unavailable for a moment (`motor_unavailable`, `unavailable`). Retry after Retry-After, or Gauss can't answer now (`temporarily_unavailable`). Retry after `retry_after_seconds`, with the same Idempotency-Key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "temporarily_unavailable",
                    "message": "Gauss can't answer now. Try again in a moment.",
                    "retryable": true,
                    "retry_after_seconds": 1
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/gauss/repos/{handle}/{repo}/events": {
      "get": {
        "operationId": "list_repository_events",
        "summary": "List a repository's events",
        "description": "Returns a repository's events, newest first, with `read`: each push that added changes to a channel (`channel.updated`), each tag that a push made (`tag.created`), and each time of a schedule of a channel's head (`schedule`). Gauss records an event within seconds, with the state whose hooks it runs (`hook_state`), and then finds those hooks (`discovery`).",
        "tags": [
          "Events"
        ],
        "parameters": [
          {
            "name": "handle",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The handle of the repository's account: a user, for their personal account, or a team."
          },
          {
            "name": "repo",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The repository's name."
          },
          {
            "name": "type",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "channel.updated",
                "tag.created",
                "merge.candidate_updated",
                "schedule"
              ]
            },
            "description": "Only events of this type."
          },
          {
            "name": "channel",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Only events of this channel."
          },
          {
            "name": "tag",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Only events of this tag."
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 500
            },
            "description": "At most this many. Default: 50."
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "The `next_cursor` of the last page."
          }
        ],
        "responses": {
          "200": {
            "description": "A page of events.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RepositoryEventPage"
                },
                "example": {
                  "data": [
                    {
                      "id": "event_1BbA6sXxyUWHYvKqN5T3dM",
                      "repository_id": "repo_1BbA6sXxyUWHYvKqN5T3dM",
                      "handle": "ada",
                      "repository": "web",
                      "type": "channel.updated",
                      "channel": "main",
                      "tag": "",
                      "before": "MZ4XKH…",
                      "after": "QW3YPL…",
                      "hook_state": "QW3YPL…",
                      "uploader": "Ada Lovelace (user_1BbA6sXxyUWHYvKqN5T3dM)",
                      "summary": "",
                      "change_count": 1,
                      "silent": false,
                      "occurred_at": "2026-10-22T09:00:00Z",
                      "recorded_at": "2026-10-22T09:00:01Z",
                      "discovery": {
                        "status": "done",
                        "error": "",
                        "attempts": 0,
                        "discovered_at": "2026-10-22T09:00:02Z"
                      },
                      "actor": {
                        "kind": "user",
                        "id": "user_1BbA6sXxyUWHYvKqN5T3dM",
                        "name": "Ada Lovelace"
                      },
                      "causation": {
                        "root_event_id": "event_1BbA6sXxyUWHYvKqN5T3dM",
                        "parent_invocation_id": "",
                        "depth": 0
                      },
                      "merge_id": "",
                      "merge_generation": 0,
                      "schedule": ""
                    }
                  ],
                  "next_cursor": null
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "A scope of the repository that the caller doesn't have, or a team key without the scope (`insufficient_scope`), or a suspended team (`suspended`, `account_suspended`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "insufficient_scope",
                    "message": "you need the manage scope of ada/web; ask someone who manages it",
                    "retryable": false
                  }
                }
              }
            }
          },
          "404": {
            "description": "No such repository, or a private one of another account (`repository_not_found`): Gauss doesn't tell them apart.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "repository_not_found",
                    "message": "no repository ada/web, or it's private to another account",
                    "retryable": false
                  }
                }
              }
            }
          },
          "422": {
            "description": "An invalid limit or cursor (`invalid_limit`, `invalid_cursor`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "invalid_cursor",
                    "message": "use the next_cursor of the last page",
                    "retryable": false
                  }
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "503": {
            "description": "Motor, the database, or the engine is unavailable for a moment (`motor_unavailable`, `unavailable`). Retry after Retry-After, or Gauss can't answer now (`temporarily_unavailable`). Retry after `retry_after_seconds`, with the same Idempotency-Key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "temporarily_unavailable",
                    "message": "Gauss can't answer now. Try again in a moment.",
                    "retryable": true,
                    "retry_after_seconds": 1
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/gauss/repos/{handle}/{repo}/events/{event_id}": {
      "get": {
        "operationId": "get_repository_event",
        "summary": "Get an event",
        "description": "Returns an event, with `read`, and each hook of its hook state with whether it matches the event: the matching hooks are what the event runs. They stay what they were, whatever later changes do to `.gauss/hooks.star`. Before discovery is done, `evaluation` is null and `matches` empty.",
        "tags": [
          "Events"
        ],
        "parameters": [
          {
            "name": "handle",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The handle of the repository's account: a user, for their personal account, or a team."
          },
          {
            "name": "repo",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The repository's name."
          },
          {
            "name": "event_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The event's ID."
          }
        ],
        "responses": {
          "200": {
            "description": "The event.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RepositoryEventDetail"
                },
                "example": {
                  "event": {
                    "id": "event_1BbA6sXxyUWHYvKqN5T3dM",
                    "repository_id": "repo_1BbA6sXxyUWHYvKqN5T3dM",
                    "handle": "ada",
                    "repository": "web",
                    "type": "channel.updated",
                    "channel": "main",
                    "tag": "",
                    "before": "MZ4XKH…",
                    "after": "QW3YPL…",
                    "hook_state": "QW3YPL…",
                    "uploader": "Ada Lovelace (user_1BbA6sXxyUWHYvKqN5T3dM)",
                    "summary": "",
                    "change_count": 1,
                    "silent": false,
                    "occurred_at": "2026-10-22T09:00:00Z",
                    "recorded_at": "2026-10-22T09:00:01Z",
                    "discovery": {
                      "status": "done",
                      "error": "",
                      "attempts": 0,
                      "discovered_at": "2026-10-22T09:00:02Z"
                    },
                    "actor": {
                      "kind": "user",
                      "id": "user_1BbA6sXxyUWHYvKqN5T3dM",
                      "name": "Ada Lovelace"
                    },
                    "causation": {
                      "root_event_id": "event_1BbA6sXxyUWHYvKqN5T3dM",
                      "parent_invocation_id": "",
                      "depth": 0
                    },
                    "merge_id": "",
                    "merge_generation": 0,
                    "schedule": ""
                  },
                  "invocations": [
                    {
                      "id": "inv_1BbA6sXxyUWHYvKqN5T3dM",
                      "repository_id": "repo_1BbA6sXxyUWHYvKqN5T3dM",
                      "handle": "ada",
                      "repository": "web",
                      "hook": "deploy_staging",
                      "hook_state": "QW3YPL…",
                      "hook_version": 1,
                      "event_id": "event_1BbA6sXxyUWHYvKqN5T3dM",
                      "trigger": "event",
                      "source_state": "QW3YPL…",
                      "action": {
                        "type": "piston",
                        "piston": {
                          "config": "piston.star",
                          "targets": [
                            "deploy_staging"
                          ],
                          "inputs": {
                            "env": "staging"
                          },
                          "profile": "staging"
                        }
                      },
                      "actor": {
                        "kind": "user",
                        "id": "user_1BbA6sXxyUWHYvKqN5T3dM",
                        "name": "Ada Lovelace"
                      },
                      "runs_as": {
                        "kind": "automation",
                        "id": "repo_1BbA6sXxyUWHYvKqN5T3dM",
                        "name": "ada/web hooks"
                      },
                      "status": "completed",
                      "conclusion": "passed",
                      "suppression": "",
                      "suppression_detail": "",
                      "causation": {
                        "root_event_id": "event_1BbA6sXxyUWHYvKqN5T3dM",
                        "parent_invocation_id": "",
                        "depth": 0
                      },
                      "created_at": "2026-10-22T09:00:02Z",
                      "updated_at": "2026-10-22T09:03:00Z",
                      "attempts": [
                        {
                          "number": 1,
                          "run_id": "run_1BbA6sXxyUWHYvKqN5T3dM",
                          "status": "completed",
                          "conclusion": "passed",
                          "failure_origin": "",
                          "error": "",
                          "created_at": "2026-10-22T09:00:02Z",
                          "started_at": "2026-10-22T09:00:05Z",
                          "finished_at": "2026-10-22T09:03:00Z",
                          "requested_by": {
                            "kind": "user",
                            "id": "user_1BbA6sXxyUWHYvKqN5T3dM",
                            "name": "Ada Lovelace"
                          },
                          "context": null
                        }
                      ],
                      "check": ""
                    }
                  ],
                  "evaluation": {
                    "selected_by": "event",
                    "selected_name": "event_1BbA6sXxyUWHYvKqN5T3dM",
                    "state": "QW3YPL…",
                    "path": ".gauss/hooks.star",
                    "status": "valid",
                    "version": 1,
                    "digest": "sha256:9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08",
                    "diagnostics": []
                  },
                  "matches": [
                    {
                      "hook": {
                        "name": "deploy_staging",
                        "events": [
                          "channel.updated"
                        ],
                        "channels": [
                          "main"
                        ],
                        "tags": [],
                        "action": {
                          "type": "piston",
                          "piston": {
                            "config": "piston.star",
                            "targets": [
                              "deploy_staging"
                            ],
                            "inputs": {},
                            "profile": "staging"
                          }
                        },
                        "location": {
                          "file": ".gauss/hooks.star",
                          "line": 2,
                          "column": 5
                        },
                        "check": "",
                        "schedules": [],
                        "paths": [],
                        "paths_ignore": []
                      },
                      "matched": true,
                      "reason": "",
                      "paths": "",
                      "path": "",
                      "paths_detail": ""
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "A scope of the repository that the caller doesn't have, or a team key without the scope (`insufficient_scope`), or a suspended team (`suspended`, `account_suspended`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "insufficient_scope",
                    "message": "you need the manage scope of ada/web; ask someone who manages it",
                    "retryable": false
                  }
                }
              }
            }
          },
          "404": {
            "description": "No such repository or event (`repository_not_found`, `event_not_found`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "event_not_found",
                    "message": "the repository has no event \"event_1BbA6sXxyUWHYvKqN5T3dM\"",
                    "retryable": false
                  }
                }
              }
            }
          },
          "422": {
            "description": "An invalid request.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "invalid_event",
                    "message": "the event is invalid",
                    "retryable": false
                  }
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "503": {
            "description": "Motor, the database, or the engine is unavailable for a moment (`motor_unavailable`, `unavailable`). Retry after Retry-After, or Gauss can't answer now (`temporarily_unavailable`). Retry after `retry_after_seconds`, with the same Idempotency-Key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "temporarily_unavailable",
                    "message": "Gauss can't answer now. Try again in a moment.",
                    "retryable": true,
                    "retry_after_seconds": 1
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/gauss/repos/{handle}/{repo}/events/{event_id}/changes": {
      "get": {
        "operationId": "list_repository_event_changes",
        "summary": "List an event's changes",
        "description": "Returns a page of the changes of a `channel.updated` event, with `read`, in the order that the update applied them. The list is the update's whole only once `complete` is true: until then, Gauss is still recording it, and the last page isn't the end. The event's preview, such as the changes in `gauss.channel.updated`'s data, is never the complete list. Follow `next_page_token` until it's empty.",
        "tags": [
          "Events"
        ],
        "parameters": [
          {
            "name": "handle",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The handle of the repository's account: a user, for their personal account, or a team."
          },
          {
            "name": "repo",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The repository's name."
          },
          {
            "name": "event_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The event's ID."
          },
          {
            "name": "page_token",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "The `next_page_token` of the page before; omit it for the first page."
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 1000,
              "default": 500
            },
            "description": "The most changes of the page."
          }
        ],
        "responses": {
          "200": {
            "description": "A page of the changes.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RepositoryEventChanges"
                },
                "example": {
                  "changes": [
                    "FJ3K…",
                    "P8QZ…"
                  ],
                  "next_page_token": "MQ",
                  "complete": true,
                  "change_count": 3
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "A scope of the repository that the caller doesn't have, or a team key without the scope (`insufficient_scope`), or a suspended team (`suspended`, `account_suspended`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "insufficient_scope",
                    "message": "you need the read scope of ada/web; ask someone who manages it",
                    "retryable": false
                  }
                }
              }
            }
          },
          "404": {
            "description": "No such repository or event (`repository_not_found`, `event_not_found`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "event_not_found",
                    "message": "the repository has no event \"event_1BbA6sXxyUWHYvKqN5T3dM\"",
                    "retryable": false
                  }
                }
              }
            }
          },
          "422": {
            "description": "A page token that isn't a `next_page_token` (`invalid_page_token`), or a limit that isn't 1 to 1000 (`invalid_limit`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "invalid_page_token",
                    "message": "use the next_page_token of the page before",
                    "retryable": false
                  }
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "503": {
            "description": "Motor, the database, or the engine is unavailable for a moment (`motor_unavailable`, `unavailable`, `engine_unavailable`), or Gauss can't answer now (`temporarily_unavailable`). Retry after `retry_after_seconds`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "temporarily_unavailable",
                    "message": "Gauss can't answer now. Try again in a moment.",
                    "retryable": true,
                    "retry_after_seconds": 1
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/gauss/repos/{handle}/{repo}/channels/{channel}/automation": {
      "get": {
        "operationId": "get_channel_automation",
        "summary": "Get what a channel's events run",
        "description": "Returns the hooks of a channel's current state, with `read`, and whether a sample event of the channel matches each: what a push to the channel would run now. An actual push runs the hooks of the state that it makes, which may differ.",
        "tags": [
          "Hooks"
        ],
        "parameters": [
          {
            "name": "handle",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The handle of the repository's account: a user, for their personal account, or a team."
          },
          {
            "name": "repo",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The repository's name."
          },
          {
            "name": "channel",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The channel, escaped as a path segment."
          },
          {
            "name": "event",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "channel.updated"
              ]
            },
            "description": "The sample event's type. Default: `channel.updated`."
          }
        ],
        "responses": {
          "200": {
            "description": "What the channel's events run.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ChannelAutomation"
                },
                "example": {
                  "channel": "main",
                  "main_channel": true,
                  "evaluation": {
                    "selected_by": "channel",
                    "selected_name": "main",
                    "state": "QW3YPL…",
                    "path": ".gauss/hooks.star",
                    "status": "valid",
                    "version": 1,
                    "digest": "sha256:9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08",
                    "diagnostics": []
                  },
                  "matches": [
                    {
                      "hook": {
                        "name": "deploy_staging",
                        "events": [
                          "channel.updated"
                        ],
                        "channels": [
                          "main"
                        ],
                        "tags": [],
                        "action": {
                          "type": "piston",
                          "piston": {
                            "config": "piston.star",
                            "targets": [
                              "deploy_staging"
                            ],
                            "inputs": {},
                            "profile": "staging"
                          }
                        },
                        "location": {
                          "file": ".gauss/hooks.star",
                          "line": 2,
                          "column": 5
                        },
                        "check": "",
                        "schedules": [],
                        "paths": [],
                        "paths_ignore": []
                      },
                      "matched": true,
                      "reason": "",
                      "paths": "",
                      "path": "",
                      "paths_detail": ""
                    }
                  ],
                  "policy": {
                    "channel": "main",
                    "required_checks": [
                      "test"
                    ],
                    "forbid_direct_pushes": true,
                    "revision": 1,
                    "updated_by": {
                      "kind": "user",
                      "id": "user_1BbA6sXxyUWHYvKqN5T3dM",
                      "name": "Ada Lovelace"
                    },
                    "updated_at": "2026-10-22T09:00:00Z",
                    "merge_strategy": "amp"
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "A scope of the repository that the caller doesn't have, or a team key without the scope (`insufficient_scope`), or a suspended team (`suspended`, `account_suspended`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "insufficient_scope",
                    "message": "you need the manage scope of ada/web; ask someone who manages it",
                    "retryable": false
                  }
                }
              }
            }
          },
          "404": {
            "description": "No such repository or channel (`repository_not_found`, `channel_not_found`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "channel_not_found",
                    "message": "the repository has no channel \"dev\"",
                    "retryable": false
                  }
                }
              }
            }
          },
          "422": {
            "description": "An event that isn't a channel's (`invalid_event`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "invalid_event",
                    "message": "event is an event of a channel: channel.updated",
                    "retryable": false
                  }
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "503": {
            "description": "Motor, the database, or the engine is unavailable for a moment (`motor_unavailable`, `unavailable`). Retry after Retry-After, or Gauss can't answer now (`temporarily_unavailable`). Retry after `retry_after_seconds`, with the same Idempotency-Key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "temporarily_unavailable",
                    "message": "Gauss can't answer now. Try again in a moment.",
                    "retryable": true,
                    "retry_after_seconds": 1
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/gauss/repos/{handle}/{repo}/invocations": {
      "get": {
        "operationId": "list_invocations",
        "summary": "List a repository's hook invocations",
        "description": "Returns a repository's invocations, newest first, with `read`: one for each hook that an event matched, run or suppressed, and one for each hook invoked by hand. Each has its attempts.",
        "tags": [
          "Invocations"
        ],
        "parameters": [
          {
            "name": "handle",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The handle of the repository's account: a user, for their personal account, or a team."
          },
          {
            "name": "repo",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The repository's name."
          },
          {
            "name": "hook",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Only invocations of this hook."
          },
          {
            "name": "event_id",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Only the invocations of this event."
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "suppressed",
                "pending",
                "running",
                "completed"
              ]
            },
            "description": "Only invocations with this status."
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 500
            },
            "description": "At most this many. Default: 50."
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "The `next_cursor` of the last page."
          }
        ],
        "responses": {
          "200": {
            "description": "A page of invocations.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InvocationPage"
                },
                "example": {
                  "data": [
                    {
                      "id": "inv_1BbA6sXxyUWHYvKqN5T3dM",
                      "repository_id": "repo_1BbA6sXxyUWHYvKqN5T3dM",
                      "handle": "ada",
                      "repository": "web",
                      "hook": "deploy_staging",
                      "hook_state": "QW3YPL…",
                      "hook_version": 1,
                      "event_id": "event_1BbA6sXxyUWHYvKqN5T3dM",
                      "trigger": "event",
                      "source_state": "QW3YPL…",
                      "action": {
                        "type": "piston",
                        "piston": {
                          "config": "piston.star",
                          "targets": [
                            "deploy_staging"
                          ],
                          "inputs": {
                            "env": "staging"
                          },
                          "profile": "staging"
                        }
                      },
                      "actor": {
                        "kind": "user",
                        "id": "user_1BbA6sXxyUWHYvKqN5T3dM",
                        "name": "Ada Lovelace"
                      },
                      "runs_as": {
                        "kind": "automation",
                        "id": "repo_1BbA6sXxyUWHYvKqN5T3dM",
                        "name": "ada/web hooks"
                      },
                      "status": "completed",
                      "conclusion": "passed",
                      "suppression": "",
                      "suppression_detail": "",
                      "causation": {
                        "root_event_id": "event_1BbA6sXxyUWHYvKqN5T3dM",
                        "parent_invocation_id": "",
                        "depth": 0
                      },
                      "created_at": "2026-10-22T09:00:02Z",
                      "updated_at": "2026-10-22T09:03:00Z",
                      "attempts": [
                        {
                          "number": 1,
                          "run_id": "run_1BbA6sXxyUWHYvKqN5T3dM",
                          "status": "completed",
                          "conclusion": "passed",
                          "failure_origin": "",
                          "error": "",
                          "created_at": "2026-10-22T09:00:02Z",
                          "started_at": "2026-10-22T09:00:05Z",
                          "finished_at": "2026-10-22T09:03:00Z",
                          "requested_by": {
                            "kind": "user",
                            "id": "user_1BbA6sXxyUWHYvKqN5T3dM",
                            "name": "Ada Lovelace"
                          },
                          "context": null
                        }
                      ],
                      "check": ""
                    }
                  ],
                  "next_cursor": null
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "A scope of the repository that the caller doesn't have, or a team key without the scope (`insufficient_scope`), or a suspended team (`suspended`, `account_suspended`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "insufficient_scope",
                    "message": "you need the manage scope of ada/web; ask someone who manages it",
                    "retryable": false
                  }
                }
              }
            }
          },
          "404": {
            "description": "No such repository, or a private one of another account (`repository_not_found`): Gauss doesn't tell them apart.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "repository_not_found",
                    "message": "no repository ada/web, or it's private to another account",
                    "retryable": false
                  }
                }
              }
            }
          },
          "422": {
            "description": "An invalid limit or cursor (`invalid_limit`, `invalid_cursor`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "invalid_cursor",
                    "message": "use the next_cursor of the last page",
                    "retryable": false
                  }
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "503": {
            "description": "Motor, the database, or the engine is unavailable for a moment (`motor_unavailable`, `unavailable`). Retry after Retry-After, or Gauss can't answer now (`temporarily_unavailable`). Retry after `retry_after_seconds`, with the same Idempotency-Key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "temporarily_unavailable",
                    "message": "Gauss can't answer now. Try again in a moment.",
                    "retryable": true,
                    "retry_after_seconds": 1
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/gauss/repos/{handle}/{repo}/invocations/{invocation_id}": {
      "get": {
        "operationId": "get_invocation",
        "summary": "Get a hook invocation",
        "description": "Returns an invocation, with its attempts and the context that its run gets, with `read`. The `context` is the JSON object itself, as the run reads it.",
        "tags": [
          "Invocations"
        ],
        "parameters": [
          {
            "name": "handle",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The handle of the repository's account: a user, for their personal account, or a team."
          },
          {
            "name": "repo",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The repository's name."
          },
          {
            "name": "invocation_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The invocation's ID (`inv_…`)."
          }
        ],
        "responses": {
          "200": {
            "description": "The invocation, and its context.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InvocationDetail"
                },
                "example": {
                  "invocation": {
                    "id": "inv_1BbA6sXxyUWHYvKqN5T3dM",
                    "repository_id": "repo_1BbA6sXxyUWHYvKqN5T3dM",
                    "handle": "ada",
                    "repository": "web",
                    "hook": "deploy_staging",
                    "hook_state": "QW3YPL…",
                    "hook_version": 1,
                    "event_id": "event_1BbA6sXxyUWHYvKqN5T3dM",
                    "trigger": "event",
                    "source_state": "QW3YPL…",
                    "action": {
                      "type": "piston",
                      "piston": {
                        "config": "piston.star",
                        "targets": [
                          "deploy_staging"
                        ],
                        "inputs": {
                          "env": "staging"
                        },
                        "profile": "staging"
                      }
                    },
                    "actor": {
                      "kind": "user",
                      "id": "user_1BbA6sXxyUWHYvKqN5T3dM",
                      "name": "Ada Lovelace"
                    },
                    "runs_as": {
                      "kind": "automation",
                      "id": "repo_1BbA6sXxyUWHYvKqN5T3dM",
                      "name": "ada/web hooks"
                    },
                    "status": "completed",
                    "conclusion": "passed",
                    "suppression": "",
                    "suppression_detail": "",
                    "causation": {
                      "root_event_id": "event_1BbA6sXxyUWHYvKqN5T3dM",
                      "parent_invocation_id": "",
                      "depth": 0
                    },
                    "created_at": "2026-10-22T09:00:02Z",
                    "updated_at": "2026-10-22T09:03:00Z",
                    "attempts": [
                      {
                        "number": 1,
                        "run_id": "run_1BbA6sXxyUWHYvKqN5T3dM",
                        "status": "completed",
                        "conclusion": "passed",
                        "failure_origin": "",
                        "error": "",
                        "created_at": "2026-10-22T09:00:02Z",
                        "started_at": "2026-10-22T09:00:05Z",
                        "finished_at": "2026-10-22T09:03:00Z",
                        "requested_by": {
                          "kind": "user",
                          "id": "user_1BbA6sXxyUWHYvKqN5T3dM",
                          "name": "Ada Lovelace"
                        },
                        "context": null
                      }
                    ],
                    "check": ""
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "A scope of the repository that the caller doesn't have, or a team key without the scope (`insufficient_scope`), or a suspended team (`suspended`, `account_suspended`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "insufficient_scope",
                    "message": "you need the manage scope of ada/web; ask someone who manages it",
                    "retryable": false
                  }
                }
              }
            }
          },
          "404": {
            "description": "No such repository, or a private one of another account (`repository_not_found`), or no such invocation of the repository (`invocation_not_found`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "invocation_not_found",
                    "message": "the repository has no invocation \"inv_1BbA6sXxyUWHYvKqN5T3dM\"",
                    "retryable": false
                  }
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "503": {
            "description": "Motor, the database, or the engine is unavailable for a moment (`motor_unavailable`, `unavailable`). Retry after Retry-After, or Gauss can't answer now (`temporarily_unavailable`). Retry after `retry_after_seconds`, with the same Idempotency-Key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "temporarily_unavailable",
                    "message": "Gauss can't answer now. Try again in a moment.",
                    "retryable": true,
                    "retry_after_seconds": 1
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/gauss/repos/{handle}/{repo}/hooks/{hook}/invoke": {
      "post": {
        "operationId": "invoke_hook",
        "summary": "Invoke a hook by hand",
        "description": "Invokes a hook of a state by hand, with `write`: the main channel's current state, unless the body names a `state`, a `channel` or a `tag`. The state's files are the run's source, and `inputs` replace the hook's static inputs of the same names. It isn't an event: the invocation's trigger is `manual`, and its causation is a root of its own, at depth 0. The run acts as the repository's hooks, which read, write, and publish in the repository only, and it runs only while the caller may still write to the repository. With an `Idempotency-Key`, a request that the caller made before with the key returns the invocation that it made (`replayed`), whatever its body.",
        "tags": [
          "Invocations"
        ],
        "parameters": [
          {
            "name": "handle",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The handle of the repository's account: a user, for their personal account, or a team."
          },
          {
            "name": "repo",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The repository's name."
          },
          {
            "name": "hook",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The hook's name, as `.gauss/hooks.star` declares it."
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 200
            },
            "description": "A key of the caller's for this invocation: a retry with it returns the same invocation, and runs nothing more."
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "state": {
                    "type": "string",
                    "description": "An exact state."
                  },
                  "channel": {
                    "type": "string",
                    "description": "A channel, whose current state counts."
                  },
                  "tag": {
                    "type": "string",
                    "description": "A tag, whose state counts."
                  },
                  "inputs": {
                    "type": "object",
                    "description": "Inputs that replace the hook's static inputs of the same names: strings, never secrets.",
                    "additionalProperties": {
                      "type": "string"
                    }
                  }
                }
              },
              "example": {
                "channel": "main",
                "inputs": {
                  "version": "1.2.0"
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The invocation that the request made.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InvokedHook"
                },
                "example": {
                  "invocation": {
                    "id": "inv_1BbA6sXxyUWHYvKqN5T3dM",
                    "repository_id": "repo_1BbA6sXxyUWHYvKqN5T3dM",
                    "handle": "ada",
                    "repository": "web",
                    "hook": "deploy_staging",
                    "hook_state": "QW3YPL…",
                    "hook_version": 1,
                    "event_id": "",
                    "trigger": "manual",
                    "source_state": "QW3YPL…",
                    "action": {
                      "type": "piston",
                      "piston": {
                        "config": "piston.star",
                        "targets": [
                          "deploy_staging"
                        ],
                        "inputs": {
                          "env": "staging",
                          "version": "1.2.0"
                        },
                        "profile": "staging"
                      }
                    },
                    "actor": {
                      "kind": "user",
                      "id": "user_1BbA6sXxyUWHYvKqN5T3dM",
                      "name": "Ada Lovelace"
                    },
                    "runs_as": {
                      "kind": "automation",
                      "id": "repo_1BbA6sXxyUWHYvKqN5T3dM",
                      "name": "ada/web hooks"
                    },
                    "status": "pending",
                    "conclusion": "",
                    "suppression": "",
                    "suppression_detail": "",
                    "causation": {
                      "root_event_id": "",
                      "parent_invocation_id": "",
                      "depth": 0
                    },
                    "created_at": "2026-10-22T09:00:02Z",
                    "updated_at": "2026-10-22T09:00:02Z",
                    "attempts": [
                      {
                        "number": 1,
                        "run_id": "",
                        "status": "submitting",
                        "conclusion": "",
                        "failure_origin": "",
                        "error": "",
                        "created_at": "2026-10-22T09:00:02Z",
                        "started_at": null,
                        "finished_at": null,
                        "requested_by": {
                          "kind": "user",
                          "id": "user_1BbA6sXxyUWHYvKqN5T3dM",
                          "name": "Ada Lovelace"
                        },
                        "context": null
                      }
                    ],
                    "check": ""
                  },
                  "replayed": false
                }
              }
            }
          },
          "200": {
            "description": "A retry with the same Idempotency-Key: the invocation that the key made.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InvokedHook"
                },
                "example": {
                  "invocation": {
                    "id": "inv_1BbA6sXxyUWHYvKqN5T3dM",
                    "repository_id": "repo_1BbA6sXxyUWHYvKqN5T3dM",
                    "handle": "ada",
                    "repository": "web",
                    "hook": "deploy_staging",
                    "hook_state": "QW3YPL…",
                    "hook_version": 1,
                    "event_id": "",
                    "trigger": "manual",
                    "source_state": "QW3YPL…",
                    "action": {
                      "type": "piston",
                      "piston": {
                        "config": "piston.star",
                        "targets": [
                          "deploy_staging"
                        ],
                        "inputs": {
                          "env": "staging",
                          "version": "1.2.0"
                        },
                        "profile": "staging"
                      }
                    },
                    "actor": {
                      "kind": "user",
                      "id": "user_1BbA6sXxyUWHYvKqN5T3dM",
                      "name": "Ada Lovelace"
                    },
                    "runs_as": {
                      "kind": "automation",
                      "id": "repo_1BbA6sXxyUWHYvKqN5T3dM",
                      "name": "ada/web hooks"
                    },
                    "status": "pending",
                    "conclusion": "",
                    "suppression": "",
                    "suppression_detail": "",
                    "causation": {
                      "root_event_id": "",
                      "parent_invocation_id": "",
                      "depth": 0
                    },
                    "created_at": "2026-10-22T09:00:02Z",
                    "updated_at": "2026-10-22T09:00:02Z",
                    "attempts": [
                      {
                        "number": 1,
                        "run_id": "",
                        "status": "submitting",
                        "conclusion": "",
                        "failure_origin": "",
                        "error": "",
                        "created_at": "2026-10-22T09:00:02Z",
                        "started_at": null,
                        "finished_at": null,
                        "requested_by": {
                          "kind": "user",
                          "id": "user_1BbA6sXxyUWHYvKqN5T3dM",
                          "name": "Ada Lovelace"
                        },
                        "context": null
                      }
                    ],
                    "check": ""
                  },
                  "replayed": true
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "A scope of the repository that the caller doesn't have, or a team key without the scope (`insufficient_scope`), or a suspended team (`suspended`, `account_suspended`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "insufficient_scope",
                    "message": "you need the manage scope of ada/web; ask someone who manages it",
                    "retryable": false
                  }
                }
              }
            }
          },
          "404": {
            "description": "No such repository, or a private one of another account (`repository_not_found`); no such channel, tag or state (`channel_not_found`, `tag_not_found`, `state_not_found`); or the state declares no such hook with a Piston action (`hook_not_found`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "hook_not_found",
                    "message": "the state QW3YPL… declares no hook \"deploy_staging\"",
                    "retryable": false
                  }
                }
              }
            }
          },
          "409": {
            "description": "An Idempotency-Key that the caller used for another hook or other inputs (`idempotency_conflict`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "idempotency_conflict",
                    "message": "the Idempotency-Key was used for another request (invocation inv_1BbA6sXxyUWHYvKqN5T3dM): the same hook, state selector and inputs, or a new key",
                    "retryable": false
                  }
                }
              }
            }
          },
          "413": {
            "$ref": "#/components/responses/TooLarge"
          },
          "422": {
            "description": "More than one of `state`, `channel` and `tag` (`invalid_selector`), a `state` that isn't one (`invalid_state`), an Idempotency-Key longer than 200 bytes (`invalid_idempotency_key`); or a field of the wrong type, or an unknown one (`invalid_field`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "invalid_selector",
                    "message": "name one of state, channel and tag",
                    "retryable": false
                  }
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "503": {
            "description": "Motor, the database, or the engine is unavailable for a moment (`motor_unavailable`, `unavailable`). Retry after Retry-After, or Gauss can't answer now (`temporarily_unavailable`). Retry after `retry_after_seconds`, with the same Idempotency-Key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "temporarily_unavailable",
                    "message": "Gauss can't answer now. Try again in a moment.",
                    "retryable": true,
                    "retry_after_seconds": 1
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/gauss/repos/{handle}/{repo}/invocations/{invocation_id}/retry": {
      "post": {
        "operationId": "retry_invocation",
        "summary": "Retry a hook invocation",
        "description": "Starts a new attempt of an invocation whose last attempt completed, with `write`: of the same source, context and causation, so a retry is never a new generation of a chain of hooks. `expected_attempt` is the number of the last attempt, which the retry follows: if another retry started one since, the request fails, so that two retries don't both start attempts. A suppressed invocation can't be retried.",
        "tags": [
          "Invocations"
        ],
        "parameters": [
          {
            "name": "handle",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The handle of the repository's account: a user, for their personal account, or a team."
          },
          {
            "name": "repo",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The repository's name."
          },
          {
            "name": "invocation_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The invocation's ID (`inv_…`)."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "expected_attempt"
                ],
                "properties": {
                  "expected_attempt": {
                    "type": "integer",
                    "minimum": 1,
                    "description": "The number of the invocation's last attempt."
                  }
                }
              },
              "example": {
                "expected_attempt": 1
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The invocation, with its new attempt.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InvocationResult"
                },
                "example": {
                  "invocation": {
                    "id": "inv_1BbA6sXxyUWHYvKqN5T3dM",
                    "repository_id": "repo_1BbA6sXxyUWHYvKqN5T3dM",
                    "handle": "ada",
                    "repository": "web",
                    "hook": "deploy_staging",
                    "hook_state": "QW3YPL…",
                    "hook_version": 1,
                    "event_id": "event_1BbA6sXxyUWHYvKqN5T3dM",
                    "trigger": "event",
                    "source_state": "QW3YPL…",
                    "action": {
                      "type": "piston",
                      "piston": {
                        "config": "piston.star",
                        "targets": [
                          "deploy_staging"
                        ],
                        "inputs": {
                          "env": "staging"
                        },
                        "profile": "staging"
                      }
                    },
                    "actor": {
                      "kind": "user",
                      "id": "user_1BbA6sXxyUWHYvKqN5T3dM",
                      "name": "Ada Lovelace"
                    },
                    "runs_as": {
                      "kind": "automation",
                      "id": "repo_1BbA6sXxyUWHYvKqN5T3dM",
                      "name": "ada/web hooks"
                    },
                    "status": "pending",
                    "conclusion": "",
                    "suppression": "",
                    "suppression_detail": "",
                    "causation": {
                      "root_event_id": "event_1BbA6sXxyUWHYvKqN5T3dM",
                      "parent_invocation_id": "",
                      "depth": 0
                    },
                    "created_at": "2026-10-22T09:00:02Z",
                    "updated_at": "2026-10-22T09:10:00Z",
                    "attempts": [
                      {
                        "number": 1,
                        "run_id": "run_1BbA6sXxyUWHYvKqN5T3dM",
                        "status": "completed",
                        "conclusion": "failed",
                        "failure_origin": "command",
                        "error": "",
                        "created_at": "2026-10-22T09:00:02Z",
                        "started_at": "2026-10-22T09:00:05Z",
                        "finished_at": "2026-10-22T09:03:00Z",
                        "requested_by": {
                          "kind": "user",
                          "id": "user_1BbA6sXxyUWHYvKqN5T3dM",
                          "name": "Ada Lovelace"
                        },
                        "context": null
                      },
                      {
                        "number": 2,
                        "run_id": "",
                        "status": "submitting",
                        "conclusion": "",
                        "failure_origin": "",
                        "error": "",
                        "created_at": "2026-10-22T09:10:00Z",
                        "started_at": null,
                        "finished_at": null,
                        "requested_by": {
                          "kind": "user",
                          "id": "user_1BbA6sXxyUWHYvKqN5T3dM",
                          "name": "Ada Lovelace"
                        },
                        "context": null
                      }
                    ],
                    "check": ""
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "A scope of the repository that the caller doesn't have, or a team key without the scope (`insufficient_scope`), or a suspended team (`suspended`, `account_suspended`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "insufficient_scope",
                    "message": "you need the manage scope of ada/web; ask someone who manages it",
                    "retryable": false
                  }
                }
              }
            }
          },
          "404": {
            "description": "No such repository, or a private one of another account (`repository_not_found`), or no such invocation of the repository (`invocation_not_found`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "invocation_not_found",
                    "message": "the repository has no invocation \"inv_1BbA6sXxyUWHYvKqN5T3dM\"",
                    "retryable": false
                  }
                }
              }
            }
          },
          "409": {
            "description": "The last attempt isn't `expected_attempt` (`attempt_mismatch`), or hasn't completed: cancel it first (`attempt_running`); or the invocation is suppressed (`invocation_suppressed`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "attempt_mismatch",
                    "message": "the invocation's last attempt is 2, not 1",
                    "retryable": false
                  }
                }
              }
            }
          },
          "413": {
            "$ref": "#/components/responses/TooLarge"
          },
          "422": {
            "description": "No `expected_attempt`, a field of the wrong type, or an unknown one (`invalid_field`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "invalid_field",
                    "message": "Give expected_attempt: the number of the invocation's last attempt, which the retry follows.",
                    "retryable": false
                  }
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "503": {
            "description": "Motor, the database, or the engine is unavailable for a moment (`motor_unavailable`, `unavailable`). Retry after Retry-After, or Gauss can't answer now (`temporarily_unavailable`). Retry after `retry_after_seconds`, with the same Idempotency-Key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "temporarily_unavailable",
                    "message": "Gauss can't answer now. Try again in a moment.",
                    "retryable": true,
                    "retry_after_seconds": 1
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/gauss/repos/{handle}/{repo}/invocations/{invocation_id}/cancel": {
      "post": {
        "operationId": "cancel_invocation",
        "summary": "Cancel a hook invocation",
        "description": "Cancels an invocation's open attempt, with `write`: its Piston run, if Piston started one, or the attempt itself, if not yet. The attempt, and the invocation, complete as `cancelled` when the run ends, which the answer shows if Piston ended it at once. An invocation that completed, or is suppressed, stays as it is. The answer is the invocation.",
        "tags": [
          "Invocations"
        ],
        "parameters": [
          {
            "name": "handle",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The handle of the repository's account: a user, for their personal account, or a team."
          },
          {
            "name": "repo",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The repository's name."
          },
          {
            "name": "invocation_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The invocation's ID (`inv_…`)."
          }
        ],
        "responses": {
          "200": {
            "description": "The invocation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InvocationResult"
                },
                "example": {
                  "invocation": {
                    "id": "inv_1BbA6sXxyUWHYvKqN5T3dM",
                    "repository_id": "repo_1BbA6sXxyUWHYvKqN5T3dM",
                    "handle": "ada",
                    "repository": "web",
                    "hook": "deploy_staging",
                    "hook_state": "QW3YPL…",
                    "hook_version": 1,
                    "event_id": "event_1BbA6sXxyUWHYvKqN5T3dM",
                    "trigger": "event",
                    "source_state": "QW3YPL…",
                    "action": {
                      "type": "piston",
                      "piston": {
                        "config": "piston.star",
                        "targets": [
                          "deploy_staging"
                        ],
                        "inputs": {
                          "env": "staging"
                        },
                        "profile": "staging"
                      }
                    },
                    "actor": {
                      "kind": "user",
                      "id": "user_1BbA6sXxyUWHYvKqN5T3dM",
                      "name": "Ada Lovelace"
                    },
                    "runs_as": {
                      "kind": "automation",
                      "id": "repo_1BbA6sXxyUWHYvKqN5T3dM",
                      "name": "ada/web hooks"
                    },
                    "status": "completed",
                    "conclusion": "cancelled",
                    "suppression": "",
                    "suppression_detail": "",
                    "causation": {
                      "root_event_id": "event_1BbA6sXxyUWHYvKqN5T3dM",
                      "parent_invocation_id": "",
                      "depth": 0
                    },
                    "created_at": "2026-10-22T09:00:02Z",
                    "updated_at": "2026-10-22T09:01:00Z",
                    "attempts": [
                      {
                        "number": 1,
                        "run_id": "run_1BbA6sXxyUWHYvKqN5T3dM",
                        "status": "completed",
                        "conclusion": "cancelled",
                        "failure_origin": "canceled",
                        "error": "",
                        "created_at": "2026-10-22T09:00:02Z",
                        "started_at": "2026-10-22T09:00:05Z",
                        "finished_at": "2026-10-22T09:01:00Z",
                        "requested_by": {
                          "kind": "user",
                          "id": "user_1BbA6sXxyUWHYvKqN5T3dM",
                          "name": "Ada Lovelace"
                        },
                        "context": null
                      }
                    ],
                    "check": ""
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "A scope of the repository that the caller doesn't have, or a team key without the scope (`insufficient_scope`), or a suspended team (`suspended`, `account_suspended`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "insufficient_scope",
                    "message": "you need the manage scope of ada/web; ask someone who manages it",
                    "retryable": false
                  }
                }
              }
            }
          },
          "404": {
            "description": "No such repository, or a private one of another account (`repository_not_found`), or no such invocation of the repository (`invocation_not_found`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "invocation_not_found",
                    "message": "the repository has no invocation \"inv_1BbA6sXxyUWHYvKqN5T3dM\"",
                    "retryable": false
                  }
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "503": {
            "description": "Motor, the database, or the engine is unavailable for a moment (`motor_unavailable`, `unavailable`). Retry after Retry-After, or Gauss can't answer now (`temporarily_unavailable`). Retry after `retry_after_seconds`, with the same Idempotency-Key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "temporarily_unavailable",
                    "message": "Gauss can't answer now. Try again in a moment.",
                    "retryable": true,
                    "retry_after_seconds": 1
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/gauss/repos/{handle}/{repo}/channel_policies": {
      "get": {
        "operationId": "list_channel_policies",
        "summary": "List a repository's channel policies",
        "tags": [
          "Policies"
        ],
        "description": "Lists the policies of a repository's channels, by channel, with `read`. A channel without a policy has the default: no checks, and direct pushes.",
        "parameters": [
          {
            "name": "handle",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The handle of the repository's account: a user, for their personal account, or a team."
          },
          {
            "name": "repo",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The repository's name."
          }
        ],
        "responses": {
          "200": {
            "description": "The policies.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ChannelPolicyList"
                },
                "example": {
                  "data": [
                    {
                      "channel": "main",
                      "required_checks": [
                        "lint",
                        "test"
                      ],
                      "forbid_direct_pushes": true,
                      "revision": 2,
                      "updated_by": {
                        "kind": "user",
                        "id": "user_1BbA6sXxyUWHYvKqN5T3dM",
                        "name": "Ada Lovelace"
                      },
                      "updated_at": "2026-10-22T09:00:00Z",
                      "merge_strategy": "amp"
                    }
                  ],
                  "next_cursor": null
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "A scope of the repository that the caller doesn't have, or a team key without the scope (`insufficient_scope`), or a suspended team (`suspended`, `account_suspended`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "insufficient_scope",
                    "message": "you need the read scope of ada/web; ask someone who manages it",
                    "retryable": false
                  }
                }
              }
            }
          },
          "404": {
            "description": "No such repository, or a private one of another account (`repository_not_found`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "repository_not_found",
                    "message": "the repository ada/web doesn't exist, or you can't see it",
                    "retryable": false
                  }
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "503": {
            "description": "Motor, the database, or the engine is unavailable for a moment (`motor_unavailable`, `unavailable`, `engine_unavailable`), or Gauss can't answer now (`temporarily_unavailable`). Retry after `retry_after_seconds`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "temporarily_unavailable",
                    "message": "Gauss can't answer now. Try again in a moment.",
                    "retryable": true,
                    "retry_after_seconds": 1
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/gauss/repos/{handle}/{repo}/channels/{channel}/policy": {
      "get": {
        "operationId": "get_channel_policy",
        "summary": "Get a channel's policy",
        "tags": [
          "Policies"
        ],
        "description": "Returns a channel's policy, with `read`: the checks that a merge into it needs, and whether it takes direct pushes. A channel without a policy has the default, at revision 0.",
        "parameters": [
          {
            "name": "handle",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The handle of the repository's account: a user, for their personal account, or a team."
          },
          {
            "name": "repo",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The repository's name."
          },
          {
            "name": "channel",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The channel, escaped as a path segment."
          }
        ],
        "responses": {
          "200": {
            "description": "The policy.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ChannelPolicy"
                },
                "example": {
                  "channel": "main",
                  "required_checks": [
                    "lint",
                    "test"
                  ],
                  "forbid_direct_pushes": true,
                  "revision": 2,
                  "updated_by": {
                    "kind": "user",
                    "id": "user_1BbA6sXxyUWHYvKqN5T3dM",
                    "name": "Ada Lovelace"
                  },
                  "updated_at": "2026-10-22T09:00:00Z",
                  "merge_strategy": "amp"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "A scope of the repository that the caller doesn't have, or a team key without the scope (`insufficient_scope`), or a suspended team (`suspended`, `account_suspended`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "insufficient_scope",
                    "message": "you need the read scope of ada/web; ask someone who manages it",
                    "retryable": false
                  }
                }
              }
            }
          },
          "404": {
            "description": "No such repository, or a private one of another account (`repository_not_found`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "repository_not_found",
                    "message": "the repository ada/web doesn't exist, or you can't see it",
                    "retryable": false
                  }
                }
              }
            }
          },
          "422": {
            "description": "A channel's name that isn't one (`invalid_channel`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "invalid_channel",
                    "message": "the channels below gauss/ are Gauss's own, for merges' candidates",
                    "retryable": false
                  }
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "503": {
            "description": "Motor, the database, or the engine is unavailable for a moment (`motor_unavailable`, `unavailable`, `engine_unavailable`), or Gauss can't answer now (`temporarily_unavailable`). Retry after `retry_after_seconds`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "temporarily_unavailable",
                    "message": "Gauss can't answer now. Try again in a moment.",
                    "retryable": true,
                    "retry_after_seconds": 1
                  }
                }
              }
            }
          }
        }
      },
      "put": {
        "operationId": "set_channel_policy",
        "summary": "Set a channel's policy",
        "tags": [
          "Policies"
        ],
        "description": "Replaces a channel's policy, with `manage`, if it's at `expected_revision` (0 for a channel without one). `required_checks` are the names of the checks that a merge into the channel needs to have passed for its candidate: a candidate's `.gauss/hooks.star` says how each runs (`hook(check = ...)`), and a check that the candidate doesn't declare is missing, and fails the candidate. With `forbid_direct_pushes`, Gauss refuses pushes, applies and deletion of the channel: only merges change it. A landing and a policy's change never interleave. `merge_strategy` says how the queue lands a merge: `amp` in an Amp repository; `merge_commit`, `squash`, or `rebase_ff` in a Git one. Without it, the policy keeps its strategy, or a channel without a policy gets the repository's default (`amp`, or `merge_commit`).",
        "parameters": [
          {
            "name": "handle",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The handle of the repository's account: a user, for their personal account, or a team."
          },
          {
            "name": "repo",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The repository's name."
          },
          {
            "name": "channel",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The channel, escaped as a path segment."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "required_checks",
                  "forbid_direct_pushes",
                  "expected_revision"
                ],
                "properties": {
                  "required_checks": {
                    "type": "array",
                    "maxItems": 20,
                    "items": {
                      "type": "string",
                      "pattern": "^[a-z][a-z0-9_]{0,63}$"
                    }
                  },
                  "forbid_direct_pushes": {
                    "type": "boolean"
                  },
                  "expected_revision": {
                    "type": "integer",
                    "minimum": 0,
                    "description": "The policy's revision now: 0 for a channel without one."
                  },
                  "merge_strategy": {
                    "type": "string",
                    "enum": [
                      "amp",
                      "merge_commit",
                      "squash",
                      "rebase_ff"
                    ],
                    "description": "How the channel's queue lands a merge. Leave it out to keep the policy's."
                  }
                }
              },
              "example": {
                "required_checks": [
                  "lint",
                  "test"
                ],
                "forbid_direct_pushes": true,
                "expected_revision": 1
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The policy, at its new revision.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ChannelPolicy"
                },
                "example": {
                  "channel": "main",
                  "required_checks": [
                    "lint",
                    "test"
                  ],
                  "forbid_direct_pushes": true,
                  "revision": 2,
                  "updated_by": {
                    "kind": "user",
                    "id": "user_1BbA6sXxyUWHYvKqN5T3dM",
                    "name": "Ada Lovelace"
                  },
                  "updated_at": "2026-10-22T09:00:00Z",
                  "merge_strategy": "amp"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "A scope of the repository that the caller doesn't have, or a team key without the scope (`insufficient_scope`), or a suspended team (`suspended`, `account_suspended`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "insufficient_scope",
                    "message": "you need the manage scope of ada/web; ask someone who manages it",
                    "retryable": false
                  }
                }
              }
            }
          },
          "404": {
            "description": "No such repository, or a private one of another account (`repository_not_found`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "repository_not_found",
                    "message": "the repository ada/web doesn't exist, or you can't see it",
                    "retryable": false
                  }
                }
              }
            }
          },
          "409": {
            "description": "The policy isn't at `expected_revision` (`policy_changed`): read it, and send its revision.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "policy_changed",
                    "message": "the policy of main is at revision 2, not 1: read it, and send its revision",
                    "retryable": false
                  }
                }
              }
            }
          },
          "422": {
            "description": "A check's name that isn't one, more than 20 (`invalid_checks`), a channel's name that isn't one (`invalid_channel`), a merge strategy of the other version control, or none (`invalid_merge_strategy`), or a missing field (`invalid_field`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "invalid_checks",
                    "message": "\"Test\" isn't a check's name",
                    "retryable": false
                  }
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "503": {
            "description": "Motor, the database, or the engine is unavailable for a moment (`motor_unavailable`, `unavailable`, `engine_unavailable`), or Gauss can't answer now (`temporarily_unavailable`). Retry after `retry_after_seconds`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "temporarily_unavailable",
                    "message": "Gauss can't answer now. Try again in a moment.",
                    "retryable": true,
                    "retry_after_seconds": 1
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/gauss/repos/{handle}/{repo}/merges": {
      "post": {
        "operationId": "create_merge",
        "summary": "Open a merge",
        "tags": [
          "Merges"
        ],
        "description": "Opens a merge of a source channel into a target channel, with `write`, and, unless it's a draft, submits it to the target's queue at once: Gauss pins the source's state in a snapshot, and owns the merge until it merges or is rejected (`queue_state`, `submission`). The queue's candidate's `merge.candidate_updated` event runs its check hooks.",
        "parameters": [
          {
            "name": "handle",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The handle of the repository's account: a user, for their personal account, or a team."
          },
          {
            "name": "repo",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The repository's name."
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 128
            },
            "description": "The client's ID of this request (`motor gauss merge create` sends the ID that it prints, or `--request-id`). Gauss binds it to the request's payload: a retry with it gets the first answer. Without it, Gauss refuses the request (`client_upgrade_required`)."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "source",
                  "target"
                ],
                "properties": {
                  "source": {
                    "type": "string",
                    "description": "The channel whose changes to land."
                  },
                  "target": {
                    "type": "string",
                    "description": "The channel to land them on."
                  },
                  "title": {
                    "type": "string",
                    "maxLength": 200,
                    "description": "The source's name if empty."
                  },
                  "description": {
                    "type": "string",
                    "maxLength": 10000
                  },
                  "draft": {
                    "type": "boolean",
                    "description": "Whether the merge waits for its merge land, instead of landing itself once its current candidate's required checks passed. False if absent."
                  }
                }
              },
              "example": {
                "source": "feature",
                "target": "main",
                "title": "Add the parser"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The merge, with its first candidate, which may still be `combining`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Merge"
                },
                "example": {
                  "id": "merge_1BbA6sXxyUWHYvKqN5T3dM",
                  "repository_id": "repo_1BbA6sXxyUWHYvKqN5T3dM",
                  "handle": "ada",
                  "repository": "web",
                  "source": "feature",
                  "target": "main",
                  "title": "Add the parser",
                  "description": "",
                  "status": "open",
                  "generation": 2,
                  "candidate": {
                    "generation": 2,
                    "cause": "source_updated",
                    "status": "ready",
                    "channel": "gauss/merges/merge_1BbA6sXxyUWHYvKqN5T3dM/2",
                    "base_state": "QW3YPL…",
                    "source_state": "MZ7T4A…",
                    "state": "K2ND8Q…",
                    "changes": [
                      "FJ3K…",
                      "P8QZ…"
                    ],
                    "conflicts": 0,
                    "event_id": "event_1BbA6sXxyUWHYvKqN5T3dM",
                    "error": "",
                    "requested_by": {
                      "kind": "user",
                      "id": "user_1BbA6sXxyUWHYvKqN5T3dM",
                      "name": "Ada Lovelace"
                    },
                    "created_at": "2026-10-22T09:00:00Z",
                    "combined_at": "2026-10-22T09:00:01Z",
                    "shared": false
                  },
                  "created_by": {
                    "kind": "user",
                    "id": "user_1BbA6sXxyUWHYvKqN5T3dM",
                    "name": "Ada Lovelace"
                  },
                  "created_at": "2026-10-22T08:50:00Z",
                  "updated_at": "2026-10-22T09:00:00Z",
                  "landing": null,
                  "closing": null,
                  "checks": {
                    "generation": 2,
                    "policy": {
                      "channel": "main",
                      "required_checks": [
                        "lint",
                        "test"
                      ],
                      "forbid_direct_pushes": true,
                      "revision": 2,
                      "updated_by": {
                        "kind": "user",
                        "id": "user_1BbA6sXxyUWHYvKqN5T3dM",
                        "name": "Ada Lovelace"
                      },
                      "updated_at": "2026-10-22T09:00:00Z",
                      "merge_strategy": "amp"
                    },
                    "checks": [
                      {
                        "name": "lint",
                        "required": true,
                        "status": "passed",
                        "hook": "lint",
                        "invocation_id": "inv_1BbA6sXxyUWHYvKqN5T3dM",
                        "conclusion": "passed",
                        "detail": ""
                      },
                      {
                        "name": "test",
                        "required": true,
                        "status": "pending",
                        "hook": "tests",
                        "invocation_id": "inv_1BbA6sXxyUWHYvKqN5T3dN",
                        "conclusion": "",
                        "detail": "its run is running"
                      }
                    ],
                    "candidate_id": "qcand_1BbA6sXxyUWHYvKqN5T3dM",
                    "candidate_status": "checking",
                    "detail": "The queue checks this candidate under revision 2 of main's policy, as it is now."
                  },
                  "queue_state": "",
                  "submission": null
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "A scope of the repository that the caller doesn't have, or a team key without the scope (`insufficient_scope`), or a suspended team (`suspended`, `account_suspended`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "insufficient_scope",
                    "message": "you need the write scope of ada/web; ask someone who manages it",
                    "retryable": false
                  }
                }
              }
            }
          },
          "404": {
            "description": "No such repository (`repository_not_found`), or no such channel of it (`channel_not_found`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "channel_not_found",
                    "message": "ada/web has no channel \"feature\"",
                    "retryable": false
                  }
                }
              }
            }
          },
          "409": {
            "description": "An open merge of the source into the target exists (`merge_exists`), the request ID was used for another request (`request_conflict`), Gauss rejected the source's state in another merge (`submission_rejected`: refresh that merge).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "merge_exists",
                    "message": "the merge merge_1BbA6sXxyUWHYvKqN5T3dM of feature into main is open already",
                    "retryable": false
                  }
                }
              }
            }
          },
          "422": {
            "description": "A source and a target that aren't two channels, a channel below `gauss/` (`invalid_channel`), or a description that's too long (`invalid_description`), or no Idempotency-Key (`client_upgrade_required`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "invalid_channel",
                    "message": "a merge's source and target are two channels",
                    "retryable": false
                  }
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "503": {
            "description": "Motor, the database, or the engine is unavailable for a moment (`motor_unavailable`, `unavailable`, `engine_unavailable`), or Gauss can't answer now (`temporarily_unavailable`). Retry after `retry_after_seconds`. Gauss lost a snapshot of the source that it made (`snapshot_unavailable`): retry.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "temporarily_unavailable",
                    "message": "Gauss can't answer now. Try again in a moment.",
                    "retryable": true,
                    "retry_after_seconds": 1
                  }
                }
              }
            }
          }
        }
      },
      "get": {
        "operationId": "list_merges",
        "summary": "List a repository's merges",
        "tags": [
          "Merges"
        ],
        "description": "Lists a repository's merges, the newest first, with `read`, each with its current candidate and, while it's open, its checks.",
        "parameters": [
          {
            "name": "handle",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The handle of the repository's account: a user, for their personal account, or a team."
          },
          {
            "name": "repo",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The repository's name."
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "open",
                "merged",
                "closed"
              ]
            },
            "description": "Only merges with this status."
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 500
            },
            "description": "At most this many. Default: 50."
          },
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "The `next_cursor` of the last page."
          }
        ],
        "responses": {
          "200": {
            "description": "A page of merges.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MergePage"
                },
                "example": {
                  "data": [
                    {
                      "id": "merge_1BbA6sXxyUWHYvKqN5T3dM",
                      "repository_id": "repo_1BbA6sXxyUWHYvKqN5T3dM",
                      "handle": "ada",
                      "repository": "web",
                      "source": "feature",
                      "target": "main",
                      "title": "Add the parser",
                      "description": "",
                      "status": "open",
                      "generation": 2,
                      "candidate": {
                        "generation": 2,
                        "cause": "source_updated",
                        "status": "ready",
                        "channel": "gauss/merges/merge_1BbA6sXxyUWHYvKqN5T3dM/2",
                        "base_state": "QW3YPL…",
                        "source_state": "MZ7T4A…",
                        "state": "K2ND8Q…",
                        "changes": [
                          "FJ3K…",
                          "P8QZ…"
                        ],
                        "conflicts": 0,
                        "event_id": "event_1BbA6sXxyUWHYvKqN5T3dM",
                        "error": "",
                        "requested_by": {
                          "kind": "user",
                          "id": "user_1BbA6sXxyUWHYvKqN5T3dM",
                          "name": "Ada Lovelace"
                        },
                        "created_at": "2026-10-22T09:00:00Z",
                        "combined_at": "2026-10-22T09:00:01Z",
                        "shared": false
                      },
                      "created_by": {
                        "kind": "user",
                        "id": "user_1BbA6sXxyUWHYvKqN5T3dM",
                        "name": "Ada Lovelace"
                      },
                      "created_at": "2026-10-22T08:50:00Z",
                      "updated_at": "2026-10-22T09:00:00Z",
                      "landing": null,
                      "closing": null,
                      "checks": {
                        "generation": 2,
                        "policy": {
                          "channel": "main",
                          "required_checks": [
                            "lint",
                            "test"
                          ],
                          "forbid_direct_pushes": true,
                          "revision": 2,
                          "updated_by": {
                            "kind": "user",
                            "id": "user_1BbA6sXxyUWHYvKqN5T3dM",
                            "name": "Ada Lovelace"
                          },
                          "updated_at": "2026-10-22T09:00:00Z",
                          "merge_strategy": "amp"
                        },
                        "checks": [
                          {
                            "name": "lint",
                            "required": true,
                            "status": "passed",
                            "hook": "lint",
                            "invocation_id": "inv_1BbA6sXxyUWHYvKqN5T3dM",
                            "conclusion": "passed",
                            "detail": ""
                          },
                          {
                            "name": "test",
                            "required": true,
                            "status": "pending",
                            "hook": "tests",
                            "invocation_id": "inv_1BbA6sXxyUWHYvKqN5T3dN",
                            "conclusion": "",
                            "detail": "its run is running"
                          }
                        ],
                        "candidate_id": "qcand_1BbA6sXxyUWHYvKqN5T3dM",
                        "candidate_status": "checking",
                        "detail": "The queue checks this candidate under revision 2 of main's policy, as it is now."
                      },
                      "queue_state": "",
                      "submission": null
                    }
                  ],
                  "next_cursor": null
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "A scope of the repository that the caller doesn't have, or a team key without the scope (`insufficient_scope`), or a suspended team (`suspended`, `account_suspended`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "insufficient_scope",
                    "message": "you need the read scope of ada/web; ask someone who manages it",
                    "retryable": false
                  }
                }
              }
            }
          },
          "404": {
            "description": "No such repository, or a private one of another account (`repository_not_found`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "repository_not_found",
                    "message": "the repository ada/web doesn't exist, or you can't see it",
                    "retryable": false
                  }
                }
              }
            }
          },
          "422": {
            "description": "A status, limit or cursor that isn't one (`invalid_status`, `invalid_limit`, `invalid_cursor`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "invalid_status",
                    "message": "status is open, merged, or closed",
                    "retryable": false
                  }
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "503": {
            "description": "Motor, the database, or the engine is unavailable for a moment (`motor_unavailable`, `unavailable`, `engine_unavailable`), or Gauss can't answer now (`temporarily_unavailable`). Retry after `retry_after_seconds`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "temporarily_unavailable",
                    "message": "Gauss can't answer now. Try again in a moment.",
                    "retryable": true,
                    "retry_after_seconds": 1
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/gauss/repos/{handle}/{repo}/merges/{merge_id}": {
      "get": {
        "operationId": "get_merge",
        "summary": "Get a merge",
        "tags": [
          "Merges"
        ],
        "description": "Returns a merge, with `read`: its current candidate, and, while it's open, whether the candidate can land, each required check's status, and what blocks it.",
        "parameters": [
          {
            "name": "handle",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The handle of the repository's account: a user, for their personal account, or a team."
          },
          {
            "name": "repo",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The repository's name."
          },
          {
            "name": "merge_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The merge's ID (`merge_…`)."
          }
        ],
        "responses": {
          "200": {
            "description": "The merge.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Merge"
                },
                "example": {
                  "id": "merge_1BbA6sXxyUWHYvKqN5T3dM",
                  "repository_id": "repo_1BbA6sXxyUWHYvKqN5T3dM",
                  "handle": "ada",
                  "repository": "web",
                  "source": "feature",
                  "target": "main",
                  "title": "Add the parser",
                  "description": "",
                  "status": "open",
                  "generation": 2,
                  "candidate": {
                    "generation": 2,
                    "cause": "source_updated",
                    "status": "ready",
                    "channel": "gauss/merges/merge_1BbA6sXxyUWHYvKqN5T3dM/2",
                    "base_state": "QW3YPL…",
                    "source_state": "MZ7T4A…",
                    "state": "K2ND8Q…",
                    "changes": [
                      "FJ3K…",
                      "P8QZ…"
                    ],
                    "conflicts": 0,
                    "event_id": "event_1BbA6sXxyUWHYvKqN5T3dM",
                    "error": "",
                    "requested_by": {
                      "kind": "user",
                      "id": "user_1BbA6sXxyUWHYvKqN5T3dM",
                      "name": "Ada Lovelace"
                    },
                    "created_at": "2026-10-22T09:00:00Z",
                    "combined_at": "2026-10-22T09:00:01Z",
                    "shared": false
                  },
                  "created_by": {
                    "kind": "user",
                    "id": "user_1BbA6sXxyUWHYvKqN5T3dM",
                    "name": "Ada Lovelace"
                  },
                  "created_at": "2026-10-22T08:50:00Z",
                  "updated_at": "2026-10-22T09:00:00Z",
                  "landing": null,
                  "closing": null,
                  "checks": {
                    "generation": 2,
                    "policy": {
                      "channel": "main",
                      "required_checks": [
                        "lint",
                        "test"
                      ],
                      "forbid_direct_pushes": true,
                      "revision": 2,
                      "updated_by": {
                        "kind": "user",
                        "id": "user_1BbA6sXxyUWHYvKqN5T3dM",
                        "name": "Ada Lovelace"
                      },
                      "updated_at": "2026-10-22T09:00:00Z",
                      "merge_strategy": "amp"
                    },
                    "checks": [
                      {
                        "name": "lint",
                        "required": true,
                        "status": "passed",
                        "hook": "lint",
                        "invocation_id": "inv_1BbA6sXxyUWHYvKqN5T3dM",
                        "conclusion": "passed",
                        "detail": ""
                      },
                      {
                        "name": "test",
                        "required": true,
                        "status": "pending",
                        "hook": "tests",
                        "invocation_id": "inv_1BbA6sXxyUWHYvKqN5T3dN",
                        "conclusion": "",
                        "detail": "its run is running"
                      }
                    ],
                    "candidate_id": "qcand_1BbA6sXxyUWHYvKqN5T3dM",
                    "candidate_status": "checking",
                    "detail": "The queue checks this candidate under revision 2 of main's policy, as it is now."
                  },
                  "queue_state": "queued",
                  "submission": {
                    "generation": 2,
                    "cause": "created",
                    "status": "queued",
                    "snapshot_channel": "gauss/snapshots/mrcpt_1BbA6sXxyUWHYvKqN5T3dM",
                    "source_state": "MZ7T4A…",
                    "changes": [
                      "FJ3K…",
                      "P8QZ…"
                    ],
                    "enqueue_sequence": "42",
                    "deferred_by": "",
                    "active_candidate_id": "",
                    "rejection": null,
                    "fulfillment": null,
                    "requested_by": {
                      "kind": "user",
                      "id": "user_1BbA6sXxyUWHYvKqN5T3dM",
                      "name": "Ada Lovelace"
                    },
                    "created_at": "2026-10-22T08:50:00Z",
                    "resolved_at": null
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "A scope of the repository that the caller doesn't have, or a team key without the scope (`insufficient_scope`), or a suspended team (`suspended`, `account_suspended`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "insufficient_scope",
                    "message": "you need the read scope of ada/web; ask someone who manages it",
                    "retryable": false
                  }
                }
              }
            }
          },
          "404": {
            "description": "No such repository, or a private one of another account (`repository_not_found`), or no such merge of it (`merge_not_found`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "merge_not_found",
                    "message": "ada/web has no merge \"merge_1BbA6sXxyUWHYvKqN5T3dM\"",
                    "retryable": false
                  }
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "503": {
            "description": "Motor, the database, or the engine is unavailable for a moment (`motor_unavailable`, `unavailable`, `engine_unavailable`), or Gauss can't answer now (`temporarily_unavailable`). Retry after `retry_after_seconds`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "temporarily_unavailable",
                    "message": "Gauss can't answer now. Try again in a moment.",
                    "retryable": true,
                    "retry_after_seconds": 1
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/gauss/repos/{handle}/{repo}/merges/{merge_id}/checks": {
      "get": {
        "operationId": "get_merge_checks",
        "summary": "Get a merge's checks",
        "tags": [
          "Merges"
        ],
        "description": "Returns the checks of a merge's current generation, with `read`: those of the queue's latest candidate that tests or tested it. It keeps them after the merge lands or closes. Without a candidate, `checks` is empty, and `detail` says why.",
        "parameters": [
          {
            "name": "handle",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The handle of the repository's account: a user, for their personal account, or a team."
          },
          {
            "name": "repo",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The repository's name."
          },
          {
            "name": "merge_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The merge's ID (`merge_…`)."
          },
          {
            "name": "generation",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1
            },
            "description": "The merge's current generation, or 0 for it."
          }
        ],
        "responses": {
          "200": {
            "description": "The checks.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MergeChecks"
                },
                "example": {
                  "generation": 2,
                  "policy": {
                    "channel": "main",
                    "required_checks": [
                      "lint",
                      "test"
                    ],
                    "forbid_direct_pushes": true,
                    "revision": 2,
                    "updated_by": {
                      "kind": "user",
                      "id": "user_1BbA6sXxyUWHYvKqN5T3dM",
                      "name": "Ada Lovelace"
                    },
                    "updated_at": "2026-10-22T09:00:00Z",
                    "merge_strategy": "amp"
                  },
                  "checks": [
                    {
                      "name": "lint",
                      "required": true,
                      "status": "passed",
                      "hook": "lint",
                      "invocation_id": "inv_1BbA6sXxyUWHYvKqN5T3dM",
                      "conclusion": "passed",
                      "detail": ""
                    },
                    {
                      "name": "test",
                      "required": true,
                      "status": "pending",
                      "hook": "tests",
                      "invocation_id": "inv_1BbA6sXxyUWHYvKqN5T3dN",
                      "conclusion": "",
                      "detail": "its run is running"
                    }
                  ],
                  "candidate_id": "qcand_1BbA6sXxyUWHYvKqN5T3dM",
                  "candidate_status": "checking",
                  "detail": "The queue checks this candidate under revision 2 of main's policy, as it is now."
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "A scope of the repository that the caller doesn't have, or a team key without the scope (`insufficient_scope`), or a suspended team (`suspended`, `account_suspended`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "insufficient_scope",
                    "message": "you need the read scope of ada/web; ask someone who manages it",
                    "retryable": false
                  }
                }
              }
            }
          },
          "404": {
            "description": "No such repository (`repository_not_found`) or merge (`merge_not_found`), or a generation that isn't the merge's current one (`generation_not_found`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "generation_not_found",
                    "message": "the merge merge_1BbA6sXxyUWHYvKqN5T3dM has generations 1 to 2",
                    "retryable": false
                  }
                }
              }
            }
          },
          "422": {
            "description": "A generation that isn't one (`invalid_generation`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "invalid_generation",
                    "message": "generation is a generation of the merge, from 1",
                    "retryable": false
                  }
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "503": {
            "description": "Motor, the database, or the engine is unavailable for a moment (`motor_unavailable`, `unavailable`, `engine_unavailable`), or Gauss can't answer now (`temporarily_unavailable`). Retry after `retry_after_seconds`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "temporarily_unavailable",
                    "message": "Gauss can't answer now. Try again in a moment.",
                    "retryable": true,
                    "retry_after_seconds": 1
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/gauss/repos/{handle}/{repo}/merges/{merge_id}/diff": {
      "get": {
        "operationId": "get_merge_diff",
        "summary": "Get a merge's diff",
        "tags": [
          "Merges"
        ],
        "description": "Returns the unified diff of a merge's candidate against its base, with `read`: in a Git repository, of the source's commit against the target's. Gauss cuts a long diff after a whole line, at `max_bytes` or its own limit of 4 MiB, and says so in `truncated`. Gauss doesn't make diffs of an Amp repository's merges (`merge_diff_unavailable`).",
        "parameters": [
          {
            "name": "handle",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The handle of the repository's account: a user, for their personal account, or a team."
          },
          {
            "name": "repo",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The repository's name."
          },
          {
            "name": "merge_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The merge's ID (`merge_…`)."
          },
          {
            "name": "max_bytes",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 4194304
            },
            "description": "The most bytes of the diff to return. Defaults to Gauss's limit, 4 MiB."
          }
        ],
        "responses": {
          "200": {
            "description": "The diff.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MergeDiff"
                },
                "example": {
                  "diff": "ZGlmZiAtLWdpdCBhL1JFQURNRSBiL1JFQURNRQotLS0gYS9SRUFETUUKKysrIGIvUkVBRE1FCkBAIC0xICsxIEBACi1IZWxsbworSGVsbG8sIHdvcmxkCg==",
                  "truncated": false,
                  "base_state": "4b825dc642cb6eb9a060e54bf8d69288fbee4904",
                  "candidate_state": "9f2c1e0a6b7d4c3e8f1a2b3c4d5e6f708192a3b4"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "A scope of the repository that the caller doesn't have, or a team key without the scope (`insufficient_scope`), or a suspended team (`suspended`, `account_suspended`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "insufficient_scope",
                    "message": "you need the read scope of ada/web; ask someone who manages it",
                    "retryable": false
                  }
                }
              }
            }
          },
          "404": {
            "description": "No such repository (`repository_not_found`) or merge (`merge_not_found`), or a merge without a commit to show (`merge_diff_unavailable`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "merge_not_found",
                    "message": "the merge merge_1BbA6sXxyUWHYvKqN5T3dM doesn't exist",
                    "retryable": false
                  }
                }
              }
            }
          },
          "422": {
            "description": "A `max_bytes` that isn't from 1 to 4194304 (`invalid_max_bytes`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "invalid_max_bytes",
                    "message": "max_bytes is from 1 to 4194304",
                    "retryable": false
                  }
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "501": {
            "description": "A merge of an Amp repository, whose diffs Gauss doesn't make (`merge_diff_unavailable`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "merge_diff_unavailable",
                    "message": "merge diff is not yet enabled",
                    "retryable": false
                  }
                }
              }
            }
          },
          "503": {
            "description": "Motor, the database, or the engine is unavailable for a moment (`motor_unavailable`, `unavailable`, `engine_unavailable`), or Gauss can't answer now (`temporarily_unavailable`). Retry after `retry_after_seconds`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "temporarily_unavailable",
                    "message": "Gauss can't answer now. Try again in a moment.",
                    "retryable": true,
                    "retry_after_seconds": 1
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/gauss/repos/{handle}/{repo}/merges/{merge_id}/refresh": {
      "post": {
        "operationId": "refresh_merge",
        "summary": "Refresh a merge's candidate",
        "tags": [
          "Merges"
        ],
        "description": "Makes a draft's next generation, of its source now, or submits a rejected merge's source again, with `write`, if its current generation is `expected_generation`. A queued merge isn't replaced (`merge_queued`): Gauss owns it until it merges or is rejected.",
        "parameters": [
          {
            "name": "handle",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The handle of the repository's account: a user, for their personal account, or a team."
          },
          {
            "name": "repo",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The repository's name."
          },
          {
            "name": "merge_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The merge's ID (`merge_…`)."
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 128
            },
            "description": "The client's ID of this request, as for opening a merge: a retry with it gets the first answer. Without it, Gauss refuses the request (`client_upgrade_required`)."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "expected_generation"
                ],
                "properties": {
                  "expected_generation": {
                    "type": "integer",
                    "minimum": 1,
                    "description": "The merge's current generation, which the refresh follows."
                  },
                  "expected_source_state": {
                    "type": "string",
                    "description": "If set, the source's state that the refresh must pin: if the source moved, nothing changes."
                  }
                }
              },
              "example": {
                "expected_generation": 2
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The merge, with its next generation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Merge"
                },
                "example": {
                  "id": "merge_1BbA6sXxyUWHYvKqN5T3dM",
                  "repository_id": "repo_1BbA6sXxyUWHYvKqN5T3dM",
                  "handle": "ada",
                  "repository": "web",
                  "source": "feature",
                  "target": "main",
                  "title": "Add the parser",
                  "description": "",
                  "status": "open",
                  "generation": 2,
                  "candidate": {
                    "generation": 2,
                    "cause": "source_updated",
                    "status": "ready",
                    "channel": "gauss/merges/merge_1BbA6sXxyUWHYvKqN5T3dM/2",
                    "base_state": "QW3YPL…",
                    "source_state": "MZ7T4A…",
                    "state": "K2ND8Q…",
                    "changes": [
                      "FJ3K…",
                      "P8QZ…"
                    ],
                    "conflicts": 0,
                    "event_id": "event_1BbA6sXxyUWHYvKqN5T3dM",
                    "error": "",
                    "requested_by": {
                      "kind": "user",
                      "id": "user_1BbA6sXxyUWHYvKqN5T3dM",
                      "name": "Ada Lovelace"
                    },
                    "created_at": "2026-10-22T09:00:00Z",
                    "combined_at": "2026-10-22T09:00:01Z",
                    "shared": false
                  },
                  "created_by": {
                    "kind": "user",
                    "id": "user_1BbA6sXxyUWHYvKqN5T3dM",
                    "name": "Ada Lovelace"
                  },
                  "created_at": "2026-10-22T08:50:00Z",
                  "updated_at": "2026-10-22T09:00:00Z",
                  "landing": null,
                  "closing": null,
                  "checks": {
                    "generation": 2,
                    "policy": {
                      "channel": "main",
                      "required_checks": [
                        "lint",
                        "test"
                      ],
                      "forbid_direct_pushes": true,
                      "revision": 2,
                      "updated_by": {
                        "kind": "user",
                        "id": "user_1BbA6sXxyUWHYvKqN5T3dM",
                        "name": "Ada Lovelace"
                      },
                      "updated_at": "2026-10-22T09:00:00Z",
                      "merge_strategy": "amp"
                    },
                    "checks": [
                      {
                        "name": "lint",
                        "required": true,
                        "status": "passed",
                        "hook": "lint",
                        "invocation_id": "inv_1BbA6sXxyUWHYvKqN5T3dM",
                        "conclusion": "passed",
                        "detail": ""
                      },
                      {
                        "name": "test",
                        "required": true,
                        "status": "pending",
                        "hook": "tests",
                        "invocation_id": "inv_1BbA6sXxyUWHYvKqN5T3dN",
                        "conclusion": "",
                        "detail": "its run is running"
                      }
                    ],
                    "candidate_id": "qcand_1BbA6sXxyUWHYvKqN5T3dM",
                    "candidate_status": "checking",
                    "detail": "The queue checks this candidate under revision 2 of main's policy, as it is now."
                  },
                  "queue_state": "",
                  "submission": null
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "A scope of the repository that the caller doesn't have, or a team key without the scope (`insufficient_scope`), or a suspended team (`suspended`, `account_suspended`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "insufficient_scope",
                    "message": "you need the write scope of ada/web; ask someone who manages it",
                    "retryable": false
                  }
                }
              }
            }
          },
          "404": {
            "description": "No such repository, or a private one of another account (`repository_not_found`), or no such merge of it (`merge_not_found`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "merge_not_found",
                    "message": "ada/web has no merge \"merge_1BbA6sXxyUWHYvKqN5T3dM\"",
                    "retryable": false
                  }
                }
              }
            }
          },
          "409": {
            "description": "The merge isn't open (`merge_not_open`), or isn't at `expected_generation` (`stale_generation`), the merge is queued, which Gauss owns until it merges or is rejected (`merge_queued`), the request ID was used for another request (`request_conflict`), the source isn't at `expected_source_state` (`source_changed`), Gauss rejected the source's state in another merge (`submission_rejected`: refresh that merge).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "stale_generation",
                    "message": "the merge merge_1BbA6sXxyUWHYvKqN5T3dM is at generation 3, not 2",
                    "retryable": false
                  }
                }
              }
            }
          },
          "422": {
            "description": "No `expected_generation`, or an unknown field (`invalid_field`), or no Idempotency-Key (`client_upgrade_required`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "invalid_field",
                    "message": "Give expected_generation: the merge's current generation, which the refresh follows.",
                    "retryable": false
                  }
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "503": {
            "description": "Motor, the database, or the engine is unavailable for a moment (`motor_unavailable`, `unavailable`, `engine_unavailable`), or Gauss can't answer now (`temporarily_unavailable`). Retry after `retry_after_seconds`. Gauss lost a snapshot of the source that it made (`snapshot_unavailable`): retry.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "temporarily_unavailable",
                    "message": "Gauss can't answer now. Try again in a moment.",
                    "retryable": true,
                    "retry_after_seconds": 1
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/gauss/repos/{handle}/{repo}/merges/{merge_id}/merge": {
      "post": {
        "operationId": "complete_merge",
        "summary": "Land a merge",
        "tags": [
          "Merges"
        ],
        "description": "Submits a draft's generation `expected_generation` to its target's queue, with `write`, which lands it once its checks pass (`queue_state`). Landing a merge again with the generation that landed gets the merge. A rejected merge lands again only after a refresh (`merge_rejected`).",
        "parameters": [
          {
            "name": "handle",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The handle of the repository's account: a user, for their personal account, or a team."
          },
          {
            "name": "repo",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The repository's name."
          },
          {
            "name": "merge_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The merge's ID (`merge_…`)."
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 128
            },
            "description": "The client's ID of this request, as for opening a merge: a retry with it gets the first answer. Without it, Gauss refuses the request (`client_upgrade_required`)."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "expected_generation"
                ],
                "properties": {
                  "expected_generation": {
                    "type": "integer",
                    "minimum": 1,
                    "description": "The draft's generation to submit: the merge's current one."
                  },
                  "expected_source_state": {
                    "type": "string",
                    "description": "If set, the source's state that the land must submit: if the source moved, nothing changes."
                  }
                }
              },
              "example": {
                "expected_generation": 2
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The merge, landed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Merge"
                },
                "example": {
                  "id": "merge_1BbA6sXxyUWHYvKqN5T3dM",
                  "repository_id": "repo_1BbA6sXxyUWHYvKqN5T3dM",
                  "handle": "ada",
                  "repository": "web",
                  "source": "feature",
                  "target": "main",
                  "title": "Add the parser",
                  "description": "",
                  "status": "merged",
                  "generation": 2,
                  "candidate": {
                    "generation": 2,
                    "cause": "source_updated",
                    "status": "ready",
                    "channel": "gauss/merges/merge_1BbA6sXxyUWHYvKqN5T3dM/2",
                    "base_state": "QW3YPL…",
                    "source_state": "MZ7T4A…",
                    "state": "K2ND8Q…",
                    "changes": [
                      "FJ3K…",
                      "P8QZ…"
                    ],
                    "conflicts": 0,
                    "event_id": "event_1BbA6sXxyUWHYvKqN5T3dM",
                    "error": "",
                    "requested_by": {
                      "kind": "user",
                      "id": "user_1BbA6sXxyUWHYvKqN5T3dM",
                      "name": "Ada Lovelace"
                    },
                    "created_at": "2026-10-22T09:00:00Z",
                    "combined_at": "2026-10-22T09:00:01Z",
                    "shared": false
                  },
                  "created_by": {
                    "kind": "user",
                    "id": "user_1BbA6sXxyUWHYvKqN5T3dM",
                    "name": "Ada Lovelace"
                  },
                  "created_at": "2026-10-22T08:50:00Z",
                  "updated_at": "2026-10-22T09:00:00Z",
                  "landing": {
                    "generation": 2,
                    "before": "QW3YPL…",
                    "after": "K2ND8Q…",
                    "merged_by": {
                      "kind": "user",
                      "id": "user_1BbA6sXxyUWHYvKqN5T3dM",
                      "name": "Ada Lovelace"
                    },
                    "merged_at": "2026-10-22T09:10:00Z"
                  },
                  "closing": null,
                  "checks": null,
                  "queue_state": "",
                  "submission": null
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "A scope of the repository that the caller doesn't have, or a team key without the scope (`insufficient_scope`), or a suspended team (`suspended`, `account_suspended`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "insufficient_scope",
                    "message": "you need the write scope of ada/web; ask someone who manages it",
                    "retryable": false
                  }
                }
              }
            }
          },
          "404": {
            "description": "No such repository, or a private one of another account (`repository_not_found`), or no such merge of it (`merge_not_found`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "merge_not_found",
                    "message": "ada/web has no merge \"merge_1BbA6sXxyUWHYvKqN5T3dM\"",
                    "retryable": false
                  }
                }
              }
            }
          },
          "409": {
            "description": "The merge isn't open (`merge_not_open`) or isn't at `expected_generation` (`stale_generation`), Gauss rejected the merge's generation (`merge_rejected`: refresh it), the request ID was used for another request (`request_conflict`), the source isn't at `expected_source_state` (`source_changed`), Gauss rejected the source's state in another merge (`submission_rejected`: refresh that merge).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "merge_rejected",
                    "message": "Gauss rejected generation 2 of the merge merge_1: refresh it to submit the source again",
                    "retryable": false
                  }
                }
              }
            }
          },
          "422": {
            "description": "No `expected_generation`, or an unknown field (`invalid_field`, `invalid_generation`), or no Idempotency-Key (`client_upgrade_required`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "invalid_field",
                    "message": "Give expected_generation: the generation whose candidate to land, the merge's current one.",
                    "retryable": false
                  }
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "503": {
            "description": "Motor, the database, or the engine is unavailable for a moment (`motor_unavailable`, `unavailable`, `engine_unavailable`), or Gauss can't answer now (`temporarily_unavailable`). Retry after `retry_after_seconds`. Gauss lost a snapshot of the source that it made (`snapshot_unavailable`): retry.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "temporarily_unavailable",
                    "message": "Gauss can't answer now. Try again in a moment.",
                    "retryable": true,
                    "retry_after_seconds": 1
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/gauss/repos/{handle}/{repo}/merges/{merge_id}/close": {
      "post": {
        "operationId": "close_merge",
        "summary": "Close a merge",
        "tags": [
          "Merges"
        ],
        "description": "Closes an open merge without landing it, with `write`. Closing a closed merge again gets it.",
        "parameters": [
          {
            "name": "handle",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The handle of the repository's account: a user, for their personal account, or a team."
          },
          {
            "name": "repo",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The repository's name."
          },
          {
            "name": "merge_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The merge's ID (`merge_…`)."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "reason": {
                    "type": "string",
                    "maxLength": 200
                  },
                  "expected_generation": {
                    "type": "integer",
                    "minimum": 0,
                    "description": "If set, the merge's current generation."
                  }
                }
              },
              "example": {
                "reason": "Superseded"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The merge, closed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Merge"
                },
                "example": {
                  "id": "merge_1BbA6sXxyUWHYvKqN5T3dM",
                  "repository_id": "repo_1BbA6sXxyUWHYvKqN5T3dM",
                  "handle": "ada",
                  "repository": "web",
                  "source": "feature",
                  "target": "main",
                  "title": "Add the parser",
                  "description": "",
                  "status": "closed",
                  "generation": 2,
                  "candidate": {
                    "generation": 2,
                    "cause": "source_updated",
                    "status": "ready",
                    "channel": "gauss/merges/merge_1BbA6sXxyUWHYvKqN5T3dM/2",
                    "base_state": "QW3YPL…",
                    "source_state": "MZ7T4A…",
                    "state": "K2ND8Q…",
                    "changes": [
                      "FJ3K…",
                      "P8QZ…"
                    ],
                    "conflicts": 0,
                    "event_id": "event_1BbA6sXxyUWHYvKqN5T3dM",
                    "error": "",
                    "requested_by": {
                      "kind": "user",
                      "id": "user_1BbA6sXxyUWHYvKqN5T3dM",
                      "name": "Ada Lovelace"
                    },
                    "created_at": "2026-10-22T09:00:00Z",
                    "combined_at": "2026-10-22T09:00:01Z",
                    "shared": false
                  },
                  "created_by": {
                    "kind": "user",
                    "id": "user_1BbA6sXxyUWHYvKqN5T3dM",
                    "name": "Ada Lovelace"
                  },
                  "created_at": "2026-10-22T08:50:00Z",
                  "updated_at": "2026-10-22T09:00:00Z",
                  "landing": null,
                  "closing": {
                    "reason": "Superseded",
                    "closed_by": {
                      "kind": "user",
                      "id": "user_1BbA6sXxyUWHYvKqN5T3dM",
                      "name": "Ada Lovelace"
                    },
                    "closed_at": "2026-10-22T09:10:00Z"
                  },
                  "checks": null,
                  "queue_state": "",
                  "submission": null
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "A scope of the repository that the caller doesn't have, or a team key without the scope (`insufficient_scope`), or a suspended team (`suspended`, `account_suspended`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "insufficient_scope",
                    "message": "you need the write scope of ada/web; ask someone who manages it",
                    "retryable": false
                  }
                }
              }
            }
          },
          "404": {
            "description": "No such repository, or a private one of another account (`repository_not_found`), or no such merge of it (`merge_not_found`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "merge_not_found",
                    "message": "ada/web has no merge \"merge_1BbA6sXxyUWHYvKqN5T3dM\"",
                    "retryable": false
                  }
                }
              }
            }
          },
          "409": {
            "description": "The merge landed (`merge_not_open`), or isn't at `expected_generation` (`stale_generation`), or is queued, which Gauss owns until it merges or is rejected (`merge_queued`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "merge_not_open",
                    "message": "the merge merge_1BbA6sXxyUWHYvKqN5T3dM isn't open",
                    "retryable": false
                  }
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "503": {
            "description": "Motor, the database, or the engine is unavailable for a moment (`motor_unavailable`, `unavailable`, `engine_unavailable`), or Gauss can't answer now (`temporarily_unavailable`). Retry after `retry_after_seconds`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "temporarily_unavailable",
                    "message": "Gauss can't answer now. Try again in a moment.",
                    "retryable": true,
                    "retry_after_seconds": 1
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/gauss/repos/{handle}/{repo}/secrets": {
      "get": {
        "operationId": "list_repository_secrets",
        "summary": "List a repository's secrets",
        "tags": [
          "Secrets"
        ],
        "description": "Lists the repository's secrets, by name, without their values, for a writer of the repository. With `?profile=`, it lists the profile's bindings instead, each `owned` or `inherit`, and whether it's valid.",
        "parameters": [
          {
            "name": "handle",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The handle of the repository's account: a user, for their personal account, or a team."
          },
          {
            "name": "repo",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The repository's name."
          },
          {
            "name": "profile",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^[a-z][a-z0-9_]{0,63}$"
            },
            "description": "The profile whose binding of the secret it is; without it, the repository's secret."
          }
        ],
        "responses": {
          "200": {
            "description": "The secrets.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/RepositorySecret"
                      }
                    },
                    "next_cursor": {
                      "type": [
                        "string",
                        "null"
                      ]
                    }
                  }
                },
                "example": {
                  "data": [
                    {
                      "id": "secret_1BbA6sXxyUWHYvKqN5T3dM",
                      "name": "test_api_token",
                      "version_id": "secretv_6dJr1TzCw2c9Wn5pQhVfKx",
                      "version": 2,
                      "created_at": "2026-11-03T09:00:00Z",
                      "updated_at": "2026-11-03T10:00:00Z"
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "A caller who can't write to the repository, or a team key without `gauss:write` (`insufficient_scope`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "insufficient_scope",
                    "message": "you need the write scope of lab/web; ask someone who manages it",
                    "retryable": false
                  }
                }
              }
            }
          },
          "404": {
            "description": "No such repository, or a private one of another account (`repository_not_found`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "repository_not_found",
                    "message": "no repository ada/web",
                    "retryable": false
                  }
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/api/gauss/repos/{handle}/{repo}/secrets/{secret}": {
      "put": {
        "operationId": "set_repository_secret",
        "summary": "Set a repository secret",
        "tags": [
          "Secrets"
        ],
        "description": "Sets the secret's value, as its next version, for an administrator of the repository's team, signed in. New grants pin the new version; a run that pinned an older one keeps it. The value never comes back. With `?profile=`, it sets the profile's binding of the name instead: a `value` is the profile's own, which only its tasks get, and `inherit`, without a value, binds the repository's secret of the name, whose rotations new runs get.",
        "parameters": [
          {
            "name": "handle",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The handle of the repository's account: a user, for their personal account, or a team."
          },
          {
            "name": "repo",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The repository's name."
          },
          {
            "name": "secret",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The secret's name, in snake case."
          },
          {
            "name": "profile",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^[a-z][a-z0-9_]{0,63}$"
            },
            "description": "The profile whose binding of the secret it is; without it, the repository's secret."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "value": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 65536,
                    "description": "The value; required without inherit."
                  },
                  "inherit": {
                    "type": "boolean",
                    "description": "With `?profile=`, and no value: the profile gets the repository's secret of the name."
                  }
                }
              },
              "example": {
                "value": "tok_example"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The secret, at its new version.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RepositorySecret"
                },
                "example": {
                  "id": "secret_1BbA6sXxyUWHYvKqN5T3dM",
                  "name": "test_api_token",
                  "version_id": "secretv_6dJr1TzCw2c9Wn5pQhVfKx",
                  "version": 2,
                  "created_at": "2026-11-03T09:00:00Z",
                  "updated_at": "2026-11-03T10:00:00Z"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "A caller who isn't an administrator of the repository's team (`admin_required`), or a team key (`device_credential_required`): only an administrator, signed in, changes secrets.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "admin_required",
                    "message": "only an administrator of lab changes the secrets of lab/web",
                    "retryable": false
                  }
                }
              }
            }
          },
          "404": {
            "description": "No such repository (`repository_not_found`), or profile (`profile_not_found`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "profile_not_found",
                    "message": "lab/web has no profile production; an administrator makes it with motor profiles set production",
                    "retryable": false
                  }
                }
              }
            }
          },
          "422": {
            "description": "A name that isn't snake case, or is gauss_invocation_token (`invalid_secret`), an empty or larger value, or inherit with a value (`invalid_value`), or inherit of a secret that the repository doesn't have (`missing_secret`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "invalid_secret",
                    "message": "a secret's name is 1 to 64 lowercase letters, digits and underscores, starting with a letter, such as test_api_token; not \"Test\"",
                    "retryable": false
                  }
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      },
      "delete": {
        "operationId": "delete_repository_secret",
        "summary": "Delete a repository secret",
        "tags": [
          "Secrets"
        ],
        "description": "Deletes the secret and its versions, for an administrator of the repository's team, signed in: no grant delivers them after. Setting the name again makes another secret. With `?profile=`, it removes the profile's binding, and its own value: an inherited secret stays the repository's.",
        "parameters": [
          {
            "name": "handle",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The handle of the repository's account: a user, for their personal account, or a team."
          },
          {
            "name": "repo",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The repository's name."
          },
          {
            "name": "secret",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The secret's name, in snake case."
          },
          {
            "name": "profile",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^[a-z][a-z0-9_]{0,63}$"
            },
            "description": "The profile whose binding of the secret it is; without it, the repository's secret."
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted."
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "A caller who isn't an administrator of the repository's team (`admin_required`), or a team key (`device_credential_required`): only an administrator, signed in, changes secrets.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "admin_required",
                    "message": "only an administrator of lab changes the secrets of lab/web",
                    "retryable": false
                  }
                }
              }
            }
          },
          "404": {
            "description": "No such repository, or a private one of another account (`repository_not_found`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "repository_not_found",
                    "message": "no repository ada/web",
                    "retryable": false
                  }
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/api/gauss/repos/{handle}/{repo}/secrets/{secret}/versions/{version}/revoke": {
      "post": {
        "operationId": "revoke_repository_secret_version",
        "summary": "Revoke a secret's version",
        "tags": [
          "Secrets"
        ],
        "description": "Revokes a version of the secret at once, for an administrator of the repository's team: no grant delivers it after, even one that pinned it. Setting a new value doesn't revoke the old one. With `?profile=`, it revokes a version of the profile's own value; an inherited version is the repository's to revoke (`inherited_secret`).",
        "parameters": [
          {
            "name": "handle",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The handle of the repository's account: a user, for their personal account, or a team."
          },
          {
            "name": "repo",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The repository's name."
          },
          {
            "name": "secret",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The secret's name, in snake case."
          },
          {
            "name": "version",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 1
            },
            "description": "The version's number."
          },
          {
            "name": "profile",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^[a-z][a-z0-9_]{0,63}$"
            },
            "description": "The profile whose binding of the secret it is; without it, the repository's secret."
          }
        ],
        "responses": {
          "204": {
            "description": "Revoked."
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "A caller who isn't an administrator of the repository's team (`admin_required`), or a team key (`device_credential_required`): only an administrator, signed in, changes secrets.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "admin_required",
                    "message": "only an administrator of lab changes the secrets of lab/web",
                    "retryable": false
                  }
                }
              }
            }
          },
          "404": {
            "description": "No such repository, or a private one of another account (`repository_not_found`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "repository_not_found",
                    "message": "no repository ada/web",
                    "retryable": false
                  }
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          },
          "422": {
            "description": "An inherited binding's version (`inherited_secret`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "inherited_secret",
                    "message": "the profile production inherits test_api_token from the repository; revoke the repository's version with motor secrets revoke test_api_token --version 2",
                    "retryable": false
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/gauss/repos/{handle}/{repo}/secret_checks": {
      "post": {
        "operationId": "check_repository_secrets",
        "summary": "Check tasks' secrets",
        "tags": [
          "Secrets"
        ],
        "description": "Returns where each of the tasks' secrets would come from, and those that the repository, or a task's profile, doesn't have, for a writer. It grants nothing: a task of a profile still runs only in a hook's run.",
        "parameters": [
          {
            "name": "handle",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The handle of the repository's account: a user, for their personal account, or a team."
          },
          {
            "name": "repo",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The repository's name."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "tasks"
                ],
                "properties": {
                  "tasks": {
                    "type": "object",
                    "description": "Task → environment variable → the repository secret's name.",
                    "additionalProperties": {
                      "type": "object",
                      "additionalProperties": {
                        "type": "string",
                        "pattern": "^[a-z][a-z0-9_]{0,63}$"
                      }
                    }
                  },
                  "profiles": {
                    "type": "object",
                    "description": "Task → its profile, for the tasks that have one.",
                    "additionalProperties": {
                      "type": "string"
                    }
                  }
                }
              },
              "example": {
                "tasks": {
                  "integration_test": {
                    "TEST_API_TOKEN": "test_api_token"
                  },
                  "migrate_production": {
                    "DATABASE_URL": "database_url"
                  }
                },
                "profiles": {
                  "migrate_production": "production"
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Where each secret comes from, and what's missing.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "missing": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "task": {
                            "type": "string"
                          },
                          "variable": {
                            "type": "string"
                          },
                          "secret": {
                            "type": "string"
                          },
                          "profile": {
                            "type": "string"
                          },
                          "code": {
                            "type": "string",
                            "enum": [
                              "missing_secret",
                              "missing_profile_secret"
                            ]
                          }
                        }
                      }
                    },
                    "resolved": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "task": {
                            "type": "string"
                          },
                          "variable": {
                            "type": "string"
                          },
                          "secret": {
                            "type": "string"
                          },
                          "profile": {
                            "type": "string"
                          },
                          "source": {
                            "type": "string",
                            "enum": [
                              "repository",
                              "owned",
                              "inherit"
                            ]
                          },
                          "version": {
                            "type": "integer"
                          }
                        }
                      }
                    }
                  }
                },
                "example": {
                  "resolved": [
                    {
                      "task": "integration_test",
                      "variable": "TEST_API_TOKEN",
                      "secret": "test_api_token",
                      "source": "repository",
                      "version": 2
                    }
                  ],
                  "missing": [
                    {
                      "task": "migrate_production",
                      "variable": "DATABASE_URL",
                      "secret": "database_url",
                      "profile": "production",
                      "code": "missing_profile_secret"
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "A caller who can't write to the repository, or a team key without `gauss:write` (`insufficient_scope`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "insufficient_scope",
                    "message": "you need the write scope of lab/web; ask someone who manages it",
                    "retryable": false
                  }
                }
              }
            }
          },
          "404": {
            "description": "No such repository, or a private one of another account (`repository_not_found`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "repository_not_found",
                    "message": "no repository ada/web",
                    "retryable": false
                  }
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/api/gauss/repos/{handle}/{repo}/secret_grants": {
      "post": {
        "operationId": "create_secret_grant",
        "summary": "Grant a submission's secrets",
        "tags": [
          "Secrets"
        ],
        "description": "Lets a submission's tasks get the current versions of their repository secrets, for a writer: `motor piston run` asks for one, and Piston binds it to its run, which must have the same source and the same tasks' secrets, and delivers each task's values as it starts, while the requester may still write. With no tasks, it's a grant of the repository alone, for a reader: it delivers no secret, and its run restores the repository's protected caches. It returns the grant, never a value. The same `submission_id` returns the same grant if the source and the tasks are the same.",
        "parameters": [
          {
            "name": "handle",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The handle of the repository's account: a user, for their personal account, or a team."
          },
          {
            "name": "repo",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The repository's name."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "submission_id",
                  "source_sha256",
                  "tasks"
                ],
                "properties": {
                  "submission_id": {
                    "type": "string",
                    "pattern": "^[A-Za-z0-9_][A-Za-z0-9_.:-]{0,127}$",
                    "description": "The caller's ID of the submission."
                  },
                  "source_sha256": {
                    "type": "string",
                    "pattern": "^[0-9a-f]{64}$",
                    "description": "The SHA-256 of the run's source, as uploaded to Piston."
                  },
                  "tasks": {
                    "type": "object",
                    "description": "Task → environment variable → the repository secret's name.",
                    "additionalProperties": {
                      "type": "object",
                      "additionalProperties": {
                        "type": "string",
                        "pattern": "^[a-z][a-z0-9_]{0,63}$"
                      }
                    }
                  }
                }
              },
              "example": {
                "submission_id": "sub_3fa1",
                "source_sha256": "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08",
                "tasks": {
                  "integration_test": {
                    "TEST_API_TOKEN": "test_api_token"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The grant.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SecretGrant"
                },
                "example": {
                  "id": "grant_1BbA6sXxyUWHYvKqN5T3dM",
                  "submission_id": "sub_3fa1",
                  "status": "pending",
                  "admit_by": "2026-11-03T09:10:00Z",
                  "expires_at": "2026-11-03T09:10:00Z",
                  "versions": {
                    "integration_test": {
                      "variables": {
                        "TEST_API_TOKEN": "secretv_6dJr1TzCw2c9Wn5pQhVfKx"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "A caller who can't write to the repository, or a team key without `gauss:write` (`insufficient_scope`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "insufficient_scope",
                    "message": "you need the write scope of lab/web; ask someone who manages it",
                    "retryable": false
                  }
                }
              }
            }
          },
          "404": {
            "description": "No such repository, or a private one of another account (`repository_not_found`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "repository_not_found",
                    "message": "no repository ada/web",
                    "retryable": false
                  }
                }
              }
            }
          },
          "409": {
            "description": "The submission ID has a grant for another source or other tasks (`submission_conflict`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "submission_conflict",
                    "message": "the submission sub_3fa1 has a grant for another source or other tasks; give a new submission its own ID",
                    "retryable": false
                  }
                }
              }
            }
          },
          "422": {
            "description": "A secret that the repository doesn't have (`missing_secret`), or invalid fields.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "missing_secret",
                    "message": "lab/web has no secret test_api_token; an administrator of lab sets it with motor secrets set",
                    "retryable": false
                  }
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/api/gauss/repos/{handle}/{repo}/profiles": {
      "get": {
        "operationId": "list_profiles",
        "summary": "List a repository's profiles",
        "tags": [
          "Profiles"
        ],
        "description": "Lists the repository's profiles, with their rules and bindings, for a writer.",
        "parameters": [
          {
            "name": "handle",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The handle of the repository's account: a user, for their personal account, or a team."
          },
          {
            "name": "repo",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The repository's name."
          }
        ],
        "responses": {
          "200": {
            "description": "The profiles.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Profile"
                      }
                    },
                    "next_cursor": {
                      "type": "string"
                    }
                  }
                },
                "example": {
                  "data": [
                    {
                      "id": "profile_1BbA6sXxyUWHYvKqN5T3dM",
                      "name": "production",
                      "enabled": true,
                      "revision": 3,
                      "rules": [
                        {
                          "event": "channel.updated",
                          "pattern": "main"
                        }
                      ],
                      "bindings": [
                        {
                          "id": "secret_4Kd9PzQw2c9Wn5pQhVfKxa",
                          "name": "database_url",
                          "version_id": "secretv_7Hj2TzCw2c9Wn5pQhVfKxb",
                          "version": 1,
                          "profile": "production",
                          "kind": "owned",
                          "valid": true,
                          "created_at": "2026-11-04T09:00:00Z",
                          "updated_at": "2026-11-04T09:00:00Z"
                        }
                      ],
                      "created_at": "2026-11-04T09:00:00Z",
                      "updated_at": "2026-11-04T09:05:00Z"
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "A caller who can't write to the repository, or a team key without `gauss:write` (`insufficient_scope`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "insufficient_scope",
                    "message": "you need the write scope of lab/web; ask someone who manages it",
                    "retryable": false
                  }
                }
              }
            }
          },
          "404": {
            "description": "No such repository (`repository_not_found`), or profile (`profile_not_found`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "profile_not_found",
                    "message": "lab/web has no profile production; an administrator makes it with motor profiles set production",
                    "retryable": false
                  }
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/api/gauss/repos/{handle}/{repo}/profiles/{profile}": {
      "get": {
        "operationId": "get_profile",
        "summary": "Get a profile",
        "tags": [
          "Profiles"
        ],
        "description": "Returns the profile, with its rules and bindings, for a writer.",
        "parameters": [
          {
            "name": "handle",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The handle of the repository's account: a user, for their personal account, or a team."
          },
          {
            "name": "repo",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The repository's name."
          },
          {
            "name": "profile",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The profile's name, in snake case, such as `production`."
          }
        ],
        "responses": {
          "200": {
            "description": "The profile.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Profile"
                },
                "example": {
                  "id": "profile_1BbA6sXxyUWHYvKqN5T3dM",
                  "name": "production",
                  "enabled": true,
                  "revision": 3,
                  "rules": [
                    {
                      "event": "channel.updated",
                      "pattern": "main"
                    }
                  ],
                  "bindings": [
                    {
                      "id": "secret_4Kd9PzQw2c9Wn5pQhVfKxa",
                      "name": "database_url",
                      "version_id": "secretv_7Hj2TzCw2c9Wn5pQhVfKxb",
                      "version": 1,
                      "profile": "production",
                      "kind": "owned",
                      "valid": true,
                      "created_at": "2026-11-04T09:00:00Z",
                      "updated_at": "2026-11-04T09:00:00Z"
                    }
                  ],
                  "aws_role_arn": "arn:aws:iam::123456789012:role/deploy",
                  "audience": "sts.amazonaws.com",
                  "issuer": "https://gauss.motor.dev",
                  "subject": "repo:acme/web:profile:production:profile_1BbA6sXxyUWHYvKqN5T3dM",
                  "created_at": "2026-11-04T09:00:00Z",
                  "updated_at": "2026-11-04T09:05:00Z"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "A caller who can't write to the repository, or a team key without `gauss:write` (`insufficient_scope`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "insufficient_scope",
                    "message": "you need the write scope of lab/web; ask someone who manages it",
                    "retryable": false
                  }
                }
              }
            }
          },
          "404": {
            "description": "No such repository (`repository_not_found`), or profile (`profile_not_found`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "profile_not_found",
                    "message": "lab/web has no profile production; an administrator makes it with motor profiles set production",
                    "retryable": false
                  }
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      },
      "put": {
        "operationId": "set_profile",
        "summary": "Make a profile",
        "tags": [
          "Profiles"
        ],
        "description": "Makes the profile, if the repository doesn't have it, for an administrator of the repository's team, signed in, and sets its AWS role and its tokens' audience if the body names them; it keeps its rules and bindings. Changing them is a change of the profile: runs that started get nothing more from it. A new profile has no rules, so no hook's run may use it yet.",
        "parameters": [
          {
            "name": "handle",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The handle of the repository's account: a user, for their personal account, or a team."
          },
          {
            "name": "repo",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The repository's name."
          },
          {
            "name": "profile",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The profile's name, in snake case, such as `production`."
          }
        ],
        "responses": {
          "200": {
            "description": "The profile, which existed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Profile"
                },
                "example": {
                  "id": "profile_1BbA6sXxyUWHYvKqN5T3dM",
                  "name": "production",
                  "enabled": true,
                  "revision": 3,
                  "rules": [
                    {
                      "event": "channel.updated",
                      "pattern": "main"
                    }
                  ],
                  "bindings": [
                    {
                      "id": "secret_4Kd9PzQw2c9Wn5pQhVfKxa",
                      "name": "database_url",
                      "version_id": "secretv_7Hj2TzCw2c9Wn5pQhVfKxb",
                      "version": 1,
                      "profile": "production",
                      "kind": "owned",
                      "valid": true,
                      "created_at": "2026-11-04T09:00:00Z",
                      "updated_at": "2026-11-04T09:00:00Z"
                    }
                  ],
                  "aws_role_arn": "arn:aws:iam::123456789012:role/deploy",
                  "audience": "sts.amazonaws.com",
                  "issuer": "https://gauss.motor.dev",
                  "subject": "repo:acme/web:profile:production:profile_1BbA6sXxyUWHYvKqN5T3dM",
                  "created_at": "2026-11-04T09:00:00Z",
                  "updated_at": "2026-11-04T09:05:00Z"
                }
              }
            }
          },
          "201": {
            "description": "The new profile.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Profile"
                },
                "example": {
                  "id": "profile_1BbA6sXxyUWHYvKqN5T3dM",
                  "name": "production",
                  "enabled": true,
                  "revision": 3,
                  "rules": [
                    {
                      "event": "channel.updated",
                      "pattern": "main"
                    }
                  ],
                  "bindings": [
                    {
                      "id": "secret_4Kd9PzQw2c9Wn5pQhVfKxa",
                      "name": "database_url",
                      "version_id": "secretv_7Hj2TzCw2c9Wn5pQhVfKxb",
                      "version": 1,
                      "profile": "production",
                      "kind": "owned",
                      "valid": true,
                      "created_at": "2026-11-04T09:00:00Z",
                      "updated_at": "2026-11-04T09:00:00Z"
                    }
                  ],
                  "aws_role_arn": "arn:aws:iam::123456789012:role/deploy",
                  "audience": "sts.amazonaws.com",
                  "issuer": "https://gauss.motor.dev",
                  "subject": "repo:acme/web:profile:production:profile_1BbA6sXxyUWHYvKqN5T3dM",
                  "created_at": "2026-11-04T09:00:00Z",
                  "updated_at": "2026-11-04T09:05:00Z"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "A caller who isn't an administrator of the repository's team (`admin_required`), or a team key (`device_credential_required`): only an administrator, signed in, changes profiles.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "admin_required",
                    "message": "only an administrator of lab changes the secrets of lab/web",
                    "retryable": false
                  }
                }
              }
            }
          },
          "404": {
            "description": "No such repository (`repository_not_found`), or profile (`profile_not_found`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "profile_not_found",
                    "message": "lab/web has no profile production; an administrator makes it with motor profiles set production",
                    "retryable": false
                  }
                }
              }
            }
          },
          "422": {
            "description": "A name that isn't snake case (`invalid_profile`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "invalid_profile",
                    "message": "a profile's name is 1 to 64 lowercase letters, digits and underscores, starting with a letter, such as production; not \"Prod\"",
                    "retryable": false
                  }
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "aws_role_arn": {
                    "type": "string",
                    "description": "The AWS role's ARN, such as `arn:aws:iam::123456789012:role/deploy`, or empty for none."
                  },
                  "audience": {
                    "type": "string",
                    "description": "The tokens' audience, or empty for `sts.amazonaws.com`."
                  }
                }
              },
              "example": {
                "aws_role_arn": "arn:aws:iam::123456789012:role/deploy"
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "delete_profile",
        "summary": "Delete a profile",
        "tags": [
          "Profiles"
        ],
        "description": "Deletes the profile, its rules, its bindings, and its own values, for an administrator of the repository's team: no run gets them after. The repository's secrets that it inherited stay.",
        "parameters": [
          {
            "name": "handle",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The handle of the repository's account: a user, for their personal account, or a team."
          },
          {
            "name": "repo",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The repository's name."
          },
          {
            "name": "profile",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The profile's name, in snake case, such as `production`."
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted."
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "A caller who isn't an administrator of the repository's team (`admin_required`), or a team key (`device_credential_required`): only an administrator, signed in, changes profiles.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "admin_required",
                    "message": "only an administrator of lab changes the secrets of lab/web",
                    "retryable": false
                  }
                }
              }
            }
          },
          "404": {
            "description": "No such repository (`repository_not_found`), or profile (`profile_not_found`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "profile_not_found",
                    "message": "lab/web has no profile production; an administrator makes it with motor profiles set production",
                    "retryable": false
                  }
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/api/gauss/repos/{handle}/{repo}/profiles/{profile}/enable": {
      "post": {
        "operationId": "enable_profile",
        "summary": "Enable a profile",
        "tags": [
          "Profiles"
        ],
        "description": "Enables the profile, for an administrator of the repository's team.",
        "parameters": [
          {
            "name": "handle",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The handle of the repository's account: a user, for their personal account, or a team."
          },
          {
            "name": "repo",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The repository's name."
          },
          {
            "name": "profile",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The profile's name, in snake case, such as `production`."
          }
        ],
        "responses": {
          "200": {
            "description": "The profile.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Profile"
                },
                "example": {
                  "id": "profile_1BbA6sXxyUWHYvKqN5T3dM",
                  "name": "production",
                  "enabled": true,
                  "revision": 3,
                  "rules": [
                    {
                      "event": "channel.updated",
                      "pattern": "main"
                    }
                  ],
                  "bindings": [
                    {
                      "id": "secret_4Kd9PzQw2c9Wn5pQhVfKxa",
                      "name": "database_url",
                      "version_id": "secretv_7Hj2TzCw2c9Wn5pQhVfKxb",
                      "version": 1,
                      "profile": "production",
                      "kind": "owned",
                      "valid": true,
                      "created_at": "2026-11-04T09:00:00Z",
                      "updated_at": "2026-11-04T09:00:00Z"
                    }
                  ],
                  "aws_role_arn": "arn:aws:iam::123456789012:role/deploy",
                  "audience": "sts.amazonaws.com",
                  "issuer": "https://gauss.motor.dev",
                  "subject": "repo:acme/web:profile:production:profile_1BbA6sXxyUWHYvKqN5T3dM",
                  "created_at": "2026-11-04T09:00:00Z",
                  "updated_at": "2026-11-04T09:05:00Z"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "A caller who isn't an administrator of the repository's team (`admin_required`), or a team key (`device_credential_required`): only an administrator, signed in, changes profiles.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "admin_required",
                    "message": "only an administrator of lab changes the secrets of lab/web",
                    "retryable": false
                  }
                }
              }
            }
          },
          "404": {
            "description": "No such repository (`repository_not_found`), or profile (`profile_not_found`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "profile_not_found",
                    "message": "lab/web has no profile production; an administrator makes it with motor profiles set production",
                    "retryable": false
                  }
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/api/gauss/repos/{handle}/{repo}/profiles/{profile}/disable": {
      "post": {
        "operationId": "disable_profile",
        "summary": "Disable a profile",
        "tags": [
          "Profiles"
        ],
        "description": "Disables the profile, for an administrator of the repository's team: its tasks get nothing, even those of runs that started.",
        "parameters": [
          {
            "name": "handle",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The handle of the repository's account: a user, for their personal account, or a team."
          },
          {
            "name": "repo",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The repository's name."
          },
          {
            "name": "profile",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The profile's name, in snake case, such as `production`."
          }
        ],
        "responses": {
          "200": {
            "description": "The profile.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Profile"
                },
                "example": {
                  "id": "profile_1BbA6sXxyUWHYvKqN5T3dM",
                  "name": "production",
                  "enabled": true,
                  "revision": 3,
                  "rules": [
                    {
                      "event": "channel.updated",
                      "pattern": "main"
                    }
                  ],
                  "bindings": [
                    {
                      "id": "secret_4Kd9PzQw2c9Wn5pQhVfKxa",
                      "name": "database_url",
                      "version_id": "secretv_7Hj2TzCw2c9Wn5pQhVfKxb",
                      "version": 1,
                      "profile": "production",
                      "kind": "owned",
                      "valid": true,
                      "created_at": "2026-11-04T09:00:00Z",
                      "updated_at": "2026-11-04T09:00:00Z"
                    }
                  ],
                  "aws_role_arn": "arn:aws:iam::123456789012:role/deploy",
                  "audience": "sts.amazonaws.com",
                  "issuer": "https://gauss.motor.dev",
                  "subject": "repo:acme/web:profile:production:profile_1BbA6sXxyUWHYvKqN5T3dM",
                  "created_at": "2026-11-04T09:00:00Z",
                  "updated_at": "2026-11-04T09:05:00Z"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "A caller who isn't an administrator of the repository's team (`admin_required`), or a team key (`device_credential_required`): only an administrator, signed in, changes profiles.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "admin_required",
                    "message": "only an administrator of lab changes the secrets of lab/web",
                    "retryable": false
                  }
                }
              }
            }
          },
          "404": {
            "description": "No such repository (`repository_not_found`), or profile (`profile_not_found`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "profile_not_found",
                    "message": "lab/web has no profile production; an administrator makes it with motor profiles set production",
                    "retryable": false
                  }
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/api/gauss/repos/{handle}/{repo}/profiles/{profile}/rules": {
      "post": {
        "operationId": "add_profile_rule",
        "summary": "Add a rule of a profile",
        "tags": [
          "Profiles"
        ],
        "description": "Lets an event, and its channels or tags that the pattern matches, use the profile, for an administrator of the repository's team. Gauss matches the rule against its own record of a hook's event, never what a caller says.",
        "parameters": [
          {
            "name": "handle",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The handle of the repository's account: a user, for their personal account, or a team."
          },
          {
            "name": "repo",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The repository's name."
          },
          {
            "name": "profile",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The profile's name, in snake case, such as `production`."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "event",
                  "pattern"
                ],
                "properties": {
                  "event": {
                    "type": "string",
                    "enum": [
                      "channel.updated",
                      "tag.created",
                      "schedule",
                      "request"
                    ]
                  },
                  "pattern": {
                    "type": "string"
                  }
                }
              },
              "example": {
                "event": "channel.updated",
                "pattern": "main"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The profile.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Profile"
                },
                "example": {
                  "id": "profile_1BbA6sXxyUWHYvKqN5T3dM",
                  "name": "production",
                  "enabled": true,
                  "revision": 3,
                  "rules": [
                    {
                      "event": "channel.updated",
                      "pattern": "main"
                    }
                  ],
                  "bindings": [
                    {
                      "id": "secret_4Kd9PzQw2c9Wn5pQhVfKxa",
                      "name": "database_url",
                      "version_id": "secretv_7Hj2TzCw2c9Wn5pQhVfKxb",
                      "version": 1,
                      "profile": "production",
                      "kind": "owned",
                      "valid": true,
                      "created_at": "2026-11-04T09:00:00Z",
                      "updated_at": "2026-11-04T09:00:00Z"
                    }
                  ],
                  "aws_role_arn": "arn:aws:iam::123456789012:role/deploy",
                  "audience": "sts.amazonaws.com",
                  "issuer": "https://gauss.motor.dev",
                  "subject": "repo:acme/web:profile:production:profile_1BbA6sXxyUWHYvKqN5T3dM",
                  "created_at": "2026-11-04T09:00:00Z",
                  "updated_at": "2026-11-04T09:05:00Z"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "A caller who isn't an administrator of the repository's team (`admin_required`), or a team key (`device_credential_required`): only an administrator, signed in, changes profiles.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "admin_required",
                    "message": "only an administrator of lab changes the secrets of lab/web",
                    "retryable": false
                  }
                }
              }
            }
          },
          "404": {
            "description": "No such repository (`repository_not_found`), or profile (`profile_not_found`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "profile_not_found",
                    "message": "lab/web has no profile production; an administrator makes it with motor profiles set production",
                    "retryable": false
                  }
                }
              }
            }
          },
          "422": {
            "description": "An event that a profile's rule can't name, or an invalid pattern (`invalid_rule`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "invalid_rule",
                    "message": "a profile's rule names the event channel.updated, tag.created, schedule, request; not \"merge.candidate_updated\"",
                    "retryable": false
                  }
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      },
      "delete": {
        "operationId": "remove_profile_rule",
        "summary": "Remove a rule of a profile",
        "tags": [
          "Profiles"
        ],
        "description": "Removes a rule of the profile, for an administrator of the repository's team.",
        "parameters": [
          {
            "name": "handle",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The handle of the repository's account: a user, for their personal account, or a team."
          },
          {
            "name": "repo",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The repository's name."
          },
          {
            "name": "profile",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The profile's name, in snake case, such as `production`."
          },
          {
            "name": "event",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The rule's event."
          },
          {
            "name": "pattern",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The rule's pattern."
          }
        ],
        "responses": {
          "200": {
            "description": "The profile.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Profile"
                },
                "example": {
                  "id": "profile_1BbA6sXxyUWHYvKqN5T3dM",
                  "name": "production",
                  "enabled": true,
                  "revision": 3,
                  "rules": [
                    {
                      "event": "channel.updated",
                      "pattern": "main"
                    }
                  ],
                  "bindings": [
                    {
                      "id": "secret_4Kd9PzQw2c9Wn5pQhVfKxa",
                      "name": "database_url",
                      "version_id": "secretv_7Hj2TzCw2c9Wn5pQhVfKxb",
                      "version": 1,
                      "profile": "production",
                      "kind": "owned",
                      "valid": true,
                      "created_at": "2026-11-04T09:00:00Z",
                      "updated_at": "2026-11-04T09:00:00Z"
                    }
                  ],
                  "aws_role_arn": "arn:aws:iam::123456789012:role/deploy",
                  "audience": "sts.amazonaws.com",
                  "issuer": "https://gauss.motor.dev",
                  "subject": "repo:acme/web:profile:production:profile_1BbA6sXxyUWHYvKqN5T3dM",
                  "created_at": "2026-11-04T09:00:00Z",
                  "updated_at": "2026-11-04T09:05:00Z"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "description": "A caller who isn't an administrator of the repository's team (`admin_required`), or a team key (`device_credential_required`): only an administrator, signed in, changes profiles.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "admin_required",
                    "message": "only an administrator of lab changes the secrets of lab/web",
                    "retryable": false
                  }
                }
              }
            }
          },
          "404": {
            "description": "No such repository, profile, or rule (`rule_not_found`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "rule_not_found",
                    "message": "the profile production has no rule of channel.updated main",
                    "retryable": false
                  }
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearer": {
        "type": "http",
        "scheme": "bearer",
        "description": "A session key (`motor_sk_`), a user key (`motor_uk_`), or a team key (`motor_tk_`)."
      },
      "dpop": {
        "type": "http",
        "scheme": "DPoP",
        "description": "Device-bound session key. Each request requires a `DPoP` proof signed by the device key (RFC 9449)."
      }
    },
    "responses": {
      "BadRequest": {
        "description": "The request body must be a JSON object (`invalid_json`).",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "error": {
                "code": "invalid_json",
                "message": "The body isn't a JSON object: unexpected EOF.",
                "retryable": false
              }
            }
          }
        }
      },
      "Unauthorized": {
        "description": "Motor refused the credential: `unauthorized`, `credential_expired`, `credential_revoked`, `dpop_required`, or `invalid_dpop_proof`. An agent can run `motor auth` to request a new session; the person must approve the sign-in.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "error": {
                "code": "credential_expired",
                "message": "The credential expired. Get a new one: motor auth for a session key, or a new team key from a team admin.",
                "retryable": false
              }
            }
          }
        }
      },
      "TooLarge": {
        "description": "The body is too large (`body_too_large`).",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "error": {
                "code": "body_too_large",
                "message": "The body is larger than 1 MiB.",
                "retryable": false
              }
            }
          }
        }
      },
      "RateLimited": {
        "description": "The credential exceeded its rate limit (`rate_limited`). Wait `retry_after_seconds` before retrying.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "error": {
                "code": "rate_limited",
                "message": "Too many requests: the limit is 600 a minute.",
                "retryable": true,
                "retry_after_seconds": 12
              }
            }
          }
        }
      },
      "Unavailable": {
        "description": "Gauss, or a service that it needs, can't answer now (`temporarily_unavailable`, `unavailable`, `motor_unavailable`, `database_unavailable`, `engine_unavailable`): wait `retry_after_seconds`, and retry the same request, with the same Idempotency-Key.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "error": {
                "code": "temporarily_unavailable",
                "message": "Gauss can't answer now. Try again in a moment.",
                "retryable": true,
                "retry_after_seconds": 1
              }
            }
          }
        }
      }
    },
    "schemas": {
      "Repository": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "id",
          "handle",
          "name",
          "main_channel",
          "visibility",
          "status",
          "provisioning_error",
          "url",
          "created_at",
          "updated_at",
          "effective_scopes",
          "vcs_kind"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "The repository's ID, which never changes."
          },
          "handle": {
            "type": "string",
            "description": "The owning team’s handle."
          },
          "name": {
            "type": "string"
          },
          "main_channel": {
            "type": "string",
            "description": "The main channel. Pushes that add changes to this channel create merge records."
          },
          "visibility": {
            "type": "string",
            "enum": [
              "private",
              "public"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "provisioning",
              "ready"
            ],
            "description": "`provisioning` until the engine has the repository. Gauss serves only ready repositories."
          },
          "provisioning_error": {
            "type": "string",
            "description": "Last provisioning error, or an empty string."
          },
          "url": {
            "type": "string",
            "description": "The repository's URL: for `amp clone`, or, with `.git` after it, for `git clone` of a Git repository."
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          },
          "effective_scopes": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "read",
                "write",
                "publish",
                "manage"
              ]
            },
            "description": "The caller’s effective scopes, including implied permissions: `read`, `write`, `publish`, and `manage`."
          },
          "vcs_kind": {
            "type": "string",
            "enum": [
              "amp",
              "git"
            ],
            "description": "The repository's version control: `amp`, or `git`, which Git clones and pushes at `<url>.git`. It never changes."
          }
        }
      },
      "RepositoryPage": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "data",
          "next_cursor"
        ],
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Repository"
            }
          },
          "next_cursor": {
            "type": [
              "string",
              "null"
            ],
            "description": "Cursor for the next page, or null if there are no more results."
          }
        }
      },
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "description": "What went wrong, for programs: Gauss's stable code, such as `repository_not_found`, or Motor's, such as `credential_expired`."
              },
              "message": {
                "type": "string",
                "description": "Human-readable error message."
              },
              "field": {
                "type": "string",
                "description": "The invalid field’s name, for `invalid_field` errors."
              },
              "retryable": {
                "type": "boolean",
                "description": "Whether retrying the same request may succeed."
              },
              "retry_after_seconds": {
                "type": "integer",
                "description": "Seconds to wait before retrying."
              }
            },
            "required": [
              "code",
              "message",
              "retryable"
            ],
            "additionalProperties": false
          }
        },
        "required": [
          "error"
        ],
        "additionalProperties": false,
        "title": "Error"
      },
      "ArtifactFile": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "name",
          "size",
          "sha256",
          "content_type"
        ],
        "properties": {
          "name": {
            "type": "string"
          },
          "size": {
            "type": "integer"
          },
          "sha256": {
            "type": "string",
            "description": "The SHA-256 of the file, in hex."
          },
          "content_type": {
            "type": "string"
          }
        }
      },
      "Artifact": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "id",
          "version",
          "source_tag",
          "source_state",
          "status",
          "files",
          "url",
          "created_at",
          "published_at"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "version": {
            "type": "string"
          },
          "source_tag": {
            "type": "string"
          },
          "source_state": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "uploading",
              "published",
              "deleted"
            ],
            "description": "Deleted artifacts retain their version but have no files."
          },
          "files": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ArtifactFile"
            }
          },
          "url": {
            "type": "string",
            "description": "The artifact's public URL: its manifest is at <url>/manifest.json, and each file at <url>/<name>."
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "published_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          }
        }
      },
      "ArtifactList": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "data"
        ],
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Artifact"
            }
          }
        }
      },
      "Upload": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "name",
          "size",
          "sha256",
          "content_type",
          "upload"
        ],
        "properties": {
          "name": {
            "type": "string"
          },
          "size": {
            "type": "integer",
            "format": "int64"
          },
          "sha256": {
            "type": "string"
          },
          "content_type": {
            "type": "string"
          },
          "upload": {
            "description": "Presigned upload request, or null if the file is already uploaded. Before `expires_at`, send the file to `url` using `method` and the supplied headers. Storage rejects mismatched size, digest, or content type, and refuses to overwrite an existing object.",
            "oneOf": [
              {
                "type": "null"
              },
              {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "url",
                  "method",
                  "headers",
                  "expires_at"
                ],
                "properties": {
                  "url": {
                    "type": "string"
                  },
                  "method": {
                    "type": "string"
                  },
                  "headers": {
                    "type": "object",
                    "additionalProperties": {
                      "type": "string"
                    }
                  },
                  "expires_at": {
                    "type": "string",
                    "format": "date-time"
                  }
                }
              }
            ]
          }
        }
      },
      "Access": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "repository_id",
          "handle",
          "repository",
          "team_scopes",
          "admin_scopes",
          "grants"
        ],
        "properties": {
          "repository_id": {
            "type": "string"
          },
          "handle": {
            "type": "string"
          },
          "repository": {
            "type": "string",
            "description": "The repository's name."
          },
          "team_scopes": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "read",
                "write",
                "publish",
                "manage"
              ]
            },
            "description": "Default repository scopes for every team member."
          },
          "admin_scopes": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "read",
                "write",
                "publish",
                "manage"
              ]
            },
            "description": "Repository scopes granted to team admins, regardless of explicit grants."
          },
          "grants": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Grant"
            },
            "description": "The explicit grants, by user ID."
          }
        }
      },
      "Grant": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "user_id",
          "scopes",
          "granted_by",
          "updated_at",
          "active",
          "effective_scopes",
          "sources"
        ],
        "properties": {
          "user_id": {
            "type": "string",
            "description": "The Motor user's ID."
          },
          "scopes": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "read",
                "write",
                "publish",
                "manage"
              ]
            },
            "description": "The scopes that the grant names."
          },
          "granted_by": {
            "type": "string",
            "description": "ID of the user who last updated the grant."
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          },
          "active": {
            "type": "boolean",
            "description": "Whether the membership associated with the grant is still active. Leaving the team invalidates the grant; rejoining does not restore it."
          },
          "effective_scopes": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "read",
                "write",
                "publish",
                "manage"
              ]
            },
            "description": "Combined scopes from the active grant, team defaults, and admin role. Empty if the user is not a team member."
          },
          "sources": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "grant",
                "team",
                "admin"
              ]
            },
            "description": "Where the effective scopes come from."
          }
        }
      },
      "HookDiagnostic": {
        "type": "object",
        "description": "A problem of the files of `.gauss/`.",
        "additionalProperties": false,
        "required": [
          "file",
          "line",
          "column",
          "code",
          "message"
        ],
        "properties": {
          "file": {
            "type": "string",
            "description": "The file, from the repository's root, or empty for a problem of no file."
          },
          "line": {
            "type": "integer"
          },
          "column": {
            "type": "integer"
          },
          "code": {
            "type": "string",
            "description": "A stable code: `evaluation_limit` for an evaluation that exceeded a limit of Starlark, such as its steps, or a problem of the files, such as `syntax`, `runtime`, `load`, `invalid_hook`, `duplicate_hook`, `unknown_event`, `unused_filter`, `invalid_pattern`, `invalid_action` or `too_large`."
          },
          "message": {
            "type": "string",
            "description": "What is wrong, and what to do."
          }
        }
      },
      "HookLocation": {
        "type": "object",
        "description": "Where `hook()` was called.",
        "additionalProperties": false,
        "required": [
          "file",
          "line",
          "column"
        ],
        "properties": {
          "file": {
            "type": "string"
          },
          "line": {
            "type": "integer"
          },
          "column": {
            "type": "integer"
          }
        }
      },
      "PistonHookAction": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "config",
          "targets",
          "inputs",
          "profile"
        ],
        "properties": {
          "config": {
            "type": "string",
            "description": "The Piston config, from the repository's root."
          },
          "targets": {
            "type": "array",
            "description": "The config's targets to run.",
            "items": {
              "type": "string"
            }
          },
          "inputs": {
            "type": "object",
            "description": "The config's inputs: static strings, never secrets.",
            "additionalProperties": {
              "type": "string"
            }
          },
          "profile": {
            "type": "string",
            "description": "The team's profile that the run's tasks may use (those that name it), or empty. The profile's bindings, which only the team's admins change, decide whether the hook's runs may: a binding must match the repository, the event, and its channel or tag. A hook of merge.candidate_updated names none."
          }
        }
      },
      "HookAction": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "type",
          "piston"
        ],
        "properties": {
          "type": {
            "type": "string",
            "description": "The action's kind: `piston`, whose field says how.",
            "enum": [
              "piston"
            ]
          },
          "piston": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/PistonHookAction"
              },
              {
                "type": "null"
              }
            ]
          }
        }
      },
      "Hook": {
        "type": "object",
        "description": "A hook of `.gauss/hooks.star`: the events that it subscribes to, its filters, and what it runs.",
        "additionalProperties": false,
        "required": [
          "name",
          "events",
          "channels",
          "tags",
          "action",
          "location",
          "check",
          "schedules",
          "paths",
          "paths_ignore"
        ],
        "properties": {
          "name": {
            "type": "string",
            "description": "The hook's name, unique in its state."
          },
          "events": {
            "type": "array",
            "description": "The events that it subscribes to: `channel.updated`, `tag.created`, `merge.candidate_updated`, `schedule`.",
            "items": {
              "type": "string"
            }
          },
          "channels": {
            "type": "array",
            "description": "Names and glob patterns of channels that a channel event must match; empty matches every channel. `*` matches any characters but `/`, and `**` any characters.",
            "items": {
              "type": "string"
            }
          },
          "tags": {
            "type": "array",
            "description": "Names and glob patterns of tags that a tag event must match; empty matches every tag.",
            "items": {
              "type": "string"
            }
          },
          "action": {
            "$ref": "#/components/schemas/HookAction"
          },
          "location": {
            "$ref": "#/components/schemas/HookLocation"
          },
          "check": {
            "type": "string",
            "description": "The check whose result the hook's run is, for merge candidates (`hook(check = ...)`), or empty. A check hook subscribes to `merge.candidate_updated` alone; its `channels` filter the merge's target."
          },
          "schedules": {
            "type": "array",
            "description": "The cron expressions of a hook of `schedule` (`hook(schedules = [...])`), in UTC, with their fields separated by one space, or empty. Its `channels` are the exact names of the channels whose heads they run.",
            "items": {
              "type": "string"
            }
          },
          "paths": {
            "type": "array",
            "description": "The hook's path filter (`hook(paths = [...])`) for `channel.updated` or `merge.candidate_updated`, or empty. Patterns match paths from the repository's root and apply in order. The hook runs when the last pattern that matches a changed path doesn't start with `!`. `*` matches any characters except `/`; `**` matches any characters; `**/` matches zero or more directories. As on GitHub, `?` matches zero or one occurrence of the preceding character (`*.jsx?` matches `page.js` and `page.jsx`), and `+` matches one or more occurrences.",
            "items": {
              "type": "string"
            }
          },
          "paths_ignore": {
            "type": "array",
            "description": "The hook's path filter of ignored paths (`hook(paths_ignore = [...])`), or empty: the hook runs when a changed path isn't ignored, which is when no pattern matches it, or the last that matches it starts with `!`. A hook has `paths` or `paths_ignore`, not both.",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "HookEvaluation": {
        "type": "object",
        "description": "What a state's `.gauss/hooks.star` declares, without its hooks.",
        "additionalProperties": false,
        "required": [
          "selected_by",
          "selected_name",
          "state",
          "path",
          "status",
          "version",
          "digest",
          "diagnostics"
        ],
        "properties": {
          "selected_by": {
            "type": "string",
            "description": "How the state was chosen: `state`, `channel`, `tag`, `default_channel` (the main channel, which the request didn't name), `event` (the event's hook state), `cursor` (a page after the first, of the first page's state), or `files` (proposed files, of no state).",
            "enum": [
              "state",
              "channel",
              "tag",
              "default_channel",
              "event",
              "cursor",
              "files"
            ]
          },
          "selected_name": {
            "type": "string",
            "description": "The channel, the tag or the event that chose the state, or empty."
          },
          "state": {
            "type": "string",
            "description": "The state, or empty for proposed files."
          },
          "path": {
            "type": "string",
            "description": "The file that declares hooks: `.gauss/hooks.star`."
          },
          "status": {
            "type": "string",
            "description": "`absent` (no file: no hooks), `valid`, `invalid` (problems of the files: Gauss runs none of its hooks), or `limit_exceeded` (the evaluation exceeded a limit of Starlark, such as its steps, which a diagnostic of the code `evaluation_limit` names: Gauss runs none of its hooks either, and doesn't evaluate the state again).",
            "enum": [
              "absent",
              "valid",
              "invalid",
              "limit_exceeded"
            ]
          },
          "version": {
            "type": "integer",
            "description": "The version of the evaluation. A new one evaluates states again."
          },
          "digest": {
            "type": "string",
            "description": "The identity of the files of `.gauss/` that the evaluation read, `sha256:<hex>`, or empty when there were none."
          },
          "diagnostics": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/HookDiagnostic"
            }
          }
        }
      },
      "HookMatch": {
        "type": "object",
        "description": "Whether a hook matches an event.",
        "additionalProperties": false,
        "required": [
          "hook",
          "matched",
          "reason",
          "paths",
          "path",
          "paths_detail"
        ],
        "properties": {
          "hook": {
            "$ref": "#/components/schemas/Hook"
          },
          "matched": {
            "type": "boolean"
          },
          "reason": {
            "type": "string",
            "description": "Why the hook doesn't match, or empty."
          },
          "paths": {
            "type": "string",
            "description": "The outcome of the hook's path filters, for a hook that has them and whose other filters match the event: `matched` (`path` passes them), `missed` (no changed path passes them, so the hook doesn't run), `unknown` (Gauss didn't know the changed paths, so the hook runs: `paths_detail` says why), or `bypassed` (the event doesn't filter paths, as a run by hand or a diagnostic of a merge's target doesn't). Empty for other hooks.",
            "enum": [
              "",
              "matched",
              "missed",
              "unknown",
              "bypassed"
            ]
          },
          "path": {
            "type": "string",
            "description": "The first changed path that passes the hook's path filters, for `matched`, or empty."
          },
          "paths_detail": {
            "type": "string",
            "description": "Why the outcome of the path filters is `unknown`, or how many paths the event changed, for `missed`, or empty."
          }
        }
      },
      "HookList": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "evaluation",
          "hooks",
          "next_cursor"
        ],
        "properties": {
          "evaluation": {
            "$ref": "#/components/schemas/HookEvaluation"
          },
          "hooks": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Hook"
            }
          },
          "next_cursor": {
            "type": [
              "string",
              "null"
            ],
            "description": "The cursor of the next page, of the same state, or null after the last."
          }
        }
      },
      "HookDetail": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "evaluation",
          "hook"
        ],
        "properties": {
          "evaluation": {
            "$ref": "#/components/schemas/HookEvaluation"
          },
          "hook": {
            "$ref": "#/components/schemas/Hook"
          }
        }
      },
      "HookValidation": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "evaluation",
          "hooks",
          "matches"
        ],
        "properties": {
          "evaluation": {
            "$ref": "#/components/schemas/HookEvaluation"
          },
          "hooks": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Hook"
            }
          },
          "matches": {
            "type": "array",
            "description": "Each hook, and whether the sample event matches it; empty without a sample event.",
            "items": {
              "$ref": "#/components/schemas/HookMatch"
            }
          }
        }
      },
      "EventDiscovery": {
        "type": "object",
        "description": "How far Gauss is in finding the hooks that an event runs.",
        "additionalProperties": false,
        "required": [
          "status",
          "error",
          "attempts",
          "discovered_at"
        ],
        "properties": {
          "status": {
            "type": "string",
            "description": "`pending` until Gauss evaluated the event's hook state and matched its hooks, then `done`; `failed` if the engine can't read the state, or after a few tries that failed, such as while the engine was down; or `skipped` for a silent event.",
            "enum": [
              "pending",
              "done",
              "failed",
              "skipped"
            ]
          },
          "error": {
            "type": "string",
            "description": "Why it failed, or why its last try failed while it's pending, or empty."
          },
          "attempts": {
            "type": "integer",
            "description": "The tries that failed. Gauss tries a pending event again later, at most five times, without holding up the events after it."
          },
          "discovered_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          }
        }
      },
      "RepositoryEvent": {
        "type": "object",
        "description": "An event of a repository.",
        "additionalProperties": false,
        "required": [
          "id",
          "repository_id",
          "handle",
          "repository",
          "type",
          "channel",
          "tag",
          "before",
          "after",
          "hook_state",
          "uploader",
          "summary",
          "change_count",
          "silent",
          "occurred_at",
          "recorded_at",
          "discovery",
          "actor",
          "causation",
          "merge_id",
          "merge_generation",
          "schedule"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "The event's ID, which never changes."
          },
          "repository_id": {
            "type": "string"
          },
          "handle": {
            "type": "string"
          },
          "repository": {
            "type": "string"
          },
          "type": {
            "type": "string",
            "description": "What happened: changes reached a channel (`channel.updated`), a tag was made (`tag.created`), a merge has a new candidate (`merge.candidate_updated`), or a scheduled run of a channel's head became due (`schedule`).",
            "enum": [
              "channel.updated",
              "tag.created",
              "merge.candidate_updated",
              "schedule"
            ]
          },
          "schedule": {
            "type": "string",
            "description": "The cron expression of a `schedule` event, whose `occurred_at` is the schedule's time, and whose `after` is the channel's head that it runs; or empty."
          },
          "channel": {
            "type": "string",
            "description": "The channel of a channel event, or empty."
          },
          "tag": {
            "type": "string",
            "description": "The tag of a tag event, or empty."
          },
          "before": {
            "type": "string",
            "description": "The channel's state before a `channel.updated`, or empty."
          },
          "after": {
            "type": "string",
            "description": "The channel's state after a `channel.updated`, or the tag's state."
          },
          "hook_state": {
            "type": "string",
            "description": "The state whose `.gauss/hooks.star` says what the event runs, chosen when Gauss recorded the event: `after`. A later change of the file doesn't change it."
          },
          "uploader": {
            "type": "string",
            "description": "The user or the team key that pushed, as Gauss verified it, or empty."
          },
          "summary": {
            "type": "string",
            "description": "The push's summary, or empty."
          },
          "change_count": {
            "type": "integer",
            "description": "The changes that a `channel.updated` added."
          },
          "silent": {
            "type": "boolean",
            "description": "Whether the event is of history that the repository brought to Gauss, which runs nothing."
          },
          "occurred_at": {
            "type": "string",
            "format": "date-time"
          },
          "recorded_at": {
            "type": "string",
            "format": "date-time"
          },
          "discovery": {
            "$ref": "#/components/schemas/EventDiscovery"
          },
          "actor": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Actor"
              },
              {
                "type": "null"
              }
            ],
            "description": "Who made the event, as Gauss authenticated them, or null for the engine's own operations, whose events invoke no hooks."
          },
          "causation": {
            "$ref": "#/components/schemas/Causation"
          },
          "merge_id": {
            "type": "string",
            "description": "The merge of a `merge.candidate_updated`, or empty."
          },
          "merge_generation": {
            "type": "integer",
            "description": "The merge's generation of a `merge.candidate_updated`, or 0."
          }
        }
      },
      "RepositoryEventPage": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "data",
          "next_cursor"
        ],
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/RepositoryEvent"
            }
          },
          "next_cursor": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "RepositoryEventDetail": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "event",
          "invocations",
          "evaluation",
          "matches"
        ],
        "properties": {
          "event": {
            "$ref": "#/components/schemas/RepositoryEvent"
          },
          "invocations": {
            "type": "array",
            "description": "The invocations of the hooks that matched the event, run or suppressed: empty until discovery is done.",
            "items": {
              "$ref": "#/components/schemas/Invocation"
            }
          },
          "evaluation": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/HookEvaluation"
              },
              {
                "type": "null"
              }
            ],
            "description": "What the event's hook state declares, once discovery is done; null before."
          },
          "matches": {
            "type": "array",
            "description": "Each hook of the event's hook state, and whether it matches the event: the matching hooks are what the event runs.",
            "items": {
              "$ref": "#/components/schemas/HookMatch"
            }
          }
        }
      },
      "RepositoryEventChanges": {
        "type": "object",
        "description": "A page of the changes of a `channel.updated` event.",
        "additionalProperties": false,
        "required": [
          "changes",
          "next_page_token",
          "complete",
          "change_count"
        ],
        "properties": {
          "changes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The changes' hashes, in the order that the update applied them."
          },
          "next_page_token": {
            "type": "string",
            "description": "The token of the next page, or empty after the last page that Gauss has."
          },
          "complete": {
            "type": "boolean",
            "description": "Whether Gauss recorded every change of the update. Until it's true, the last page isn't the end of the list: list it again later."
          },
          "change_count": {
            "type": "integer",
            "description": "The number of the update's changes."
          }
        }
      },
      "ChannelAutomation": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "channel",
          "main_channel",
          "evaluation",
          "matches",
          "policy"
        ],
        "properties": {
          "channel": {
            "type": "string"
          },
          "main_channel": {
            "type": "boolean",
            "description": "Whether the channel is the repository's main channel."
          },
          "evaluation": {
            "$ref": "#/components/schemas/HookEvaluation"
          },
          "matches": {
            "type": "array",
            "description": "Each hook of the channel's current state, and whether a sample event of the channel matches it.",
            "items": {
              "$ref": "#/components/schemas/HookMatch"
            }
          },
          "policy": {
            "allOf": [
              {
                "$ref": "#/components/schemas/ChannelPolicy"
              }
            ],
            "description": "The channel's policy: the checks that a merge into it needs, whatever its hooks declare."
          },
          "schedules": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/ChannelSchedules"
              },
              {
                "type": "null"
              }
            ],
            "description": "The schedules that Gauss runs on the channel, or null if no head of the channel declared any."
          }
        }
      },
      "ChannelSchedules": {
        "type": "object",
        "description": "The schedules registered for the channel's most recently observed head.",
        "additionalProperties": false,
        "required": [
          "state",
          "status",
          "error",
          "check_error",
          "checked_at",
          "schedules"
        ],
        "properties": {
          "state": {
            "type": "string",
            "description": "The state that declares the schedules and is used for their runs."
          },
          "status": {
            "type": "string",
            "description": "`valid`, or `invalid`: the state's `.gauss/hooks.star` has problems (`error`), so no schedule of the channel runs until a later head fixes them.",
            "enum": [
              "valid",
              "invalid"
            ]
          },
          "error": {
            "type": "string"
          },
          "check_error": {
            "type": "string",
            "description": "Why Gauss couldn't check the channel's head the last time that it tried, or empty: the schedules wait until it can."
          },
          "checked_at": {
            "type": "string",
            "format": "date-time",
            "description": "When Gauss last found that `state` is the channel's head."
          },
          "schedules": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ChannelSchedule"
            }
          }
        }
      },
      "ChannelSchedule": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "schedule",
          "hooks",
          "next_at",
          "last_at",
          "last_event_id"
        ],
        "properties": {
          "schedule": {
            "type": "string",
            "description": "The cron expression, in UTC."
          },
          "hooks": {
            "type": "array",
            "description": "The hooks of the state that have the schedule.",
            "items": {
              "type": "string"
            }
          },
          "next_at": {
            "type": "string",
            "format": "date-time",
            "description": "The schedule's next time."
          },
          "last_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "The time of the schedule's last occurrence, or null."
          },
          "last_event_id": {
            "type": "string",
            "description": "The event of the last occurrence, or empty."
          }
        }
      },
      "Actor": {
        "type": "object",
        "description": "Who made an event, invoked a hook, or asked for an attempt, as Gauss authenticated them, or what an invocation's runs execute as: a user, a team key, or an `automation`, a repository's hooks (as a push or a publication with an invocation's token acts, in its own repository alone).",
        "additionalProperties": false,
        "required": [
          "kind",
          "id",
          "name"
        ],
        "properties": {
          "kind": {
            "type": "string",
            "enum": [
              "user",
              "team_key",
              "automation"
            ]
          },
          "id": {
            "type": "string",
            "description": "`user_…`, `tkey_…`, or, for a repository's hooks, the repository's `repo_…`."
          },
          "name": {
            "type": "string",
            "description": "Such as `acme/app hooks`, for a repository's hooks."
          }
        }
      },
      "Causation": {
        "type": "object",
        "description": "Where an event or an invocation comes from. An event that a person or a service made from outside is a root: its `depth` is 0, and `root_event_id` its own ID. An invocation has its event's root and depth; one invoked by hand has no root event, and depth 0. An event that an invocation's run made, by pushing with the invocation's token, has the invocation's root, the invocation as its parent, and the invocation's depth + 1. Gauss suppresses the invocations of events deeper than its maximum, so that hooks can't trigger each other forever.",
        "additionalProperties": false,
        "required": [
          "root_event_id",
          "parent_invocation_id",
          "depth"
        ],
        "properties": {
          "root_event_id": {
            "type": "string",
            "description": "The event at the root of the chain, or empty."
          },
          "parent_invocation_id": {
            "type": "string",
            "description": "The invocation whose run made the event, or empty."
          },
          "depth": {
            "type": "integer"
          }
        }
      },
      "InvocationAttempt": {
        "type": "object",
        "description": "An attempt of an invocation: a Piston run.",
        "additionalProperties": false,
        "required": [
          "number",
          "run_id",
          "status",
          "conclusion",
          "failure_origin",
          "error",
          "created_at",
          "started_at",
          "finished_at",
          "requested_by",
          "context"
        ],
        "properties": {
          "number": {
            "type": "integer",
            "description": "From 1."
          },
          "run_id": {
            "type": "string",
            "description": "The Piston run (`run_…`), once Piston started it, or empty."
          },
          "status": {
            "type": "string",
            "enum": [
              "submitting",
              "queued",
              "running",
              "completed"
            ]
          },
          "conclusion": {
            "type": "string",
            "enum": [
              "",
              "passed",
              "failed",
              "infrastructure_error",
              "cancelled",
              "timed_out"
            ],
            "description": "Once completed, as the invocation's; empty before."
          },
          "failure_origin": {
            "type": "string",
            "enum": [
              "",
              "command",
              "timeout",
              "infrastructure",
              "permission",
              "quota",
              "configuration",
              "canceled",
              "skipped",
              "publication"
            ],
            "description": "Once completed without passing, where the failure came from, as Piston or Gauss decided it, never from the run's config or logs: the command's code, a timeout of a task or a step, Piston's infrastructure, a refusal of permission, a quota or the team's standing, the service's configuration, a cancellation, a task that didn't run, or an artifact that didn't publish. Empty for a pass, before it completed, or if unknown."
          },
          "error": {
            "type": "string",
            "description": "Why the attempt failed to start, or Piston's reason for how it ended, or empty."
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "started_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "finished_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "requested_by": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Actor"
              },
              {
                "type": "null"
              }
            ],
            "description": "Who asked for the attempt: the invocation's actor for the first, or whoever retried it."
          },
          "context": {
            "type": [
              "object",
              "null"
            ],
            "description": "The context that the attempt's run got, exactly, as a JSON object: the event, the repository, the actor, the channel or the tag, the source state, the hook, the invocation with this attempt (`attempt_id`, `attempt`), and the causation. Piston gives it to the workflow as `context()`. It never holds a credential."
          }
        }
      },
      "Invocation": {
        "type": "object",
        "description": "An invocation of a hook: of an event's matching hook, or by hand. Its `actor` is who caused it; its runs execute as the repository's hooks (`runs_as`), which read, write, and publish in their own repository alone, and manage nothing; each attempt's `requested_by` is who asked for it. Gauss starts a run only while the actor, the attempt's requester, and for a merge's check whoever opened the merge, may write to the repository; otherwise the attempt fails, with why.",
        "additionalProperties": false,
        "required": [
          "id",
          "repository_id",
          "handle",
          "repository",
          "hook",
          "hook_state",
          "hook_version",
          "event_id",
          "trigger",
          "source_state",
          "action",
          "actor",
          "runs_as",
          "status",
          "conclusion",
          "suppression",
          "suppression_detail",
          "causation",
          "created_at",
          "updated_at",
          "attempts",
          "check"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "The invocation's ID (`inv_…`), which never changes."
          },
          "repository_id": {
            "type": "string"
          },
          "handle": {
            "type": "string"
          },
          "repository": {
            "type": "string"
          },
          "hook": {
            "type": "string",
            "description": "The hook's name."
          },
          "hook_state": {
            "type": "string",
            "description": "The state whose `.gauss/hooks.star` declared the hook."
          },
          "hook_version": {
            "type": "integer",
            "description": "The version of that state's evaluation."
          },
          "event_id": {
            "type": "string",
            "description": "The event that matched the hook, or empty for an invocation by hand."
          },
          "trigger": {
            "type": "string",
            "enum": [
              "event",
              "manual"
            ]
          },
          "source_state": {
            "type": "string",
            "description": "The state whose files the run gets."
          },
          "action": {
            "$ref": "#/components/schemas/HookAction"
          },
          "actor": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Actor"
              },
              {
                "type": "null"
              }
            ],
            "description": "Who caused the invocation: who made its event, or invoked the hook by hand. A push that another invocation's run made with its token has that invocation's repository's hooks as its actor, and the invocation as its causation's parent. A retry never changes it."
          },
          "runs_as": {
            "allOf": [
              {
                "$ref": "#/components/schemas/Actor"
              }
            ],
            "description": "What the invocation's runs execute as: the repository's hooks (`automation`)."
          },
          "status": {
            "type": "string",
            "enum": [
              "suppressed",
              "pending",
              "running",
              "completed"
            ],
            "description": "`suppressed` if Gauss won't run it (see `suppression`); otherwise `pending` until its attempt's run starts, `running`, then `completed`. A retry makes a completed invocation pending again."
          },
          "conclusion": {
            "type": "string",
            "enum": [
              "",
              "passed",
              "failed",
              "infrastructure_error",
              "cancelled",
              "timed_out"
            ],
            "description": "Once completed, its last attempt's; empty before."
          },
          "suppression": {
            "type": "string",
            "enum": [
              "",
              "depth",
              "no_actor"
            ],
            "description": "Why Gauss won't run it, or empty: the event is deeper in its chain of hooks than the maximum (`depth`), nobody that Gauss authenticated made the event (`no_actor`), or the event is of history that the repository brought to Gauss (). A suppressed invocation has no attempts, and can't be retried: it records that the hook matched."
          },
          "suppression_detail": {
            "type": "string",
            "description": "The suppression, for people, or empty."
          },
          "causation": {
            "$ref": "#/components/schemas/Causation"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          },
          "attempts": {
            "type": "array",
            "description": "The attempts, the first first.",
            "items": {
              "$ref": "#/components/schemas/InvocationAttempt"
            }
          },
          "check": {
            "type": "string",
            "description": "The check whose result the invocation is, for its event's merge candidate, or empty."
          }
        }
      },
      "InvocationPage": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "data",
          "next_cursor"
        ],
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Invocation"
            }
          },
          "next_cursor": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "InvocationDetail": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "invocation"
        ],
        "properties": {
          "invocation": {
            "$ref": "#/components/schemas/Invocation"
          }
        }
      },
      "InvokedHook": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "invocation",
          "replayed"
        ],
        "properties": {
          "invocation": {
            "$ref": "#/components/schemas/Invocation"
          },
          "replayed": {
            "type": "boolean",
            "description": "Whether an earlier request with the same Idempotency-Key made the invocation."
          }
        }
      },
      "InvocationResult": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "invocation"
        ],
        "properties": {
          "invocation": {
            "$ref": "#/components/schemas/Invocation"
          }
        }
      },
      "ChannelPolicy": {
        "type": "object",
        "description": "A channel's policy, which managers set through the API: the repository's files can't change it.",
        "additionalProperties": false,
        "required": [
          "channel",
          "required_checks",
          "forbid_direct_pushes",
          "revision",
          "updated_by",
          "updated_at"
        ],
        "properties": {
          "channel": {
            "type": "string"
          },
          "required_checks": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The checks that a merge into the channel needs to have passed, for its candidate. A candidate's hooks say how each runs; a check that none declares is missing, and blocks the merge."
          },
          "forbid_direct_pushes": {
            "type": "boolean",
            "description": "Whether the channel refuses pushes, applies and deletion, so that only merges change it."
          },
          "revision": {
            "type": "integer",
            "minimum": 0,
            "description": "The policy's version, from 1; 0 for a channel without a policy, which has the default: no checks, and direct pushes."
          },
          "updated_by": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Actor"
              },
              {
                "type": "null"
              }
            ],
            "description": "Null for the default."
          },
          "updated_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "merge_strategy": {
            "type": "string",
            "enum": [
              "amp",
              "merge_commit",
              "squash",
              "rebase_ff"
            ],
            "description": "How the channel's queue lands a merge: `amp` in an Amp repository, which lands Amp's changes as they are; in a Git repository, `merge_commit` (the default), `squash`, or `rebase_ff`. A policy that a merge's checks recorded before Gauss hosted Git may leave it out."
          }
        }
      },
      "ChannelPolicyList": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "data",
          "next_cursor"
        ],
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ChannelPolicy"
            }
          },
          "next_cursor": {
            "type": "null"
          }
        }
      },
      "MergeCheck": {
        "type": "object",
        "description": "A check of a merge's candidate.",
        "additionalProperties": false,
        "required": [
          "name",
          "required",
          "status",
          "hook",
          "invocation_id",
          "conclusion",
          "detail"
        ],
        "properties": {
          "name": {
            "type": "string"
          },
          "required": {
            "type": "boolean",
            "description": "Whether the target's policy requires it."
          },
          "status": {
            "type": "string",
            "enum": [
              "passed",
              "pending",
              "failed",
              "missing",
              "skipped"
            ],
            "description": "`skipped`: the hook's path filters ruled out the paths that the candidate changes, against the target's state that it builds on, so the check doesn't apply and holds nothing up. It isn't a pass of the check."
          },
          "hook": {
            "type": "string",
            "description": "The candidate's hook that declares the check, or empty."
          },
          "invocation_id": {
            "type": "string",
            "description": "The hook's invocation of the candidate, whose run is the check, or empty."
          },
          "conclusion": {
            "type": "string",
            "description": "The invocation's conclusion, once it completed."
          },
          "detail": {
            "type": "string",
            "description": "Why the check is pending, failed, missing, or skipped."
          }
        }
      },
      "MergeChecks": {
        "type": "object",
        "description": "The checks of a merge's current generation: those of the queue's latest candidate that tests or tested it. They stay after the merge lands or closes.",
        "additionalProperties": false,
        "required": [
          "generation",
          "policy",
          "checks",
          "candidate_id",
          "candidate_status",
          "detail"
        ],
        "properties": {
          "generation": {
            "type": "integer"
          },
          "policy": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/ChannelPolicy"
              },
              {
                "type": "null"
              }
            ],
            "description": "The target's policy that the checks are of. While the queue builds or checks the candidate, it's the policy now. After the queue decided the candidate, it's the channel, revision, required checks, and direct pushes that the decision applied, with `updated_by` and `updated_at` null. It's null when Gauss doesn't know the policy that a decision applied (a decision before Gauss recorded it), or when no candidate tests the generation."
          },
          "checks": {
            "type": "array",
            "description": "Each check that the policy requires, and each other check that the candidate's hooks declare. With a null policy, no check is marked required: which checks were required is unknown.",
            "items": {
              "$ref": "#/components/schemas/MergeCheck"
            }
          },
          "candidate_id": {
            "type": "string",
            "description": "The candidate that the checks are of, or empty when no candidate tests the generation."
          },
          "candidate_status": {
            "type": "string",
            "enum": [
              "",
              "building",
              "checking",
              "landing",
              "landed",
              "failed",
              "abandoned"
            ],
            "description": "The candidate's status, or empty without a candidate."
          },
          "detail": {
            "type": "string",
            "description": "One sentence that says what the checks show: which policy they are of, whether another submission's landing published the merge's changes, or why there are no checks."
          }
        }
      },
      "MergeCandidate": {
        "type": "object",
        "description": "The queue's candidate that tests a merge: the target combined with the merge's snapshot, and with the others of its batch, in a channel of its own that only Gauss writes.",
        "additionalProperties": false,
        "required": [
          "generation",
          "cause",
          "status",
          "channel",
          "base_state",
          "source_state",
          "state",
          "changes",
          "conflicts",
          "event_id",
          "error",
          "requested_by",
          "created_at",
          "combined_at",
          "shared"
        ],
        "properties": {
          "generation": {
            "type": "integer"
          },
          "cause": {
            "type": "string",
            "enum": [
              "created",
              "refreshed",
              "source_updated",
              "target_updated"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "combining",
              "ready",
              "conflicted",
              "failed"
            ],
            "description": "`combining` until the engine made it; then `ready`, or `conflicted`, which nothing can check or land; or `failed`, with `error`."
          },
          "channel": {
            "type": "string",
            "description": "The candidate's channel, below `gauss/`."
          },
          "base_state": {
            "type": "string",
            "description": "The target's state that the candidate combines."
          },
          "source_state": {
            "type": "string"
          },
          "state": {
            "type": "string",
            "description": "The candidate's state, which its checks run on, and which landing makes the target's."
          },
          "changes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The source's changes that the target lacked: what landing applies."
          },
          "conflicts": {
            "type": "integer"
          },
          "event_id": {
            "type": "string",
            "description": "The candidate's `merge.candidate_updated` event, which runs its checks."
          },
          "error": {
            "type": "string"
          },
          "requested_by": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Actor"
              },
              {
                "type": "null"
              }
            ]
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "combined_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "shared": {
            "type": "boolean",
            "description": "Whether the candidate tests other merges with this one."
          }
        }
      },
      "MergeLanding": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "generation",
          "before",
          "after",
          "merged_by",
          "merged_at"
        ],
        "properties": {
          "generation": {
            "type": "integer"
          },
          "before": {
            "type": "string",
            "description": "The target's state before."
          },
          "after": {
            "type": "string",
            "description": "The target's state after: the candidate's."
          },
          "merged_by": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Actor"
              },
              {
                "type": "null"
              }
            ]
          },
          "merged_at": {
            "type": "string",
            "format": "date-time"
          },
          "lost_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When a recovery of the engine's store (a rewind or a restore) went back to a state before the landing, or null: the target no longer has the merge's changes. To land them again, push the source and open a new merge."
          },
          "lost_recovery": {
            "type": "string",
            "description": "The ID of the recovery that lost the landing, or empty."
          }
        }
      },
      "MergeClosing": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "reason",
          "closed_by",
          "closed_at"
        ],
        "properties": {
          "reason": {
            "type": "string"
          },
          "closed_by": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Actor"
              },
              {
                "type": "null"
              }
            ]
          },
          "closed_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "MergeSubmission": {
        "type": "object",
        "description": "A submission of a merge: a generation, pinned to a snapshot of the source, which Gauss owns until it merges or is rejected. Later pushes of the source don't change it.",
        "additionalProperties": false,
        "required": [
          "generation",
          "cause",
          "status",
          "snapshot_channel",
          "source_state",
          "changes",
          "enqueue_sequence",
          "deferred_by",
          "active_candidate_id",
          "rejection",
          "fulfillment",
          "requested_by",
          "created_at",
          "resolved_at"
        ],
        "properties": {
          "generation": {
            "type": "integer"
          },
          "cause": {
            "type": "string",
            "enum": [
              "created",
              "refreshed",
              "landed",
              "migrated"
            ],
            "description": "What submitted it: opening the merge, refreshing it, landing a draft, or Gauss moving a merge of before the queue into it (`migrated`)."
          },
          "status": {
            "type": "string",
            "enum": [
              "queued",
              "rejected",
              "merged"
            ]
          },
          "snapshot_channel": {
            "type": "string",
            "description": "The snapshot's channel, below `gauss/`, which only Gauss writes."
          },
          "source_state": {
            "type": "string",
            "description": "The source's state that was submitted: the snapshot's."
          },
          "changes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The changes that the snapshot added to the target when Gauss accepted it."
          },
          "enqueue_sequence": {
            "type": "string",
            "description": "The submission's order in the queue, as a decimal string (an int64). A submission that an unpublished candidate kept out of a batch keeps it, and `deferred_by` names the candidate."
          },
          "deferred_by": {
            "type": "string"
          },
          "active_candidate_id": {
            "type": "string",
            "description": "The queue's candidate that tests it now, or empty."
          },
          "rejection": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/MergeRejection"
              },
              {
                "type": "null"
              }
            ],
            "description": "Why Gauss rejected it, or null."
          },
          "fulfillment": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/MergeFulfillment"
              },
              {
                "type": "null"
              }
            ],
            "description": "The landing that published it, or null."
          },
          "requested_by": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Actor"
              },
              {
                "type": "null"
              }
            ]
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "resolved_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When it merged or was rejected, or null."
          }
        }
      },
      "MergeRejection": {
        "type": "object",
        "description": "Why Gauss rejected a submission: what it tested, and what failed. A rejection says that validation failed, not that the submission caused the failure.",
        "additionalProperties": false,
        "required": [
          "kind",
          "message",
          "base",
          "candidate_id",
          "state",
          "checks",
          "base_evidence"
        ],
        "properties": {
          "kind": {
            "type": "string",
            "enum": [
              "checks_failed",
              "red_target",
              "infrastructure",
              "conflicted",
              "source_unavailable",
              "duplicate",
              "unauthorized"
            ],
            "description": "Why: `checks_failed`, the merge failed checks that pass on the target; `red_target`, it failed on a target that fails its checks without it; `infrastructure`, the checks' runs said nothing about it, such as Piston's failure; `conflicted`; `source_unavailable`; `duplicate`, another merge submitted the same state; `unauthorized`, its author can't submit it any more. Gauss runs nothing again by itself: refresh the merge to submit it again."
          },
          "message": {
            "type": "string"
          },
          "base": {
            "type": "string",
            "description": "The target's state that the submission was tested against."
          },
          "candidate_id": {
            "type": "string",
            "description": "The queue's candidate that tested it."
          },
          "state": {
            "type": "string",
            "description": "The candidate's state."
          },
          "checks": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/MergeCheck"
            },
            "description": "The failed checks, with their invocations."
          },
          "base_evidence": {
            "type": "string",
            "description": "What showed that the target passes the checks: a landed candidate of the target, or a diagnostic."
          }
        }
      },
      "MergeFulfillment": {
        "type": "object",
        "description": "The landing that published a submission: its own, or another submission's that contained it.",
        "additionalProperties": false,
        "required": [
          "landing_id",
          "by_other",
          "before",
          "after"
        ],
        "properties": {
          "landing_id": {
            "type": "string"
          },
          "by_other": {
            "type": "boolean",
            "description": "Whether another submission's changes brought it, or the target had them already."
          },
          "before": {
            "type": "string",
            "description": "The target's state before the landing."
          },
          "after": {
            "type": "string",
            "description": "The target's state after it."
          }
        }
      },
      "Merge": {
        "type": "object",
        "description": "A merge: a request to land a source channel's changes on a target channel, through the target's queue.",
        "additionalProperties": false,
        "required": [
          "id",
          "repository_id",
          "handle",
          "repository",
          "source",
          "target",
          "title",
          "description",
          "status",
          "generation",
          "candidate",
          "created_by",
          "created_at",
          "updated_at",
          "landing",
          "closing",
          "checks",
          "queue_state",
          "submission"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "The merge's ID (`merge_…`)."
          },
          "repository_id": {
            "type": "string"
          },
          "handle": {
            "type": "string"
          },
          "repository": {
            "type": "string"
          },
          "source": {
            "type": "string"
          },
          "target": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "open",
              "merged",
              "closed"
            ]
          },
          "generation": {
            "type": "integer",
            "description": "The current generation, from 1."
          },
          "candidate": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/MergeCandidate"
              },
              {
                "type": "null"
              }
            ]
          },
          "created_by": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Actor"
              },
              {
                "type": "null"
              }
            ]
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          },
          "landing": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/MergeLanding"
              },
              {
                "type": "null"
              }
            ],
            "description": "Set once the merge landed."
          },
          "closing": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/MergeClosing"
              },
              {
                "type": "null"
              }
            ],
            "description": "Set once the merge closed without landing."
          },
          "checks": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/MergeChecks"
              },
              {
                "type": "null"
              }
            ],
            "description": "The checks of the queue's latest candidate that tests or tested the current generation, also after the merge lands or closes; null while no candidate has checks to show. `GET …/checks` says why."
          },
          "queue_state": {
            "type": "string",
            "enum": [
              "",
              "draft",
              "queued",
              "merged",
              "rejected"
            ],
            "description": "`draft` until it's submitted, then `queued` until it's `merged` or `rejected`. Empty for a merge that closed or merged before every channel had a queue."
          },
          "submission": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/MergeSubmission"
              },
              {
                "type": "null"
              }
            ],
            "description": "The merge's current submission, or null for a draft."
          }
        }
      },
      "MergePage": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "data",
          "next_cursor"
        ],
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Merge"
            }
          },
          "next_cursor": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "RepositorySecret": {
        "type": "object",
        "description": "A repository's secret, or a profile's binding of a secret's name, without its value: nobody reads a value back.",
        "required": [
          "id",
          "name",
          "version_id",
          "version",
          "created_at",
          "updated_at"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "The secret's ID. Deleting a secret and setting its name again makes another one."
          },
          "name": {
            "type": "string"
          },
          "version_id": {
            "type": "string",
            "description": "The current version, which new grants pin."
          },
          "version": {
            "type": "integer"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          },
          "profile": {
            "type": "string",
            "description": "A binding's profile."
          },
          "kind": {
            "type": "string",
            "enum": [
              "owned",
              "inherit"
            ],
            "description": "A binding's kind: the profile's own value, or the repository's secret of the name, with the identity that it had when it was bound."
          },
          "valid": {
            "type": "boolean",
            "description": "False for a binding whose secret was deleted or whose current version was revoked: the profile's tasks get nothing for it until it's bound again."
          }
        }
      },
      "SecretGrant": {
        "type": "object",
        "description": "A grant of a submission's repository secrets, which Piston binds to its run and delivers to its tasks as they start. It carries no value.",
        "required": [
          "id",
          "submission_id",
          "status",
          "admit_by",
          "expires_at",
          "versions"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "submission_id": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "pending",
              "bound",
              "finished"
            ]
          },
          "run_id": {
            "type": "string",
            "description": "The run that Piston bound it to, once bound."
          },
          "admit_by": {
            "type": "string",
            "format": "date-time",
            "description": "A run must bind it by then."
          },
          "expires_at": {
            "type": "string",
            "format": "date-time",
            "description": "It delivers nothing after."
          },
          "versions": {
            "type": "object",
            "description": "Task → {variables: environment variable → the version ID that the grant pinned}.",
            "additionalProperties": {
              "type": "object",
              "properties": {
                "variables": {
                  "type": "object",
                  "additionalProperties": {
                    "type": "string"
                  }
                }
              }
            }
          }
        }
      },
      "ProfileRule": {
        "type": "object",
        "required": [
          "event",
          "pattern"
        ],
        "properties": {
          "event": {
            "type": "string",
            "enum": [
              "channel.updated",
              "tag.created",
              "request"
            ],
            "description": "The event: a push to a channel, a new tag, or a hook invoked by hand (`request`)."
          },
          "pattern": {
            "type": "string",
            "description": "A pattern of the event's channel or tag: `*` matches any characters but `/`, `**` any characters, such as `main` or `release/*`."
          }
        }
      },
      "Profile": {
        "type": "object",
        "description": "A profile of a repository: what its hooks' privileged tasks use. Only the run of a hook whose action allows the profile, for an event and a channel or tag that a rule matches, gets its secrets; a task of the profile gets only what the profile binds. A profile with an AWS role also gives its tasks OIDC tokens, which Gauss signs, to assume the role.",
        "required": [
          "id",
          "name",
          "enabled",
          "revision",
          "rules",
          "bindings",
          "created_at",
          "updated_at"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "enabled": {
            "type": "boolean",
            "description": "A disabled profile's tasks get nothing, even those of runs that started."
          },
          "revision": {
            "type": "integer",
            "description": "Counts the changes of its rules, bindings, and state: a run's grant pins it, and delivers nothing to the profile's tasks after it changed."
          },
          "rules": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ProfileRule"
            }
          },
          "bindings": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/RepositorySecret"
            }
          },
          "aws_role_arn": {
            "type": "string",
            "description": "The AWS role that the profile's tasks assume with Gauss's OIDC tokens, or empty: they get none."
          },
          "audience": {
            "type": "string",
            "description": "The tokens' audience: `sts.amazonaws.com` unless set."
          },
          "issuer": {
            "type": "string",
            "description": "The tokens' issuer, such as `https://gauss.motor.dev`, or empty if Gauss issues none."
          },
          "subject": {
            "type": "string",
            "description": "The tokens' subject, `repo:<team>/<repo>:profile:<profile>:<profile ID>`, which the role's trust policy names."
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "MergeDiff": {
        "type": "object",
        "description": "The diff of a merge's candidate against its base.",
        "additionalProperties": false,
        "required": [
          "diff",
          "truncated",
          "base_state",
          "candidate_state"
        ],
        "properties": {
          "diff": {
            "type": "string",
            "contentEncoding": "base64",
            "description": "The unified diff, in base64: its bytes needn't be UTF-8."
          },
          "truncated": {
            "type": "boolean",
            "description": "Whether Gauss cut the diff, after a whole line, at `max_bytes` or its own limit."
          },
          "base_state": {
            "type": "string",
            "description": "The target's commit that the diff starts from."
          },
          "candidate_state": {
            "type": "string",
            "description": "The candidate's commit that the diff ends at."
          }
        }
      }
    }
  }
}
