feat(practice): store code submissions and practice states apart from attempts

This commit is contained in:
shira committed 2026-10-11 14:58:04 +03:00
1 parent d5e169e71b
commit 51770eea6c
61 files changed
+8584 -135

No files matched your search

+3
View File
@@ -267,6 +267,8 @@ The `assessment` tag covers the assessment attempts of the current candidate (PR
| `GET /api/v1/me/assessment-attempts/{attempt_id}` | `GetMyAssessmentAttempt` | session | 200 `AssessmentAttempt`, `Cache-Control: no-store` | 401, 403 `forbidden`, 404 `not_found` |
| `POST /api/v1/me/assessment-attempts/{attempt_id}/sessions` | `StartMyAssessmentAttemptSession` | session and CSRF, Idempotency-Key | 200 `AssessmentAttempt`, `Cache-Control: no-store` | 400, 401, 403, 404, 409 `state_conflict` or `idempotency_in_progress`, 412 `version_conflict`, 422, 429 |
| `POST /api/v1/me/assessment-attempts/{attempt_id}/answers` | `SubmitMyAssessmentAnswer` | session and CSRF, Idempotency-Key | 200 `AssessmentAttempt`, `Cache-Control: no-store` | 400, 401, 403, 404, 409 `state_conflict` or `idempotency_in_progress`, 412 `version_conflict`, 422, 429 |
| `POST /api/v1/me/assessment-attempts/{attempt_id}/practice-runs` | `CreateMyAssessmentPracticeRun` | session and CSRF, Idempotency-Key | 202 `PracticeRun`, `Cache-Control: no-store` | 400, 401, 403, 404, 409 `state_conflict`, 422, 503 `service_unavailable` |
| `GET /api/v1/me/assessment-attempts/{attempt_id}/practice-runs/{run_id}` | `GetMyAssessmentPracticeRun` | session | 200 `PracticeRun`, `Cache-Control: no-store` | 401, 403 `forbidden`, 404 `not_found` |
| `PUT /api/v1/me/assessment-attempts/{attempt_id}/work-session` | `HoldMyAssessmentWorkSession` | session and CSRF, `X-Attempt-Client` | 200 `AssessmentWorkSession`, `Cache-Control: no-store` | 400, 401, 403, 404, 409 `state_conflict` (another page holds it, or the attempt has no work session) |
| `DELETE /api/v1/me/assessment-attempts/{attempt_id}/work-session` | `ReleaseMyAssessmentWorkSession` | session and CSRF, `X-Attempt-Client` | 204, `Cache-Control: no-store` | 400, 401, 403, 404 |
| `POST /api/v1/me/assessment-attempts/{attempt_id}/finalize` | `FinalizeMyAssessmentAttempt` | session and CSRF, Idempotency-Key | 200 `AssessmentAttempt`, `Cache-Control: no-store` | 400, 401, 403, 404, 409 `state_conflict` or `idempotency_in_progress`, 412 `version_conflict`, 422 |
@@ -320,6 +322,7 @@ Items and answers:
- One open window. A real attempt allows one open page at a time. The page generates a random identifier when it loads and sends it as `X-Attempt-Client` (16 to 64 characters of `A-Za-z0-9_-`) to `HoldMyAssessmentWorkSession`, which holds the work session for 120 seconds and asks the page to renew every 15 seconds, and to `ReleaseMyAssessmentWorkSession` when it closes. `StartMyAssessmentAttemptSession` and `SubmitMyAssessmentAnswer` take the same header as an optional parameter; while another page holds the session, a request from a different page or from none answers 409 `state_conflict` and changes nothing, and that refusal is not stored under the Idempotency-Key. An attempt that nobody holds, a released hold, and a hold that stopped renewing admit every page. It is a one-page-at-a-time rule, not a security boundary, and it is separate from `sessions` (`used`, `max`, `idle_timeout_seconds`), which count sequential work sessions. The server keeps only keyed digests of the page identifier and of the User-Agent bound to the attempt. No new problem code is added, so the page reads 409 on these operations as "open in another window".
- An answer (`AssessmentAnswer`) has the same seven formats and carries only the answer. Unknown fields such as `score`, `duration`, or `seed` answer 400. The server records the times and scores the answer with the key of the item instance; time never enters the grade decision. Responses never say whether an answer was correct.
- The practice solution runs asynchronously in the sandbox against three hidden check groups; the client polls the attempt while it is `pending`. The verdict shows only the score 0-3 and the pass state of each group. Every outcome caused by the solution (a compilation or runtime error, a time or memory limit) is `finished` with groups not passed. `failed` (`sandbox_busy` or `sandbox_error`) means only that the infrastructure could not run it; it consumes nothing. This keeps `failed` from acting as an oracle for hidden checks and from allowing endless retries. After `finished` no other solution is accepted.
- Debug runs (`CreateMyAssessmentPracticeRun`, `GetMyAssessmentPracticeRun`) run a solution against the public examples and up to ten tests of the candidate while the practice is the current item. They never run, list, or score a hidden check, and change neither the practice state, the verdict, nor the attempt version. A run is queued and read by its own identifier; a repeat with the same Idempotency-Key and body returns the stored run. Without a configured sandbox the operation answers 503 `service_unavailable` and stores nothing.
- If the latest submission is still `failed` when the limit passes, the result is `not_determined` with the reason `sandbox_unavailable`. A practice never submitted gives `practice_incomplete`.
- An attempt has no practice only in `demo_basic` while code practice is disabled until the sandbox isolation is verified; the result then lists the `practice_not_included` limitation.
+3
View File
@@ -267,6 +267,8 @@ ML-сервис отвечает на ошибки той же схемой `Pro
| `GET /api/v1/me/assessment-attempts/{attempt_id}` | `GetMyAssessmentAttempt` | сессия | 200 `AssessmentAttempt`, `Cache-Control: no-store` | 401, 403 `forbidden`, 404 `not_found` |
| `POST /api/v1/me/assessment-attempts/{attempt_id}/sessions` | `StartMyAssessmentAttemptSession` | сессия и CSRF, Idempotency-Key | 200 `AssessmentAttempt`, `Cache-Control: no-store` | 400, 401, 403, 404, 409 `state_conflict` или `idempotency_in_progress`, 412 `version_conflict`, 422, 429 |
| `POST /api/v1/me/assessment-attempts/{attempt_id}/answers` | `SubmitMyAssessmentAnswer` | сессия и CSRF, Idempotency-Key | 200 `AssessmentAttempt`, `Cache-Control: no-store` | 400, 401, 403, 404, 409 `state_conflict` или `idempotency_in_progress`, 412 `version_conflict`, 422, 429 |
| `POST /api/v1/me/assessment-attempts/{attempt_id}/practice-runs` | `CreateMyAssessmentPracticeRun` | сессия и CSRF, Idempotency-Key | 202 `PracticeRun`, `Cache-Control: no-store` | 400, 401, 403, 404, 409 `state_conflict`, 422, 503 `service_unavailable` |
| `GET /api/v1/me/assessment-attempts/{attempt_id}/practice-runs/{run_id}` | `GetMyAssessmentPracticeRun` | сессия | 200 `PracticeRun`, `Cache-Control: no-store` | 401, 403 `forbidden`, 404 `not_found` |
| `PUT /api/v1/me/assessment-attempts/{attempt_id}/work-session` | `HoldMyAssessmentWorkSession` | сессия и CSRF, `X-Attempt-Client` | 200 `AssessmentWorkSession`, `Cache-Control: no-store` | 400, 401, 403, 404, 409 `state_conflict` (сеанс занят другой страницей или у попытки нет рабочего сеанса) |
| `DELETE /api/v1/me/assessment-attempts/{attempt_id}/work-session` | `ReleaseMyAssessmentWorkSession` | сессия и CSRF, `X-Attempt-Client` | 204, `Cache-Control: no-store` | 400, 401, 403, 404 |
| `POST /api/v1/me/assessment-attempts/{attempt_id}/finalize` | `FinalizeMyAssessmentAttempt` | сессия и CSRF, Idempotency-Key | 200 `AssessmentAttempt`, `Cache-Control: no-store` | 400, 401, 403, 404, 409 `state_conflict` или `idempotency_in_progress`, 412 `version_conflict`, 422 |
@@ -320,6 +322,7 @@ ML-сервис отвечает на ошибки той же схемой `Pro
- Одно открытое окно. Реальная попытка допускает одну открытую страницу за раз. Страница при загрузке создает случайный идентификатор и отправляет его как `X-Attempt-Client` (от 16 до 64 символов `A-Za-z0-9_-`) в `HoldMyAssessmentWorkSession`, который занимает рабочий сеанс на 120 секунд и просит страницу продлевать его раз в 15 секунд, и в `ReleaseMyAssessmentWorkSession` при закрытии. `StartMyAssessmentAttemptSession` и `SubmitMyAssessmentAnswer` принимают тот же заголовок как необязательный параметр; пока сеанс занят другой страницей, запрос от другой страницы или без заголовка получает 409 `state_conflict` и ничего не меняет, а этот отказ не сохраняется под Idempotency-Key. Попытка, которую никто не держит, освобожденное занятие и переставшее продлеваться пускают любую страницу. Это правило "одна страница за раз", а не граница безопасности, и оно отделено от `sessions` (`used`, `max`, `idle_timeout_seconds`), которые считают последовательные рабочие сеансы. Сервер хранит только ключевые отпечатки идентификатора страницы и User-Agent, привязанные к попытке. Новый код ошибки не добавлялся, поэтому страница читает 409 на этих операциях как "открыто в другом окне".
- Ответ (`AssessmentAnswer`) имеет те же семь форматов и несет только ответ. Неизвестные поля вроде `score`, `duration` или `seed` дают 400. Сервер сам записывает время и оценивает ответ по ключу экземпляра задания; время не входит в решение о грейде. Ответы API никогда не сообщают, был ли ответ правильным.
- Решение практики исполняется в песочнице асинхронно на трех группах скрытых проверок; клиент опрашивает попытку, пока оно `pending`. Вердикт показывает только балл 0-3 и прохождение каждой группы. Любой исход, вызванный самим решением (ошибка компиляции или выполнения, лимит времени или памяти), - это `finished` с непройденными группами. `failed` (`sandbox_busy` или `sandbox_error`) означает только, что инфраструктура не смогла исполнить решение; он ничего не расходует. Так `failed` не становится оракулом для скрытых проверок и не дает бесконечных повторов. После `finished` другое решение не принимается.
- Отладочные прогоны (`CreateMyAssessmentPracticeRun`, `GetMyAssessmentPracticeRun`) исполняют решение на публичных примерах и до десяти тестах кандидата, пока практика - текущий элемент. Они никогда не запускают, не показывают и не оценивают скрытые проверки и не меняют ни состояние практики, ни вердикт, ни версию попытки. Прогон ставится в очередь и читается по своему идентификатору; повтор с тем же Idempotency-Key и телом возвращает сохраненный прогон. Без настроенной песочницы операция отвечает 503 `service_unavailable` и ничего не сохраняет.
- Если к истечению лимита последняя отправка все еще `failed`, результат - `not_determined` с причиной `sandbox_unavailable`. Неотправленная практика дает `practice_incomplete`.
- Попытка бывает без практики только в `demo_basic`, пока кодовая практика выключена до проверки изоляции песочницы; результат тогда содержит ограничение `practice_not_included`.
+21
View File
@@ -140,6 +140,27 @@ NotImplemented:
examples:
not_implemented:
$ref: ./examples.yml#/NotImplemented
ServiceUnavailable:
description: >-
The service cannot serve the request now; code service_unavailable.
Retry-After is sent when a retry after that wait can succeed, for example
when a queue is full, and omitted when a retry cannot help soon, for
example when the feature is not enabled on this server.
headers:
Retry-After:
$ref: ./headers.yml#/RetryAfter
content:
application/problem+json:
schema:
$ref: ./schemas.yml#/Problem
examples:
service_unavailable:
summary: A queue is full.
value:
type: urn:lincodex:problem:service_unavailable
title: Service unavailable
status: 503
code: service_unavailable
Problem:
description: >-
Any error response. The body is a Problem whose `status` equals the HTTP
+173
View File
@@ -6837,6 +6837,179 @@ MyOrganizationList:
$ref: '#/MyOrganization'
page:
$ref: '#/PageInfo'
PracticeRunTest:
type: object
description: 'One test of the candidate for a debug run: an input and the output the candidate expects. It is compared with the checker of the task.'
additionalProperties: false
required:
- input
- expected_output
properties:
input:
type: string
maxLength: 10000
expected_output:
type: string
maxLength: 10000
PracticeRunCreate:
type: object
description: Debug run of a practice solution against the public examples of the task and up to ten tests of the candidate. It never runs a hidden check and never changes the practice state, the verdict, or the attempt version. Unknown fields are rejected.
additionalProperties: false
required:
- item_id
- language
- source_code
properties:
item_id:
$ref: '#/AssessmentItemId'
language:
description: One of the `languages` of the practice item, or null when the item offers none.
oneOf:
- $ref: '#/TaskLanguage'
- type: 'null'
source_code:
type: string
minLength: 1
maxLength: 65536
tests:
type: array
maxItems: 10
description: Tests of the candidate, run after the public examples.
items:
$ref: '#/PracticeRunTest'
PracticeRunState:
type: string
description: 'State of a debug run.
- queued: the run waits in the sandbox queue.
- running: the sandbox runs it.
- finished: `result` holds the outcome of the public examples and the tests of the candidate.
- failed: the sandbox infrastructure could not run it, independently of the solution; `failure_reason` is `sandbox_error`. Start a new run.
Adding a value is a contract change.'
enum:
- queued
- running
- finished
- failed
PracticeRunOutcome:
type: string
description: Outcome of a run or one of its tests. Every outcome caused by the solution, such as a compilation error, a crash, or a limit, is a finished run with this outcome; an infrastructure failure is a failed run instead.
enum:
- accepted
- wrong_answer
- compile_error
- time_limit_exceeded
- memory_limit_exceeded
- output_limit_exceeded
- runtime_error
PracticeRunTestSource:
type: string
description: 'Where a test of a debug run comes from: a public example of the task or a test of the candidate.'
enum:
- example
- candidate
PracticeRunTestResult:
type: object
description: Outcome of one evaluated test. The tests of a source stop at the first failed one, so later tests of that source are not listed.
additionalProperties: false
required:
- source
- index
- outcome
- time_ms
- memory_kb
- diagnostic
properties:
source:
$ref: '#/PracticeRunTestSource'
index:
type: integer
format: int32
minimum: 1
maximum: 10
description: Position of the test in its source, from 1.
outcome:
$ref: '#/PracticeRunOutcome'
time_ms:
type: integer
format: int64
minimum: 0
memory_kb:
type: integer
format: int64
minimum: 0
diagnostic:
description: Truncated error output of a failed test, or null.
oneOf:
- type: string
maxLength: 2048
- type: 'null'
PracticeRunResult:
type: object
description: Result of a debug run on the public examples and the tests of the candidate. It never contains a hidden check, its outcome, or the score.
additionalProperties: false
required:
- outcome
- compile_diagnostic
- tests
properties:
outcome:
$ref: '#/PracticeRunOutcome'
compile_diagnostic:
description: The compiler message when `outcome` is `compile_error`, otherwise null.
oneOf:
- type: string
maxLength: 4096
- type: 'null'
tests:
type: array
maxItems: 20
items:
$ref: '#/PracticeRunTestResult'
PracticeRun:
type: object
description: Debug run of a practice solution. It shows only the public examples and the tests of the candidate; hidden checks are never run, listed, or scored by a debug run.
additionalProperties: false
required:
- id
- item_id
- state
- created_at
- finished_at
- failure_reason
- result
properties:
id:
type: string
format: uuid
description: Identifier of the run.
item_id:
$ref: '#/AssessmentItemId'
state:
$ref: '#/PracticeRunState'
created_at:
$ref: '#/Timestamp'
finished_at:
description: Time the run reached `finished` or `failed`, or null.
oneOf:
- $ref: '#/Timestamp'
- type: 'null'
failure_reason:
description: '`sandbox_error` when `state` is `failed`, otherwise null.'
oneOf:
- $ref: '#/PracticeFailureReason'
- type: 'null'
result:
description: The result when `state` is `finished`, otherwise null.
oneOf:
- $ref: '#/PracticeRunResult'
- type: 'null'
PublicationVersion:
type: integer
format: int64
@@ -0,0 +1,189 @@
schemas:
PracticeRunTest:
type: object
description: >-
One test of the candidate for a debug run: an input and the output the
candidate expects. It is compared with the checker of the task.
additionalProperties: false
required:
- input
- expected_output
properties:
input:
type: string
maxLength: 10000
expected_output:
type: string
maxLength: 10000
PracticeRunCreate:
type: object
description: >-
Debug run of a practice solution against the public examples of the task
and up to ten tests of the candidate. It never runs a hidden check and
never changes the practice state, the verdict, or the attempt version.
Unknown fields are rejected.
additionalProperties: false
required:
- item_id
- language
- source_code
properties:
item_id:
$ref: "./assessment_schemas.yml#/schemas/AssessmentItemId"
language:
description: One of the `languages` of the practice item, or null when the item offers none.
oneOf:
- $ref: "./catalog_schemas.yml#/schemas/TaskLanguage"
- type: "null"
source_code:
type: string
minLength: 1
maxLength: 65536
tests:
type: array
maxItems: 10
description: Tests of the candidate, run after the public examples.
items:
$ref: "#/schemas/PracticeRunTest"
PracticeRunState:
type: string
description: |-
State of a debug run.
- queued: the run waits in the sandbox queue.
- running: the sandbox runs it.
- finished: `result` holds the outcome of the public examples and the tests of the candidate.
- failed: the sandbox infrastructure could not run it, independently of the solution; `failure_reason` is `sandbox_error`. Start a new run.
Adding a value is a contract change.
enum:
- queued
- running
- finished
- failed
PracticeRunOutcome:
type: string
description: >-
Outcome of a run or one of its tests. Every outcome caused by the
solution, such as a compilation error, a crash, or a limit, is a
finished run with this outcome; an infrastructure failure is a failed
run instead.
enum:
- accepted
- wrong_answer
- compile_error
- time_limit_exceeded
- memory_limit_exceeded
- output_limit_exceeded
- runtime_error
PracticeRunTestSource:
type: string
description: >-
Where a test of a debug run comes from: a public example of the task or
a test of the candidate.
enum:
- example
- candidate
PracticeRunTestResult:
type: object
description: >-
Outcome of one evaluated test. The tests of a source stop at the first
failed one, so later tests of that source are not listed.
additionalProperties: false
required:
- source
- index
- outcome
- time_ms
- memory_kb
- diagnostic
properties:
source:
$ref: "#/schemas/PracticeRunTestSource"
index:
type: integer
format: int32
minimum: 1
maximum: 10
description: Position of the test in its source, from 1.
outcome:
$ref: "#/schemas/PracticeRunOutcome"
time_ms:
type: integer
format: int64
minimum: 0
memory_kb:
type: integer
format: int64
minimum: 0
diagnostic:
description: Truncated error output of a failed test, or null.
oneOf:
- type: string
maxLength: 2048
- type: "null"
PracticeRunResult:
type: object
description: >-
Result of a debug run on the public examples and the tests of the
candidate. It never contains a hidden check, its outcome, or the score.
additionalProperties: false
required:
- outcome
- compile_diagnostic
- tests
properties:
outcome:
$ref: "#/schemas/PracticeRunOutcome"
compile_diagnostic:
description: The compiler message when `outcome` is `compile_error`, otherwise null.
oneOf:
- type: string
maxLength: 4096
- type: "null"
tests:
type: array
maxItems: 20
items:
$ref: "#/schemas/PracticeRunTestResult"
PracticeRun:
type: object
description: >-
Debug run of a practice solution. It shows only the public examples and
the tests of the candidate; hidden checks are never run, listed, or
scored by a debug run.
additionalProperties: false
required:
- id
- item_id
- state
- created_at
- finished_at
- failure_reason
- result
properties:
id:
type: string
format: uuid
description: Identifier of the run.
item_id:
$ref: "./assessment_schemas.yml#/schemas/AssessmentItemId"
state:
$ref: "#/schemas/PracticeRunState"
created_at:
$ref: "./common_schemas.yml#/schemas/Timestamp"
finished_at:
description: Time the run reached `finished` or `failed`, or null.
oneOf:
- $ref: "./common_schemas.yml#/schemas/Timestamp"
- type: "null"
failure_reason:
description: "`sandbox_error` when `state` is `failed`, otherwise null."
oneOf:
- $ref: "./assessment_schemas.yml#/schemas/PracticeFailureReason"
- type: "null"
result:
description: The result when `state` is `finished`, otherwise null.
oneOf:
- $ref: "#/schemas/PracticeRunResult"
- type: "null"
+331
View File
@@ -1281,6 +1281,151 @@ paths:
$ref: '#/components/responses/TooManyRequests'
default:
$ref: '#/components/responses/Problem'
/api/v1/me/assessment-attempts/{attempt_id}/practice-runs:
post:
operationId: CreateMyAssessmentPracticeRun
summary: Start a debug run of a practice solution.
description: |-
Requires the session cookie of a candidate account, the CSRF token of that session in X-CSRF-Token, an allowed Origin, and an Idempotency-Key. The body names the practice item of the attempt and carries the language, the source, and up to ten tests of the candidate.
A debug run executes the solution in the isolated sandbox against the public examples of the task and the tests of the candidate only. It never runs, lists, or scores a hidden check, and it changes neither the practice state, the verdict, nor the attempt version; the graded solution is submitted with SubmitMyAssessmentAnswer. The run is stored with its own identifier and executed asynchronously: the response is 202 with the run `queued`, and the client polls GetMyAssessmentPracticeRun. The source is never echoed.
The practice must be the current item: the attempt is in `practice_pending` for the main practice or `additional_practice_pending` for the additional one, and its deadline has not passed. Otherwise the server answers 409 state_conflict.
Availability. When code practice is not enabled on this server, the server answers 503 service_unavailable and stores nothing.
Repeats. A retry with the same Idempotency-Key and body within 24 hours returns the stored run in its current state with 202, without starting another run. A different body with the same key answers 422 idempotency_key_reused. Refusals (400, 404, 409, 503) are not stored under the key and are evaluated again.
Order of checks: session (401), CSRF and Origin (403 csrf_check_failed), request validation (400), account scenario (403 forbidden), the availability of code practice (503), the Idempotency-Key (422, replay), the attempt and the practice (404 not_found for an unknown attempt or item, or one of another candidate), the state (409), then the solution against the item (400 with a pointer such as `/language` or `/source_code`).
security:
- sessionCookie: []
sessionCsrf: []
tags:
- assessment
parameters:
- $ref: '#/components/parameters/AssessmentAttemptId'
- $ref: '#/components/parameters/IdempotencyKey'
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/PracticeRunCreate'
examples:
run:
summary: A Python solution with one test of the candidate.
value:
item_id: 0192a1b2-c3d4-7e5f-8a9b-0c1d2e3f4a60
language: python
source_code: |
print(sum(map(int, input().split())))
tests:
- input: |
2 3
expected_output: |
5
responses:
'202':
description: The run is queued, or this request was already accepted and the stored run is returned.
headers:
Cache-Control:
$ref: '#/components/headers/CacheControlNoStore'
content:
application/json:
schema:
$ref: '#/components/schemas/PracticeRun'
examples:
queued:
summary: A queued run.
value:
id: 0192a1b2-c3d4-7e5f-8a9b-0c1d2e3f4a70
item_id: 0192a1b2-c3d4-7e5f-8a9b-0c1d2e3f4a60
state: queued
created_at: '2026-10-05T09:30:00Z'
finished_at: null
failure_reason: null
result: null
'400':
$ref: '#/components/responses/ValidationFailed'
'401':
$ref: '#/components/responses/Unauthenticated'
'403':
$ref: '#/components/responses/CsrfCheckFailedOrForbidden'
'404':
$ref: '#/components/responses/NotFound'
'409':
$ref: '#/components/responses/StateConflict'
'422':
$ref: '#/components/responses/UnprocessableContent'
'503':
$ref: '#/components/responses/ServiceUnavailable'
default:
$ref: '#/components/responses/Problem'
/api/v1/me/assessment-attempts/{attempt_id}/practice-runs/{run_id}:
get:
operationId: GetMyAssessmentPracticeRun
summary: Read a debug run of a practice solution.
description: |-
Requires the session cookie of a candidate account. Returns the state of a debug run started with CreateMyAssessmentPracticeRun and, once it is `finished`, the outcome of the public examples and of the tests of the candidate. It never contains a hidden check, its outcome, the score, or the source. This GET is read-only.
A run of another candidate's attempt, a run of another attempt, and an unknown identifier all answer 404 not_found. The graded solution submitted with SubmitMyAssessmentAnswer is not a debug run and is not readable here.
security:
- sessionCookie: []
tags:
- assessment
parameters:
- $ref: '#/components/parameters/AssessmentAttemptId'
- name: run_id
in: path
required: true
description: Identifier of a debug run of this attempt.
schema:
type: string
format: uuid
responses:
'200':
description: The run.
headers:
Cache-Control:
$ref: '#/components/headers/CacheControlNoStore'
content:
application/json:
schema:
$ref: '#/components/schemas/PracticeRun'
examples:
finished:
summary: A finished run whose test of the candidate failed.
value:
id: 0192a1b2-c3d4-7e5f-8a9b-0c1d2e3f4a70
item_id: 0192a1b2-c3d4-7e5f-8a9b-0c1d2e3f4a60
state: finished
created_at: '2026-10-05T09:30:00Z'
finished_at: '2026-10-05T09:30:04Z'
failure_reason: null
result:
outcome: wrong_answer
compile_diagnostic: null
tests:
- source: example
index: 1
outcome: accepted
time_ms: 21
memory_kb: 9216
diagnostic: null
- source: candidate
index: 1
outcome: wrong_answer
time_ms: 20
memory_kb: 9180
diagnostic: null
'401':
$ref: '#/components/responses/Unauthenticated'
'403':
$ref: '#/components/responses/Forbidden'
'404':
$ref: '#/components/responses/NotFound'
default:
$ref: '#/components/responses/Problem'
/api/v1/me/assessment-attempts/{attempt_id}/finalize:
post:
operationId: FinalizeMyAssessmentAttempt
@@ -5714,6 +5859,175 @@ components:
oneOf:
- $ref: '#/components/schemas/PracticeFailureReason'
- type: 'null'
PracticeRunTest:
type: object
description: 'One test of the candidate for a debug run: an input and the output the candidate expects. It is compared with the checker of the task.'
additionalProperties: false
required:
- input
- expected_output
properties:
input:
type: string
maxLength: 10000
expected_output:
type: string
maxLength: 10000
PracticeRunCreate:
type: object
description: Debug run of a practice solution against the public examples of the task and up to ten tests of the candidate. It never runs a hidden check and never changes the practice state, the verdict, or the attempt version. Unknown fields are rejected.
additionalProperties: false
required:
- item_id
- language
- source_code
properties:
item_id:
$ref: '#/components/schemas/AssessmentItemId'
language:
description: One of the `languages` of the practice item, or null when the item offers none.
oneOf:
- $ref: '#/components/schemas/TaskLanguage'
- type: 'null'
source_code:
type: string
minLength: 1
maxLength: 65536
tests:
type: array
maxItems: 10
description: Tests of the candidate, run after the public examples.
items:
$ref: '#/components/schemas/PracticeRunTest'
PracticeRunState:
type: string
description: |-
State of a debug run.
- queued: the run waits in the sandbox queue.
- running: the sandbox runs it.
- finished: `result` holds the outcome of the public examples and the tests of the candidate.
- failed: the sandbox infrastructure could not run it, independently of the solution; `failure_reason` is `sandbox_error`. Start a new run.
Adding a value is a contract change.
enum:
- queued
- running
- finished
- failed
PracticeRunOutcome:
type: string
description: Outcome of a run or one of its tests. Every outcome caused by the solution, such as a compilation error, a crash, or a limit, is a finished run with this outcome; an infrastructure failure is a failed run instead.
enum:
- accepted
- wrong_answer
- compile_error
- time_limit_exceeded
- memory_limit_exceeded
- output_limit_exceeded
- runtime_error
PracticeRunTestSource:
type: string
description: 'Where a test of a debug run comes from: a public example of the task or a test of the candidate.'
enum:
- example
- candidate
PracticeRunTestResult:
type: object
description: Outcome of one evaluated test. The tests of a source stop at the first failed one, so later tests of that source are not listed.
additionalProperties: false
required:
- source
- index
- outcome
- time_ms
- memory_kb
- diagnostic
properties:
source:
$ref: '#/components/schemas/PracticeRunTestSource'
index:
type: integer
format: int32
minimum: 1
maximum: 10
description: Position of the test in its source, from 1.
outcome:
$ref: '#/components/schemas/PracticeRunOutcome'
time_ms:
type: integer
format: int64
minimum: 0
memory_kb:
type: integer
format: int64
minimum: 0
diagnostic:
description: Truncated error output of a failed test, or null.
oneOf:
- type: string
maxLength: 2048
- type: 'null'
PracticeRunResult:
type: object
description: Result of a debug run on the public examples and the tests of the candidate. It never contains a hidden check, its outcome, or the score.
additionalProperties: false
required:
- outcome
- compile_diagnostic
- tests
properties:
outcome:
$ref: '#/components/schemas/PracticeRunOutcome'
compile_diagnostic:
description: The compiler message when `outcome` is `compile_error`, otherwise null.
oneOf:
- type: string
maxLength: 4096
- type: 'null'
tests:
type: array
maxItems: 20
items:
$ref: '#/components/schemas/PracticeRunTestResult'
PracticeRun:
type: object
description: Debug run of a practice solution. It shows only the public examples and the tests of the candidate; hidden checks are never run, listed, or scored by a debug run.
additionalProperties: false
required:
- id
- item_id
- state
- created_at
- finished_at
- failure_reason
- result
properties:
id:
type: string
format: uuid
description: Identifier of the run.
item_id:
$ref: '#/components/schemas/AssessmentItemId'
state:
$ref: '#/components/schemas/PracticeRunState'
created_at:
$ref: '#/components/schemas/Timestamp'
finished_at:
description: Time the run reached `finished` or `failed`, or null.
oneOf:
- $ref: '#/components/schemas/Timestamp'
- type: 'null'
failure_reason:
description: '`sandbox_error` when `state` is `failed`, otherwise null.'
oneOf:
- $ref: '#/components/schemas/PracticeFailureReason'
- type: 'null'
result:
description: The result when `state` is `finished`, otherwise null.
oneOf:
- $ref: '#/components/schemas/PracticeRunResult'
- type: 'null'
AssessmentAttempt:
description: Candidate view of a real assessment, a corrective real assessment, or a demo_express training run. The variants keep training output separate from qualification attempts.
oneOf:
@@ -12407,6 +12721,23 @@ components:
$ref: '#/components/examples/VerificationCodeInvalid'
validation_failed:
$ref: '#/components/examples/VerificationCodeMalformed'
ServiceUnavailable:
description: The service cannot serve the request now; code service_unavailable. Retry-After is sent when a retry after that wait can succeed, for example when a queue is full, and omitted when a retry cannot help soon, for example when the feature is not enabled on this server.
headers:
Retry-After:
$ref: '#/components/headers/RetryAfter'
content:
application/problem+json:
schema:
$ref: '#/components/schemas/Problem'
examples:
service_unavailable:
summary: A queue is full.
value:
type: urn:lincodex:problem:service_unavailable
title: Service unavailable
status: 503
code: service_unavailable
securitySchemes:
sessionCookie:
type: apiKey
+20
View File
@@ -139,6 +139,10 @@ paths:
$ref: ./routes/candidate_assessment_attempt_work_session.yml
/api/v1/me/assessment-attempts/{attempt_id}/answers:
$ref: ./routes/candidate_assessment_attempt_answers.yml
/api/v1/me/assessment-attempts/{attempt_id}/practice-runs:
$ref: ./routes/candidate_assessment_attempt_practice_runs.yml
/api/v1/me/assessment-attempts/{attempt_id}/practice-runs/{run_id}:
$ref: ./routes/candidate_assessment_attempt_practice_run.yml
/api/v1/me/assessment-attempts/{attempt_id}/finalize:
$ref: ./routes/candidate_assessment_attempt_finalize.yml
/api/v1/me/assessment-attempts/{attempt_id}/result:
@@ -463,6 +467,22 @@ components:
$ref: ./components/schemas.yml#/PracticeVerdict
AssessmentPractice:
$ref: ./components/schemas.yml#/AssessmentPractice
PracticeRunTest:
$ref: ./components/schemas.yml#/PracticeRunTest
PracticeRunCreate:
$ref: ./components/schemas.yml#/PracticeRunCreate
PracticeRunState:
$ref: ./components/schemas.yml#/PracticeRunState
PracticeRunOutcome:
$ref: ./components/schemas.yml#/PracticeRunOutcome
PracticeRunTestSource:
$ref: ./components/schemas.yml#/PracticeRunTestSource
PracticeRunTestResult:
$ref: ./components/schemas.yml#/PracticeRunTestResult
PracticeRunResult:
$ref: ./components/schemas.yml#/PracticeRunResult
PracticeRun:
$ref: ./components/schemas.yml#/PracticeRun
AssessmentAttempt:
$ref: ./components/schemas.yml#/AssessmentAttempt
ChoiceAnswer:
@@ -0,0 +1,64 @@
get:
operationId: GetMyAssessmentPracticeRun
summary: Read a debug run of a practice solution.
description: |-
Requires the session cookie of a candidate account. Returns the state of a debug run started with CreateMyAssessmentPracticeRun and, once it is `finished`, the outcome of the public examples and of the tests of the candidate. It never contains a hidden check, its outcome, the score, or the source. This GET is read-only.
A run of another candidate's attempt, a run of another attempt, and an unknown identifier all answer 404 not_found. The graded solution submitted with SubmitMyAssessmentAnswer is not a debug run and is not readable here.
security:
- sessionCookie: []
tags:
- assessment
parameters:
- $ref: ../components/parameters.yml#/AssessmentAttemptId
- name: run_id
in: path
required: true
description: Identifier of a debug run of this attempt.
schema:
type: string
format: uuid
responses:
"200":
description: The run.
headers:
Cache-Control:
$ref: ../components/headers.yml#/CacheControlNoStore
content:
application/json:
schema:
$ref: ../components/schemas.yml#/PracticeRun
examples:
finished:
summary: A finished run whose test of the candidate failed.
value:
id: 0192a1b2-c3d4-7e5f-8a9b-0c1d2e3f4a70
item_id: 0192a1b2-c3d4-7e5f-8a9b-0c1d2e3f4a60
state: finished
created_at: "2026-10-05T09:30:00Z"
finished_at: "2026-10-05T09:30:04Z"
failure_reason: null
result:
outcome: wrong_answer
compile_diagnostic: null
tests:
- source: example
index: 1
outcome: accepted
time_ms: 21
memory_kb: 9216
diagnostic: null
- source: candidate
index: 1
outcome: wrong_answer
time_ms: 20
memory_kb: 9180
diagnostic: null
"401":
$ref: ../components/responses.yml#/Unauthenticated
"403":
$ref: ../components/responses.yml#/Forbidden
"404":
$ref: ../components/responses.yml#/NotFound
default:
$ref: ../components/responses.yml#/Problem
@@ -0,0 +1,76 @@
post:
operationId: CreateMyAssessmentPracticeRun
summary: Start a debug run of a practice solution.
description: |-
Requires the session cookie of a candidate account, the CSRF token of that session in X-CSRF-Token, an allowed Origin, and an Idempotency-Key. The body names the practice item of the attempt and carries the language, the source, and up to ten tests of the candidate.
A debug run executes the solution in the isolated sandbox against the public examples of the task and the tests of the candidate only. It never runs, lists, or scores a hidden check, and it changes neither the practice state, the verdict, nor the attempt version; the graded solution is submitted with SubmitMyAssessmentAnswer. The run is stored with its own identifier and executed asynchronously: the response is 202 with the run `queued`, and the client polls GetMyAssessmentPracticeRun. The source is never echoed.
The practice must be the current item: the attempt is in `practice_pending` for the main practice or `additional_practice_pending` for the additional one, and its deadline has not passed. Otherwise the server answers 409 state_conflict.
Availability. When code practice is not enabled on this server, the server answers 503 service_unavailable and stores nothing.
Repeats. A retry with the same Idempotency-Key and body within 24 hours returns the stored run in its current state with 202, without starting another run. A different body with the same key answers 422 idempotency_key_reused. Refusals (400, 404, 409, 503) are not stored under the key and are evaluated again.
Order of checks: session (401), CSRF and Origin (403 csrf_check_failed), request validation (400), account scenario (403 forbidden), the availability of code practice (503), the Idempotency-Key (422, replay), the attempt and the practice (404 not_found for an unknown attempt or item, or one of another candidate), the state (409), then the solution against the item (400 with a pointer such as `/language` or `/source_code`).
security:
- sessionCookie: []
sessionCsrf: []
tags:
- assessment
parameters:
- $ref: ../components/parameters.yml#/AssessmentAttemptId
- $ref: ../components/parameters.yml#/IdempotencyKey
requestBody:
required: true
content:
application/json:
schema:
$ref: ../components/schemas.yml#/PracticeRunCreate
examples:
run:
summary: A Python solution with one test of the candidate.
value:
item_id: 0192a1b2-c3d4-7e5f-8a9b-0c1d2e3f4a60
language: python
source_code: "print(sum(map(int, input().split())))\n"
tests:
- input: "2 3\n"
expected_output: "5\n"
responses:
"202":
description: The run is queued, or this request was already accepted and the stored run is returned.
headers:
Cache-Control:
$ref: ../components/headers.yml#/CacheControlNoStore
content:
application/json:
schema:
$ref: ../components/schemas.yml#/PracticeRun
examples:
queued:
summary: A queued run.
value:
id: 0192a1b2-c3d4-7e5f-8a9b-0c1d2e3f4a70
item_id: 0192a1b2-c3d4-7e5f-8a9b-0c1d2e3f4a60
state: queued
created_at: "2026-10-05T09:30:00Z"
finished_at: null
failure_reason: null
result: null
"400":
$ref: ../components/responses.yml#/ValidationFailed
"401":
$ref: ../components/responses.yml#/Unauthenticated
"403":
$ref: ../components/responses.yml#/CsrfCheckFailedOrForbidden
"404":
$ref: ../components/responses.yml#/NotFound
"409":
$ref: ../components/responses.yml#/StateConflict
"422":
$ref: ../components/responses.yml#/UnprocessableContent
"503":
$ref: ../components/responses.yml#/ServiceUnavailable
default:
$ref: ../components/responses.yml#/Problem