{
  "openapi": "3.1.0",
  "info": {
    "title": "Piston API",
    "version": "2026-10-22",
    "description": "Run builds, tests, and scripts remotely against your project files, including local, unrecorded edits, and fetch structured logs, results, and output files. The `motor piston` commands are built on this API."
  },
  "servers": [
    {
      "url": "https://www.motor.dev"
    }
  ],
  "security": [
    {
      "bearer": []
    },
    {
      "dpop": []
    }
  ],
  "tags": [
    {
      "name": "Using this API",
      "description": "To run a task through the API:\n\n- Package your project files as a `tar.zst` archive and register it with `POST /api/piston/sources`. Upload the archive with a `PUT` request to `upload_url`. If `upload_url` is `null`, no upload is needed.\n- Optionally validate `piston.star` with `POST /api/piston/plans` before starting the run.\n- Start the run with `POST /api/piston/runs`, including an `Idempotency-Key` header.\n- Follow the logs with `GET /api/piston/runs/{run_id}/logs/stream` until the stream ends, or poll `GET /api/piston/runs/{run_id}` until `finished_at` is no longer `null`.\n- Inspect each task’s status, step exit codes, test reports, and failure details in the run results. Download any saved outputs.\n\nEach request applies to one team. Pass its handle as `team`: in the query string for `GET` and `DELETE` requests, or in the request body for `POST` and `PUT` requests. When using a team key, you can omit `team` to use the key’s team.\n\nSee https://www.motor.dev/docs/apis#api_conventions for the credentials, errors, and lists that every Motor API shares."
    },
    {
      "name": "Sources",
      "description": "An uploaded `tar.zst` archive containing the project files used by a run. Tasks receive these files in their working directory. Piston doesn’t expire a source by the age of its upload."
    },
    {
      "name": "Plans",
      "description": "A plan defines tasks, artifacts, and groups. Submit it as JSON or generate it from a `piston.star` configuration in the uploaded source."
    },
    {
      "name": "Runs",
      "description": "A run executes selected targets and their dependencies against an uploaded source. Each task runs on a separate machine."
    },
    {
      "name": "Logs",
      "description": "Output written by task steps and Piston, ordered by cursor."
    },
    {
      "name": "Outputs",
      "description": "Saved files and directories produced by tasks. Other tasks can use them as inputs."
    },
    {
      "name": "Volumes",
      "description": "Team storage volumes for task caches and Docker images and layers."
    },
    {
      "name": "Secrets",
      "description": "Team secrets supplied as environment variables only to tasks that request them."
    }
  ],
  "paths": {
    "/api/piston/sources": {
      "post": {
        "operationId": "create_source",
        "summary": "Register a source",
        "description": "Registers a project archive by its SHA-256 digest and size. Requires `piston:run` for a team key and a team eligible for billable work.\n\nPackage the files as `tar.zst`. If the response includes an `upload_url`, upload the archive with `PUT` before `upload_expires_at`. Do not send Motor credentials to that URL. If `upload_url` is null, the source is already available.\n\nUse the returned source `id` to start a run. Registering the same digest again is safe and returns a fresh upload URL if the upload is still needed.\n\nSources and runs incur charges. Requests return `402` if the team’s billing status prevents new work.",
        "tags": [
          "Sources"
        ],
        "responses": {
          "200": {
            "description": "Source metadata and upload instructions.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SourceUpload"
                },
                "example": {
                  "source": {
                    "id": "src_1BbA6sXxyUWHYvKqN5T3dM",
                    "sha256": "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08",
                    "size": 1843200,
                    "repo": "acme/web",
                    "uploaded": false,
                    "created_at": "2026-10-22T09:00:00.000Z"
                  },
                  "upload_url": "https://piston-data.s3.amazonaws.com/teams/team_1BbA6sXxyUWHYvKqN5T3dM/sources/9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08.tar.zst?X-Amz-Signature=…",
                  "upload_expires_at": "2026-10-22T09:15:00.000Z"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "410": {
            "$ref": "#/components/responses/Gone"
          },
          "422": {
            "$ref": "#/components/responses/InvalidField"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "sha256": {
                    "type": "string",
                    "pattern": "^[0-9a-f]{64}$",
                    "description": "The SHA-256 digest of the tar.zst, in lowercase hex."
                  },
                  "size": {
                    "type": "integer",
                    "minimum": 1,
                    "description": "The size of the tar.zst, in bytes."
                  },
                  "repo": {
                    "type": "string",
                    "description": "Source repository label, such as `acme/app`, shown in run details."
                  },
                  "team": {
                    "type": "string",
                    "description": "The team’s handle, such as `motor`. Required for session and user keys. Defaults to the key’s team when using a team key."
                  }
                },
                "required": [
                  "sha256",
                  "size"
                ],
                "additionalProperties": false
              },
              "example": {
                "team": "motor",
                "sha256": "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08",
                "size": 1843200,
                "repo": "acme/web"
              }
            }
          }
        }
      }
    },
    "/api/piston/plans": {
      "post": {
        "operationId": "evaluate_plan",
        "summary": "Check a plan",
        "description": "Validates a configuration or JSON plan without running tasks. Requires `piston:run` for a team key.\n\nProvide `source_id` and an optional configuration `path`, or provide `plan` as JSON. Use `tasks` to select tasks and their dependencies. Invalid configurations return `422 invalid_plan` with details in `diagnostics`.",
        "tags": [
          "Plans"
        ],
        "responses": {
          "200": {
            "description": "The validated execution plan.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PlanResult"
                },
                "example": {
                  "plan": {
                    "tasks": [
                      {
                        "name": "test",
                        "platform": "linux/amd64",
                        "image": "golang:1.26",
                        "cpu": 4,
                        "memory_gb": 16,
                        "caches": {
                          "/go/pkg/mod": "go_mod"
                        },
                        "steps": [
                          {
                            "name": "vet",
                            "run": "go vet ./..."
                          },
                          {
                            "name": "test",
                            "run": "go test -json ./... > test.json",
                            "report": {
                              "format": "go_test_json",
                              "path": "test.json"
                            }
                          }
                        ]
                      }
                    ]
                  },
                  "diagnostics": []
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "410": {
            "$ref": "#/components/responses/Gone"
          },
          "422": {
            "$ref": "#/components/responses/InvalidPlan"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "source_id": {
                    "type": "string",
                    "description": "ID of the source containing the configuration. Supply either `source_id` or `plan`."
                  },
                  "path": {
                    "type": "string",
                    "description": "Configuration path within the source. Defaults to `piston.star`. Only valid with `source_id`."
                  },
                  "plan": {
                    "allOf": [
                      {
                        "$ref": "#/components/schemas/Plan"
                      }
                    ],
                    "description": "A plan to check, as JSON. Send `source_id` or `plan`."
                  },
                  "tasks": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "description": "Task names to include, along with their dependencies. Omit to include all tasks."
                  },
                  "team": {
                    "type": "string",
                    "description": "The team’s handle, such as `motor`. Required for session and user keys. Defaults to the key’s team when using a team key."
                  },
                  "context": {
                    "allOf": [
                      {
                        "$ref": "#/components/schemas/RunContext"
                      }
                    ],
                    "description": "The context that the config reads with `context()`, as `POST /api/piston/runs` takes it. Only with `source_id`'s config; a `plan` is already evaluated."
                  }
                },
                "required": [],
                "additionalProperties": false
              },
              "example": {
                "team": "motor",
                "source_id": "src_1BbA6sXxyUWHYvKqN5T3dM",
                "path": "piston.star",
                "tasks": [
                  "test"
                ]
              }
            }
          }
        }
      }
    },
    "/api/piston/contexts": {
      "post": {
        "operationId": "resolve_context",
        "summary": "Resolve a run's context",
        "description": "Returns the context document that a run of the caller, of `source_id` or of no source, with `context` gets, exactly as `POST /api/piston/runs` makes it: its submitted fields, with `piston` (the source) and `motor` (the caller, as the run's identities) filled. Requires `piston:run` for a team key.\n\nA client that evaluates a configuration itself, such as `motor piston run --config-file`, resolves the context after it registers the source and evaluates with this document, so that the plan it sends and the run's tasks get the same values. An invalid `context` returns `422 invalid_field` naming the field.",
        "tags": [
          "Runs"
        ],
        "responses": {
          "200": {
            "description": "The run's context document.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RunContextDocument"
                },
                "example": {
                  "amp": {
                    "channel": null,
                    "state": "S1",
                    "tag": {
                      "name": "v1.2.3"
                    }
                  },
                  "event": "github.push",
                  "gauss": null,
                  "git": null,
                  "github": {
                    "pr": {
                      "number": 7
                    },
                    "sha": "abc"
                  },
                  "motor": {
                    "actor": {
                      "id": "user_1BbA6sXxyUWHYvKqN5T3dM",
                      "kind": "user",
                      "name": null
                    },
                    "requested_by": {
                      "id": "user_1BbA6sXxyUWHYvKqN5T3dM",
                      "kind": "user",
                      "name": null
                    },
                    "runs_as": {
                      "id": "user_1BbA6sXxyUWHYvKqN5T3dM",
                      "kind": "user",
                      "name": null
                    }
                  },
                  "piston": {
                    "source": {
                      "id": "src_1BbA6sXxyUWHYvKqN5T3dM",
                      "sha256": "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08"
                    }
                  },
                  "schema": 1
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "410": {
            "$ref": "#/components/responses/Gone"
          },
          "422": {
            "$ref": "#/components/responses/InvalidField"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "source_id": {
                    "type": "string",
                    "description": "ID of the run's source, whose ID and digest `piston.source` has. Omit it for a run without a source, whose `piston.source` is null."
                  },
                  "team": {
                    "type": "string",
                    "description": "The team’s handle, such as `motor`. Required for session and user keys. Defaults to the key’s team when using a team key."
                  },
                  "context": {
                    "allOf": [
                      {
                        "$ref": "#/components/schemas/RunContext"
                      }
                    ],
                    "description": "The context that the run would be submitted with, as `POST /api/piston/runs` takes it."
                  }
                },
                "required": [],
                "additionalProperties": false
              },
              "example": {
                "team": "motor",
                "source_id": "src_1BbA6sXxyUWHYvKqN5T3dM",
                "context": {
                  "event": "github.push",
                  "amp": {
                    "state": "S1",
                    "tag": {
                      "name": "v1.2.3"
                    }
                  },
                  "github": {
                    "sha": "abc",
                    "pr": {
                      "number": 7
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/piston/runs": {
      "post": {
        "operationId": "create_run",
        "summary": "Start a run",
        "description": "Starts a run against an uploaded source. Requires `piston:run` for a team key and a team eligible for billable work.\n\nUse the source’s configuration (`path`) or supply a JSON `plan`. Specify `targets` to run selected tasks, artifacts, or groups and their dependencies. Alternatively, set `all: true` to run every target, including artifact publication. Supplying both or neither returns `422 invalid_plan` with diagnostic code `P0301` or `P0302`.\n\nEach task runs in its configured container on a separate machine. Billing covers its allocated resources from the first step until the task ends.\n\nArtifact targets publish their outputs after their dependencies succeed. Publication requires repository `publish` access; team keys also need `gauss:publish`. Piston checks access before execution, and Gauss checks it again at publication. Piston stores the caller’s identity, not the credential.\n\nUse an `Idempotency-Key` to avoid duplicate runs when retrying. Configuration errors return `422 invalid_plan` with `diagnostics`. After starting a run, stream its logs or poll its details until `finished_at` is non-null.",
        "tags": [
          "Runs"
        ],
        "responses": {
          "201": {
            "description": "The queued run. `Location` contains its URL. Replayed requests include `Idempotency-Replayed: true`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Run"
                },
                "example": {
                  "id": "run_1BbA6sXxyUWHYvKqN5T3dM",
                  "team": "motor",
                  "user_id": "user_1BbA6sXxyUWHYvKqN5T3dM",
                  "team_key_id": null,
                  "actor": {
                    "kind": "user",
                    "id": "user_1BbA6sXxyUWHYvKqN5T3dM",
                    "name": null
                  },
                  "runs_as": {
                    "kind": "user",
                    "id": "user_1BbA6sXxyUWHYvKqN5T3dM",
                    "name": null
                  },
                  "requested_by": {
                    "kind": "user",
                    "id": "user_1BbA6sXxyUWHYvKqN5T3dM",
                    "name": null
                  },
                  "publisher": {
                    "kind": "user",
                    "id": "user_1BbA6sXxyUWHYvKqN5T3dM",
                    "name": null
                  },
                  "source_id": "src_1BbA6sXxyUWHYvKqN5T3dM",
                  "status": "queued",
                  "reason": null,
                  "created_at": "2026-10-22T09:00:00.000Z",
                  "started_at": null,
                  "finished_at": null,
                  "vcpu_milliseconds": 0,
                  "memory_byte_milliseconds": "0",
                  "tasks": [
                    {
                      "name": "test",
                      "status": "queued",
                      "platform": "linux/amd64",
                      "cpu": 4,
                      "memory_gb": 16,
                      "key": null,
                      "cached_from_run_id": null,
                      "started_at": null,
                      "finished_at": null,
                      "steps": [],
                      "outputs": [],
                      "reports": [],
                      "failure": null
                    }
                  ],
                  "plan": {
                    "tasks": [
                      {
                        "name": "test",
                        "platform": "linux/amd64",
                        "image": "golang:1.26@sha256:9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08",
                        "cpu": 4,
                        "memory_gb": 16,
                        "caches": {
                          "/go/pkg/mod": "go_mod"
                        },
                        "steps": [
                          {
                            "name": "vet",
                            "run": "go vet ./..."
                          },
                          {
                            "name": "test",
                            "run": "go test -json ./... > test.json",
                            "report": {
                              "format": "go_test_json",
                              "path": "test.json"
                            }
                          }
                        ]
                      }
                    ]
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "410": {
            "$ref": "#/components/responses/Gone"
          },
          "422": {
            "$ref": "#/components/responses/InvalidPlan"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "source_id": {
                    "type": "string",
                    "description": "ID of the uploaded source to execute."
                  },
                  "path": {
                    "type": "string",
                    "description": "Configuration path within the source. Defaults to `piston.star`. Use this or `plan`."
                  },
                  "plan": {
                    "allOf": [
                      {
                        "$ref": "#/components/schemas/Plan"
                      }
                    ],
                    "description": "A plan to run, as JSON, instead of the source's config."
                  },
                  "targets": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "description": "Names of targets to execute, including their dependencies. Targets can be tasks, artifacts, or groups. Supply either `targets` or `all`."
                  },
                  "all": {
                    "type": "boolean",
                    "description": "Run every target, including artifact publication. Supply either `all` or `targets`, not both."
                  },
                  "refresh_layers": {
                    "type": "boolean",
                    "description": "Build each layer that the run's tasks need again, with their parent layers, instead of reusing a build. A layer's build that fails fails the run; the run never uses an earlier build instead."
                  },
                  "tasks": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "deprecated": true,
                    "description": "Deprecated alias for `targets`."
                  },
                  "team": {
                    "type": "string",
                    "description": "The team’s handle, such as `motor`. Required for session and user keys. Defaults to the key’s team when using a team key."
                  },
                  "context": {
                    "allOf": [
                      {
                        "$ref": "#/components/schemas/RunContext"
                      }
                    ],
                    "description": "The run's context, which its config reads with `context()` and its tasks with `context = True` get as a file. Omit it for a run with only what Piston fills: `piston`, its source, and `motor`, its caller."
                  },
                  "credential_protocol": {
                    "type": "string",
                    "enum": [
                      "",
                      "grants_v1"
                    ],
                    "description": "How the run's tasks get their secrets. Empty: the team's secrets in Piston (`/api/piston/secrets`), which repository secrets replace. `grants_v1`: a grant of the repository's secrets from Gauss (`secret_grant`) and the caller's own values (`caller_secrets`); Piston then never reads the team's secrets, and a secret that neither has is missing (`missing_secret`)."
                  },
                  "secret_grant": {
                    "type": "string",
                    "description": "With `grants_v1`, the grant that `POST /api/gauss/repos/{handle}/{repo}/secret_grants` returned for the run's source and its tasks' repository secrets. Piston binds it to the run, and redeems it with Gauss as each task starts."
                  },
                  "caller_secrets": {
                    "type": "string",
                    "format": "byte",
                    "description": "With `grants_v1`, the caller's own values of secrets, sealed to Piston's payload key (`GET /api/piston/payload_key`) for the team, the source, and exactly the tasks' variables that they go to, in base64. They replace the repository's secrets of the same names. Piston keeps them sealed, and empties them when the run ends."
                  }
                },
                "required": [
                  "source_id"
                ],
                "additionalProperties": false
              },
              "example": {
                "team": "motor",
                "source_id": "src_1BbA6sXxyUWHYvKqN5T3dM",
                "targets": [
                  "test"
                ]
              }
            }
          }
        }
      },
      "get": {
        "operationId": "list_runs",
        "summary": "List runs",
        "description": "Lists the team’s runs, newest first, without task details or plans. Fetch an individual run for complete results. Requires `piston:read` for a team key.",
        "tags": [
          "Runs"
        ],
        "responses": {
          "200": {
            "description": "A page of runs.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RunPage"
                },
                "example": {
                  "data": [
                    {
                      "id": "run_1BbA6sXxyUWHYvKqN5T3dM",
                      "team": "motor",
                      "user_id": "user_1BbA6sXxyUWHYvKqN5T3dM",
                      "team_key_id": null,
                      "actor": {
                        "kind": "user",
                        "id": "user_1BbA6sXxyUWHYvKqN5T3dM",
                        "name": null
                      },
                      "runs_as": {
                        "kind": "user",
                        "id": "user_1BbA6sXxyUWHYvKqN5T3dM",
                        "name": null
                      },
                      "requested_by": {
                        "kind": "user",
                        "id": "user_1BbA6sXxyUWHYvKqN5T3dM",
                        "name": null
                      },
                      "publisher": {
                        "kind": "user",
                        "id": "user_1BbA6sXxyUWHYvKqN5T3dM",
                        "name": null
                      },
                      "source_id": "src_1BbA6sXxyUWHYvKqN5T3dM",
                      "status": "failed",
                      "reason": null,
                      "created_at": "2026-10-22T09:00:00.000Z",
                      "started_at": "2026-10-22T09:00:05.250Z",
                      "finished_at": "2026-10-22T09:01:12.500Z",
                      "vcpu_milliseconds": 268000,
                      "memory_byte_milliseconds": "1151051235328000"
                    }
                  ],
                  "next_cursor": null
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "410": {
            "$ref": "#/components/responses/Gone"
          },
          "422": {
            "$ref": "#/components/responses/InvalidField"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamQuery"
          },
          {
            "$ref": "#/components/parameters/Limit"
          },
          {
            "$ref": "#/components/parameters/Cursor"
          }
        ]
      }
    },
    "/api/piston/runs/{run_id}": {
      "get": {
        "operationId": "get_run",
        "summary": "Get a run",
        "description": "Returns task statuses, step exit codes, test reports, and saved outputs. Failures include details and the failed step’s recent log output. A non-null `finished_at` means the run is complete. Requires `piston:read` for a team key.\n\nA run with status `errored` encountered a problem in Piston. Start a new run to try again.",
        "tags": [
          "Runs"
        ],
        "responses": {
          "200": {
            "description": "The run.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Run"
                },
                "example": {
                  "id": "run_1BbA6sXxyUWHYvKqN5T3dM",
                  "team": "motor",
                  "user_id": "user_1BbA6sXxyUWHYvKqN5T3dM",
                  "team_key_id": null,
                  "actor": {
                    "kind": "user",
                    "id": "user_1BbA6sXxyUWHYvKqN5T3dM",
                    "name": null
                  },
                  "runs_as": {
                    "kind": "user",
                    "id": "user_1BbA6sXxyUWHYvKqN5T3dM",
                    "name": null
                  },
                  "requested_by": {
                    "kind": "user",
                    "id": "user_1BbA6sXxyUWHYvKqN5T3dM",
                    "name": null
                  },
                  "publisher": {
                    "kind": "user",
                    "id": "user_1BbA6sXxyUWHYvKqN5T3dM",
                    "name": null
                  },
                  "source_id": "src_1BbA6sXxyUWHYvKqN5T3dM",
                  "status": "failed",
                  "reason": null,
                  "created_at": "2026-10-22T09:00:00.000Z",
                  "started_at": "2026-10-22T09:00:05.250Z",
                  "finished_at": "2026-10-22T09:01:12.500Z",
                  "vcpu_milliseconds": 268000,
                  "memory_byte_milliseconds": "1151051235328000",
                  "tasks": [
                    {
                      "name": "test",
                      "status": "failed",
                      "platform": "linux/amd64",
                      "cpu": 4,
                      "memory_gb": 16,
                      "key": null,
                      "cached_from_run_id": null,
                      "started_at": "2026-10-22T09:00:05.250Z",
                      "finished_at": "2026-10-22T09:01:12.500Z",
                      "steps": [
                        {
                          "name": "vet",
                          "status": "succeeded",
                          "exit_code": 0,
                          "started_at": "2026-10-22T09:00:05.250Z",
                          "finished_at": "2026-10-22T09:00:20.000Z"
                        },
                        {
                          "name": "test",
                          "status": "failed",
                          "exit_code": 1,
                          "started_at": "2026-10-22T09:00:20.000Z",
                          "finished_at": "2026-10-22T09:01:12.500Z"
                        }
                      ],
                      "outputs": [],
                      "reports": [
                        {
                          "step": "test",
                          "format": "go_test_json",
                          "passed": 41,
                          "failed": 1,
                          "skipped": 0,
                          "failures": [
                            {
                              "name": "example.com/app/ids.TestNew",
                              "message": "ids_test.go:12: got \"run_\", want \"src_\"",
                              "file": "lib/ids/ids_test.go",
                              "line": 12
                            }
                          ]
                        }
                      ],
                      "failure": {
                        "step": "test",
                        "message": "The step exited with 1.",
                        "log_tail": "--- FAIL: TestNew (0.00s)\n    ids_test.go:12: got \"run_\", want \"src_\"\nFAIL"
                      }
                    }
                  ],
                  "plan": {
                    "tasks": [
                      {
                        "name": "test",
                        "platform": "linux/amd64",
                        "image": "golang:1.26@sha256:9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08",
                        "cpu": 4,
                        "memory_gb": 16,
                        "caches": {
                          "/go/pkg/mod": "go_mod"
                        },
                        "steps": [
                          {
                            "name": "vet",
                            "run": "go vet ./..."
                          },
                          {
                            "name": "test",
                            "run": "go test -json ./... > test.json",
                            "report": {
                              "format": "go_test_json",
                              "path": "test.json"
                            }
                          }
                        ]
                      }
                    ]
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "410": {
            "$ref": "#/components/responses/Gone"
          },
          "422": {
            "$ref": "#/components/responses/InvalidField"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "parameters": [
          {
            "$ref": "#/components/parameters/RunID"
          },
          {
            "$ref": "#/components/parameters/TeamQuery"
          }
        ]
      }
    },
    "/api/piston/runs/{run_id}/cancel": {
      "post": {
        "operationId": "cancel_run",
        "summary": "Cancel a run",
        "description": "Cancels unfinished tasks and terminates their machines. Completed task results are retained. Canceling a completed run has no effect. Requires `piston:run` for a team key.",
        "tags": [
          "Runs"
        ],
        "responses": {
          "200": {
            "description": "The run.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Run"
                },
                "example": {
                  "id": "run_1BbA6sXxyUWHYvKqN5T3dM",
                  "team": "motor",
                  "user_id": "user_1BbA6sXxyUWHYvKqN5T3dM",
                  "team_key_id": null,
                  "actor": {
                    "kind": "user",
                    "id": "user_1BbA6sXxyUWHYvKqN5T3dM",
                    "name": null
                  },
                  "runs_as": {
                    "kind": "user",
                    "id": "user_1BbA6sXxyUWHYvKqN5T3dM",
                    "name": null
                  },
                  "requested_by": {
                    "kind": "user",
                    "id": "user_1BbA6sXxyUWHYvKqN5T3dM",
                    "name": null
                  },
                  "publisher": {
                    "kind": "user",
                    "id": "user_1BbA6sXxyUWHYvKqN5T3dM",
                    "name": null
                  },
                  "source_id": "src_1BbA6sXxyUWHYvKqN5T3dM",
                  "status": "canceled",
                  "reason": "canceled",
                  "created_at": "2026-10-22T09:00:00.000Z",
                  "started_at": "2026-10-22T09:00:05.250Z",
                  "finished_at": "2026-10-22T09:01:12.500Z",
                  "vcpu_milliseconds": 268000,
                  "memory_byte_milliseconds": "1151051235328000",
                  "tasks": [
                    {
                      "name": "test",
                      "status": "canceled",
                      "platform": "linux/amd64",
                      "cpu": 4,
                      "memory_gb": 16,
                      "key": null,
                      "cached_from_run_id": null,
                      "started_at": "2026-10-22T09:00:05.250Z",
                      "finished_at": "2026-10-22T09:01:12.500Z",
                      "steps": [
                        {
                          "name": "vet",
                          "status": "succeeded",
                          "exit_code": 0,
                          "started_at": "2026-10-22T09:00:05.250Z",
                          "finished_at": "2026-10-22T09:00:20.000Z"
                        },
                        {
                          "name": "test",
                          "status": "failed",
                          "exit_code": 1,
                          "started_at": "2026-10-22T09:00:20.000Z",
                          "finished_at": "2026-10-22T09:01:12.500Z"
                        }
                      ],
                      "outputs": [],
                      "reports": [],
                      "failure": {
                        "step": "test",
                        "message": "The run was canceled.",
                        "log_tail": ""
                      }
                    }
                  ],
                  "plan": {
                    "tasks": [
                      {
                        "name": "test",
                        "platform": "linux/amd64",
                        "image": "golang:1.26@sha256:9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08",
                        "cpu": 4,
                        "memory_gb": 16,
                        "caches": {
                          "/go/pkg/mod": "go_mod"
                        },
                        "steps": [
                          {
                            "name": "vet",
                            "run": "go vet ./..."
                          },
                          {
                            "name": "test",
                            "run": "go test -json ./... > test.json",
                            "report": {
                              "format": "go_test_json",
                              "path": "test.json"
                            }
                          }
                        ]
                      }
                    ]
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "410": {
            "$ref": "#/components/responses/Gone"
          },
          "422": {
            "$ref": "#/components/responses/InvalidField"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "parameters": [
          {
            "$ref": "#/components/parameters/RunID"
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "team": {
                    "type": "string",
                    "description": "The team’s handle, such as `motor`. Required for session and user keys. Defaults to the key’s team when using a team key."
                  }
                },
                "required": [],
                "additionalProperties": false
              },
              "example": {
                "team": "motor"
              }
            }
          }
        }
      }
    },
    "/api/piston/runs/{run_id}/retry": {
      "post": {
        "operationId": "retry_run",
        "summary": "Retry artifact publication",
        "description": "Retries failed artifact publications from a completed run. Requires `piston:run` for a team key.\n\nTasks do not run again. Publication reuses their saved outputs and the previously reserved versions. Already published artifacts remain unchanged. If nothing needs republication, the run is returned unchanged. Monitor the run for publication results.",
        "tags": [
          "Runs"
        ],
        "responses": {
          "200": {
            "description": "The run.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Run"
                },
                "example": {
                  "id": "run_1BbA6sXxyUWHYvKqN5T3dM",
                  "team": "motor",
                  "user_id": "user_1BbA6sXxyUWHYvKqN5T3dM",
                  "team_key_id": null,
                  "actor": {
                    "kind": "user",
                    "id": "user_1BbA6sXxyUWHYvKqN5T3dM",
                    "name": null
                  },
                  "runs_as": {
                    "kind": "user",
                    "id": "user_1BbA6sXxyUWHYvKqN5T3dM",
                    "name": null
                  },
                  "requested_by": {
                    "kind": "user",
                    "id": "user_1BbA6sXxyUWHYvKqN5T3dM",
                    "name": null
                  },
                  "publisher": {
                    "kind": "user",
                    "id": "user_1BbA6sXxyUWHYvKqN5T3dM",
                    "name": null
                  },
                  "source_id": "src_1BbA6sXxyUWHYvKqN5T3dM",
                  "status": "running",
                  "reason": null,
                  "created_at": "2026-10-22T09:00:00.000Z",
                  "started_at": "2026-10-22T09:00:05.250Z",
                  "finished_at": null,
                  "vcpu_milliseconds": 268000,
                  "memory_byte_milliseconds": "1151051235328000",
                  "tasks": [
                    {
                      "name": "build",
                      "status": "succeeded",
                      "platform": "linux/amd64",
                      "cpu": 2,
                      "memory_gb": 8,
                      "key": null,
                      "cached_from_run_id": null,
                      "started_at": "2026-10-22T09:00:05.250Z",
                      "finished_at": "2026-10-22T09:01:12.500Z",
                      "steps": [
                        {
                          "name": "build",
                          "status": "succeeded",
                          "exit_code": 0,
                          "started_at": "2026-10-22T09:00:05.250Z",
                          "finished_at": "2026-10-22T09:01:12.500Z"
                        }
                      ],
                      "outputs": [
                        {
                          "name": "app",
                          "sha256": "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08",
                          "size": 10485760,
                          "directory": false,
                          "download_url": "https://motor.dev/api/piston/runs/run_1BbA6sXxyUWHYvKqN5T3dM/outputs/build/app"
                        }
                      ],
                      "reports": [],
                      "failure": null
                    }
                  ],
                  "plan": {
                    "tasks": [
                      {
                        "name": "build",
                        "platform": "linux/amd64",
                        "image": "golang:1.26@sha256:9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08",
                        "cpu": 2,
                        "memory_gb": 8,
                        "steps": [
                          {
                            "run": "go build -o out/app ./cmd/app"
                          }
                        ],
                        "outputs": {
                          "app": "out/app"
                        }
                      }
                    ],
                    "artifacts": [
                      {
                        "name": "release",
                        "repo": "acme/app",
                        "files": {
                          "app_linux_amd64": {
                            "task": "build",
                            "output": "app"
                          }
                        }
                      }
                    ]
                  },
                  "artifacts": [
                    {
                      "name": "release",
                      "repo": "acme/app",
                      "status": "queued",
                      "version": "2026_10_0007",
                      "url": "https://gauss.motor.dev/acme/app/artifacts/2026_10_0007",
                      "source_tag": null,
                      "source_state": null,
                      "files": [
                        {
                          "name": "app_linux_amd64",
                          "task": "build",
                          "output": "app",
                          "sha256": "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08",
                          "size": 10485760
                        }
                      ],
                      "started_at": "2026-10-22T09:01:12.600Z",
                      "finished_at": null,
                      "failure": null
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "410": {
            "$ref": "#/components/responses/Gone"
          },
          "422": {
            "$ref": "#/components/responses/InvalidField"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "parameters": [
          {
            "$ref": "#/components/parameters/RunID"
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "team": {
                    "type": "string",
                    "description": "The team’s handle, such as `motor`. Required for session and user keys. Defaults to the key’s team when using a team key."
                  }
                },
                "required": [],
                "additionalProperties": false
              },
              "example": {
                "team": "motor"
              }
            }
          }
        }
      }
    },
    "/api/piston/runs/{run_id}/logs": {
      "get": {
        "operationId": "list_logs",
        "summary": "Read the logs",
        "description": "Returns log lines after the specified `after` cursor. Pass `next_cursor` as `after` on subsequent requests, or use the streaming endpoint. Requires `piston:read` for a team key.\n\nWhile a run is in progress, and for an hour after it ends, lines come from the run’s live log. The live log holds about 15 MiB of a run’s lines, counting about 128 bytes per line besides its text and its task’s name, and 1 MiB more for messages; once the lines pass that, a message says so, and the rest of the run’s lines come from the steps’ full logs once the run ends. A line is cut at 16 KiB, and Piston reads the first 256 MiB of each step’s full log. Full logs expire 30 days after their upload, and Piston’s own messages a day after the run ends.",
        "tags": [
          "Logs"
        ],
        "responses": {
          "200": {
            "description": "A page of lines.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LogPage"
                },
                "example": {
                  "data": [
                    {
                      "task": "test",
                      "step": 1,
                      "stream": "stdout",
                      "text": "ok  \texample.com/app/ids\t0.012s",
                      "at": "2026-10-22T09:00:05.250Z",
                      "cursor": "c_000000000000002a"
                    }
                  ],
                  "next_cursor": "c_000000000000002a",
                  "has_more": false
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "410": {
            "$ref": "#/components/responses/Gone"
          },
          "422": {
            "$ref": "#/components/responses/InvalidField"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "parameters": [
          {
            "$ref": "#/components/parameters/RunID"
          },
          {
            "$ref": "#/components/parameters/TeamQuery"
          },
          {
            "name": "task",
            "in": "query",
            "required": false,
            "description": "Filter logs by task name. Omit to include all tasks.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "after",
            "in": "query",
            "required": false,
            "description": "Return lines after this cursor. Omit to start at the beginning of the log.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Maximum log lines per page. Range: 1–5,000. Defaults to 1,000.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 5000
            }
          }
        ]
      }
    },
    "/api/piston/runs/{run_id}/logs/stream": {
      "get": {
        "operationId": "stream_logs",
        "summary": "Stream the logs",
        "description": "Streams log lines as server-sent events. Requires `piston:read` for a team key. Resume after a cursor using `Last-Event-ID` or `after`; omit both to start at the beginning.\n\n- `line`: a log line as JSON, with its cursor in the event ID.\n- `end`: the completed run as JSON. The stream closes; do not reconnect.\n- `error`: an error object. The stream closes; reconnect from the last cursor only if the error is retryable.\n\nHeartbeat comments arrive every 25 seconds. Connections close after an hour; reconnect with the last received cursor if the run is still active.\n\nWhile a run is in progress, and for an hour after it ends, lines come from the run’s live log. The live log holds about 15 MiB of a run’s lines, counting about 128 bytes per line besides its text and its task’s name, and 1 MiB more for messages; once the lines pass that, a message says so, and the rest of the run’s lines come from the steps’ full logs once the run ends. A line is cut at 16 KiB, and Piston reads the first 256 MiB of each step’s full log. Full logs expire 30 days after their upload, and Piston’s own messages a day after the run ends.",
        "tags": [
          "Logs"
        ],
        "responses": {
          "200": {
            "description": "The stream.",
            "content": {
              "text/event-stream": {
                "schema": {
                  "type": "string"
                },
                "example": "id: c_000000000000002a\nevent: line\ndata: {\"task\":\"test\",\"step\":1,\"stream\":\"stdout\",\"text\":\"ok  \\texample.com/app/ids\\t0.012s\",\"at\":\"2026-10-22T09:00:05.250Z\",\"cursor\":\"c_000000000000002a\"}\n\nevent: end\ndata: {\"id\":\"run_1BbA6sXxyUWHYvKqN5T3dM\",\"status\":\"succeeded\",…}\n\n"
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "410": {
            "$ref": "#/components/responses/Gone"
          },
          "422": {
            "$ref": "#/components/responses/InvalidField"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "parameters": [
          {
            "$ref": "#/components/parameters/RunID"
          },
          {
            "$ref": "#/components/parameters/TeamQuery"
          },
          {
            "name": "task",
            "in": "query",
            "required": false,
            "description": "Filter logs by task name. Omit to include all tasks.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "after",
            "in": "query",
            "required": false,
            "description": "Cursor of the last received log line.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Last-Event-ID",
            "in": "header",
            "required": false,
            "description": "Cursor of the last received log line. EventSource clients send it when reconnecting.",
            "schema": {
              "type": "string"
            }
          }
        ]
      }
    },
    "/api/piston/runs/{run_id}/outputs/{task}/{output}": {
      "get": {
        "operationId": "download_output",
        "summary": "Download an output",
        "description": "Returns a `302` redirect to a download URL valid for 15 minutes. Requires `piston:read` for a team key. Follow `Location` without forwarding Motor credentials. Directory outputs are `tar.zst` archives. Tasks that reuse cached results return those results’ outputs.\n\nMotor serves the download (`get_output_bytes`) and bills the bytes it sends as bytes out. Check the bytes you receive against `output.sha256` (also in `X-Output-SHA256`), the SHA-256 that Piston recorded when the task finished, before you use them; `motor piston download` does this. Piston deletes an output once no run recorded or reused it for 30 days, unless a task result that is still in use needs it. Download an output you need to keep, or publish it as an artifact.",
        "tags": [
          "Outputs"
        ],
        "responses": {
          "302": {
            "description": "The output. `Location` has the URL of the download.",
            "headers": {
              "Location": {
                "description": "The URL that downloads the output.",
                "schema": {
                  "type": "string"
                }
              },
              "X-Output-SHA256": {
                "description": "The SHA-256 that Piston recorded for the output, in lowercase hex. Check the downloaded bytes against it.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OutputDownload"
                },
                "example": {
                  "output": {
                    "name": "motor",
                    "sha256": "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08",
                    "size": 31457280,
                    "directory": false,
                    "download_url": "https://www.motor.dev/api/piston/runs/run_1BbA6sXxyUWHYvKqN5T3dM/outputs/build_amd64/motor"
                  },
                  "url": "https://www.motor.dev/api/piston/downloads/AAAA…"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "410": {
            "$ref": "#/components/responses/Gone"
          },
          "422": {
            "$ref": "#/components/responses/InvalidField"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "parameters": [
          {
            "$ref": "#/components/parameters/RunID"
          },
          {
            "name": "task",
            "in": "path",
            "required": true,
            "description": "The task's name.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "output",
            "in": "path",
            "required": true,
            "description": "The output's name in the task.",
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/TeamQuery"
          }
        ]
      }
    },
    "/api/piston/downloads/{token}": {
      "get": {
        "operationId": "get_output_bytes",
        "summary": "Get an output's bytes",
        "description": "The URL returned by `download_output` works for 15 minutes without authentication. Do not send Motor credentials. `HEAD` returns only headers. A `Range` header requesting a single byte range returns `206` with that range. If `If-Range` does not match the `ETag`, Motor returns the whole output.\n\nMotor bills the team for the bytes sent in each download or range response. Check the complete output against `X-Output-SHA256` before you use it; `motor piston download` does this. This hash cannot verify an individual byte range.",
        "tags": [
          "Outputs"
        ],
        "security": [],
        "parameters": [
          {
            "name": "token",
            "in": "path",
            "required": true,
            "description": "The download's token, from `download_output`'s URL.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The output's bytes.",
            "headers": {
              "X-Output-SHA256": {
                "description": "The SHA-256 that Piston recorded for the output, in lowercase hex. Check the downloaded bytes against it.",
                "schema": {
                  "type": "string"
                }
              },
              "ETag": {
                "description": "The output's SHA-256, quoted, for `If-Range`.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/octet-stream": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "206": {
            "description": "The requested byte range, identified by `Content-Range`.",
            "content": {
              "application/octet-stream": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "416": {
            "description": "The range is outside the output. `Content-Range` has the output's size.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "invalid_range",
                    "message": "The requested byte range is outside the output.",
                    "retryable": false
                  }
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/api/piston/submissions/{submission_id}": {
      "get": {
        "operationId": "get_submission_run",
        "summary": "Get the run of a submission",
        "description": "Returns the run that the caller started with an `Idempotency-Key`, which `motor piston run` sends as its submission's ID, such as after the response that created the run was lost. Only the caller who sent the key finds the run. A run whose `reason` says that it waits for Gauss hasn't started its tasks yet. Requires `piston:read` for a team key.",
        "tags": [
          "Runs"
        ],
        "responses": {
          "200": {
            "description": "The run.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Run"
                },
                "example": {
                  "id": "run_1BbA6sXxyUWHYvKqN5T3dM",
                  "team": "motor",
                  "user_id": "user_1BbA6sXxyUWHYvKqN5T3dM",
                  "team_key_id": null,
                  "actor": {
                    "kind": "user",
                    "id": "user_1BbA6sXxyUWHYvKqN5T3dM",
                    "name": null
                  },
                  "runs_as": {
                    "kind": "user",
                    "id": "user_1BbA6sXxyUWHYvKqN5T3dM",
                    "name": null
                  },
                  "requested_by": {
                    "kind": "user",
                    "id": "user_1BbA6sXxyUWHYvKqN5T3dM",
                    "name": null
                  },
                  "publisher": {
                    "kind": "user",
                    "id": "user_1BbA6sXxyUWHYvKqN5T3dM",
                    "name": null
                  },
                  "source_id": "src_1BbA6sXxyUWHYvKqN5T3dM",
                  "status": "failed",
                  "reason": null,
                  "created_at": "2026-10-22T09:00:00.000Z",
                  "started_at": "2026-10-22T09:00:05.250Z",
                  "finished_at": "2026-10-22T09:01:12.500Z",
                  "vcpu_milliseconds": 268000,
                  "memory_byte_milliseconds": "1151051235328000",
                  "tasks": [
                    {
                      "name": "test",
                      "status": "failed",
                      "platform": "linux/amd64",
                      "cpu": 4,
                      "memory_gb": 16,
                      "key": null,
                      "cached_from_run_id": null,
                      "started_at": "2026-10-22T09:00:05.250Z",
                      "finished_at": "2026-10-22T09:01:12.500Z",
                      "steps": [
                        {
                          "name": "vet",
                          "status": "succeeded",
                          "exit_code": 0,
                          "started_at": "2026-10-22T09:00:05.250Z",
                          "finished_at": "2026-10-22T09:00:20.000Z"
                        },
                        {
                          "name": "test",
                          "status": "failed",
                          "exit_code": 1,
                          "started_at": "2026-10-22T09:00:20.000Z",
                          "finished_at": "2026-10-22T09:01:12.500Z"
                        }
                      ],
                      "outputs": [],
                      "reports": [
                        {
                          "step": "test",
                          "format": "go_test_json",
                          "passed": 41,
                          "failed": 1,
                          "skipped": 0,
                          "failures": [
                            {
                              "name": "example.com/app/ids.TestNew",
                              "message": "ids_test.go:12: got \"run_\", want \"src_\"",
                              "file": "lib/ids/ids_test.go",
                              "line": 12
                            }
                          ]
                        }
                      ],
                      "failure": {
                        "step": "test",
                        "message": "The step exited with 1.",
                        "log_tail": "--- FAIL: TestNew (0.00s)\n    ids_test.go:12: got \"run_\", want \"src_\"\nFAIL"
                      }
                    }
                  ],
                  "plan": {
                    "tasks": [
                      {
                        "name": "test",
                        "platform": "linux/amd64",
                        "image": "golang:1.26@sha256:9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08",
                        "cpu": 4,
                        "memory_gb": 16,
                        "caches": {
                          "/go/pkg/mod": "go_mod"
                        },
                        "steps": [
                          {
                            "name": "vet",
                            "run": "go vet ./..."
                          },
                          {
                            "name": "test",
                            "run": "go test -json ./... > test.json",
                            "report": {
                              "format": "go_test_json",
                              "path": "test.json"
                            }
                          }
                        ]
                      }
                    ]
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "parameters": [
          {
            "name": "submission_id",
            "in": "path",
            "required": true,
            "description": "The submission's ID: the `Idempotency-Key` of the request that created the run.",
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/TeamQuery"
          }
        ]
      }
    },
    "/api/piston/volumes": {
      "get": {
        "operationId": "list_volumes",
        "summary": "List volumes",
        "description": "Lists team volumes used for task caches and Docker image and layer caches. Each task receives a copy of its volume and commits changes if it succeeds. Requires `piston:read` for a team key.",
        "tags": [
          "Volumes"
        ],
        "responses": {
          "200": {
            "description": "The volumes.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/VolumePage"
                },
                "example": {
                  "data": [
                    {
                      "id": "vol_1BbA6sXxyUWHYvKqN5T3dM",
                      "key": "go_mod",
                      "size": 734003200,
                      "committed_by_run_id": "run_1BbA6sXxyUWHYvKqN5T3dM",
                      "committed_at": "2026-10-22T09:01:12.500Z",
                      "used_at": "2026-10-22T09:01:12.500Z"
                    }
                  ],
                  "next_cursor": null
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "410": {
            "$ref": "#/components/responses/Gone"
          },
          "422": {
            "$ref": "#/components/responses/InvalidField"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamQuery"
          }
        ]
      }
    },
    "/api/piston/volumes/{volume_id}": {
      "delete": {
        "operationId": "delete_volume",
        "summary": "Delete a volume",
        "description": "Deletes a cached volume. The next task using its key starts with an empty volume. Requires `piston:run` for a team key.",
        "tags": [
          "Volumes"
        ],
        "responses": {
          "204": {
            "description": "The volume is deleted."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "410": {
            "$ref": "#/components/responses/Gone"
          },
          "422": {
            "$ref": "#/components/responses/InvalidField"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "parameters": [
          {
            "name": "volume_id",
            "in": "path",
            "required": true,
            "description": "The volume's ID.",
            "schema": {
              "type": "string",
              "pattern": "^vol_"
            }
          },
          {
            "$ref": "#/components/parameters/TeamQuery"
          }
        ]
      }
    },
    "/api/piston/secrets": {
      "get": {
        "operationId": "list_secrets",
        "summary": "List secrets",
        "description": "Lists team secret names and metadata, never their values. Tasks receive only secrets explicitly named in their plans. Requires `piston:secrets` for a team key.",
        "tags": [
          "Secrets"
        ],
        "responses": {
          "200": {
            "description": "The secrets.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SecretPage"
                },
                "example": {
                  "data": [
                    {
                      "name": "registry_token",
                      "updated_at": "2026-10-22T09:00:00.000Z"
                    }
                  ],
                  "next_cursor": null
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "410": {
            "$ref": "#/components/responses/Gone"
          },
          "422": {
            "$ref": "#/components/responses/InvalidField"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "parameters": [
          {
            "$ref": "#/components/parameters/TeamQuery"
          }
        ]
      }
    },
    "/api/piston/secrets/{name}": {
      "put": {
        "operationId": "put_secret",
        "summary": "Set a secret",
        "description": "Creates or replaces a team secret. Piston encrypts its value and supplies it only to tasks that request it. The value cannot be read back through the API. Requires `piston:secrets` for a team key.",
        "tags": [
          "Secrets"
        ],
        "responses": {
          "200": {
            "description": "The secret, without its value.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Secret"
                },
                "example": {
                  "name": "registry_token",
                  "updated_at": "2026-10-22T09:00:00.000Z"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "410": {
            "$ref": "#/components/responses/Gone"
          },
          "422": {
            "$ref": "#/components/responses/InvalidField"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "parameters": [
          {
            "name": "name",
            "in": "path",
            "required": true,
            "description": "The secret's name, in snake case, such as `registry_token`.",
            "schema": {
              "type": "string",
              "pattern": "^[a-z][a-z0-9_]*$"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "value": {
                    "type": "string",
                    "maxLength": 65536,
                    "description": "The secret's value, at most 64 KiB."
                  },
                  "team": {
                    "type": "string",
                    "description": "The team’s handle, such as `motor`. Required for session and user keys. Defaults to the key’s team when using a team key."
                  }
                },
                "required": [
                  "value"
                ],
                "additionalProperties": false
              },
              "example": {
                "team": "motor",
                "value": "ghp_…"
              }
            }
          }
        }
      },
      "delete": {
        "operationId": "delete_secret",
        "summary": "Delete a secret",
        "description": "Deletes a team secret. Future runs that require it fail validation. Requires `piston:secrets` for a team key.",
        "tags": [
          "Secrets"
        ],
        "responses": {
          "204": {
            "description": "The secret is deleted."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "$ref": "#/components/responses/Conflict"
          },
          "410": {
            "$ref": "#/components/responses/Gone"
          },
          "422": {
            "$ref": "#/components/responses/InvalidField"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "parameters": [
          {
            "name": "name",
            "in": "path",
            "required": true,
            "description": "The secret's name, in snake case, such as `registry_token`.",
            "schema": {
              "type": "string",
              "pattern": "^[a-z][a-z0-9_]*$"
            }
          },
          {
            "$ref": "#/components/parameters/TeamQuery"
          }
        ]
      }
    },
    "/api/piston/payload_key": {
      "get": {
        "operationId": "get_payload_key",
        "summary": "Get Piston's payload key",
        "description": "Returns Piston's current payload key: an HPKE public key (ML-KEM-768 with X25519, HKDF-SHA256, AES-256-GCM) that a caller seals its own values of secrets to, for `caller_secrets` of `POST /api/piston/runs`. `motor piston run --secret` uses it. Requires `piston:run` for a team key.",
        "tags": [
          "Runs"
        ],
        "parameters": [
          {
            "name": "team",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "The team's handle, for a session or user key."
          }
        ],
        "responses": {
          "200": {
            "description": "The key.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "key_id",
                    "public_key",
                    "team_id"
                  ],
                  "properties": {
                    "key_id": {
                      "type": "string"
                    },
                    "public_key": {
                      "type": "string",
                      "format": "byte",
                      "description": "The public key, in base64."
                    },
                    "team_id": {
                      "type": "string",
                      "description": "The caller's team's ID, which a payload's metadata names."
                    }
                  }
                },
                "example": {
                  "key_id": "pk_1BbA6sXxyUWHYvKqN5T3dM",
                  "public_key": "bG9uZyBwdWJsaWMga2V5",
                  "team_id": "team_1BbA6sXxyUWHYvKqN5T3dM"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "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_`), where an endpoint says that a team key works."
      },
      "dpop": {
        "type": "http",
        "scheme": "DPoP",
        "description": "Device-bound session key. Each request requires a `DPoP` proof signed by the device key (RFC 9449)."
      }
    },
    "parameters": {
      "IdempotencyKey": {
        "name": "Idempotency-Key",
        "in": "header",
        "required": false,
        "description": "Request deduplication key: 1–128 printable ASCII characters, excluding spaces. For 24 hours, identical requests with the same key and credential return the stored response.",
        "schema": {
          "type": "string",
          "minLength": 1,
          "maxLength": 128
        }
      },
      "Limit": {
        "name": "limit",
        "in": "query",
        "required": false,
        "description": "Maximum results per page. Range: 1–100. Defaults to 50.",
        "schema": {
          "type": "integer",
          "minimum": 1,
          "maximum": 100
        }
      },
      "Cursor": {
        "name": "cursor",
        "in": "query",
        "required": false,
        "description": "The previous response’s `next_cursor`. Omit for the first page.",
        "schema": {
          "type": "string"
        }
      },
      "TeamQuery": {
        "name": "team",
        "in": "query",
        "required": false,
        "description": "The team’s handle, such as `motor`.",
        "schema": {
          "type": "string"
        }
      },
      "RunID": {
        "name": "run_id",
        "in": "path",
        "required": true,
        "description": "The run's ID.",
        "schema": {
          "type": "string",
          "pattern": "^run_"
        }
      }
    },
    "responses": {
      "BadRequest": {
        "description": "The request body is not a JSON object, or the request is otherwise invalid.",
        "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": "The credential is missing, unknown, revoked, or expired, or a bound session key has no valid DPoP proof.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "error": {
                "code": "unauthorized",
                "message": "The credential is unknown, revoked, or expired.",
                "retryable": false
              }
            }
          }
        }
      },
      "Forbidden": {
        "description": "The credential does not authorize this operation. Codes include `insufficient_scope`, `team_key_not_accepted`, `forbidden`, and `team_suspended`. For `insufficient_scope`, ask a team admin for a key with the required scope.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "error": {
                "code": "insufficient_scope",
                "message": "The team key's scopes don't include piston:run.",
                "retryable": false
              }
            }
          }
        }
      },
      "NotFound": {
        "description": "There is no such resource in the team, or the credential can't see it. Check the ID, and `team`.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "error": {
                "code": "not_found",
                "message": "There is no run run_1BbA6sXxyUWHYvKqN5T3dM in the team.",
                "retryable": false
              }
            }
          }
        }
      },
      "Gone": {
        "description": "This team handle is no longer active. Use the team’s current handle.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "error": {
                "code": "team_gone",
                "message": "lighthouse was a team's handle, which it changed or gave up.",
                "retryable": false
              }
            }
          }
        }
      },
      "Conflict": {
        "description": "The request conflicts with the resource’s state, such as starting a run before its source is uploaded. Check the error message.\n\n`idempotency_conflict` means the key was used for a different request; use a new key for new work. `request_in_progress` means the original request is still running; wait `retry_after_seconds` before retrying.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "error": {
                "code": "conflict",
                "message": "The source src_1BbA6sXxyUWHYvKqN5T3dM isn't uploaded yet: PUT it to its upload_url first.",
                "retryable": false
              }
            }
          }
        }
      },
      "InvalidField": {
        "description": "A field or a parameter has a value that Motor or Piston can't accept: `field` names it, and the message says what to send.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "error": {
                "code": "invalid_field",
                "message": "`sha256` must be the SHA-256 digest of the source's tar.zst, as 64 lowercase hex digits.",
                "retryable": false,
                "field": "sha256"
              }
            }
          }
        }
      },
      "RateLimited": {
        "description": "The credential exceeded 600 requests per minute, or Piston is at capacity. 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
              }
            }
          }
        }
      },
      "PaymentRequired": {
        "description": "New work is blocked by billing. For `billing_required`, a team admin must add a payment card. For `over_limit`, an admin can raise the monthly spending limit. Retry only after the billing restriction is resolved.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "error": {
                "code": "over_limit",
                "message": "The team spent its spending limit for this month, so Piston doesn't start new work for it. An admin raises the limit at https://www.motor.dev/console, or the work waits until next month.",
                "retryable": false
              }
            }
          }
        }
      },
      "InvalidPlan": {
        "description": "`invalid_plan` includes diagnostics with a code, message, source location, or plan field path. Correct the reported errors before retrying. `invalid_field` identifies an invalid request field in `field`.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "error": {
                "code": "invalid_plan",
                "message": "The plan has 1 problem. Fix each one, and send the request again.\npiston.star:14:9: tasks.test.caches: \"go mod\" isn't snake case; use \"go_mod\" [P0107]",
                "retryable": false,
                "diagnostics": [
                  {
                    "file": "piston.star",
                    "line": 14,
                    "column": 9,
                    "path": "tasks.test.caches",
                    "code": "P0107",
                    "message": "\"go mod\" isn't snake case; use \"go_mod\""
                  }
                ]
              }
            }
          }
        }
      },
      "Unavailable": {
        "description": "For `temporarily_unavailable`, wait `retry_after_seconds` before retrying. Preserve the original `Idempotency-Key` if supplied. `unavailable` means this Motor server is not configured to call Piston.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "example": {
              "error": {
                "code": "temporarily_unavailable",
                "message": "Piston can't answer now. Try again in a moment.",
                "retryable": true,
                "retry_after_seconds": 1
              }
            }
          }
        }
      }
    },
    "schemas": {
      "Source": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "Source ID (`src_…`), used in the `source_id` request field."
          },
          "sha256": {
            "type": "string",
            "description": "The SHA-256 digest of the source's tar.zst, in lowercase hex."
          },
          "size": {
            "type": "integer",
            "description": "The size of the tar.zst, in bytes."
          },
          "repo": {
            "type": [
              "string",
              "null"
            ],
            "description": "Source repository label, such as `acme/app`, or null."
          },
          "uploaded": {
            "type": "boolean",
            "description": "Whether Piston has the source's bytes. A run needs an uploaded source."
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "description": "When the team registered the source."
          }
        },
        "required": [
          "id",
          "sha256",
          "size",
          "repo",
          "uploaded",
          "created_at"
        ],
        "additionalProperties": false,
        "title": "Source"
      },
      "SourceUpload": {
        "type": "object",
        "properties": {
          "source": {
            "$ref": "#/components/schemas/Source"
          },
          "upload_url": {
            "type": [
              "string",
              "null"
            ],
            "description": "Upload the `tar.zst` archive to this URL using `PUT` before `upload_expires_at`. Do not include Motor credentials. Null means the source is already uploaded."
          },
          "upload_expires_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When `upload_url` stops working. Register the source again for a new URL."
          }
        },
        "required": [
          "source",
          "upload_url",
          "upload_expires_at"
        ],
        "additionalProperties": false
      },
      "Diagnostic": {
        "type": "object",
        "properties": {
          "file": {
            "type": "string",
            "description": "Configuration file containing the diagnostic, such as `piston.star`."
          },
          "line": {
            "type": "integer",
            "description": "Line number in `file`, starting at 1."
          },
          "column": {
            "type": "integer",
            "description": "Column number in `line`, starting at 1."
          },
          "path": {
            "type": "string",
            "description": "The path of the field in the plan, such as `tasks.test.caches`."
          },
          "code": {
            "type": "string",
            "description": "Stable diagnostic code, such as `P0107`."
          },
          "message": {
            "type": "string",
            "description": "What is wrong, and how to fix it."
          }
        },
        "required": [
          "code",
          "message"
        ],
        "additionalProperties": false,
        "title": "Diagnostic",
        "description": "A configuration or plan diagnostic."
      },
      "PlanTask": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "description": "The task's name, unique in the plan, in snake case."
          },
          "platform": {
            "type": "string",
            "enum": [
              "linux/amd64",
              "linux/arm64",
              "windows/amd64"
            ],
            "description": "Defaults to `linux/amd64`."
          },
          "image": {
            "type": "string",
            "description": "An OCI image reference, such as `golang:1.26`. A Linux task needs one, or a `layer`. In a run, it has its digest."
          },
          "layer": {
            "$ref": "#/components/schemas/PlanLayer",
            "description": "The task's image as a layer, instead of `image`: Piston builds it once, and reuses the build."
          },
          "cpu": {
            "type": "integer",
            "enum": [
              2,
              4,
              8,
              16,
              32,
              48
            ],
            "description": "The number of vCPUs."
          },
          "memory_gb": {
            "type": "integer",
            "description": "Memory in GB: 2, 4, or 8 per vCPU. Defaults to 4 GB per vCPU."
          },
          "workdir": {
            "type": "string",
            "description": "Working directory containing the source. Defaults to `/workspace`, or `C:\\workspace` on Windows."
          },
          "env": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            },
            "description": "Environment variables of each step."
          },
          "secrets": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            },
            "description": "Environment variables whose values are the team's secrets: the variable's name → the secret's name."
          },
          "caches": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            },
            "description": "Volumes at paths of the container: the path → the volume's key, in snake case."
          },
          "docker": {
            "type": "object",
            "properties": {
              "cache": {
                "type": "string",
                "description": "Volume key for the Docker daemon’s image and layer cache. Omit to start with an empty cache."
              }
            },
            "required": [],
            "description": "A Docker daemon of the task's own, at /var/run/docker.sock."
          },
          "inputs": {
            "type": "object",
            "additionalProperties": {
              "type": "object",
              "properties": {
                "task": {
                  "type": "string"
                },
                "output": {
                  "type": "string"
                }
              },
              "required": [
                "task",
                "output"
              ]
            },
            "description": "Outputs of other tasks, at paths relative to the working directory: the path → the output."
          },
          "needs": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Task dependencies that must succeed before this task starts, in addition to dependencies implied by `inputs`."
          },
          "steps": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "name": {
                  "type": "string",
                  "description": "Step name shown in results and logs. Defaults to a name derived from the command."
                },
                "run": {
                  "type": "string",
                  "description": "Script executed by `sh -e`, or `pwsh` on Windows. Piston does not interpolate values into the script."
                },
                "argv": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  },
                  "description": "A command and its arguments, without a shell. Send `run` or `argv`."
                },
                "env": {
                  "type": "object",
                  "additionalProperties": {
                    "type": "string"
                  },
                  "description": "Environment variables of this step, added to the task's."
                },
                "report": {
                  "type": "object",
                  "properties": {
                    "format": {
                      "type": "string",
                      "enum": [
                        "junit",
                        "go_test_json"
                      ]
                    },
                    "path": {
                      "type": "string",
                      "description": "The report's file, relative to the working directory. A glob for `junit`."
                    }
                  },
                  "required": [
                    "format",
                    "path"
                  ],
                  "title": "Report",
                  "description": "A test report that the step writes, which Piston parses into the results, even when the step fails."
                },
                "timeout_seconds": {
                  "type": "integer",
                  "description": "Step timeout in seconds, bounded by the task’s remaining time."
                }
              },
              "required": [],
              "title": "Step"
            },
            "description": "Ordered task steps. Execution stops at the first failed step."
          },
          "outputs": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            },
            "description": "Files or directories that the task makes, relative to its working directory: the output's name → its path."
          },
          "cache": {
            "type": "boolean",
            "description": "Reuse an earlier result of the team for the task's key, and its outputs, instead of running it again."
          },
          "network": {
            "type": "string",
            "enum": [
              "internet",
              "none"
            ],
            "description": "Defaults to `internet`."
          },
          "timeout_seconds": {
            "type": "integer",
            "description": "Task timeout in seconds. Defaults to 3,600; maximum 43,200."
          }
        },
        "required": [
          "name",
          "steps"
        ],
        "title": "PlanTask",
        "description": "A task and its execution settings. Its steps run in the configured container on a dedicated machine."
      },
      "PlanLayer": {
        "type": "object",
        "properties": {
          "parent": {
            "type": "string",
            "description": "The image that the steps start from, such as `golang:1.27`. In a run, it has its digest. A layer has `parent` or `parent_layer`."
          },
          "parent_layer": {
            "$ref": "#/components/schemas/PlanLayer",
            "description": "A layer that the steps start from, instead of `parent`."
          },
          "steps": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "name": {
                  "type": "string",
                  "description": "Step name shown in results and logs. Defaults to a name derived from the command."
                },
                "run": {
                  "type": "string",
                  "description": "Script executed by `sh -e`, or `pwsh` on Windows. Piston does not interpolate values into the script."
                },
                "argv": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  },
                  "description": "A command and its arguments, without a shell. Send `run` or `argv`."
                },
                "env": {
                  "type": "object",
                  "additionalProperties": {
                    "type": "string"
                  },
                  "description": "Environment variables of this step, added to the task's."
                },
                "timeout_seconds": {
                  "type": "integer",
                  "description": "Step timeout in seconds, bounded by the task’s remaining time."
                }
              },
              "required": [],
              "title": "Step"
            },
            "description": "The commands that install and configure, in order. A layer's step has no report."
          },
          "env": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            },
            "description": "Environment variables of each step. The image doesn't keep them."
          },
          "name": {
            "type": "string",
            "description": "A name for logs and messages only. It isn't part of the layer's identity."
          },
          "timeout_seconds": {
            "type": "integer",
            "description": "The time limit of all the steps. Defaults to 1,800; maximum 7,200."
          }
        },
        "required": [
          "steps"
        ],
        "title": "PlanLayer",
        "description": "A recipe for an image: a parent image with what the steps install and configure. Piston runs the steps once, in a build of their own, and reuses the build's image while the recipe stays the same."
      },
      "Plan": {
        "type": "object",
        "properties": {
          "tasks": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PlanTask"
            }
          },
          "artifacts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PlanArtifact"
            },
            "description": "Publications of tasks' outputs to Gauss."
          },
          "groups": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PlanGroup"
            },
            "description": "Names of sets of targets."
          }
        },
        "required": [
          "tasks"
        ],
        "title": "Plan",
        "description": "Tasks, artifacts, and groups generated from `piston.star` or supplied as JSON. Values are passed through environment variables, files, or argument arrays; Piston does not interpolate them into commands."
      },
      "PlanResult": {
        "type": "object",
        "properties": {
          "plan": {
            "$ref": "#/components/schemas/Plan"
          },
          "diagnostics": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Diagnostic"
            },
            "description": "Warnings, if any. A plan with errors is a 422 `invalid_plan` instead."
          }
        },
        "required": [
          "plan",
          "diagnostics"
        ],
        "additionalProperties": false
      },
      "Step": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "queued",
              "starting",
              "running",
              "succeeded",
              "failed",
              "canceled",
              "timed_out",
              "errored",
              "skipped"
            ],
            "description": "Execution status. Active states: `queued`, `starting`, `running`. Final states: `succeeded`, `failed`, `canceled`, `timed_out`, `errored`, `skipped`. `errored` indicates a Piston infrastructure failure; `skipped` indicates an unmet dependency. See the failure details for the cause."
          },
          "exit_code": {
            "type": [
              "integer",
              "null"
            ],
            "description": "Exit code after the step finishes."
          },
          "started_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When the step started."
          },
          "finished_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When the step ended."
          }
        },
        "required": [
          "name",
          "status",
          "exit_code",
          "started_at",
          "finished_at"
        ],
        "additionalProperties": false,
        "title": "StepResult"
      },
      "Output": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "description": "The output's name in the plan."
          },
          "sha256": {
            "type": "string",
            "description": "The SHA-256 digest of the output's bytes, in lowercase hex."
          },
          "size": {
            "type": "integer",
            "description": "The size in bytes."
          },
          "directory": {
            "type": "boolean",
            "description": "Whether the output is a directory, which downloads as a tar.zst."
          },
          "download_url": {
            "type": "string",
            "description": "Authenticated Motor endpoint that redirects to the output download. Include Motor credentials on this request, but not on the redirected download."
          }
        },
        "required": [
          "name",
          "sha256",
          "size",
          "directory",
          "download_url"
        ],
        "additionalProperties": false,
        "title": "Output"
      },
      "TestFailure": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "description": "The test's name, with its suite or package."
          },
          "message": {
            "type": "string",
            "description": "The failure's message and output, at most 8 KiB."
          },
          "file": {
            "type": [
              "string",
              "null"
            ],
            "description": "The test’s file, if included in the report."
          },
          "line": {
            "type": [
              "integer",
              "null"
            ],
            "description": "The line number in `file`, if included in the report."
          }
        },
        "required": [
          "name",
          "message",
          "file",
          "line"
        ],
        "additionalProperties": false,
        "title": "TestFailure"
      },
      "TestReport": {
        "type": "object",
        "properties": {
          "step": {
            "type": "string",
            "description": "The step that produced the test report."
          },
          "format": {
            "type": "string",
            "enum": [
              "junit",
              "go_test_json"
            ]
          },
          "passed": {
            "type": "integer"
          },
          "failed": {
            "type": "integer"
          },
          "skipped": {
            "type": "integer"
          },
          "failures": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TestFailure"
            },
            "description": "The failed tests, at most 100."
          }
        },
        "required": [
          "step",
          "format",
          "passed",
          "failed",
          "skipped",
          "failures"
        ],
        "additionalProperties": false,
        "title": "TestReport"
      },
      "Failure": {
        "type": "object",
        "properties": {
          "step": {
            "type": [
              "string",
              "null"
            ],
            "description": "The step that failed, or null if the task failed outside its steps."
          },
          "message": {
            "type": "string",
            "description": "Why the task didn't succeed."
          },
          "log_tail": {
            "type": "string",
            "description": "The last lines of the step's log, at most 100 lines and 16 KiB. Read it first; get the full log from the logs endpoint."
          }
        },
        "required": [
          "step",
          "message",
          "log_tail"
        ],
        "additionalProperties": false,
        "title": "Failure"
      },
      "Task": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "queued",
              "starting",
              "running",
              "succeeded",
              "failed",
              "canceled",
              "timed_out",
              "errored",
              "skipped"
            ],
            "description": "Execution status. Active states: `queued`, `starting`, `running`. Final states: `succeeded`, `failed`, `canceled`, `timed_out`, `errored`, `skipped`. `errored` indicates a Piston infrastructure failure; `skipped` indicates an unmet dependency. See the failure details for the cause."
          },
          "platform": {
            "type": "string",
            "description": "Such as `linux/amd64`."
          },
          "cpu": {
            "type": "integer",
            "description": "The vCPUs that the task asked for."
          },
          "memory_gb": {
            "type": "integer",
            "description": "The memory that the task asked for, in GB."
          },
          "key": {
            "type": [
              "string",
              "null"
            ],
            "description": "The task's key, in lowercase hex, if the task has `cache`."
          },
          "cached_from_run_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "The run whose result this task reused, or null if it ran."
          },
          "started_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When the task's first step started."
          },
          "finished_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When the task ended."
          },
          "steps": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Step"
            }
          },
          "outputs": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Output"
            }
          },
          "reports": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TestReport"
            }
          },
          "failure": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Failure"
              },
              {
                "type": "null"
              }
            ],
            "description": "Why the task didn't succeed, or null."
          }
        },
        "required": [
          "name",
          "status",
          "platform",
          "cpu",
          "memory_gb",
          "key",
          "cached_from_run_id",
          "started_at",
          "finished_at",
          "steps",
          "outputs",
          "reports",
          "failure"
        ],
        "additionalProperties": false,
        "title": "Task"
      },
      "Run": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "The run's ID, `run_…`."
          },
          "user_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "ID of the user who started the run. Null if a team key started it."
          },
          "team_key_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "The team key that started the run, `tkey_…`, or null for a person."
          },
          "actor": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Identity"
              },
              {
                "type": "null"
              }
            ],
            "description": "Who caused the run: the person or team key that started it, or, for a run of a Gauss hook, whoever made the Gauss event or invoked the hook, which can be another repository's hooks whose run pushed. Null when it isn't known, as for a hook's run from before Piston recorded it."
          },
          "runs_as": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Identity"
              },
              {
                "type": "null"
              }
            ],
            "description": "What the run executes as: the person or team key that started it, or, for a run of a Gauss hook, the hook's repository's hooks (`automation`)."
          },
          "requested_by": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Identity"
              },
              {
                "type": "null"
              }
            ],
            "description": "Who asked for the run's execution: its `actor`, or, for a retry of a Gauss hook's invocation, whoever retried it. A retry of the run's publications doesn't change it; it changes `publisher`."
          },
          "publisher": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Identity"
              },
              {
                "type": "null"
              }
            ],
            "description": "Who the run's artifacts publish as: who started the run, or, for a run of a Gauss hook, the hook's repository's hooks, until somebody retries its publications (`POST /api/piston/runs/{run_id}/retry`), who then publishes them."
          },
          "source_id": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "queued",
              "starting",
              "running",
              "succeeded",
              "failed",
              "canceled",
              "timed_out",
              "errored",
              "skipped"
            ],
            "description": "Execution status. Active states: `queued`, `starting`, `running`. Final states: `succeeded`, `failed`, `canceled`, `timed_out`, `errored`, `skipped`. `errored` indicates a Piston infrastructure failure; `skipped` indicates an unmet dependency. See the failure details for the cause."
          },
          "reason": {
            "type": [
              "string",
              "null"
            ],
            "description": "Why the run ended when it didn't succeed, such as `over_limit`, or null."
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "description": "When the run started."
          },
          "started_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When the first task started."
          },
          "finished_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "Completion time. Non-null when the run has finished."
          },
          "vcpu_milliseconds": {
            "type": "integer",
            "description": "The compute that the run's tasks used, which Piston bills."
          },
          "memory_byte_milliseconds": {
            "type": "string",
            "description": "Billable memory usage in byte-milliseconds. Encoded as a string because it can exceed JavaScript’s safe integer range."
          },
          "tasks": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Task"
            },
            "description": "Tasks and their results. Included only when fetching an individual run."
          },
          "artifacts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Artifact"
            },
            "description": "Artifacts published to Gauss after their dependencies succeed. Included only when fetching an individual run."
          },
          "layers": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/RunLayer"
            },
            "description": "The layers that the run's tasks need, parents first, and the builds that the run bound. Included only when fetching an individual run."
          },
          "refresh_layers": {
            "type": "boolean",
            "description": "Whether the run builds its layers again instead of reusing builds."
          },
          "cache_scope": {
            "type": "string",
            "description": "Where the run restores and saves its caches, task results, and layer builds: its caller's scope (`user:…` or `team_key:…`), or the scope that Gauss assigned a hook's run (`protected:…`, `channel:…`, or `repository:…`)."
          },
          "cache_fallback": {
            "type": "string",
            "description": "The protected scope that the run restores from when its own scope has no entry of a key, or empty. The run never saves to it."
          },
          "plan": {
            "allOf": [
              {
                "$ref": "#/components/schemas/Plan"
              }
            ],
            "description": "Execution plan with resolved image digests. Included only when fetching an individual run."
          },
          "team": {
            "type": [
              "string",
              "null"
            ],
            "description": "The team’s handle. Null if the personal team’s owner has not chosen one."
          }
        },
        "required": [
          "id",
          "team",
          "team_key_id",
          "user_id",
          "actor",
          "runs_as",
          "requested_by",
          "publisher",
          "source_id",
          "status",
          "reason",
          "created_at",
          "started_at",
          "finished_at",
          "vcpu_milliseconds",
          "memory_byte_milliseconds"
        ],
        "additionalProperties": false,
        "title": "Run"
      },
      "RunLayer": {
        "type": "object",
        "properties": {
          "position": {
            "type": "integer",
            "description": "The layer's position in the run's layers."
          },
          "parent": {
            "type": [
              "integer",
              "null"
            ],
            "description": "The position of the parent layer, or null for a parent image."
          },
          "parent_image": {
            "type": [
              "string",
              "null"
            ],
            "description": "The parent image, with its digest, or null for a parent layer."
          },
          "name": {
            "type": [
              "string",
              "null"
            ],
            "description": "The layer's name, for people."
          },
          "recipe_key": {
            "type": [
              "string",
              "null"
            ],
            "description": "The recipe key: the digest of what the layer does. Null until the parent layer is bound."
          },
          "build_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "The build that the run waits for or bound, `bld_…`."
          },
          "status": {
            "type": "string",
            "enum": [
              "waiting",
              "building",
              "bound",
              "failed"
            ],
            "description": "`waiting` for the parent layer, `building`, `bound` to a build that succeeded, or `failed`."
          },
          "image": {
            "type": [
              "string",
              "null"
            ],
            "description": "The image identity of the bound build: the digest of its manifest."
          },
          "reused": {
            "type": "boolean",
            "description": "Whether the run bound a build that another run made."
          },
          "build_run_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "The run that runs the build."
          },
          "build_task": {
            "type": [
              "string",
              "null"
            ],
            "description": "The build's task in that run."
          },
          "failure": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Failure"
              },
              {
                "type": "null"
              }
            ],
            "description": "Why the layer failed."
          }
        },
        "required": [
          "position",
          "parent",
          "parent_image",
          "name",
          "recipe_key",
          "build_id",
          "status",
          "image",
          "reused",
          "build_run_id",
          "build_task",
          "failure"
        ],
        "title": "RunLayer",
        "description": "A layer of a run, and the build that it bound."
      },
      "RunPage": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Run"
            }
          },
          "next_cursor": {
            "type": [
              "string",
              "null"
            ],
            "description": "Pass this value as `cursor` to fetch the next page. Null if there are no more results."
          }
        },
        "required": [
          "data",
          "next_cursor"
        ],
        "additionalProperties": false
      },
      "LogLine": {
        "type": "object",
        "properties": {
          "task": {
            "type": "string"
          },
          "step": {
            "type": "integer",
            "description": "The step’s index within the task, starting at 0."
          },
          "stream": {
            "type": "string",
            "enum": [
              "stdout",
              "stderr",
              "piston",
              "pistond"
            ],
            "description": "`piston` for the messages of Piston's control plane, such as the start of an instance; `pistond` for the messages of the task's instance, such as the pull of the image. Only Piston writes `piston` lines."
          },
          "text": {
            "type": "string"
          },
          "at": {
            "type": "string",
            "format": "date-time",
            "description": "When the line was written."
          },
          "cursor": {
            "type": "string",
            "description": "The line's position, for `after` and `Last-Event-ID`."
          }
        },
        "required": [
          "task",
          "step",
          "stream",
          "text",
          "at",
          "cursor"
        ],
        "additionalProperties": false,
        "title": "LogLine"
      },
      "LogPage": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/LogLine"
            }
          },
          "next_cursor": {
            "type": [
              "string",
              "null"
            ],
            "description": "Pass this cursor as `after` for the next page. An empty page returns the supplied cursor; a run without logs returns null."
          },
          "has_more": {
            "type": "boolean",
            "description": "Whether more log lines are currently available. If false while the run is active, poll again later or use streaming."
          }
        },
        "required": [
          "data",
          "next_cursor",
          "has_more"
        ],
        "additionalProperties": false
      },
      "OutputDownload": {
        "type": "object",
        "properties": {
          "output": {
            "$ref": "#/components/schemas/Output"
          },
          "url": {
            "type": "string",
            "description": "Download URL valid for 15 minutes, also returned in `Location`. Do not include Motor credentials."
          }
        },
        "required": [
          "output",
          "url"
        ],
        "additionalProperties": false
      },
      "Volume": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "The volume's ID, `vol_…`."
          },
          "key": {
            "type": "string",
            "description": "The volume's key in plans, such as `go_mod`."
          },
          "scope": {
            "type": "string",
            "description": "The cache scope that the volume belongs to. A run restores its own scope's volumes, else its protected fallback's, and saves only its own."
          },
          "size": {
            "type": "integer",
            "description": "The size of its head version, in bytes."
          },
          "committed_by_run_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "The run that committed its head version."
          },
          "committed_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When that run committed it."
          },
          "used_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When a task last used the volume. Piston deletes a volume that no task uses for 7 days."
          }
        },
        "required": [
          "id",
          "key",
          "size",
          "committed_by_run_id",
          "committed_at",
          "used_at"
        ],
        "additionalProperties": false,
        "title": "Volume"
      },
      "VolumePage": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Volume"
            }
          },
          "next_cursor": {
            "type": [
              "string",
              "null"
            ],
            "description": "Always null. The response includes all volumes."
          }
        },
        "required": [
          "data",
          "next_cursor"
        ],
        "additionalProperties": false
      },
      "Secret": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "description": "The secret's name, in snake case, for a task's `secrets`."
          },
          "updated_at": {
            "type": "string",
            "format": "date-time",
            "description": "When the value was last set."
          }
        },
        "required": [
          "name",
          "updated_at"
        ],
        "additionalProperties": false,
        "title": "Secret",
        "description": "A team secret. Responses never include its value."
      },
      "SecretPage": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Secret"
            }
          },
          "next_cursor": {
            "type": [
              "string",
              "null"
            ],
            "description": "Always null. The response includes all secret names."
          }
        },
        "required": [
          "data",
          "next_cursor"
        ],
        "additionalProperties": false
      },
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string",
                "description": "Machine-readable error code, such as `invalid_field`."
              },
              "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."
              },
              "diagnostics": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Diagnostic"
                },
                "description": "Configuration or plan diagnostics for `invalid_plan`. Correct the errors before retrying."
              }
            },
            "required": [
              "code",
              "message",
              "retryable"
            ],
            "additionalProperties": false
          }
        },
        "required": [
          "error"
        ],
        "additionalProperties": false,
        "title": "Error"
      },
      "ArtifactFile": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "description": "The file's name in the artifact."
          },
          "task": {
            "type": "string",
            "description": "The task whose output the file is."
          },
          "output": {
            "type": "string",
            "description": "The task's output."
          },
          "sha256": {
            "type": [
              "string",
              "null"
            ],
            "description": "The SHA-256 digest of the file, in lowercase hex, once the task succeeded."
          },
          "size": {
            "type": [
              "integer",
              "null"
            ],
            "description": "The size in bytes, once the task succeeded."
          }
        },
        "required": [
          "name",
          "task",
          "output",
          "sha256",
          "size"
        ],
        "additionalProperties": false,
        "title": "ArtifactFile"
      },
      "Artifact": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "description": "The artifact's name in the plan."
          },
          "repo": {
            "type": "string",
            "description": "The Gauss repository that it publishes to, `<handle>/<name>`."
          },
          "status": {
            "type": "string",
            "enum": [
              "queued",
              "running",
              "succeeded",
              "failed",
              "canceled",
              "skipped"
            ],
            "description": "`queued` (waiting for its tasks), `running` (publishing), and the final ones: `succeeded` (published: open `url`), `failed` (read `failure`; `POST /api/piston/runs/{run_id}/retry` publishes it again without running the tasks again), `canceled`, and `skipped` (a task that it needs didn't succeed)."
          },
          "version": {
            "type": [
              "string",
              "null"
            ],
            "description": "Artifact version from the plan or allocated by Gauss as `YYYY_MM_NNNN` in UTC. Null until an automatic version is allocated."
          },
          "url": {
            "type": [
              "string",
              "null"
            ],
            "description": "The artifact's page on Gauss, once its version is reserved."
          },
          "source_tag": {
            "type": [
              "string",
              "null"
            ],
            "description": "Repository tag declared as the artifact’s source, or null. Piston does not verify that the uploaded source matches this tag."
          },
          "source_state": {
            "type": [
              "string",
              "null"
            ],
            "description": "The state that Piston resolved `source_tag` to before the run started, or null."
          },
          "files": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ArtifactFile"
            }
          },
          "started_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When the publication started."
          },
          "finished_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When the publication ended."
          },
          "failure": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Failure"
              },
              {
                "type": "null"
              }
            ],
            "description": "Why the artifact didn't publish, or null."
          }
        },
        "required": [
          "name",
          "repo",
          "status",
          "version",
          "url",
          "source_tag",
          "source_state",
          "files",
          "started_at",
          "finished_at",
          "failure"
        ],
        "additionalProperties": false,
        "title": "Artifact"
      },
      "PlanArtifact": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "description": "The artifact's name, unique among the plan's targets, in snake case."
          },
          "repo": {
            "type": "string",
            "description": "The Gauss repository, `<handle>/<name>`, such as `acme/app`."
          },
          "version": {
            "type": "string",
            "description": "Artifact version. Omit to let Gauss allocate the next `YYYY_MM_NNNN` version in UTC."
          },
          "source_tag": {
            "type": "string",
            "description": "A tag of the repository that the artifact declares as its source. Piston resolves it to its state before the run."
          },
          "source_state": {
            "type": "string",
            "description": "The state that `source_tag` must name."
          },
          "files": {
            "type": "object",
            "additionalProperties": {
              "type": "object",
              "properties": {
                "task": {
                  "type": "string"
                },
                "output": {
                  "type": "string"
                }
              },
              "required": [
                "task",
                "output"
              ]
            },
            "description": "The artifact's files: the file's name → a task's output. A directory output publishes as its tar.zst, under a name that ends in `.tar.zst`."
          },
          "needs": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Tasks and groups required before publication, in addition to dependencies implied by `files`."
          }
        },
        "required": [
          "name",
          "repo",
          "files"
        ],
        "title": "PlanArtifact"
      },
      "PlanGroup": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "description": "The group's name, unique among the plan's targets, in snake case."
          },
          "needs": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The targets that the group names."
          }
        },
        "required": [
          "name",
          "needs"
        ],
        "title": "PlanGroup"
      },
      "RunContext": {
        "type": "object",
        "description": "The run's context: what started it, which the config reads with `context()` and a task with `context = True` gets as a JSON file. At most 64 KiB. `event` names what triggered the run as `<system>.<event>`, such as `gauss.tag.created` (128 bytes at most, matching `^[a-z][a-z0-9_]{0,31}(\\.[a-z0-9_]+)+$`), or is null. Every other key is a namespace, a lowercase name such as `github` (`^[a-z][a-z0-9_]{0,31}$`) whose value is an object or null. `piston` (the run's source) and `motor` (the run's identities) are the platform's: Piston fills them, and a request that has either, even as null, returns `422 invalid_field`. `amp`, `git`, and `gauss` have known fields, each of its type or null; any other field, in them or in their known objects, and every field of another namespace, is an extension, carried as given (8 levels deep at most, keys of 64 bytes at most). `schema`, if present, is 1. A known field of the wrong type returns `422 invalid_field` naming it, such as `context.amp.tag.name must be a string`. The context is descriptive: it grants no credential, secret, or billing authority.",
        "properties": {
          "schema": {
            "type": "integer",
            "enum": [
              1
            ]
          },
          "event": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 128,
            "pattern": "^[a-z][a-z0-9_]{0,31}(\\.[a-z0-9_]+)+$"
          },
          "amp": {
            "type": [
              "object",
              "null"
            ],
            "properties": {
              "state": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "channel": {
                "type": [
                  "object",
                  "null"
                ],
                "properties": {
                  "name": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "before": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "after": {
                    "type": [
                      "string",
                      "null"
                    ]
                  }
                }
              },
              "tag": {
                "type": [
                  "object",
                  "null"
                ],
                "properties": {
                  "name": {
                    "type": [
                      "string",
                      "null"
                    ]
                  }
                }
              }
            },
            "description": "What Amp says of the run: the repository's `state`, the event's `channel` and its states `before` and `after` it, and its `tag`. Fields that Piston doesn't know, here or in a known object, are extensions."
          },
          "git": {
            "type": [
              "object",
              "null"
            ],
            "properties": {
              "sha": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "ref": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "ref_name": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "ref_type": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "base_ref": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "head_ref": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "author": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "description": "What a Git repository's host says of the run: the commit (`sha`, 40 hex digits), the event's `ref` (such as `refs/heads/main` or `refs/tags/v1.2.3`), its `ref_name` (`main`, `v1.2.3`) and `ref_type` (`branch` or `tag`), a merge's target and source branches (`base_ref`, `head_ref`), and the commit's `author` (`Name <email>`). A run of an Amp repository has no `git`, as a run of a Git repository has no `amp`. Fields that Piston doesn't know are extensions."
          },
          "gauss": {
            "type": [
              "object",
              "null"
            ],
            "properties": {
              "event": {
                "type": [
                  "object",
                  "null"
                ],
                "properties": {
                  "id": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "occurred_at": {
                    "type": [
                      "string",
                      "null"
                    ]
                  }
                }
              },
              "actor": {
                "type": [
                  "object",
                  "null"
                ],
                "properties": {
                  "kind": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "id": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "name": {
                    "type": [
                      "string",
                      "null"
                    ]
                  }
                }
              },
              "repository": {
                "type": [
                  "object",
                  "null"
                ],
                "properties": {
                  "id": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "handle": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "name": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "url": {
                    "type": [
                      "string",
                      "null"
                    ]
                  }
                }
              },
              "hook": {
                "type": [
                  "object",
                  "null"
                ],
                "properties": {
                  "name": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "state": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "digest": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "version": {
                    "type": [
                      "integer",
                      "null"
                    ]
                  }
                }
              },
              "invocation": {
                "type": [
                  "object",
                  "null"
                ],
                "properties": {
                  "id": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "trigger": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "attempt_id": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "attempt": {
                    "type": [
                      "integer",
                      "null"
                    ]
                  }
                }
              },
              "causation": {
                "type": [
                  "object",
                  "null"
                ],
                "properties": {
                  "root_event_id": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "parent_invocation_id": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "depth": {
                    "type": [
                      "integer",
                      "null"
                    ]
                  }
                }
              }
            },
            "description": "What Gauss says of the run: its `event`'s ID and time (its type is the top-level `event`), the `actor` who caused it as Gauss describes them, the `repository` (`name` is `handle/repo`), the `hook`, the `invocation` and its attempt, and the `causation`. Fields that Piston doesn't know, here or in a known object, are extensions."
          }
        },
        "propertyNames": {
          "not": {
            "enum": [
              "piston",
              "motor"
            ]
          }
        },
        "additionalProperties": {
          "type": [
            "object",
            "null"
          ]
        },
        "example": {
          "event": "github.push",
          "amp": {
            "state": "S1",
            "tag": {
              "name": "v1.2.3"
            }
          },
          "github": {
            "sha": "abc",
            "pr": {
              "number": 7
            }
          }
        }
      },
      "RunContextDocument": {
        "type": "object",
        "description": "A run's effective context document: what its config reads with `context()` and its tasks with `context = True` get. It has `schema` 1, `event`, `piston`, `motor`, `amp`, `git`, and `gauss` (null for none), and each other namespace of the context. Each known object has every one of its fields, null for a value that the run doesn't have, with the extensions as given. Its keys are sorted.",
        "properties": {
          "schema": {
            "type": "integer",
            "enum": [
              1
            ]
          },
          "event": {
            "type": [
              "string",
              "null"
            ]
          },
          "piston": {
            "type": "object",
            "description": "The platform's: `source` is the run's Piston source snapshot, which identifies the archive, not an Amp state, or null for a run without a source.",
            "properties": {
              "source": {
                "type": [
                  "object",
                  "null"
                ],
                "properties": {
                  "id": {
                    "type": "string"
                  },
                  "sha256": {
                    "type": "string"
                  }
                },
                "required": [
                  "id",
                  "sha256"
                ],
                "additionalProperties": false
              }
            },
            "required": [
              "source"
            ],
            "additionalProperties": false
          },
          "motor": {
            "type": "object",
            "description": "The platform's: the run's identities, which Piston has from the authenticated caller or, for a run of a Gauss hook, from Gauss, never from what a request says. `actor` is who caused the run, `runs_as` what it executes as, and `requested_by` who asked for it; a run that a person or a team key starts has them as all three, with `name` null. A run of a Gauss hook runs as its repository's hooks (`automation`), and its `actor` is who caused the hook's invocation.",
            "properties": {
              "actor": {
                "type": [
                  "object",
                  "null"
                ],
                "properties": {
                  "kind": {
                    "type": "string",
                    "enum": [
                      "user",
                      "team_key",
                      "automation"
                    ]
                  },
                  "id": {
                    "type": "string"
                  },
                  "name": {
                    "type": [
                      "string",
                      "null"
                    ]
                  }
                },
                "required": [
                  "kind",
                  "id",
                  "name"
                ],
                "additionalProperties": false
              },
              "runs_as": {
                "type": [
                  "object",
                  "null"
                ],
                "properties": {
                  "kind": {
                    "type": "string",
                    "enum": [
                      "user",
                      "team_key",
                      "automation"
                    ]
                  },
                  "id": {
                    "type": "string"
                  },
                  "name": {
                    "type": [
                      "string",
                      "null"
                    ]
                  }
                },
                "required": [
                  "kind",
                  "id",
                  "name"
                ],
                "additionalProperties": false
              },
              "requested_by": {
                "type": [
                  "object",
                  "null"
                ],
                "properties": {
                  "kind": {
                    "type": "string",
                    "enum": [
                      "user",
                      "team_key",
                      "automation"
                    ]
                  },
                  "id": {
                    "type": "string"
                  },
                  "name": {
                    "type": [
                      "string",
                      "null"
                    ]
                  }
                },
                "required": [
                  "kind",
                  "id",
                  "name"
                ],
                "additionalProperties": false
              }
            },
            "required": [
              "actor",
              "runs_as",
              "requested_by"
            ],
            "additionalProperties": false
          },
          "amp": {
            "type": [
              "object",
              "null"
            ],
            "properties": {
              "state": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "channel": {
                "type": [
                  "object",
                  "null"
                ],
                "properties": {
                  "name": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "before": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "after": {
                    "type": [
                      "string",
                      "null"
                    ]
                  }
                }
              },
              "tag": {
                "type": [
                  "object",
                  "null"
                ],
                "properties": {
                  "name": {
                    "type": [
                      "string",
                      "null"
                    ]
                  }
                }
              }
            },
            "description": "What Amp says of the run: the repository's `state`, the event's `channel` and its states `before` and `after` it, and its `tag`. Fields that Piston doesn't know, here or in a known object, are extensions."
          },
          "git": {
            "type": [
              "object",
              "null"
            ],
            "properties": {
              "sha": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "ref": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "ref_name": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "ref_type": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "base_ref": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "head_ref": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "author": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "description": "What a Git repository's host says of the run: the commit (`sha`, 40 hex digits), the event's `ref` (such as `refs/heads/main` or `refs/tags/v1.2.3`), its `ref_name` (`main`, `v1.2.3`) and `ref_type` (`branch` or `tag`), a merge's target and source branches (`base_ref`, `head_ref`), and the commit's `author` (`Name <email>`). A run of an Amp repository has no `git`, as a run of a Git repository has no `amp`. Fields that Piston doesn't know are extensions."
          },
          "gauss": {
            "type": [
              "object",
              "null"
            ],
            "properties": {
              "event": {
                "type": [
                  "object",
                  "null"
                ],
                "properties": {
                  "id": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "occurred_at": {
                    "type": [
                      "string",
                      "null"
                    ]
                  }
                }
              },
              "actor": {
                "type": [
                  "object",
                  "null"
                ],
                "properties": {
                  "kind": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "id": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "name": {
                    "type": [
                      "string",
                      "null"
                    ]
                  }
                }
              },
              "repository": {
                "type": [
                  "object",
                  "null"
                ],
                "properties": {
                  "id": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "handle": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "name": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "url": {
                    "type": [
                      "string",
                      "null"
                    ]
                  }
                }
              },
              "hook": {
                "type": [
                  "object",
                  "null"
                ],
                "properties": {
                  "name": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "state": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "digest": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "version": {
                    "type": [
                      "integer",
                      "null"
                    ]
                  }
                }
              },
              "invocation": {
                "type": [
                  "object",
                  "null"
                ],
                "properties": {
                  "id": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "trigger": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "attempt_id": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "attempt": {
                    "type": [
                      "integer",
                      "null"
                    ]
                  }
                }
              },
              "causation": {
                "type": [
                  "object",
                  "null"
                ],
                "properties": {
                  "root_event_id": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "parent_invocation_id": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "depth": {
                    "type": [
                      "integer",
                      "null"
                    ]
                  }
                }
              }
            },
            "description": "What Gauss says of the run: its `event`'s ID and time (its type is the top-level `event`), the `actor` who caused it as Gauss describes them, the `repository` (`name` is `handle/repo`), the `hook`, the `invocation` and its attempt, and the `causation`. Fields that Piston doesn't know, here or in a known object, are extensions."
          }
        },
        "required": [
          "schema",
          "event",
          "piston",
          "motor",
          "amp",
          "git",
          "gauss"
        ],
        "additionalProperties": {
          "type": "object"
        },
        "example": {
          "amp": {
            "channel": null,
            "state": "S1",
            "tag": {
              "name": "v1.2.3"
            }
          },
          "event": "github.push",
          "gauss": null,
          "git": null,
          "github": {
            "pr": {
              "number": 7
            },
            "sha": "abc"
          },
          "motor": {
            "actor": {
              "id": "user_1BbA6sXxyUWHYvKqN5T3dM",
              "kind": "user",
              "name": null
            }
          },
          "piston": {
            "source": {
              "id": "src_1BbA6sXxyUWHYvKqN5T3dM",
              "sha256": "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08"
            }
          },
          "schema": 1
        }
      },
      "Identity": {
        "type": "object",
        "description": "An identity of a run: a person (`user`), a team key (`team_key`), or an `automation` that an internal service runs as, such as a Gauss repository's hooks, whose `id` is the repository's (`repo_…`) and whose `name` is such as `acme/app hooks`. `name` is null when Piston doesn't know it, as for a person or a team key that started a run.",
        "properties": {
          "kind": {
            "type": "string",
            "enum": [
              "user",
              "team_key",
              "automation"
            ]
          },
          "id": {
            "type": "string"
          },
          "name": {
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "kind",
          "id",
          "name"
        ],
        "additionalProperties": false
      }
    }
  }
}
