feat(runner): add the own code runner contract, client and nsjail service

This commit is contained in:
shira committed 2026-10-11 08:23:42 +03:00
1 parent 5e1db37746
commit cdf6bcbb91
109 files changed
+24084 -28

No files matched your search

+15
View File
@@ -0,0 +1,15 @@
get:
operationId: GetRunnerHealthz
summary: Check whether the runner process is responding.
security: []
tags:
- health
responses:
"200":
description: The runner process is responding.
content:
application/json:
schema:
$ref: ../components/schemas.yml#/RunnerHealthResponse
default:
$ref: ../components/responses.yml#/Problem
+25
View File
@@ -0,0 +1,25 @@
get:
operationId: GetRunnerReadyz
summary: Check whether the sandbox is prepared to accept runs.
description: >-
Ready means that the cgroup hierarchy, the work directory, and the sandbox
binary were prepared at startup and the process is not draining. A busy
runner is still ready; busy is reported by SubmitRun.
security: []
tags:
- health
responses:
"200":
description: The sandbox is prepared.
content:
application/json:
schema:
$ref: ../components/schemas.yml#/RunnerReadinessResponse
"503":
description: The sandbox is not prepared or the process is draining.
content:
application/json:
schema:
$ref: ../components/schemas.yml#/RunnerReadinessResponse
default:
$ref: ../components/responses.yml#/Problem
+72
View File
@@ -0,0 +1,72 @@
parameters:
- name: run_id
in: path
required: true
description: >-
Random UUID chosen by the backend for one logical run. It is the
idempotency key of SubmitRun and must not encode a candidate, attempt,
or task identifier.
schema:
type: string
format: uuid
put:
operationId: SubmitRun
summary: Start a sandboxed run of one source against its test groups.
description: |-
Idempotent by `run_id`:
- a new ID with a free sandbox slot starts the run and answers 202 with `state: running`;
- the same ID with the same payload answers 200 with the current state of that run, including the finished result, without running it again;
- the same ID with a different payload answers 422 `idempotency_key_reused` and changes nothing;
- a new ID while every slot is busy, or while the runner is draining, answers 503 `runner_busy` with Retry-After; nothing is stored, so the caller retries with the same ID.
Payloads are compared by a SHA-256 fingerprint of the decoded request.
The runner keeps runs only in memory for a bounded time after they
finish; an ID that was forgotten or lost in a restart starts a new run.
Requests above the configured body limit (8 MiB by default) answer 413
`payload_too_large`. Semantic rules that the schema cannot express answer
400 `validation_failed`: group IDs are unique in a run, test IDs are
unique in a group, and the number of tests multiplied by
`limits.time_limit_ms` does not exceed 300000.
tags:
- runs
requestBody:
required: true
content:
application/json:
schema:
$ref: ../components/schemas.yml#/RunRequest
responses:
"200":
description: A run with this ID and the same payload already exists.
content:
application/json:
schema:
$ref: ../components/schemas.yml#/RunStatus
"202":
description: The run was accepted and started.
content:
application/json:
schema:
$ref: ../components/schemas.yml#/RunStatus
"503":
$ref: ../components/responses.yml#/RunnerBusy
default:
$ref: ../components/responses.yml#/Problem
get:
operationId: GetRun
summary: Read the state and, when finished, the per-group result of a run.
description: >-
Answers 404 `not_found` for an ID the runner does not hold, including a
run forgotten after its retention time or lost in a restart.
tags:
- runs
responses:
"200":
description: The current state of the run.
content:
application/json:
schema:
$ref: ../components/schemas.yml#/RunStatus
default:
$ref: ../components/responses.yml#/Problem