# Checks_RunCheck

`POST /v1/accounts/{account}/checks/{check}:run`

Runs a check over a dataset again; `checks/-` runs the dataset's default
set (an upload runs episode-rules, a mixture runs mixture; reach is never
in it, name `checks/reach`). Answers as soon as the run is accepted,
naming the checks started;
they run in the background. Their findings land as issues, and a
finding no longer raised is dismissed as RESOLVED. INVALID_ARGUMENT,
before anything starts, when the check does not apply to the dataset
(MIXTURE on an upload, EPISODE_RULES on a mixture, REACH on a dataset
with no target robot, or one whose target robot is in another workspace,
VLM when no selected episode has a published task) or the
selection matches no episode. VLM is FAILED_PRECONDITION on a
deployment with no VLM check pipeline. On a merged dataset VLM and REACH
are one run over its own episodes, and the other
checks run in each upload it holds, one run per upload, the selection
split by upload; either way the findings are issues of the upload that
holds each episode, named under the merged dataset. `model` chooses the
VLM check's model; with `validate_only` nothing starts and the response
carries the estimate.
Each run is a CheckRun (`check_runs`): GetCheckRun says where it stands.
A person's `checks/vlm` while a run of it is on the dataset (an automatic
run after preparation, or a person's, running or
queued) waits its turn: its run is recorded QUEUED behind the
newest such run (`queued_behind`, `queued_reason`) and starts when that
one ends, reserving only then. Runs queued on one dataset start in the
order they were asked for. An estimate is never refused for a run in
flight. A retry with the first call's request_id is answered with its
receipt.

`checks/reach` is the Run solver press, and it is recorded before the
answer: the dataset's settings (reach_settings, else the target robot's
defaults) and the robot's config make the run's key, every episode that
already has a succeeded result under that key is answered from it (the
other episodes, failed ones included, are queued), and the run, counted
in ReachRun, is what GetReachStatus reports. The RunCheck operation ends
when the work is queued; the run's own progress is the ReachRun. On a
merged dataset the press is one run over all its episodes, every
upload's, on its own settings. Succeeded results under its current full
reach key answer it from storage; separate pre-merge TCP solves can
have different calibration identities.
FAILED_PRECONDITION, before anything is queued, on a server where the
reach check is switched off (nothing would run the work), and for
`checks/reach` when the target robot has no solver (there is no default
one, and the dataset's own reach_settings do not give the robot one; a
`validate_only` press is refused too).

- Base URL: `https://junction-api.qualiastudios.dev`
- Authentication: an API key in the `X-API-Key` header

## Parameters

- `account` (path, string, required): The account id.
- `check` (path, string, required): The check id.

## Request body

Required: `application/json` `qualia.v1.RunCheckRequest`

## Responses

- `200` OK: `application/json` `qualia.v1.RunCheckResponse`
- `default` Default error response: `application/json` `google.rpc.Status`

## Schemas

