feat(labs): describe the lab task contract and the provisioner port
This commit is contained in:
1 parent
3de226b16c
commit
9fdaa62b9b
91 files changed
+19262
-155
No files matched your search
@@ -4,6 +4,8 @@ post:
|
||||
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 item and carries the answer in the format of that item: `choice`, `number`, `string`, `order`, `find_error`, `configuration`, or `practice`. It never carries a score, a duration, or a correctness flag; the server records the times itself and scores the answer with the key of the fixed item instance. Time never enters the ability estimate or the grade decision.
|
||||
|
||||
Lab: an item with format `lab` takes no answer here. Its lab is started with CreateMyAssessmentLab and submitted with SubmitMyAssessmentLab; any answer to a lab item answers 400 validation_failed with the pointer `/answer/format`, like an answer in the wrong format, and stores nothing.
|
||||
|
||||
The response is the attempt with the next item to answer. It never says whether the answer was correct. Items are answered in order and each answer is final.
|
||||
|
||||
A work command requires an active session. After `idle_timeout_seconds` of inactivity, the candidate calls StartMyAssessmentAttemptSession to explicitly start or resume a session; this answer command never starts one or consumes session quota. Reading the attempt or result is always read-only. A command that finds a due deadline transition may commit it before returning; a command that finds an expired idle session answers 409 until the candidate explicitly starts the next session.
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
get:
|
||||
operationId: GetMyAssessmentLab
|
||||
summary: Read the lab of an assessment attempt item.
|
||||
description: |-
|
||||
Requires the session cookie of a candidate account. Returns the state of a lab started with CreateMyAssessmentLab: whether it is still provisioning, ready for the consoles, being checked after the submission, or ended. It never contains a node address, a credential, the seed, the checker state, or the result of the check. This GET is read-only; the server may record a due timer transition, such as `ready` to `expired`, before it answers.
|
||||
|
||||
A lab of another candidate's attempt, a lab of another attempt, and an unknown identifier all answer 404 not_found.
|
||||
security:
|
||||
- sessionCookie: []
|
||||
tags:
|
||||
- assessment
|
||||
parameters:
|
||||
- $ref: ../components/parameters.yml#/AssessmentAttemptId
|
||||
- name: lab_id
|
||||
in: path
|
||||
required: true
|
||||
description: Identifier of a lab of this attempt.
|
||||
schema:
|
||||
type: string
|
||||
format: uuid
|
||||
responses:
|
||||
"200":
|
||||
description: The lab.
|
||||
headers:
|
||||
Cache-Control:
|
||||
$ref: ../components/headers.yml#/CacheControlNoStore
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: ../components/schemas.yml#/AssessmentLab
|
||||
examples:
|
||||
ready:
|
||||
summary: A ready lab whose consoles can be opened.
|
||||
value:
|
||||
id: 0192a1b2-c3d4-7e5f-8a9b-0c1d2e3f4a80
|
||||
item_id: 0192a1b2-c3d4-7e5f-8a9b-0c1d2e3f4a61
|
||||
state: ready
|
||||
nodes:
|
||||
- name: r1
|
||||
kind: mikrotik
|
||||
- name: r2
|
||||
kind: mikrotik
|
||||
created_at: "2026-10-11T09:00:00Z"
|
||||
ready_at: "2026-10-11T09:00:40Z"
|
||||
expires_at: "2026-10-11T09:45:00Z"
|
||||
finished_at: null
|
||||
failure_reason: 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,70 @@
|
||||
post:
|
||||
operationId: CreateMyAssessmentLabConsoleSession
|
||||
summary: Open a console session of one node of a ready lab.
|
||||
description: |-
|
||||
Requires the session cookie of a candidate account, the CSRF token of that session in X-CSRF-Token, and an allowed Origin. The body names a node of the lab by its task name.
|
||||
|
||||
The response describes one console session: the client opens a WebSocket to `websocket_path` on the same origin before `expires_at`. The upgrade is authorized by the session cookie and the Origin check, and the server relays the serial console of the node through the lab provisioner. The response never carries a node address, a port, a password, a key, or a token; the browser never connects to a node or to the provisioner. Console traffic is not stored as an answer and is not logged.
|
||||
|
||||
The WebSocket relay is planned together with the candidate interface of labs; this contract fixes the session shape it uses.
|
||||
|
||||
Order of checks: session (401), CSRF and Origin (403 csrf_check_failed), request validation (400), account scenario (403 forbidden), the attempt and the lab (404 not_found for an unknown attempt, lab, or one of another candidate), the node (400 with the pointer `/node`), the state (409 state_conflict: the lab is not `ready`, the attempt is terminal, or its work session ended), the limit of open sessions per lab (429 rate_limited with Retry-After), then the provisioner (503 service_unavailable without Retry-After; nothing was opened).
|
||||
security:
|
||||
- sessionCookie: []
|
||||
sessionCsrf: []
|
||||
tags:
|
||||
- assessment
|
||||
parameters:
|
||||
- $ref: ../components/parameters.yml#/AssessmentAttemptId
|
||||
- name: lab_id
|
||||
in: path
|
||||
required: true
|
||||
description: Identifier of a lab of this attempt.
|
||||
schema:
|
||||
type: string
|
||||
format: uuid
|
||||
requestBody:
|
||||
required: true
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: ../components/schemas.yml#/AssessmentLabConsoleSessionCreate
|
||||
examples:
|
||||
r1:
|
||||
summary: Open the console of r1.
|
||||
value:
|
||||
node: r1
|
||||
responses:
|
||||
"201":
|
||||
description: The console session was opened.
|
||||
headers:
|
||||
Cache-Control:
|
||||
$ref: ../components/headers.yml#/CacheControlNoStore
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: ../components/schemas.yml#/AssessmentLabConsoleSession
|
||||
examples:
|
||||
opened:
|
||||
summary: A console session of r1.
|
||||
value:
|
||||
id: 0192a1b2-c3d4-7e5f-8a9b-0c1d2e3f4a90
|
||||
node: r1
|
||||
websocket_path: /api/v1/me/assessment-lab-consoles/0192a1b2-c3d4-7e5f-8a9b-0c1d2e3f4a90
|
||||
expires_at: "2026-10-11T09:02:00Z"
|
||||
"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
|
||||
"429":
|
||||
$ref: ../components/responses.yml#/TooManyRequests
|
||||
"503":
|
||||
$ref: ../components/responses.yml#/ServiceUnavailable
|
||||
default:
|
||||
$ref: ../components/responses.yml#/Problem
|
||||
@@ -0,0 +1,89 @@
|
||||
post:
|
||||
operationId: SubmitMyAssessmentLab
|
||||
summary: Submit the lab of the current lab item as its answer.
|
||||
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 carries the attempt version last read and the answer with format `lab`, which names the lab.
|
||||
|
||||
The server closes the consoles, freezes the lab, and answers 202 with the lab `checking`; the checker of the task reads the state of the nodes asynchronously, the answer is recorded, and the lab becomes `submitted` and is deleted. The client polls GetMyAssessmentLab and then reads the attempt, which moves to the next item. Neither response says whether the answer was correct, and the candidate never sees the checker criteria or their results.
|
||||
|
||||
When the checker cannot reach the nodes because of the lab infrastructure, the lab becomes `failed` with `lab_error`: nothing is recorded or consumed, the attempt version is unchanged, and the candidate may start a new lab of the item while it is current. A failure of the infrastructure is never scored as a wrong answer.
|
||||
|
||||
Optimistic concurrency: `expected_version` must equal the current attempt version, otherwise the server answers 412 version_conflict and stores nothing.
|
||||
|
||||
Order of checks: session (401), CSRF and Origin (403 csrf_check_failed), request validation (400), account scenario (403 forbidden), the Idempotency-Key (422, 409 idempotency_in_progress, replay), the attempt and the lab (404 not_found for an unknown attempt or lab, or one of another candidate), the version (412), the state (409 state_conflict: the lab is not `ready`, `answer.lab_id` is not the lab in the path, the item is not current, the attempt is terminal, or its work session ended), then the provisioner (503 service_unavailable without Retry-After; nothing was stored and the lab keeps running). Following the Idempotency-Key convention, 202, 404, and 409 state_conflict are stored under the key and replayed; 400, 412, 429, and 5xx are not.
|
||||
security:
|
||||
- sessionCookie: []
|
||||
sessionCsrf: []
|
||||
tags:
|
||||
- assessment
|
||||
parameters:
|
||||
- $ref: ../components/parameters.yml#/AssessmentAttemptId
|
||||
- $ref: ../components/parameters.yml#/IdempotencyKey
|
||||
- name: lab_id
|
||||
in: path
|
||||
required: true
|
||||
description: Identifier of the lab to submit.
|
||||
schema:
|
||||
type: string
|
||||
format: uuid
|
||||
requestBody:
|
||||
required: true
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: ../components/schemas.yml#/AssessmentLabSubmission
|
||||
examples:
|
||||
submit:
|
||||
summary: Submit the lab as the answer of its item.
|
||||
value:
|
||||
expected_version: 7
|
||||
answer:
|
||||
format: lab
|
||||
lab_id: 0192a1b2-c3d4-7e5f-8a9b-0c1d2e3f4a80
|
||||
responses:
|
||||
"202":
|
||||
description: The submission was accepted and the lab is being checked.
|
||||
headers:
|
||||
Cache-Control:
|
||||
$ref: ../components/headers.yml#/CacheControlNoStore
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: ../components/schemas.yml#/AssessmentLab
|
||||
examples:
|
||||
checking:
|
||||
summary: A submitted lab whose nodes are being checked.
|
||||
value:
|
||||
id: 0192a1b2-c3d4-7e5f-8a9b-0c1d2e3f4a80
|
||||
item_id: 0192a1b2-c3d4-7e5f-8a9b-0c1d2e3f4a61
|
||||
state: checking
|
||||
nodes:
|
||||
- name: r1
|
||||
kind: mikrotik
|
||||
- name: r2
|
||||
kind: mikrotik
|
||||
created_at: "2026-10-11T09:00:00Z"
|
||||
ready_at: "2026-10-11T09:00:40Z"
|
||||
expires_at: "2026-10-11T09:45:00Z"
|
||||
finished_at: null
|
||||
failure_reason: 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#/AssessmentCommandConflict
|
||||
"412":
|
||||
$ref: ../components/responses.yml#/AssessmentVersionConflict
|
||||
"422":
|
||||
$ref: ../components/responses.yml#/UnprocessableContent
|
||||
"429":
|
||||
$ref: ../components/responses.yml#/TooManyRequests
|
||||
"503":
|
||||
$ref: ../components/responses.yml#/ServiceUnavailable
|
||||
default:
|
||||
$ref: ../components/responses.yml#/Problem
|
||||
@@ -0,0 +1,86 @@
|
||||
post:
|
||||
operationId: CreateMyAssessmentLab
|
||||
summary: Start the lab of the current lab item of an assessment attempt.
|
||||
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 current item, whose content has the format `lab`.
|
||||
|
||||
The server asks the lab provisioner for a lab of the variant fixed for this item instance and answers 201 with the lab `provisioning`; the client polls GetMyAssessmentLab until it is `ready`. The lab lives until `expires_at`, the earlier of the item's `time_limit_seconds` and the attempt deadline, and is then deleted with everything done in it. Creating a lab does not change the attempt version, the current item, or any answer.
|
||||
|
||||
One lab per item at a time. While the item has a lab in `provisioning`, `ready`, or `checking`, the server answers 200 with that lab and starts no second one. After a `failed` lab the candidate may start a new one while the item is current; after `submitted` or `expired` the item cannot start another lab (409 state_conflict).
|
||||
|
||||
Busy pool. When the lab pool of the provisioner has no free capacity, the server answers 503 service_unavailable with Retry-After, for example `{"type": "urn:lincodex:problem:service_unavailable", "title": "Service unavailable", "status": 503, "code": "service_unavailable", "detail": "No lab capacity is free. The attempt is unchanged; retry later."}`. Nothing was stored: no lab exists, the attempt version and the current item are unchanged, the lab lifetime has not started, and the attempt is not consumed; the client retries after Retry-After with a new Idempotency-Key. When labs are not enabled on this server, or the provisioner cannot be reached, the server answers 503 service_unavailable without Retry-After and stores nothing either. The attempt deadline keeps running in both cases.
|
||||
|
||||
Order of checks: session (401), CSRF and Origin (403 csrf_check_failed), request validation (400), account scenario (403 forbidden), the Idempotency-Key (422, 409 idempotency_in_progress, replay), the attempt and the item (404 not_found for an unknown attempt or item, or one of another candidate), the state (409 state_conflict: the attempt is terminal or its work session ended, the item is not current, its format is not `lab`, or its lab was submitted or expired), the rate limit (429), then the availability of labs and the capacity (503). Following the Idempotency-Key convention, 201, 200, 404, and 409 state_conflict are stored under the key and replayed; 400, 429, and 503 are not.
|
||||
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#/AssessmentLabCreate
|
||||
examples:
|
||||
start:
|
||||
summary: Start the lab of the current item.
|
||||
value:
|
||||
item_id: 0192a1b2-c3d4-7e5f-8a9b-0c1d2e3f4a61
|
||||
responses:
|
||||
"200":
|
||||
description: The item already has an active lab; it is returned and no second lab is started.
|
||||
headers:
|
||||
Cache-Control:
|
||||
$ref: ../components/headers.yml#/CacheControlNoStore
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: ../components/schemas.yml#/AssessmentLab
|
||||
"201":
|
||||
description: The lab was requested and is provisioning.
|
||||
headers:
|
||||
Cache-Control:
|
||||
$ref: ../components/headers.yml#/CacheControlNoStore
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: ../components/schemas.yml#/AssessmentLab
|
||||
examples:
|
||||
provisioning:
|
||||
summary: A lab of two routers that is being prepared.
|
||||
value:
|
||||
id: 0192a1b2-c3d4-7e5f-8a9b-0c1d2e3f4a80
|
||||
item_id: 0192a1b2-c3d4-7e5f-8a9b-0c1d2e3f4a61
|
||||
state: provisioning
|
||||
nodes:
|
||||
- name: r1
|
||||
kind: mikrotik
|
||||
- name: r2
|
||||
kind: mikrotik
|
||||
created_at: "2026-10-11T09:00:00Z"
|
||||
ready_at: null
|
||||
expires_at: "2026-10-11T09:45:00Z"
|
||||
finished_at: null
|
||||
failure_reason: 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#/AssessmentCommandConflict
|
||||
"422":
|
||||
$ref: ../components/responses.yml#/UnprocessableContent
|
||||
"429":
|
||||
$ref: ../components/responses.yml#/TooManyRequests
|
||||
"503":
|
||||
$ref: ../components/responses.yml#/ServiceUnavailable
|
||||
default:
|
||||
$ref: ../components/responses.yml#/Problem
|
||||
Reference in new issue
Block a user