```yaml
qualia.v1.RunCheckRequest:
  required:
    - name
    - dataset
  type: object
  properties:
    name:
      type: string
      description: |-
        accounts/{account}/checks/{check}. `checks/-` runs the dataset's
        default set: an upload runs episode-rules, a mixture runs mixture.
        Reach is never in it; name `checks/reach`.
    dataset:
      type: string
      description: accounts/{account}/datasets/{dataset}
    selection:
      allOf:
        - $ref: "#/components/schemas/qualia.v1.EpisodeSelection"
      description: |-
        Only these episodes (names under `dataset`); unset means all. Ignored by
        MIXTURE, which always reads the whole mixture.
    model:
      type: string
      description: |-
        `checks/vlm` only: the Qualia model tier that reads the episodes, one of
        CheckEstimate.models (what this deployment's VLM check template offers).
        Empty: the template's default. INVALID_ARGUMENT, before anything starts,
        for a model the template does not offer, or on any other check.
    validateOnly:
      type: boolean
      description: |-
        Check the request and answer what it would do, starting nothing and
        reserving nothing: every refusal a run would meet, then `estimate` (VLM
        only). `checks` and `check_runs` are empty.
    maxEpisodes:
      type: integer
      description: |-
        `checks/vlm` only: sample at most this many linked episodes across the
        scope. Must be positive; unset checks all eligible episodes.
      format: int32
    maxCost:
      type: string
      description: "`checks/vlm` only: maximum credits reserved and spent. Must be positive."
    requestId:
      type: string
      description: |-
        Optional UUID4 idempotency key. Matching retries return the original
        admission; a different caller, scope or normalized input is refused.
        An intentional rerun needs a new key. validate_only never reserves it.
  description: Request for Checks.RunCheck.
qualia.v1.EpisodeSelection:
  type: object
  properties:
    names:
      allOf:
        - $ref: "#/components/schemas/qualia.v1.EpisodeNames"
      description: Episode names under the request's parent.
    filter:
      type: string
      description: A ListEpisodes filter over the parent (e.g. what the filter bar leaves).
  description: |-
    Which episodes a bulk ruling acts on: an explicit list, or a filter. Names
    must be under the request's parent (INVALID_ARGUMENT otherwise); a filter
    only ever matches the parent's own episodes (a mixture: its pool).
qualia.v1.EpisodeNames:
  type: object
  properties:
    names:
      type: array
      items:
        type: string
      description: accounts/{account}/datasets/{dataset}/episodes/{episode}, at most 10000.
  description: A list of episode names.
qualia.v1.RunCheckResponse:
  type: object
  properties:
    checks:
      type: array
      items:
        type: string
      description: |-
        accounts/{account}/checks/{check} of the checks started, in the order
        they run.
    operation:
      type: string
      description: |-
        accounts/{account}/operations/{operation}: the run RunCheck recorded (the
        first upload's, for a merged dataset's per-upload checks). For
        `checks/reach` it is also ReachRun.operation, the run GetReachStatus
        reports.
    checkRuns:
      type: array
      items:
        type: string
      description: |-
        Every run started, in the order they run: one, or one per upload of a
        merged dataset for the checks run per upload (VLM and REACH are one run).
        Read each with GetCheckRun.
    estimate:
      allOf:
        - $ref: "#/components/schemas/qualia.v1.CheckEstimate"
      description: "`checks/vlm` with validate_only: what the run would read and reserve."
    activityEvent:
      type: string
      description: The durable request event, when correlated Activity writing is enabled.
    queuedBehind:
      type: string
      description: |-
        `checks/vlm` asked for while another run of it is on the dataset (an
        automatic run after preparation, or a person's): that
        run. This run is recorded QUEUED behind it and starts when it ends; it
        reserves nothing until then. Empty when the run started at once.
    queuedReason:
      type: string
      description: |-
        With queued_behind, the same in a sentence: "queued behind the automatic
        VLM check started 10:41 UTC (accounts/…/runs/…); it starts when that
        ends".
  description: "Response for Checks.RunCheck: what was started."
qualia.v1.CheckEstimate:
  type: object
  properties:
    credits:
      readOnly: true
      type: string
      description: |-
        Credits the run would reserve: on a merged dataset, the sum over its
        uploads' runs.
    episodeCount:
      readOnly: true
      type: integer
      description: |-
        Episodes the model would read: linked to a published task, in a
        published version, with a camera.
      format: int32
    unlinkedCount:
      readOnly: true
      type: integer
      description: |-
        Episodes of the selection it would leave out: not linked to a task,
        linked to one with no published revision, not in a published version, or
        without a camera.
      format: int32
    model:
      readOnly: true
      type: string
      description: |-
        The Qualia model tier it would read with ("qualia-vlm-fast"): the
        request's, else the template's default.
    models:
      readOnly: true
      type: array
      items:
        type: string
      description: |-
        Every Qualia model tier this deployment's VLM check offers, the default
        first. A request may still name a legacy vendor model id (deprecated).
  description: |-
    What a VLM check run would read and the credits it would reserve, before
    it starts (RunCheck with validate_only). Nothing is reserved or charged by
    asking. A run reserves when it starts, sized the same way on the episodes
    it can read then; its charge is the calls it made, never more than its
    reservation, and a failed run is refunded.
google.rpc.Status:
  oneOf:
    - $ref: "#/components/schemas/ApiError"
    - $ref: "#/components/schemas/GatewayError"
  description: "The body of a failed call: one of the two shapes below."
ApiError:
  title: API error
  type: object
  required:
    - code
    - message
    - retryable
    - details
  properties:
    code:
      type: string
      description: The gRPC code name in upper case, e.g. `NOT_FOUND`.
    message:
      type: string
    retryable:
      type: boolean
      description: Whether the same call may succeed if retried.
    details:
      type: array
      items:
        type: object
      description: "Empty, except when a dataset copy or move is refused: then one `google.rpc.ErrorInfo` with the refusal's `reason` code, its `domain` and, in `metadata`, the datasets it names."
  description: A refusal from the API itself.
GatewayError:
  title: Gateway error
  type: object
  required:
    - detail
  properties:
    detail:
      type: string
      description: What went wrong.
  description: A refusal from the gateway before the call reaches the API, for example `401` bad or missing API key, `403` key lacks the scope or environment closed, `413` body too large.
```
