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
+5
-1
@@ -16,19 +16,22 @@ install: ## Install pinned OpenAPI tooling
|
||||
npm ci --prefix "$(API_DIR)" --ignore-scripts --no-audit --no-fund
|
||||
|
||||
.PHONY: bundle
|
||||
bundle: ## Merge split schemas and create public, ML, and code runner bundles
|
||||
bundle: ## Merge split schemas and create public, ML, code runner, and lab provisioner bundles
|
||||
"$(CODEGEN_PYTHON)" "$(ROOT_DIR)/scripts/merge-schemas.py" "$(API_DIR)/core"
|
||||
"$(CODEGEN_PYTHON)" "$(ROOT_DIR)/scripts/merge-schemas.py" "$(API_DIR)/ml"
|
||||
"$(CODEGEN_PYTHON)" "$(ROOT_DIR)/scripts/merge-schemas.py" "$(API_DIR)/runner"
|
||||
"$(CODEGEN_PYTHON)" "$(ROOT_DIR)/scripts/merge-schemas.py" "$(API_DIR)/labd"
|
||||
"$(REDOCLY)" bundle "$(API_DIR)/core/openapi.yml" --output "$(API_DIR)/core/openapi.bundle.yml"
|
||||
"$(REDOCLY)" bundle "$(API_DIR)/ml/openapi.yml" --output "$(API_DIR)/ml/openapi.bundle.yml"
|
||||
"$(REDOCLY)" bundle "$(API_DIR)/runner/openapi.yml" --output "$(API_DIR)/runner/openapi.bundle.yml"
|
||||
"$(REDOCLY)" bundle "$(API_DIR)/labd/openapi.yml" --output "$(API_DIR)/labd/openapi.bundle.yml"
|
||||
|
||||
.PHONY: lint
|
||||
lint: bundle ## Lint every bundled contract
|
||||
"$(REDOCLY)" lint --config "$(API_DIR)/redocly.yaml" "$(API_DIR)/core/openapi.bundle.yml"
|
||||
"$(REDOCLY)" lint --config "$(API_DIR)/redocly.yaml" "$(API_DIR)/ml/openapi.bundle.yml"
|
||||
"$(REDOCLY)" lint --config "$(API_DIR)/redocly.yaml" "$(API_DIR)/runner/openapi.bundle.yml"
|
||||
"$(REDOCLY)" lint --config "$(API_DIR)/redocly.yaml" "$(API_DIR)/labd/openapi.bundle.yml"
|
||||
|
||||
.PHONY: check
|
||||
check: lint ## Build and lint every contract bundle and run the contract tests
|
||||
@@ -37,6 +40,7 @@ check: lint ## Build and lint every contract bundle and run the contract tests
|
||||
PYTHONDONTWRITEBYTECODE=1 "$(CODEGEN_PYTHON)" -m unittest discover -s "$(ROOT_DIR)/scripts" -p 'test_assessment_contract.py'
|
||||
PYTHONDONTWRITEBYTECODE=1 "$(CODEGEN_PYTHON)" -m unittest discover -s "$(ROOT_DIR)/scripts" -p 'test_match_contract.py'
|
||||
PYTHONDONTWRITEBYTECODE=1 "$(CODEGEN_PYTHON)" -m unittest discover -s "$(ROOT_DIR)/scripts" -p 'test_runner_contract.py'
|
||||
PYTHONDONTWRITEBYTECODE=1 "$(CODEGEN_PYTHON)" -m unittest discover -s "$(ROOT_DIR)/scripts" -p 'test_lab_contract.py'
|
||||
|
||||
.PHONY: check-compat
|
||||
check-compat: bundle ## Compare the public contract with API_BASE_REF
|
||||
|
||||
@@ -476,6 +476,7 @@ ItemContent:
|
||||
- $ref: '#/FindErrorItemContent'
|
||||
- $ref: '#/ConfigurationItemContent'
|
||||
- $ref: '#/PracticeItemContent'
|
||||
- $ref: '#/LabItemContent'
|
||||
AssessmentItem:
|
||||
type: object
|
||||
description: 'Item instance served to the candidate. The variant is fixed when it is first served: a reload, a retried request, or a resumed session returns the same instance with the same text and option order. The item never says whether an earlier answer was correct, and seed items, which are not scored, are indistinguishable from scored ones.'
|
||||
@@ -4829,6 +4830,214 @@ InvitationDeclineRequest:
|
||||
oneOf:
|
||||
- $ref: '#/InvitationDeclineComment'
|
||||
- type: 'null'
|
||||
AssessmentLabNodeName:
|
||||
type: string
|
||||
minLength: 1
|
||||
maxLength: 15
|
||||
pattern: ^[a-z][a-z0-9-]{0,14}$
|
||||
description: Name of a lab node as the task statement uses it, such as `r1` or `srv`. It is a label of the task, not a host name or an address.
|
||||
AssessmentLabNodeKind:
|
||||
type: string
|
||||
description: 'What the console of a node shows.
|
||||
|
||||
|
||||
- mikrotik: a MikroTik router with the RouterOS console.
|
||||
|
||||
- ubuntu: a small Ubuntu server with a Linux login.
|
||||
|
||||
|
||||
Adding a value is a contract change.'
|
||||
enum:
|
||||
- mikrotik
|
||||
- ubuntu
|
||||
AssessmentLabNode:
|
||||
type: object
|
||||
description: A node of a lab by its task name and kind. It never carries an address, a MAC address, a port, a password, a key, or an infrastructure name.
|
||||
additionalProperties: false
|
||||
required:
|
||||
- name
|
||||
- kind
|
||||
properties:
|
||||
name:
|
||||
$ref: '#/AssessmentLabNodeName'
|
||||
kind:
|
||||
$ref: '#/AssessmentLabNodeKind'
|
||||
LabItemContent:
|
||||
type: object
|
||||
description: 'Practical lab: configure or repair a small network of virtual nodes through their consoles. The candidate starts the lab of the item with CreateMyAssessmentLab, works in the node consoles, and submits with SubmitMyAssessmentLab; the server then checks the state of the nodes. The content lists only the nodes the statement names and the lifetime of the lab, never the checker, its criteria, the seed, or an address. SubmitMyAssessmentAnswer takes no answer to a lab item; its result is submitted only with SubmitMyAssessmentLab.'
|
||||
additionalProperties: false
|
||||
required:
|
||||
- format
|
||||
- nodes
|
||||
- time_limit_seconds
|
||||
properties:
|
||||
format:
|
||||
type: string
|
||||
enum:
|
||||
- lab
|
||||
nodes:
|
||||
type: array
|
||||
minItems: 1
|
||||
maxItems: 8
|
||||
description: Nodes of the lab in the order of the statement.
|
||||
items:
|
||||
$ref: '#/AssessmentLabNode'
|
||||
time_limit_seconds:
|
||||
type: integer
|
||||
format: int32
|
||||
minimum: 300
|
||||
maximum: 14400
|
||||
description: Lifetime of a lab of this item from its creation. The lab also ends no later than the attempt deadline.
|
||||
LabAnswer:
|
||||
type: object
|
||||
description: 'Answer of a lab item: the state of the nodes of the named lab at the moment of submission. The server reads that state with the checker of the task; the body carries no configuration text, score, or correctness flag. Two answers are equal when they name the same lab. It is the answer of SubmitMyAssessmentLab only and is not a member of AssessmentAnswer.'
|
||||
additionalProperties: false
|
||||
required:
|
||||
- format
|
||||
- lab_id
|
||||
properties:
|
||||
format:
|
||||
type: string
|
||||
enum:
|
||||
- lab
|
||||
lab_id:
|
||||
type: string
|
||||
format: uuid
|
||||
description: The lab of this item that the candidate worked in.
|
||||
AssessmentLabState:
|
||||
type: string
|
||||
description: 'State of a lab of an attempt item.
|
||||
|
||||
|
||||
- provisioning: the nodes are being prepared; poll GetMyAssessmentLab.
|
||||
|
||||
- ready: the consoles can be opened until `expires_at`.
|
||||
|
||||
- checking: the answer was accepted; the consoles are closed and the server checks the nodes.
|
||||
|
||||
- submitted: the check finished and the answer is recorded; the lab is deleted. The state never says whether the answer was correct.
|
||||
|
||||
- expired: the lifetime or the attempt deadline ended before a submission; the lab is deleted and the item cannot start another lab.
|
||||
|
||||
- failed: the lab infrastructure failed, independently of the candidate; `failure_reason` is `lab_error`. Nothing was recorded or consumed, and the candidate may start a new lab of the same item while the item is current.
|
||||
|
||||
|
||||
Adding a value is a contract change.'
|
||||
enum:
|
||||
- provisioning
|
||||
- ready
|
||||
- checking
|
||||
- submitted
|
||||
- expired
|
||||
- failed
|
||||
AssessmentLabFailureReason:
|
||||
type: string
|
||||
description: 'Why a lab failed: `lab_error` for an infrastructure failure, such as a node that did not boot or a check that could not reach a node. It never depends on the candidate and is never a failed check.'
|
||||
enum:
|
||||
- lab_error
|
||||
AssessmentLab:
|
||||
type: object
|
||||
description: Candidate view of the lab of one attempt item. It contains no node address, MAC address, port, password, key, token, seed, checker state, criteria, score, or infrastructure name.
|
||||
additionalProperties: false
|
||||
required:
|
||||
- id
|
||||
- item_id
|
||||
- state
|
||||
- nodes
|
||||
- created_at
|
||||
- ready_at
|
||||
- expires_at
|
||||
- finished_at
|
||||
- failure_reason
|
||||
properties:
|
||||
id:
|
||||
type: string
|
||||
format: uuid
|
||||
description: Identifier of the lab.
|
||||
item_id:
|
||||
$ref: '#/AssessmentItemId'
|
||||
state:
|
||||
$ref: '#/AssessmentLabState'
|
||||
nodes:
|
||||
type: array
|
||||
minItems: 1
|
||||
maxItems: 8
|
||||
items:
|
||||
$ref: '#/AssessmentLabNode'
|
||||
created_at:
|
||||
$ref: '#/Timestamp'
|
||||
ready_at:
|
||||
description: Time the lab became `ready`, or null before.
|
||||
oneOf:
|
||||
- $ref: '#/Timestamp'
|
||||
- type: 'null'
|
||||
expires_at:
|
||||
description: 'Time the lab ends unless it was submitted before: the earlier of the lifetime of the item and the attempt deadline. It never moves.'
|
||||
$ref: '#/Timestamp'
|
||||
finished_at:
|
||||
description: Time the lab reached `submitted`, `expired`, or `failed`, or null.
|
||||
oneOf:
|
||||
- $ref: '#/Timestamp'
|
||||
- type: 'null'
|
||||
failure_reason:
|
||||
description: '`lab_error` when `state` is `failed`, otherwise null.'
|
||||
oneOf:
|
||||
- $ref: '#/AssessmentLabFailureReason'
|
||||
- type: 'null'
|
||||
AssessmentLabCreate:
|
||||
type: object
|
||||
description: Start the lab of the current lab item. Unknown fields are rejected.
|
||||
additionalProperties: false
|
||||
required:
|
||||
- item_id
|
||||
properties:
|
||||
item_id:
|
||||
$ref: '#/AssessmentItemId'
|
||||
AssessmentLabConsoleSessionCreate:
|
||||
type: object
|
||||
description: Open a console of one node of a ready lab. Unknown fields are rejected.
|
||||
additionalProperties: false
|
||||
required:
|
||||
- node
|
||||
properties:
|
||||
node:
|
||||
$ref: '#/AssessmentLabNodeName'
|
||||
AssessmentLabConsoleSession:
|
||||
type: object
|
||||
description: A console session of one node. The client opens a WebSocket to `websocket_path` on the same origin before `expires_at`; the session cookie and the Origin check authorize the upgrade, so no secret travels in the path, the body, or a query string. A session can be attached once and ends with the lab.
|
||||
additionalProperties: false
|
||||
required:
|
||||
- id
|
||||
- node
|
||||
- websocket_path
|
||||
- expires_at
|
||||
properties:
|
||||
id:
|
||||
type: string
|
||||
format: uuid
|
||||
description: Identifier of the console session; it is not a secret.
|
||||
node:
|
||||
$ref: '#/AssessmentLabNodeName'
|
||||
websocket_path:
|
||||
type: string
|
||||
maxLength: 128
|
||||
pattern: ^/api/v1/me/assessment-lab-consoles/[0-9a-f-]{36}$
|
||||
description: Same-origin path of the console WebSocket.
|
||||
expires_at:
|
||||
description: Time by which the WebSocket must be opened.
|
||||
$ref: '#/Timestamp'
|
||||
AssessmentLabSubmission:
|
||||
type: object
|
||||
description: Submit the lab of the current lab item as its answer. Unknown fields are rejected, so a request cannot send a score or a correctness flag.
|
||||
additionalProperties: false
|
||||
required:
|
||||
- expected_version
|
||||
- answer
|
||||
properties:
|
||||
expected_version:
|
||||
$ref: '#/AssessmentAttemptVersion'
|
||||
answer:
|
||||
$ref: '#/LabAnswer'
|
||||
MatchConfirmationStatus:
|
||||
type: string
|
||||
description: Confirmation state for this specialization only. A result for one specialization never changes the state of another specialization.
|
||||
|
||||
@@ -511,6 +511,7 @@ schemas:
|
||||
- $ref: "#/schemas/FindErrorItemContent"
|
||||
- $ref: "#/schemas/ConfigurationItemContent"
|
||||
- $ref: "#/schemas/PracticeItemContent"
|
||||
- $ref: "./lab_schemas.yml#/schemas/LabItemContent"
|
||||
AssessmentItem:
|
||||
type: object
|
||||
description: >-
|
||||
|
||||
@@ -0,0 +1,236 @@
|
||||
schemas:
|
||||
AssessmentLabNodeName:
|
||||
type: string
|
||||
minLength: 1
|
||||
maxLength: 15
|
||||
pattern: "^[a-z][a-z0-9-]{0,14}$"
|
||||
description: >-
|
||||
Name of a lab node as the task statement uses it, such as `r1` or
|
||||
`srv`. It is a label of the task, not a host name or an address.
|
||||
AssessmentLabNodeKind:
|
||||
type: string
|
||||
description: |-
|
||||
What the console of a node shows.
|
||||
|
||||
- mikrotik: a MikroTik router with the RouterOS console.
|
||||
- ubuntu: a small Ubuntu server with a Linux login.
|
||||
|
||||
Adding a value is a contract change.
|
||||
enum:
|
||||
- mikrotik
|
||||
- ubuntu
|
||||
AssessmentLabNode:
|
||||
type: object
|
||||
description: >-
|
||||
A node of a lab by its task name and kind. It never carries an address,
|
||||
a MAC address, a port, a password, a key, or an infrastructure name.
|
||||
additionalProperties: false
|
||||
required:
|
||||
- name
|
||||
- kind
|
||||
properties:
|
||||
name:
|
||||
$ref: "#/schemas/AssessmentLabNodeName"
|
||||
kind:
|
||||
$ref: "#/schemas/AssessmentLabNodeKind"
|
||||
LabItemContent:
|
||||
type: object
|
||||
description: >-
|
||||
Practical lab: configure or repair a small network of virtual nodes
|
||||
through their consoles. The candidate starts the lab of the item with
|
||||
CreateMyAssessmentLab, works in the node consoles, and submits with
|
||||
SubmitMyAssessmentLab; the server then checks the state of the nodes.
|
||||
The content lists only the nodes the statement names and the lifetime
|
||||
of the lab, never the checker, its criteria, the seed, or an address.
|
||||
SubmitMyAssessmentAnswer takes no answer to a lab item; its result is
|
||||
submitted only with SubmitMyAssessmentLab.
|
||||
additionalProperties: false
|
||||
required:
|
||||
- format
|
||||
- nodes
|
||||
- time_limit_seconds
|
||||
properties:
|
||||
format:
|
||||
type: string
|
||||
enum:
|
||||
- lab
|
||||
nodes:
|
||||
type: array
|
||||
minItems: 1
|
||||
maxItems: 8
|
||||
description: Nodes of the lab in the order of the statement.
|
||||
items:
|
||||
$ref: "#/schemas/AssessmentLabNode"
|
||||
time_limit_seconds:
|
||||
type: integer
|
||||
format: int32
|
||||
minimum: 300
|
||||
maximum: 14400
|
||||
description: >-
|
||||
Lifetime of a lab of this item from its creation. The lab also ends
|
||||
no later than the attempt deadline.
|
||||
LabAnswer:
|
||||
type: object
|
||||
description: >-
|
||||
Answer of a lab item: the state of the nodes of the named lab at the
|
||||
moment of submission. The server reads that state with the checker of
|
||||
the task; the body carries no configuration text, score, or
|
||||
correctness flag. Two answers are equal when they name the same lab.
|
||||
It is the answer of SubmitMyAssessmentLab only and is not a member of
|
||||
AssessmentAnswer.
|
||||
additionalProperties: false
|
||||
required:
|
||||
- format
|
||||
- lab_id
|
||||
properties:
|
||||
format:
|
||||
type: string
|
||||
enum:
|
||||
- lab
|
||||
lab_id:
|
||||
type: string
|
||||
format: uuid
|
||||
description: The lab of this item that the candidate worked in.
|
||||
AssessmentLabState:
|
||||
type: string
|
||||
description: |-
|
||||
State of a lab of an attempt item.
|
||||
|
||||
- provisioning: the nodes are being prepared; poll GetMyAssessmentLab.
|
||||
- ready: the consoles can be opened until `expires_at`.
|
||||
- checking: the answer was accepted; the consoles are closed and the server checks the nodes.
|
||||
- submitted: the check finished and the answer is recorded; the lab is deleted. The state never says whether the answer was correct.
|
||||
- expired: the lifetime or the attempt deadline ended before a submission; the lab is deleted and the item cannot start another lab.
|
||||
- failed: the lab infrastructure failed, independently of the candidate; `failure_reason` is `lab_error`. Nothing was recorded or consumed, and the candidate may start a new lab of the same item while the item is current.
|
||||
|
||||
Adding a value is a contract change.
|
||||
enum:
|
||||
- provisioning
|
||||
- ready
|
||||
- checking
|
||||
- submitted
|
||||
- expired
|
||||
- failed
|
||||
AssessmentLabFailureReason:
|
||||
type: string
|
||||
description: >-
|
||||
Why a lab failed: `lab_error` for an infrastructure failure, such as a
|
||||
node that did not boot or a check that could not reach a node. It never
|
||||
depends on the candidate and is never a failed check.
|
||||
enum:
|
||||
- lab_error
|
||||
AssessmentLab:
|
||||
type: object
|
||||
description: >-
|
||||
Candidate view of the lab of one attempt item. It contains no node
|
||||
address, MAC address, port, password, key, token, seed, checker state,
|
||||
criteria, score, or infrastructure name.
|
||||
additionalProperties: false
|
||||
required:
|
||||
- id
|
||||
- item_id
|
||||
- state
|
||||
- nodes
|
||||
- created_at
|
||||
- ready_at
|
||||
- expires_at
|
||||
- finished_at
|
||||
- failure_reason
|
||||
properties:
|
||||
id:
|
||||
type: string
|
||||
format: uuid
|
||||
description: Identifier of the lab.
|
||||
item_id:
|
||||
$ref: "./assessment_schemas.yml#/schemas/AssessmentItemId"
|
||||
state:
|
||||
$ref: "#/schemas/AssessmentLabState"
|
||||
nodes:
|
||||
type: array
|
||||
minItems: 1
|
||||
maxItems: 8
|
||||
items:
|
||||
$ref: "#/schemas/AssessmentLabNode"
|
||||
created_at:
|
||||
$ref: "./common_schemas.yml#/schemas/Timestamp"
|
||||
ready_at:
|
||||
description: Time the lab became `ready`, or null before.
|
||||
oneOf:
|
||||
- $ref: "./common_schemas.yml#/schemas/Timestamp"
|
||||
- type: "null"
|
||||
expires_at:
|
||||
description: >-
|
||||
Time the lab ends unless it was submitted before: the earlier of the
|
||||
lifetime of the item and the attempt deadline. It never moves.
|
||||
$ref: "./common_schemas.yml#/schemas/Timestamp"
|
||||
finished_at:
|
||||
description: Time the lab reached `submitted`, `expired`, or `failed`, or null.
|
||||
oneOf:
|
||||
- $ref: "./common_schemas.yml#/schemas/Timestamp"
|
||||
- type: "null"
|
||||
failure_reason:
|
||||
description: "`lab_error` when `state` is `failed`, otherwise null."
|
||||
oneOf:
|
||||
- $ref: "#/schemas/AssessmentLabFailureReason"
|
||||
- type: "null"
|
||||
AssessmentLabCreate:
|
||||
type: object
|
||||
description: Start the lab of the current lab item. Unknown fields are rejected.
|
||||
additionalProperties: false
|
||||
required:
|
||||
- item_id
|
||||
properties:
|
||||
item_id:
|
||||
$ref: "./assessment_schemas.yml#/schemas/AssessmentItemId"
|
||||
AssessmentLabConsoleSessionCreate:
|
||||
type: object
|
||||
description: Open a console of one node of a ready lab. Unknown fields are rejected.
|
||||
additionalProperties: false
|
||||
required:
|
||||
- node
|
||||
properties:
|
||||
node:
|
||||
$ref: "#/schemas/AssessmentLabNodeName"
|
||||
AssessmentLabConsoleSession:
|
||||
type: object
|
||||
description: >-
|
||||
A console session of one node. The client opens a WebSocket to
|
||||
`websocket_path` on the same origin before `expires_at`; the session
|
||||
cookie and the Origin check authorize the upgrade, so no secret travels
|
||||
in the path, the body, or a query string. A session can be attached
|
||||
once and ends with the lab.
|
||||
additionalProperties: false
|
||||
required:
|
||||
- id
|
||||
- node
|
||||
- websocket_path
|
||||
- expires_at
|
||||
properties:
|
||||
id:
|
||||
type: string
|
||||
format: uuid
|
||||
description: Identifier of the console session; it is not a secret.
|
||||
node:
|
||||
$ref: "#/schemas/AssessmentLabNodeName"
|
||||
websocket_path:
|
||||
type: string
|
||||
maxLength: 128
|
||||
pattern: "^/api/v1/me/assessment-lab-consoles/[0-9a-f-]{36}$"
|
||||
description: Same-origin path of the console WebSocket.
|
||||
expires_at:
|
||||
description: Time by which the WebSocket must be opened.
|
||||
$ref: "./common_schemas.yml#/schemas/Timestamp"
|
||||
AssessmentLabSubmission:
|
||||
type: object
|
||||
description: >-
|
||||
Submit the lab of the current lab item as its answer. Unknown fields
|
||||
are rejected, so a request cannot send a score or a correctness flag.
|
||||
additionalProperties: false
|
||||
required:
|
||||
- expected_version
|
||||
- answer
|
||||
properties:
|
||||
expected_version:
|
||||
$ref: "./assessment_schemas.yml#/schemas/AssessmentAttemptVersion"
|
||||
answer:
|
||||
$ref: "#/schemas/LabAnswer"
|
||||
@@ -1201,6 +1201,8 @@ paths:
|
||||
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.
|
||||
@@ -3832,6 +3834,310 @@ paths:
|
||||
$ref: '#/components/responses/NotFound'
|
||||
default:
|
||||
$ref: '#/components/responses/Problem'
|
||||
/api/v1/me/assessment-attempts/{attempt_id}/labs:
|
||||
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/AssessmentAttemptId'
|
||||
- $ref: '#/components/parameters/IdempotencyKey'
|
||||
requestBody:
|
||||
required: true
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/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/CacheControlNoStore'
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/AssessmentLab'
|
||||
'201':
|
||||
description: The lab was requested and is provisioning.
|
||||
headers:
|
||||
Cache-Control:
|
||||
$ref: '#/components/headers/CacheControlNoStore'
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/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/ValidationFailed'
|
||||
'401':
|
||||
$ref: '#/components/responses/Unauthenticated'
|
||||
'403':
|
||||
$ref: '#/components/responses/CsrfCheckFailedOrForbidden'
|
||||
'404':
|
||||
$ref: '#/components/responses/NotFound'
|
||||
'409':
|
||||
$ref: '#/components/responses/AssessmentCommandConflict'
|
||||
'422':
|
||||
$ref: '#/components/responses/UnprocessableContent'
|
||||
'429':
|
||||
$ref: '#/components/responses/TooManyRequests'
|
||||
'503':
|
||||
$ref: '#/components/responses/ServiceUnavailable'
|
||||
default:
|
||||
$ref: '#/components/responses/Problem'
|
||||
/api/v1/me/assessment-attempts/{attempt_id}/labs/{lab_id}:
|
||||
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/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/CacheControlNoStore'
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/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/Unauthenticated'
|
||||
'403':
|
||||
$ref: '#/components/responses/Forbidden'
|
||||
'404':
|
||||
$ref: '#/components/responses/NotFound'
|
||||
default:
|
||||
$ref: '#/components/responses/Problem'
|
||||
/api/v1/me/assessment-attempts/{attempt_id}/labs/{lab_id}/console-sessions:
|
||||
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/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/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/CacheControlNoStore'
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/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/ValidationFailed'
|
||||
'401':
|
||||
$ref: '#/components/responses/Unauthenticated'
|
||||
'403':
|
||||
$ref: '#/components/responses/CsrfCheckFailedOrForbidden'
|
||||
'404':
|
||||
$ref: '#/components/responses/NotFound'
|
||||
'409':
|
||||
$ref: '#/components/responses/StateConflict'
|
||||
'429':
|
||||
$ref: '#/components/responses/TooManyRequests'
|
||||
'503':
|
||||
$ref: '#/components/responses/ServiceUnavailable'
|
||||
default:
|
||||
$ref: '#/components/responses/Problem'
|
||||
/api/v1/me/assessment-attempts/{attempt_id}/labs/{lab_id}/submission:
|
||||
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/AssessmentAttemptId'
|
||||
- $ref: '#/components/parameters/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/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/CacheControlNoStore'
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/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/ValidationFailed'
|
||||
'401':
|
||||
$ref: '#/components/responses/Unauthenticated'
|
||||
'403':
|
||||
$ref: '#/components/responses/CsrfCheckFailedOrForbidden'
|
||||
'404':
|
||||
$ref: '#/components/responses/NotFound'
|
||||
'409':
|
||||
$ref: '#/components/responses/AssessmentCommandConflict'
|
||||
'412':
|
||||
$ref: '#/components/responses/AssessmentVersionConflict'
|
||||
'422':
|
||||
$ref: '#/components/responses/UnprocessableContent'
|
||||
'429':
|
||||
$ref: '#/components/responses/TooManyRequests'
|
||||
'503':
|
||||
$ref: '#/components/responses/ServiceUnavailable'
|
||||
default:
|
||||
$ref: '#/components/responses/Problem'
|
||||
components:
|
||||
schemas:
|
||||
Problem:
|
||||
@@ -5712,6 +6018,7 @@ components:
|
||||
- $ref: '#/components/schemas/FindErrorItemContent'
|
||||
- $ref: '#/components/schemas/ConfigurationItemContent'
|
||||
- $ref: '#/components/schemas/PracticeItemContent'
|
||||
- $ref: '#/components/schemas/LabItemContent'
|
||||
AssessmentItem:
|
||||
type: object
|
||||
description: 'Item instance served to the candidate. The variant is fixed when it is first served: a reload, a retried request, or a resumed session returns the same instance with the same text and option order. The item never says whether an earlier answer was correct, and seed items, which are not scored, are indistinguishable from scored ones.'
|
||||
@@ -10531,6 +10838,206 @@ components:
|
||||
description: Identifier of the marked item.
|
||||
read_at:
|
||||
$ref: '#/components/schemas/Timestamp'
|
||||
AssessmentLabNodeName:
|
||||
type: string
|
||||
minLength: 1
|
||||
maxLength: 15
|
||||
pattern: ^[a-z][a-z0-9-]{0,14}$
|
||||
description: Name of a lab node as the task statement uses it, such as `r1` or `srv`. It is a label of the task, not a host name or an address.
|
||||
AssessmentLabNodeKind:
|
||||
type: string
|
||||
description: |-
|
||||
What the console of a node shows.
|
||||
|
||||
- mikrotik: a MikroTik router with the RouterOS console.
|
||||
- ubuntu: a small Ubuntu server with a Linux login.
|
||||
|
||||
Adding a value is a contract change.
|
||||
enum:
|
||||
- mikrotik
|
||||
- ubuntu
|
||||
AssessmentLabNode:
|
||||
type: object
|
||||
description: A node of a lab by its task name and kind. It never carries an address, a MAC address, a port, a password, a key, or an infrastructure name.
|
||||
additionalProperties: false
|
||||
required:
|
||||
- name
|
||||
- kind
|
||||
properties:
|
||||
name:
|
||||
$ref: '#/components/schemas/AssessmentLabNodeName'
|
||||
kind:
|
||||
$ref: '#/components/schemas/AssessmentLabNodeKind'
|
||||
LabItemContent:
|
||||
type: object
|
||||
description: 'Practical lab: configure or repair a small network of virtual nodes through their consoles. The candidate starts the lab of the item with CreateMyAssessmentLab, works in the node consoles, and submits with SubmitMyAssessmentLab; the server then checks the state of the nodes. The content lists only the nodes the statement names and the lifetime of the lab, never the checker, its criteria, the seed, or an address. SubmitMyAssessmentAnswer takes no answer to a lab item; its result is submitted only with SubmitMyAssessmentLab.'
|
||||
additionalProperties: false
|
||||
required:
|
||||
- format
|
||||
- nodes
|
||||
- time_limit_seconds
|
||||
properties:
|
||||
format:
|
||||
type: string
|
||||
enum:
|
||||
- lab
|
||||
nodes:
|
||||
type: array
|
||||
minItems: 1
|
||||
maxItems: 8
|
||||
description: Nodes of the lab in the order of the statement.
|
||||
items:
|
||||
$ref: '#/components/schemas/AssessmentLabNode'
|
||||
time_limit_seconds:
|
||||
type: integer
|
||||
format: int32
|
||||
minimum: 300
|
||||
maximum: 14400
|
||||
description: Lifetime of a lab of this item from its creation. The lab also ends no later than the attempt deadline.
|
||||
LabAnswer:
|
||||
type: object
|
||||
description: 'Answer of a lab item: the state of the nodes of the named lab at the moment of submission. The server reads that state with the checker of the task; the body carries no configuration text, score, or correctness flag. Two answers are equal when they name the same lab. It is the answer of SubmitMyAssessmentLab only and is not a member of AssessmentAnswer.'
|
||||
additionalProperties: false
|
||||
required:
|
||||
- format
|
||||
- lab_id
|
||||
properties:
|
||||
format:
|
||||
type: string
|
||||
enum:
|
||||
- lab
|
||||
lab_id:
|
||||
type: string
|
||||
format: uuid
|
||||
description: The lab of this item that the candidate worked in.
|
||||
AssessmentLabState:
|
||||
type: string
|
||||
description: |-
|
||||
State of a lab of an attempt item.
|
||||
|
||||
- provisioning: the nodes are being prepared; poll GetMyAssessmentLab.
|
||||
- ready: the consoles can be opened until `expires_at`.
|
||||
- checking: the answer was accepted; the consoles are closed and the server checks the nodes.
|
||||
- submitted: the check finished and the answer is recorded; the lab is deleted. The state never says whether the answer was correct.
|
||||
- expired: the lifetime or the attempt deadline ended before a submission; the lab is deleted and the item cannot start another lab.
|
||||
- failed: the lab infrastructure failed, independently of the candidate; `failure_reason` is `lab_error`. Nothing was recorded or consumed, and the candidate may start a new lab of the same item while the item is current.
|
||||
|
||||
Adding a value is a contract change.
|
||||
enum:
|
||||
- provisioning
|
||||
- ready
|
||||
- checking
|
||||
- submitted
|
||||
- expired
|
||||
- failed
|
||||
AssessmentLabFailureReason:
|
||||
type: string
|
||||
description: 'Why a lab failed: `lab_error` for an infrastructure failure, such as a node that did not boot or a check that could not reach a node. It never depends on the candidate and is never a failed check.'
|
||||
enum:
|
||||
- lab_error
|
||||
AssessmentLab:
|
||||
type: object
|
||||
description: Candidate view of the lab of one attempt item. It contains no node address, MAC address, port, password, key, token, seed, checker state, criteria, score, or infrastructure name.
|
||||
additionalProperties: false
|
||||
required:
|
||||
- id
|
||||
- item_id
|
||||
- state
|
||||
- nodes
|
||||
- created_at
|
||||
- ready_at
|
||||
- expires_at
|
||||
- finished_at
|
||||
- failure_reason
|
||||
properties:
|
||||
id:
|
||||
type: string
|
||||
format: uuid
|
||||
description: Identifier of the lab.
|
||||
item_id:
|
||||
$ref: '#/components/schemas/AssessmentItemId'
|
||||
state:
|
||||
$ref: '#/components/schemas/AssessmentLabState'
|
||||
nodes:
|
||||
type: array
|
||||
minItems: 1
|
||||
maxItems: 8
|
||||
items:
|
||||
$ref: '#/components/schemas/AssessmentLabNode'
|
||||
created_at:
|
||||
$ref: '#/components/schemas/Timestamp'
|
||||
ready_at:
|
||||
description: Time the lab became `ready`, or null before.
|
||||
oneOf:
|
||||
- $ref: '#/components/schemas/Timestamp'
|
||||
- type: 'null'
|
||||
expires_at:
|
||||
description: 'Time the lab ends unless it was submitted before: the earlier of the lifetime of the item and the attempt deadline. It never moves.'
|
||||
$ref: '#/components/schemas/Timestamp'
|
||||
finished_at:
|
||||
description: Time the lab reached `submitted`, `expired`, or `failed`, or null.
|
||||
oneOf:
|
||||
- $ref: '#/components/schemas/Timestamp'
|
||||
- type: 'null'
|
||||
failure_reason:
|
||||
description: '`lab_error` when `state` is `failed`, otherwise null.'
|
||||
oneOf:
|
||||
- $ref: '#/components/schemas/AssessmentLabFailureReason'
|
||||
- type: 'null'
|
||||
AssessmentLabCreate:
|
||||
type: object
|
||||
description: Start the lab of the current lab item. Unknown fields are rejected.
|
||||
additionalProperties: false
|
||||
required:
|
||||
- item_id
|
||||
properties:
|
||||
item_id:
|
||||
$ref: '#/components/schemas/AssessmentItemId'
|
||||
AssessmentLabConsoleSessionCreate:
|
||||
type: object
|
||||
description: Open a console of one node of a ready lab. Unknown fields are rejected.
|
||||
additionalProperties: false
|
||||
required:
|
||||
- node
|
||||
properties:
|
||||
node:
|
||||
$ref: '#/components/schemas/AssessmentLabNodeName'
|
||||
AssessmentLabConsoleSession:
|
||||
type: object
|
||||
description: A console session of one node. The client opens a WebSocket to `websocket_path` on the same origin before `expires_at`; the session cookie and the Origin check authorize the upgrade, so no secret travels in the path, the body, or a query string. A session can be attached once and ends with the lab.
|
||||
additionalProperties: false
|
||||
required:
|
||||
- id
|
||||
- node
|
||||
- websocket_path
|
||||
- expires_at
|
||||
properties:
|
||||
id:
|
||||
type: string
|
||||
format: uuid
|
||||
description: Identifier of the console session; it is not a secret.
|
||||
node:
|
||||
$ref: '#/components/schemas/AssessmentLabNodeName'
|
||||
websocket_path:
|
||||
type: string
|
||||
maxLength: 128
|
||||
pattern: ^/api/v1/me/assessment-lab-consoles/[0-9a-f-]{36}$
|
||||
description: Same-origin path of the console WebSocket.
|
||||
expires_at:
|
||||
description: Time by which the WebSocket must be opened.
|
||||
$ref: '#/components/schemas/Timestamp'
|
||||
AssessmentLabSubmission:
|
||||
type: object
|
||||
description: Submit the lab of the current lab item as its answer. Unknown fields are rejected, so a request cannot send a score or a correctness flag.
|
||||
additionalProperties: false
|
||||
required:
|
||||
- expected_version
|
||||
- answer
|
||||
properties:
|
||||
expected_version:
|
||||
$ref: '#/components/schemas/AssessmentAttemptVersion'
|
||||
answer:
|
||||
$ref: '#/components/schemas/LabAnswer'
|
||||
HealthResponse:
|
||||
type: object
|
||||
additionalProperties: false
|
||||
|
||||
@@ -225,6 +225,14 @@ paths:
|
||||
$ref: ./routes/support_cases.yml
|
||||
/api/v1/me/support-cases/{case_id}:
|
||||
$ref: ./routes/support_case.yml
|
||||
/api/v1/me/assessment-attempts/{attempt_id}/labs:
|
||||
$ref: ./routes/candidate_assessment_attempt_labs.yml
|
||||
/api/v1/me/assessment-attempts/{attempt_id}/labs/{lab_id}:
|
||||
$ref: ./routes/candidate_assessment_attempt_lab.yml
|
||||
/api/v1/me/assessment-attempts/{attempt_id}/labs/{lab_id}/console-sessions:
|
||||
$ref: ./routes/candidate_assessment_attempt_lab_console_sessions.yml
|
||||
/api/v1/me/assessment-attempts/{attempt_id}/labs/{lab_id}/submission:
|
||||
$ref: ./routes/candidate_assessment_attempt_lab_submission.yml
|
||||
components:
|
||||
schemas:
|
||||
Problem:
|
||||
@@ -963,6 +971,30 @@ components:
|
||||
$ref: ./components/schemas.yml#/NotificationList
|
||||
NotificationReadReceipt:
|
||||
$ref: ./components/schemas.yml#/NotificationReadReceipt
|
||||
AssessmentLabNodeName:
|
||||
$ref: ./components/schemas.yml#/AssessmentLabNodeName
|
||||
AssessmentLabNodeKind:
|
||||
$ref: ./components/schemas.yml#/AssessmentLabNodeKind
|
||||
AssessmentLabNode:
|
||||
$ref: ./components/schemas.yml#/AssessmentLabNode
|
||||
LabItemContent:
|
||||
$ref: ./components/schemas.yml#/LabItemContent
|
||||
LabAnswer:
|
||||
$ref: ./components/schemas.yml#/LabAnswer
|
||||
AssessmentLabState:
|
||||
$ref: ./components/schemas.yml#/AssessmentLabState
|
||||
AssessmentLabFailureReason:
|
||||
$ref: ./components/schemas.yml#/AssessmentLabFailureReason
|
||||
AssessmentLab:
|
||||
$ref: ./components/schemas.yml#/AssessmentLab
|
||||
AssessmentLabCreate:
|
||||
$ref: ./components/schemas.yml#/AssessmentLabCreate
|
||||
AssessmentLabConsoleSessionCreate:
|
||||
$ref: ./components/schemas.yml#/AssessmentLabConsoleSessionCreate
|
||||
AssessmentLabConsoleSession:
|
||||
$ref: ./components/schemas.yml#/AssessmentLabConsoleSession
|
||||
AssessmentLabSubmission:
|
||||
$ref: ./components/schemas.yml#/AssessmentLabSubmission
|
||||
parameters:
|
||||
IdempotencyKey:
|
||||
$ref: ./components/parameters.yml#/IdempotencyKey
|
||||
|
||||
@@ -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
|
||||
@@ -0,0 +1,11 @@
|
||||
LabId:
|
||||
name: lab_id
|
||||
in: path
|
||||
required: true
|
||||
description: >-
|
||||
Random UUID chosen by the backend for one lab. It is the idempotency key
|
||||
of CreateLab and must not encode a candidate, attempt, or task
|
||||
identifier.
|
||||
schema:
|
||||
type: string
|
||||
format: uuid
|
||||
@@ -0,0 +1,67 @@
|
||||
Problem:
|
||||
description: >-
|
||||
Any error response. The body is a Problem whose `status` equals the HTTP
|
||||
status and whose `code` is one of ProblemCode.
|
||||
content:
|
||||
application/problem+json:
|
||||
schema:
|
||||
$ref: ./schemas.yml#/Problem
|
||||
examples:
|
||||
validation_failed:
|
||||
summary: The template is unknown
|
||||
value:
|
||||
type: urn:lincodex:problem:validation_failed
|
||||
title: Request validation failed
|
||||
status: 400
|
||||
code: validation_failed
|
||||
detail: One or more request fields are invalid.
|
||||
errors:
|
||||
- in: body
|
||||
pointer: /template_id
|
||||
code: invalid
|
||||
message: The value does not match the contract.
|
||||
state_conflict:
|
||||
summary: The lab is not ready
|
||||
value:
|
||||
type: urn:lincodex:problem:state_conflict
|
||||
title: State conflict
|
||||
status: 409
|
||||
code: state_conflict
|
||||
detail: The lab is not ready.
|
||||
lab_unavailable:
|
||||
summary: The checker could not reach a node
|
||||
value:
|
||||
type: urn:lincodex:problem:lab_unavailable
|
||||
title: Lab unavailable
|
||||
status: 503
|
||||
code: lab_unavailable
|
||||
detail: The lab could not be evaluated. Nothing was checked.
|
||||
LabPoolBusy:
|
||||
description: >-
|
||||
The lab does not fit the memory budget or the lab limit of the
|
||||
provisioner, or the provisioner is draining; code lab_pool_busy. Nothing
|
||||
was stored and no capacity was reserved. Retry with the same lab ID after
|
||||
Retry-After.
|
||||
headers:
|
||||
Retry-After:
|
||||
description: Number of seconds to wait before retrying the request.
|
||||
required: true
|
||||
schema:
|
||||
type: integer
|
||||
format: int32
|
||||
minimum: 0
|
||||
maximum: 3600
|
||||
example: 30
|
||||
content:
|
||||
application/problem+json:
|
||||
schema:
|
||||
$ref: ./schemas.yml#/Problem
|
||||
examples:
|
||||
lab_pool_busy:
|
||||
summary: No capacity for another lab
|
||||
value:
|
||||
type: urn:lincodex:problem:lab_pool_busy
|
||||
title: Lab pool busy
|
||||
status: 503
|
||||
code: lab_pool_busy
|
||||
detail: No capacity for another lab. Retry later with the same lab ID.
|
||||
@@ -0,0 +1,391 @@
|
||||
LabdHealthResponse:
|
||||
type: object
|
||||
additionalProperties: false
|
||||
required:
|
||||
- status
|
||||
properties:
|
||||
status:
|
||||
type: string
|
||||
enum:
|
||||
- ok
|
||||
LabdReadinessResponse:
|
||||
type: object
|
||||
additionalProperties: false
|
||||
required:
|
||||
- status
|
||||
properties:
|
||||
status:
|
||||
type: string
|
||||
enum:
|
||||
- ready
|
||||
- not_ready
|
||||
TemplateId:
|
||||
type: string
|
||||
minLength: 1
|
||||
maxLength: 48
|
||||
pattern: ^[a-z0-9][a-z0-9-]{0,47}$
|
||||
description: Identifier of a lab template known to the provisioner, such as `mikrotik-ospf-pair`. Templates are part of the provisioner build; the request never carries node images, commands, or configuration.
|
||||
NodeName:
|
||||
type: string
|
||||
minLength: 1
|
||||
maxLength: 15
|
||||
pattern: ^[a-z][a-z0-9-]{0,14}$
|
||||
description: Name of a node inside its template, such as `r1` or `srv`. It is the same in every lab of the template and is not an LXD instance name or a host name.
|
||||
NodeKind:
|
||||
type: string
|
||||
description: 'Guest system of a node.
|
||||
|
||||
|
||||
- mikrotik: a MikroTik Cloud Hosted Router VM; its console is RouterOS.
|
||||
|
||||
- ubuntu: a small Ubuntu VM; its console is a Linux login.
|
||||
|
||||
|
||||
Adding a value is a contract change.'
|
||||
enum:
|
||||
- mikrotik
|
||||
- ubuntu
|
||||
LabCreateRequest:
|
||||
type: object
|
||||
description: A lab of one template variant. It has no field for a candidate, account, attempt, task, or company.
|
||||
additionalProperties: false
|
||||
required:
|
||||
- template_id
|
||||
- template_version
|
||||
- seed
|
||||
- ttl_seconds
|
||||
properties:
|
||||
template_id:
|
||||
$ref: '#/TemplateId'
|
||||
template_version:
|
||||
type: integer
|
||||
format: int32
|
||||
minimum: 1
|
||||
maximum: 10000
|
||||
description: Version of the template. The provisioner refuses a version it does not hold, so a lab always matches the variant the backend served.
|
||||
seed:
|
||||
type: string
|
||||
minLength: 64
|
||||
maxLength: 64
|
||||
pattern: ^[0-9a-f]{64}$
|
||||
description: 'Variant seed: 32 random bytes in lowercase hex chosen by the backend for the item instance. The template renders the variant configuration of every node and the checker criteria from it. It is never returned by the provisioner.'
|
||||
ttl_seconds:
|
||||
type: integer
|
||||
format: int32
|
||||
minimum: 300
|
||||
maximum: 14400
|
||||
description: Lifetime of the lab from its creation. The provisioner refuses a value above its configured maximum.
|
||||
LabState:
|
||||
type: string
|
||||
description: 'State of a lab.
|
||||
|
||||
|
||||
- provisioning: capacity is reserved and the nodes are being cloned, connected, and booted.
|
||||
|
||||
- ready: every node answers on its management port; console tokens and checks are allowed.
|
||||
|
||||
- deleting: the timer ended, DeleteLab was called, or provisioning failed; the instances and bridges are being removed.
|
||||
|
||||
- deleted: every instance and bridge of the lab is gone and its capacity is free.
|
||||
|
||||
- failed: provisioning failed or timed out, or the provisioner restarted while provisioning; `failure_reason` says which. Its resources are removed as for `deleting` and the capacity returns once they are gone; create a new lab with a new ID.
|
||||
|
||||
|
||||
Adding a value is a contract change.'
|
||||
enum:
|
||||
- provisioning
|
||||
- ready
|
||||
- deleting
|
||||
- deleted
|
||||
- failed
|
||||
LabFailureReason:
|
||||
type: string
|
||||
description: 'Why a lab failed. None of the reasons depends on the person who uses the lab.
|
||||
|
||||
|
||||
- provisioning_failed: LXD refused or failed an operation of the provisioning.
|
||||
|
||||
- provisioning_timed_out: a node did not answer on its management port within the provisioning timeout.
|
||||
|
||||
- interrupted: the provisioner process stopped while the lab was provisioning.'
|
||||
enum:
|
||||
- provisioning_failed
|
||||
- provisioning_timed_out
|
||||
- interrupted
|
||||
LabNode:
|
||||
type: object
|
||||
description: A node of a lab by its template name and kind. It never carries an address, a MAC address, an instance name, or a credential.
|
||||
additionalProperties: false
|
||||
required:
|
||||
- name
|
||||
- kind
|
||||
properties:
|
||||
name:
|
||||
$ref: '#/NodeName'
|
||||
kind:
|
||||
$ref: '#/NodeKind'
|
||||
LabStatus:
|
||||
type: object
|
||||
description: State of a lab after one call. It never contains the seed, a node address, a key, a password, or an LXD object name.
|
||||
additionalProperties: false
|
||||
required:
|
||||
- lab_id
|
||||
- state
|
||||
- template_id
|
||||
- template_version
|
||||
- created_at
|
||||
- expires_at
|
||||
- nodes
|
||||
properties:
|
||||
lab_id:
|
||||
type: string
|
||||
format: uuid
|
||||
state:
|
||||
$ref: '#/LabState'
|
||||
template_id:
|
||||
$ref: '#/TemplateId'
|
||||
template_version:
|
||||
type: integer
|
||||
format: int32
|
||||
minimum: 1
|
||||
maximum: 10000
|
||||
created_at:
|
||||
type: string
|
||||
format: date-time
|
||||
ready_at:
|
||||
type: string
|
||||
format: date-time
|
||||
description: Time the lab became `ready`; absent before.
|
||||
expires_at:
|
||||
type: string
|
||||
format: date-time
|
||||
description: Time the provisioner deletes the lab. It never moves, also not across restarts of the provisioner.
|
||||
deleted_at:
|
||||
type: string
|
||||
format: date-time
|
||||
description: Time the last resource of the lab was removed; absent before.
|
||||
failure_reason:
|
||||
$ref: '#/LabFailureReason'
|
||||
nodes:
|
||||
type: array
|
||||
minItems: 1
|
||||
maxItems: 8
|
||||
description: Nodes of the template in template order.
|
||||
items:
|
||||
$ref: '#/LabNode'
|
||||
ConsoleTokenRequest:
|
||||
type: object
|
||||
additionalProperties: false
|
||||
required:
|
||||
- node
|
||||
properties:
|
||||
node:
|
||||
$ref: '#/NodeName'
|
||||
ConsoleToken:
|
||||
type: object
|
||||
description: 'Single-use console token for one node. The token is a secret of the console gateway: it is never logged, stored by the backend, or passed to a browser.'
|
||||
additionalProperties: false
|
||||
required:
|
||||
- token
|
||||
- node
|
||||
- expires_at
|
||||
- attach_path
|
||||
properties:
|
||||
token:
|
||||
type: string
|
||||
minLength: 43
|
||||
maxLength: 43
|
||||
pattern: ^[A-Za-z0-9_-]{43}$
|
||||
description: 32 random bytes in unpadded base64url.
|
||||
node:
|
||||
$ref: '#/NodeName'
|
||||
expires_at:
|
||||
type: string
|
||||
format: date-time
|
||||
attach_path:
|
||||
type: string
|
||||
maxLength: 128
|
||||
pattern: ^/v1/labs/[0-9a-f-]{36}/console$
|
||||
description: Path of the WebSocket attach on the provisioner origin.
|
||||
CriterionId:
|
||||
type: string
|
||||
minLength: 1
|
||||
maxLength: 32
|
||||
pattern: ^[a-z0-9][a-z0-9_-]{0,31}$
|
||||
description: Opaque identifier of a checker criterion of the template.
|
||||
CriterionResult:
|
||||
type: object
|
||||
additionalProperties: false
|
||||
required:
|
||||
- id
|
||||
- passed
|
||||
properties:
|
||||
id:
|
||||
$ref: '#/CriterionId'
|
||||
passed:
|
||||
type: boolean
|
||||
LabCheckResult:
|
||||
type: object
|
||||
description: 'Result of one check: whether each criterion of the variant holds on the nodes. It carries no node output, address, or configuration text.'
|
||||
additionalProperties: false
|
||||
required:
|
||||
- lab_id
|
||||
- checked_at
|
||||
- score
|
||||
- max_score
|
||||
- criteria
|
||||
properties:
|
||||
lab_id:
|
||||
type: string
|
||||
format: uuid
|
||||
checked_at:
|
||||
type: string
|
||||
format: date-time
|
||||
score:
|
||||
type: integer
|
||||
format: int32
|
||||
minimum: 0
|
||||
maximum: 50
|
||||
description: Number of passed criteria.
|
||||
max_score:
|
||||
type: integer
|
||||
format: int32
|
||||
minimum: 1
|
||||
maximum: 50
|
||||
description: Number of criteria.
|
||||
criteria:
|
||||
type: array
|
||||
minItems: 1
|
||||
maxItems: 50
|
||||
items:
|
||||
$ref: '#/CriterionResult'
|
||||
Problem:
|
||||
type: object
|
||||
description: Problem details (RFC 9457) returned with the application/problem+json media type for every error response. This is the lab provisioner copy of the public api/core Problem schema; keep both copies identical except for descriptions and the ProblemCode enum. `code` is the stable, machine-readable reason; clients branch on it rather than on `title`, `detail`, or the HTTP status alone. The body never contains internal error text, stack traces, SQL, file paths, credentials, contact data, or echoed request values.
|
||||
additionalProperties: false
|
||||
required:
|
||||
- type
|
||||
- title
|
||||
- status
|
||||
- code
|
||||
properties:
|
||||
type:
|
||||
type: string
|
||||
format: uri-reference
|
||||
maxLength: 256
|
||||
description: URI that identifies the problem type. It has the form `urn:lincodex:problem:<code>` and is an identifier, not a link to dereference.
|
||||
title:
|
||||
type: string
|
||||
minLength: 1
|
||||
maxLength: 200
|
||||
description: Short, fixed English summary of the problem type. It does not change between occurrences.
|
||||
status:
|
||||
type: integer
|
||||
format: int32
|
||||
minimum: 400
|
||||
maximum: 599
|
||||
description: HTTP status code generated by the origin server.
|
||||
code:
|
||||
$ref: '#/ProblemCode'
|
||||
detail:
|
||||
type: string
|
||||
maxLength: 1000
|
||||
description: Safe English explanation of this occurrence. It never contains internal error text or request values.
|
||||
instance:
|
||||
type: string
|
||||
format: uri-reference
|
||||
maxLength: 2048
|
||||
description: URI reference that identifies this occurrence, when one exists.
|
||||
trace_id:
|
||||
type: string
|
||||
minLength: 1
|
||||
maxLength: 128
|
||||
pattern: ^[A-Za-z0-9._-]+$
|
||||
description: Request identifier of the call when the caller propagated one; it is not a secret.
|
||||
errors:
|
||||
type: array
|
||||
maxItems: 100
|
||||
description: Field-level reasons for validation_failed. Other codes omit it.
|
||||
items:
|
||||
$ref: '#/ProblemFieldError'
|
||||
ProblemCode:
|
||||
type: string
|
||||
description: 'Stable error code of the lab provisioner API. Adding a code is a contract change; renaming or removing one is a breaking change. Clients must handle an unknown code by its HTTP status.
|
||||
|
||||
|
||||
- validation_failed (400): parameters or body do not match the contract or a semantic rule, such as an unknown template or node; `errors` points at the fields.
|
||||
|
||||
- unauthenticated (401): the bearer token is missing or wrong.
|
||||
|
||||
- not_found (404): the route or the lab does not exist.
|
||||
|
||||
- method_not_allowed (405): the route does not support the method.
|
||||
|
||||
- state_conflict (409): the lab is not in a state that allows the operation, for example a console token or a check for a lab that is not ready.
|
||||
|
||||
- payload_too_large (413): the request body exceeds the limit.
|
||||
|
||||
- unsupported_media_type (415): the request Content-Type is not accepted.
|
||||
|
||||
- idempotency_key_reused (422): the lab ID was already used with a different payload.
|
||||
|
||||
- internal (500): unexpected server error.
|
||||
|
||||
- not_implemented (501): the route is described but not implemented yet, such as the console attach.
|
||||
|
||||
- lab_pool_busy (503): the lab does not fit the capacity or the provisioner is draining; see Retry-After.
|
||||
|
||||
- lab_unavailable (503): LXD or a node could not be reached, so nothing was done or evaluated. It is an infrastructure failure, never a failed check.
|
||||
|
||||
|
||||
The Problem shape is the api/core shape; only this enum is specific to the lab provisioner.'
|
||||
enum:
|
||||
- validation_failed
|
||||
- unauthenticated
|
||||
- not_found
|
||||
- method_not_allowed
|
||||
- state_conflict
|
||||
- payload_too_large
|
||||
- unsupported_media_type
|
||||
- idempotency_key_reused
|
||||
- internal
|
||||
- not_implemented
|
||||
- lab_pool_busy
|
||||
- lab_unavailable
|
||||
ProblemFieldError:
|
||||
type: object
|
||||
description: One reason why a request field or parameter is invalid.
|
||||
additionalProperties: false
|
||||
required:
|
||||
- in
|
||||
- pointer
|
||||
- code
|
||||
- message
|
||||
properties:
|
||||
in:
|
||||
$ref: '#/ProblemFieldLocation'
|
||||
pointer:
|
||||
type: string
|
||||
maxLength: 1024
|
||||
pattern: ^(/([^~/]|~[01])*)*$
|
||||
description: JSON Pointer (RFC 6901). For `body` it points into the request body document, for example `/ttl_seconds`; an empty string means the whole body. For a parameter it is `/` followed by the parameter name, for example `/lab_id`.
|
||||
code:
|
||||
type: string
|
||||
minLength: 1
|
||||
maxLength: 64
|
||||
pattern: ^[a-z][a-z0-9_]*$
|
||||
description: Stable field reason. Current values are `required` (missing value) and `invalid` (malformed value or a value outside the schema). Clients must tolerate new values.
|
||||
message:
|
||||
type: string
|
||||
minLength: 1
|
||||
maxLength: 500
|
||||
description: Fixed English message that never echoes the submitted value.
|
||||
ProblemFieldLocation:
|
||||
type: string
|
||||
description: Part of the request that contains the invalid field.
|
||||
enum:
|
||||
- body
|
||||
- query
|
||||
- path
|
||||
- header
|
||||
- cookie
|
||||
@@ -0,0 +1,22 @@
|
||||
schemas:
|
||||
LabdHealthResponse:
|
||||
type: object
|
||||
additionalProperties: false
|
||||
required:
|
||||
- status
|
||||
properties:
|
||||
status:
|
||||
type: string
|
||||
enum:
|
||||
- ok
|
||||
LabdReadinessResponse:
|
||||
type: object
|
||||
additionalProperties: false
|
||||
required:
|
||||
- status
|
||||
properties:
|
||||
status:
|
||||
type: string
|
||||
enum:
|
||||
- ready
|
||||
- not_ready
|
||||
@@ -0,0 +1,259 @@
|
||||
schemas:
|
||||
TemplateId:
|
||||
type: string
|
||||
minLength: 1
|
||||
maxLength: 48
|
||||
pattern: "^[a-z0-9][a-z0-9-]{0,47}$"
|
||||
description: >-
|
||||
Identifier of a lab template known to the provisioner, such as
|
||||
`mikrotik-ospf-pair`. Templates are part of the provisioner build; the
|
||||
request never carries node images, commands, or configuration.
|
||||
NodeName:
|
||||
type: string
|
||||
minLength: 1
|
||||
maxLength: 15
|
||||
pattern: "^[a-z][a-z0-9-]{0,14}$"
|
||||
description: >-
|
||||
Name of a node inside its template, such as `r1` or `srv`. It is the
|
||||
same in every lab of the template and is not an LXD instance name or a
|
||||
host name.
|
||||
NodeKind:
|
||||
type: string
|
||||
description: |-
|
||||
Guest system of a node.
|
||||
|
||||
- mikrotik: a MikroTik Cloud Hosted Router VM; its console is RouterOS.
|
||||
- ubuntu: a small Ubuntu VM; its console is a Linux login.
|
||||
|
||||
Adding a value is a contract change.
|
||||
enum:
|
||||
- mikrotik
|
||||
- ubuntu
|
||||
LabCreateRequest:
|
||||
type: object
|
||||
description: >-
|
||||
A lab of one template variant. It has no field for a candidate,
|
||||
account, attempt, task, or company.
|
||||
additionalProperties: false
|
||||
required:
|
||||
- template_id
|
||||
- template_version
|
||||
- seed
|
||||
- ttl_seconds
|
||||
properties:
|
||||
template_id:
|
||||
$ref: "#/schemas/TemplateId"
|
||||
template_version:
|
||||
type: integer
|
||||
format: int32
|
||||
minimum: 1
|
||||
maximum: 10000
|
||||
description: >-
|
||||
Version of the template. The provisioner refuses a version it does
|
||||
not hold, so a lab always matches the variant the backend served.
|
||||
seed:
|
||||
type: string
|
||||
minLength: 64
|
||||
maxLength: 64
|
||||
pattern: "^[0-9a-f]{64}$"
|
||||
description: >-
|
||||
Variant seed: 32 random bytes in lowercase hex chosen by the
|
||||
backend for the item instance. The template renders the variant
|
||||
configuration of every node and the checker criteria from it. It
|
||||
is never returned by the provisioner.
|
||||
ttl_seconds:
|
||||
type: integer
|
||||
format: int32
|
||||
minimum: 300
|
||||
maximum: 14400
|
||||
description: >-
|
||||
Lifetime of the lab from its creation. The provisioner refuses a
|
||||
value above its configured maximum.
|
||||
LabState:
|
||||
type: string
|
||||
description: |-
|
||||
State of a lab.
|
||||
|
||||
- provisioning: capacity is reserved and the nodes are being cloned, connected, and booted.
|
||||
- ready: every node answers on its management port; console tokens and checks are allowed.
|
||||
- deleting: the timer ended, DeleteLab was called, or provisioning failed; the instances and bridges are being removed.
|
||||
- deleted: every instance and bridge of the lab is gone and its capacity is free.
|
||||
- failed: provisioning failed or timed out, or the provisioner restarted while provisioning; `failure_reason` says which. Its resources are removed as for `deleting` and the capacity returns once they are gone; create a new lab with a new ID.
|
||||
|
||||
Adding a value is a contract change.
|
||||
enum:
|
||||
- provisioning
|
||||
- ready
|
||||
- deleting
|
||||
- deleted
|
||||
- failed
|
||||
LabFailureReason:
|
||||
type: string
|
||||
description: |-
|
||||
Why a lab failed. None of the reasons depends on the person who uses the lab.
|
||||
|
||||
- provisioning_failed: LXD refused or failed an operation of the provisioning.
|
||||
- provisioning_timed_out: a node did not answer on its management port within the provisioning timeout.
|
||||
- interrupted: the provisioner process stopped while the lab was provisioning.
|
||||
enum:
|
||||
- provisioning_failed
|
||||
- provisioning_timed_out
|
||||
- interrupted
|
||||
LabNode:
|
||||
type: object
|
||||
description: >-
|
||||
A node of a lab by its template name and kind. It never carries an
|
||||
address, a MAC address, an instance name, or a credential.
|
||||
additionalProperties: false
|
||||
required:
|
||||
- name
|
||||
- kind
|
||||
properties:
|
||||
name:
|
||||
$ref: "#/schemas/NodeName"
|
||||
kind:
|
||||
$ref: "#/schemas/NodeKind"
|
||||
LabStatus:
|
||||
type: object
|
||||
description: >-
|
||||
State of a lab after one call. It never contains the seed, a node
|
||||
address, a key, a password, or an LXD object name.
|
||||
additionalProperties: false
|
||||
required:
|
||||
- lab_id
|
||||
- state
|
||||
- template_id
|
||||
- template_version
|
||||
- created_at
|
||||
- expires_at
|
||||
- nodes
|
||||
properties:
|
||||
lab_id:
|
||||
type: string
|
||||
format: uuid
|
||||
state:
|
||||
$ref: "#/schemas/LabState"
|
||||
template_id:
|
||||
$ref: "#/schemas/TemplateId"
|
||||
template_version:
|
||||
type: integer
|
||||
format: int32
|
||||
minimum: 1
|
||||
maximum: 10000
|
||||
created_at:
|
||||
type: string
|
||||
format: date-time
|
||||
ready_at:
|
||||
type: string
|
||||
format: date-time
|
||||
description: Time the lab became `ready`; absent before.
|
||||
expires_at:
|
||||
type: string
|
||||
format: date-time
|
||||
description: >-
|
||||
Time the provisioner deletes the lab. It never moves, also not
|
||||
across restarts of the provisioner.
|
||||
deleted_at:
|
||||
type: string
|
||||
format: date-time
|
||||
description: Time the last resource of the lab was removed; absent before.
|
||||
failure_reason:
|
||||
$ref: "#/schemas/LabFailureReason"
|
||||
nodes:
|
||||
type: array
|
||||
minItems: 1
|
||||
maxItems: 8
|
||||
description: Nodes of the template in template order.
|
||||
items:
|
||||
$ref: "#/schemas/LabNode"
|
||||
ConsoleTokenRequest:
|
||||
type: object
|
||||
additionalProperties: false
|
||||
required:
|
||||
- node
|
||||
properties:
|
||||
node:
|
||||
$ref: "#/schemas/NodeName"
|
||||
ConsoleToken:
|
||||
type: object
|
||||
description: >-
|
||||
Single-use console token for one node. The token is a secret of the
|
||||
console gateway: it is never logged, stored by the backend, or passed
|
||||
to a browser.
|
||||
additionalProperties: false
|
||||
required:
|
||||
- token
|
||||
- node
|
||||
- expires_at
|
||||
- attach_path
|
||||
properties:
|
||||
token:
|
||||
type: string
|
||||
minLength: 43
|
||||
maxLength: 43
|
||||
pattern: "^[A-Za-z0-9_-]{43}$"
|
||||
description: 32 random bytes in unpadded base64url.
|
||||
node:
|
||||
$ref: "#/schemas/NodeName"
|
||||
expires_at:
|
||||
type: string
|
||||
format: date-time
|
||||
attach_path:
|
||||
type: string
|
||||
maxLength: 128
|
||||
pattern: "^/v1/labs/[0-9a-f-]{36}/console$"
|
||||
description: Path of the WebSocket attach on the provisioner origin.
|
||||
CriterionId:
|
||||
type: string
|
||||
minLength: 1
|
||||
maxLength: 32
|
||||
pattern: "^[a-z0-9][a-z0-9_-]{0,31}$"
|
||||
description: Opaque identifier of a checker criterion of the template.
|
||||
CriterionResult:
|
||||
type: object
|
||||
additionalProperties: false
|
||||
required:
|
||||
- id
|
||||
- passed
|
||||
properties:
|
||||
id:
|
||||
$ref: "#/schemas/CriterionId"
|
||||
passed:
|
||||
type: boolean
|
||||
LabCheckResult:
|
||||
type: object
|
||||
description: >-
|
||||
Result of one check: whether each criterion of the variant holds on the
|
||||
nodes. It carries no node output, address, or configuration text.
|
||||
additionalProperties: false
|
||||
required:
|
||||
- lab_id
|
||||
- checked_at
|
||||
- score
|
||||
- max_score
|
||||
- criteria
|
||||
properties:
|
||||
lab_id:
|
||||
type: string
|
||||
format: uuid
|
||||
checked_at:
|
||||
type: string
|
||||
format: date-time
|
||||
score:
|
||||
type: integer
|
||||
format: int32
|
||||
minimum: 0
|
||||
maximum: 50
|
||||
description: Number of passed criteria.
|
||||
max_score:
|
||||
type: integer
|
||||
format: int32
|
||||
minimum: 1
|
||||
maximum: 50
|
||||
description: Number of criteria.
|
||||
criteria:
|
||||
type: array
|
||||
minItems: 1
|
||||
maxItems: 50
|
||||
items:
|
||||
$ref: "#/schemas/CriterionResult"
|
||||
@@ -0,0 +1,144 @@
|
||||
schemas:
|
||||
Problem:
|
||||
type: object
|
||||
description: >-
|
||||
Problem details (RFC 9457) returned with the application/problem+json
|
||||
media type for every error response. This is the lab provisioner copy of
|
||||
the public api/core Problem schema; keep both copies identical except
|
||||
for descriptions and the ProblemCode enum. `code` is the stable,
|
||||
machine-readable reason; clients branch on it rather than on `title`,
|
||||
`detail`, or the HTTP status alone. The body never contains internal
|
||||
error text, stack traces, SQL, file paths, credentials, contact data, or
|
||||
echoed request values.
|
||||
additionalProperties: false
|
||||
required:
|
||||
- type
|
||||
- title
|
||||
- status
|
||||
- code
|
||||
properties:
|
||||
type:
|
||||
type: string
|
||||
format: uri-reference
|
||||
maxLength: 256
|
||||
description: >-
|
||||
URI that identifies the problem type. It has the form
|
||||
`urn:lincodex:problem:<code>` and is an identifier, not a link to
|
||||
dereference.
|
||||
title:
|
||||
type: string
|
||||
minLength: 1
|
||||
maxLength: 200
|
||||
description: >-
|
||||
Short, fixed English summary of the problem type. It does not change
|
||||
between occurrences.
|
||||
status:
|
||||
type: integer
|
||||
format: int32
|
||||
minimum: 400
|
||||
maximum: 599
|
||||
description: HTTP status code generated by the origin server.
|
||||
code:
|
||||
$ref: "#/schemas/ProblemCode"
|
||||
detail:
|
||||
type: string
|
||||
maxLength: 1000
|
||||
description: >-
|
||||
Safe English explanation of this occurrence. It never contains
|
||||
internal error text or request values.
|
||||
instance:
|
||||
type: string
|
||||
format: uri-reference
|
||||
maxLength: 2048
|
||||
description: URI reference that identifies this occurrence, when one exists.
|
||||
trace_id:
|
||||
type: string
|
||||
minLength: 1
|
||||
maxLength: 128
|
||||
pattern: "^[A-Za-z0-9._-]+$"
|
||||
description: >-
|
||||
Request identifier of the call when the caller propagated one; it is
|
||||
not a secret.
|
||||
errors:
|
||||
type: array
|
||||
maxItems: 100
|
||||
description: >-
|
||||
Field-level reasons for validation_failed. Other codes omit it.
|
||||
items:
|
||||
$ref: "#/schemas/ProblemFieldError"
|
||||
ProblemCode:
|
||||
type: string
|
||||
description: |-
|
||||
Stable error code of the lab provisioner API. Adding a code is a contract change; renaming or removing one is a breaking change. Clients must handle an unknown code by its HTTP status.
|
||||
|
||||
- validation_failed (400): parameters or body do not match the contract or a semantic rule, such as an unknown template or node; `errors` points at the fields.
|
||||
- unauthenticated (401): the bearer token is missing or wrong.
|
||||
- not_found (404): the route or the lab does not exist.
|
||||
- method_not_allowed (405): the route does not support the method.
|
||||
- state_conflict (409): the lab is not in a state that allows the operation, for example a console token or a check for a lab that is not ready.
|
||||
- payload_too_large (413): the request body exceeds the limit.
|
||||
- unsupported_media_type (415): the request Content-Type is not accepted.
|
||||
- idempotency_key_reused (422): the lab ID was already used with a different payload.
|
||||
- internal (500): unexpected server error.
|
||||
- not_implemented (501): the route is described but not implemented yet, such as the console attach.
|
||||
- lab_pool_busy (503): the lab does not fit the capacity or the provisioner is draining; see Retry-After.
|
||||
- lab_unavailable (503): LXD or a node could not be reached, so nothing was done or evaluated. It is an infrastructure failure, never a failed check.
|
||||
|
||||
The Problem shape is the api/core shape; only this enum is specific to the lab provisioner.
|
||||
enum:
|
||||
- validation_failed
|
||||
- unauthenticated
|
||||
- not_found
|
||||
- method_not_allowed
|
||||
- state_conflict
|
||||
- payload_too_large
|
||||
- unsupported_media_type
|
||||
- idempotency_key_reused
|
||||
- internal
|
||||
- not_implemented
|
||||
- lab_pool_busy
|
||||
- lab_unavailable
|
||||
ProblemFieldError:
|
||||
type: object
|
||||
description: One reason why a request field or parameter is invalid.
|
||||
additionalProperties: false
|
||||
required:
|
||||
- in
|
||||
- pointer
|
||||
- code
|
||||
- message
|
||||
properties:
|
||||
in:
|
||||
$ref: "#/schemas/ProblemFieldLocation"
|
||||
pointer:
|
||||
type: string
|
||||
maxLength: 1024
|
||||
pattern: "^(/([^~/]|~[01])*)*$"
|
||||
description: >-
|
||||
JSON Pointer (RFC 6901). For `body` it points into the request body
|
||||
document, for example `/ttl_seconds`; an empty string means the whole
|
||||
body. For a parameter it is `/` followed by the parameter name, for
|
||||
example `/lab_id`.
|
||||
code:
|
||||
type: string
|
||||
minLength: 1
|
||||
maxLength: 64
|
||||
pattern: "^[a-z][a-z0-9_]*$"
|
||||
description: >-
|
||||
Stable field reason. Current values are `required` (missing value)
|
||||
and `invalid` (malformed value or a value outside the schema).
|
||||
Clients must tolerate new values.
|
||||
message:
|
||||
type: string
|
||||
minLength: 1
|
||||
maxLength: 500
|
||||
description: Fixed English message that never echoes the submitted value.
|
||||
ProblemFieldLocation:
|
||||
type: string
|
||||
description: Part of the request that contains the invalid field.
|
||||
enum:
|
||||
- body
|
||||
- query
|
||||
- path
|
||||
- header
|
||||
- cookie
|
||||
@@ -0,0 +1,721 @@
|
||||
openapi: 3.2.0
|
||||
info:
|
||||
title: Lincodex Lab Provisioner API
|
||||
version: 0.1.0
|
||||
description: |-
|
||||
Internal API of the lab provisioner `labd`. Only the Go backend calls it;
|
||||
it is never exposed to browsers or to the public network. `labd` is the
|
||||
only component that talks to the LXD API on the app host: the backend
|
||||
never receives the LXD socket, an LXD certificate, or a node address.
|
||||
|
||||
Transport and authentication: `labd` listens on a private address of the
|
||||
app host that only the backend network reaches and serves HTTPS (TLS
|
||||
1.3). Every operation except the health routes requires `Authorization:
|
||||
Bearer <token>`; the token is a shared random secret of at least 32
|
||||
characters that comes from the deployment secret store, never from this
|
||||
repository. A missing or wrong token answers 401 `unauthenticated`. Plain
|
||||
HTTP exists only behind an explicit development switch.
|
||||
|
||||
Data minimization: a lab request carries only a template reference, a
|
||||
variant seed, and a lifetime. It has no candidate, account, attempt,
|
||||
task, or company identifier. The lab ID is a random UUID chosen by the
|
||||
backend for idempotency. Responses never carry node addresses, MAC
|
||||
addresses, bridge or instance names, keys, or passwords: the backend
|
||||
reaches a node only through a console token and learns a lab's state
|
||||
only through these operations.
|
||||
|
||||
Lifecycle: CreateLab reserves capacity and answers immediately with the
|
||||
lab in `provisioning`; `labd` clones the nodes of the template from
|
||||
prepared snapshots, connects them with per-lab L2-only bridges, boots
|
||||
them, and waits until their management ports answer. The caller polls
|
||||
GetLab until `ready`. Every lab has a fixed `expires_at`; `labd` deletes
|
||||
it at that time even after a restart of its own process, and DeleteLab
|
||||
deletes it earlier. A deleted lab stays readable as `deleted` for a
|
||||
bounded time, then answers 404.
|
||||
|
||||
Capacity: the number of concurrent labs follows the host memory budget of
|
||||
`labd`. A request that does not fit answers 503 `lab_pool_busy` with
|
||||
Retry-After and stores nothing; it is a capacity signal, not an
|
||||
infrastructure failure. `labd` does not queue labs.
|
||||
servers:
|
||||
- url: /
|
||||
security:
|
||||
- bearerAuth: []
|
||||
paths:
|
||||
/healthz:
|
||||
get:
|
||||
operationId: GetLabdHealthz
|
||||
summary: Check whether the lab provisioner process is responding.
|
||||
security: []
|
||||
tags:
|
||||
- health
|
||||
responses:
|
||||
'200':
|
||||
description: The process is responding.
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/LabdHealthResponse'
|
||||
default:
|
||||
$ref: '#/components/responses/Problem'
|
||||
/readyz:
|
||||
get:
|
||||
operationId: GetLabdReadyz
|
||||
summary: Check whether the provisioner can create and delete labs.
|
||||
description: Ready means that the lab records were loaded, the startup reconciliation with LXD finished, the LXD API answered the latest probe, and the process is not draining. A provisioner without free capacity is still ready; capacity is reported by CreateLab.
|
||||
security: []
|
||||
tags:
|
||||
- health
|
||||
responses:
|
||||
'200':
|
||||
description: The provisioner is ready.
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/LabdReadinessResponse'
|
||||
'503':
|
||||
description: The provisioner is not ready or is draining.
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/LabdReadinessResponse'
|
||||
default:
|
||||
$ref: '#/components/responses/Problem'
|
||||
/v1/labs/{lab_id}:
|
||||
parameters:
|
||||
- $ref: '#/components/parameters/LabId'
|
||||
put:
|
||||
operationId: CreateLab
|
||||
summary: Create a lab from a template and a variant seed.
|
||||
description: |-
|
||||
Idempotent by `lab_id`:
|
||||
|
||||
- a new ID that fits the capacity reserves it, stores the lab, and answers 202 with `state: provisioning`; the nodes are cloned and booted in the background;
|
||||
- the same ID with the same payload answers 200 with the current state of that lab, including `deleted` or `failed`, and never creates a second one;
|
||||
- the same ID with a different payload answers 422 `idempotency_key_reused` and changes nothing;
|
||||
- a new ID that does not fit the memory budget or the lab limit, or arrives while the provisioner is draining, answers 503 `lab_pool_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.
|
||||
An unknown template or template version, or a lifetime above the
|
||||
configured maximum, answers 400 `validation_failed` with a pointer such
|
||||
as `/template_id` or `/ttl_seconds`.
|
||||
|
||||
The lab is deleted at `expires_at` = creation time + `ttl_seconds`, also
|
||||
when it is still provisioning. A lab that fails to provision or does not
|
||||
answer within the provisioning timeout becomes `failed` and its
|
||||
resources are deleted; its capacity returns when they are gone.
|
||||
|
||||
A record of a deleted or failed lab is kept for a bounded retention time;
|
||||
after it, the ID is unknown again and a CreateLab with it starts a new
|
||||
lab.
|
||||
tags:
|
||||
- labs
|
||||
requestBody:
|
||||
required: true
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/LabCreateRequest'
|
||||
examples:
|
||||
two_routers:
|
||||
summary: A lab of a networking template for one attempt item
|
||||
value:
|
||||
template_id: mikrotik-ospf-pair
|
||||
template_version: 1
|
||||
seed: 9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08
|
||||
ttl_seconds: 3600
|
||||
responses:
|
||||
'200':
|
||||
description: A lab with this ID and the same payload already exists.
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/LabStatus'
|
||||
'202':
|
||||
description: The lab was accepted and is provisioning.
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/LabStatus'
|
||||
examples:
|
||||
provisioning:
|
||||
summary: A lab that is being cloned and booted
|
||||
value:
|
||||
lab_id: 2f1c7a52-0d3e-4b8e-9b61-3c7b1f2e9a40
|
||||
state: provisioning
|
||||
template_id: mikrotik-ospf-pair
|
||||
template_version: 1
|
||||
created_at: '2026-10-11T09:00:00Z'
|
||||
expires_at: '2026-10-11T10:00:00Z'
|
||||
nodes:
|
||||
- name: r1
|
||||
kind: mikrotik
|
||||
- name: r2
|
||||
kind: mikrotik
|
||||
'503':
|
||||
$ref: '#/components/responses/LabPoolBusy'
|
||||
default:
|
||||
$ref: '#/components/responses/Problem'
|
||||
get:
|
||||
operationId: GetLab
|
||||
summary: Read the state of a lab.
|
||||
description: Answers 404 `not_found` for an ID the provisioner does not hold, including a lab whose `deleted` record outlived its retention time. The response never contains an address, a key, or an LXD object name.
|
||||
tags:
|
||||
- labs
|
||||
responses:
|
||||
'200':
|
||||
description: The current state of the lab.
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/LabStatus'
|
||||
default:
|
||||
$ref: '#/components/responses/Problem'
|
||||
delete:
|
||||
operationId: DeleteLab
|
||||
summary: Delete a lab before its timer.
|
||||
description: 'Marks the lab for deletion and answers 202 with `state: deleting`; the provisioner removes its instances and bridges in the background and retries until LXD confirms that they are gone, also across its own restarts. Deleting a lab that is already `deleting` or `deleted` answers 200 with its state and changes nothing. An unknown ID answers 404 `not_found`.'
|
||||
tags:
|
||||
- labs
|
||||
responses:
|
||||
'200':
|
||||
description: The lab was already being deleted or is deleted.
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/LabStatus'
|
||||
'202':
|
||||
description: The lab is being deleted.
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/LabStatus'
|
||||
default:
|
||||
$ref: '#/components/responses/Problem'
|
||||
/v1/labs/{lab_id}/console-tokens:
|
||||
parameters:
|
||||
- $ref: '#/components/parameters/LabId'
|
||||
post:
|
||||
operationId: CreateLabConsoleToken
|
||||
summary: Issue a short-lived console token for one node of a ready lab.
|
||||
description: |-
|
||||
The token lets the console gateway of the backend attach to the serial
|
||||
console of one node. It is random, single-use, bound to the lab and the
|
||||
node, and valid for at most 120 seconds; `labd` keeps only its SHA-256
|
||||
digest in memory, so a restart invalidates every unused token. The token
|
||||
is never a node password or an SSH key, and the response carries no node
|
||||
address.
|
||||
|
||||
Attaching: the gateway opens a WebSocket to `attach_path` on the same
|
||||
`labd` origin with the service bearer token and sends the console token
|
||||
in the `X-Lab-Console-Token` header. The WebSocket attach is described
|
||||
here as the planned interface; until it is implemented, `labd` answers
|
||||
the attach path with 501 and issuing a token changes nothing else.
|
||||
|
||||
A lab that is not `ready` answers 409 `state_conflict`; an unknown node
|
||||
answers 400 `validation_failed` with the pointer `/node`.
|
||||
tags:
|
||||
- consoles
|
||||
requestBody:
|
||||
required: true
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/ConsoleTokenRequest'
|
||||
responses:
|
||||
'201':
|
||||
description: The token was issued.
|
||||
headers:
|
||||
Cache-Control:
|
||||
description: The token must not be stored by any cache.
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
enum:
|
||||
- no-store
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/ConsoleToken'
|
||||
default:
|
||||
$ref: '#/components/responses/Problem'
|
||||
/v1/labs/{lab_id}/check:
|
||||
parameters:
|
||||
- $ref: '#/components/parameters/LabId'
|
||||
post:
|
||||
operationId: CheckLab
|
||||
summary: Run the checker of the template against the nodes of a ready lab.
|
||||
description: |-
|
||||
The checker of the template connects from the host side of the lab
|
||||
management bridge to the nodes (SSH or the RouterOS API) and evaluates
|
||||
the criteria of the variant that the seed selected. It only reads the
|
||||
node state and never changes it, so a repeated call is harmless; the
|
||||
result is not stored by `labd`. The call is synchronous and bounded by
|
||||
the check timeout of the provisioner.
|
||||
|
||||
The result is checker state for the backend only: the backend scores the
|
||||
lab answer with it and never forwards it to the candidate.
|
||||
|
||||
A lab that is not `ready` answers 409 `state_conflict`. When the
|
||||
checker cannot reach a node or the template has no working checker, the
|
||||
provisioner answers 503 `lab_unavailable`: nothing was evaluated, and the
|
||||
outcome is never a failed check.
|
||||
tags:
|
||||
- checks
|
||||
responses:
|
||||
'200':
|
||||
description: The checker evaluated every criterion.
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/LabCheckResult'
|
||||
default:
|
||||
$ref: '#/components/responses/Problem'
|
||||
components:
|
||||
securitySchemes:
|
||||
bearerAuth:
|
||||
type: http
|
||||
scheme: bearer
|
||||
description: 'Shared random service token sent as `Authorization: Bearer <token>` over TLS. `labd` compares it in constant time and never logs it. Rotation replaces the secret on both sides; there are no per-user tokens.'
|
||||
responses:
|
||||
Problem:
|
||||
description: Any error response. The body is a Problem whose `status` equals the HTTP status and whose `code` is one of ProblemCode.
|
||||
content:
|
||||
application/problem+json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Problem'
|
||||
examples:
|
||||
validation_failed:
|
||||
summary: The template is unknown
|
||||
value:
|
||||
type: urn:lincodex:problem:validation_failed
|
||||
title: Request validation failed
|
||||
status: 400
|
||||
code: validation_failed
|
||||
detail: One or more request fields are invalid.
|
||||
errors:
|
||||
- in: body
|
||||
pointer: /template_id
|
||||
code: invalid
|
||||
message: The value does not match the contract.
|
||||
state_conflict:
|
||||
summary: The lab is not ready
|
||||
value:
|
||||
type: urn:lincodex:problem:state_conflict
|
||||
title: State conflict
|
||||
status: 409
|
||||
code: state_conflict
|
||||
detail: The lab is not ready.
|
||||
lab_unavailable:
|
||||
summary: The checker could not reach a node
|
||||
value:
|
||||
type: urn:lincodex:problem:lab_unavailable
|
||||
title: Lab unavailable
|
||||
status: 503
|
||||
code: lab_unavailable
|
||||
detail: The lab could not be evaluated. Nothing was checked.
|
||||
LabPoolBusy:
|
||||
description: The lab does not fit the memory budget or the lab limit of the provisioner, or the provisioner is draining; code lab_pool_busy. Nothing was stored and no capacity was reserved. Retry with the same lab ID after Retry-After.
|
||||
headers:
|
||||
Retry-After:
|
||||
description: Number of seconds to wait before retrying the request.
|
||||
required: true
|
||||
schema:
|
||||
type: integer
|
||||
format: int32
|
||||
minimum: 0
|
||||
maximum: 3600
|
||||
example: 30
|
||||
content:
|
||||
application/problem+json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Problem'
|
||||
examples:
|
||||
lab_pool_busy:
|
||||
summary: No capacity for another lab
|
||||
value:
|
||||
type: urn:lincodex:problem:lab_pool_busy
|
||||
title: Lab pool busy
|
||||
status: 503
|
||||
code: lab_pool_busy
|
||||
detail: No capacity for another lab. Retry later with the same lab ID.
|
||||
schemas:
|
||||
ProblemCode:
|
||||
type: string
|
||||
description: |-
|
||||
Stable error code of the lab provisioner API. Adding a code is a contract change; renaming or removing one is a breaking change. Clients must handle an unknown code by its HTTP status.
|
||||
|
||||
- validation_failed (400): parameters or body do not match the contract or a semantic rule, such as an unknown template or node; `errors` points at the fields.
|
||||
- unauthenticated (401): the bearer token is missing or wrong.
|
||||
- not_found (404): the route or the lab does not exist.
|
||||
- method_not_allowed (405): the route does not support the method.
|
||||
- state_conflict (409): the lab is not in a state that allows the operation, for example a console token or a check for a lab that is not ready.
|
||||
- payload_too_large (413): the request body exceeds the limit.
|
||||
- unsupported_media_type (415): the request Content-Type is not accepted.
|
||||
- idempotency_key_reused (422): the lab ID was already used with a different payload.
|
||||
- internal (500): unexpected server error.
|
||||
- not_implemented (501): the route is described but not implemented yet, such as the console attach.
|
||||
- lab_pool_busy (503): the lab does not fit the capacity or the provisioner is draining; see Retry-After.
|
||||
- lab_unavailable (503): LXD or a node could not be reached, so nothing was done or evaluated. It is an infrastructure failure, never a failed check.
|
||||
|
||||
The Problem shape is the api/core shape; only this enum is specific to the lab provisioner.
|
||||
enum:
|
||||
- validation_failed
|
||||
- unauthenticated
|
||||
- not_found
|
||||
- method_not_allowed
|
||||
- state_conflict
|
||||
- payload_too_large
|
||||
- unsupported_media_type
|
||||
- idempotency_key_reused
|
||||
- internal
|
||||
- not_implemented
|
||||
- lab_pool_busy
|
||||
- lab_unavailable
|
||||
ProblemFieldLocation:
|
||||
type: string
|
||||
description: Part of the request that contains the invalid field.
|
||||
enum:
|
||||
- body
|
||||
- query
|
||||
- path
|
||||
- header
|
||||
- cookie
|
||||
ProblemFieldError:
|
||||
type: object
|
||||
description: One reason why a request field or parameter is invalid.
|
||||
additionalProperties: false
|
||||
required:
|
||||
- in
|
||||
- pointer
|
||||
- code
|
||||
- message
|
||||
properties:
|
||||
in:
|
||||
$ref: '#/components/schemas/ProblemFieldLocation'
|
||||
pointer:
|
||||
type: string
|
||||
maxLength: 1024
|
||||
pattern: ^(/([^~/]|~[01])*)*$
|
||||
description: JSON Pointer (RFC 6901). For `body` it points into the request body document, for example `/ttl_seconds`; an empty string means the whole body. For a parameter it is `/` followed by the parameter name, for example `/lab_id`.
|
||||
code:
|
||||
type: string
|
||||
minLength: 1
|
||||
maxLength: 64
|
||||
pattern: ^[a-z][a-z0-9_]*$
|
||||
description: Stable field reason. Current values are `required` (missing value) and `invalid` (malformed value or a value outside the schema). Clients must tolerate new values.
|
||||
message:
|
||||
type: string
|
||||
minLength: 1
|
||||
maxLength: 500
|
||||
description: Fixed English message that never echoes the submitted value.
|
||||
Problem:
|
||||
type: object
|
||||
description: Problem details (RFC 9457) returned with the application/problem+json media type for every error response. This is the lab provisioner copy of the public api/core Problem schema; keep both copies identical except for descriptions and the ProblemCode enum. `code` is the stable, machine-readable reason; clients branch on it rather than on `title`, `detail`, or the HTTP status alone. The body never contains internal error text, stack traces, SQL, file paths, credentials, contact data, or echoed request values.
|
||||
additionalProperties: false
|
||||
required:
|
||||
- type
|
||||
- title
|
||||
- status
|
||||
- code
|
||||
properties:
|
||||
type:
|
||||
type: string
|
||||
format: uri-reference
|
||||
maxLength: 256
|
||||
description: URI that identifies the problem type. It has the form `urn:lincodex:problem:<code>` and is an identifier, not a link to dereference.
|
||||
title:
|
||||
type: string
|
||||
minLength: 1
|
||||
maxLength: 200
|
||||
description: Short, fixed English summary of the problem type. It does not change between occurrences.
|
||||
status:
|
||||
type: integer
|
||||
format: int32
|
||||
minimum: 400
|
||||
maximum: 599
|
||||
description: HTTP status code generated by the origin server.
|
||||
code:
|
||||
$ref: '#/components/schemas/ProblemCode'
|
||||
detail:
|
||||
type: string
|
||||
maxLength: 1000
|
||||
description: Safe English explanation of this occurrence. It never contains internal error text or request values.
|
||||
instance:
|
||||
type: string
|
||||
format: uri-reference
|
||||
maxLength: 2048
|
||||
description: URI reference that identifies this occurrence, when one exists.
|
||||
trace_id:
|
||||
type: string
|
||||
minLength: 1
|
||||
maxLength: 128
|
||||
pattern: ^[A-Za-z0-9._-]+$
|
||||
description: Request identifier of the call when the caller propagated one; it is not a secret.
|
||||
errors:
|
||||
type: array
|
||||
maxItems: 100
|
||||
description: Field-level reasons for validation_failed. Other codes omit it.
|
||||
items:
|
||||
$ref: '#/components/schemas/ProblemFieldError'
|
||||
LabdHealthResponse:
|
||||
type: object
|
||||
additionalProperties: false
|
||||
required:
|
||||
- status
|
||||
properties:
|
||||
status:
|
||||
type: string
|
||||
enum:
|
||||
- ok
|
||||
LabdReadinessResponse:
|
||||
type: object
|
||||
additionalProperties: false
|
||||
required:
|
||||
- status
|
||||
properties:
|
||||
status:
|
||||
type: string
|
||||
enum:
|
||||
- ready
|
||||
- not_ready
|
||||
LabState:
|
||||
type: string
|
||||
description: |-
|
||||
State of a lab.
|
||||
|
||||
- provisioning: capacity is reserved and the nodes are being cloned, connected, and booted.
|
||||
- ready: every node answers on its management port; console tokens and checks are allowed.
|
||||
- deleting: the timer ended, DeleteLab was called, or provisioning failed; the instances and bridges are being removed.
|
||||
- deleted: every instance and bridge of the lab is gone and its capacity is free.
|
||||
- failed: provisioning failed or timed out, or the provisioner restarted while provisioning; `failure_reason` says which. Its resources are removed as for `deleting` and the capacity returns once they are gone; create a new lab with a new ID.
|
||||
|
||||
Adding a value is a contract change.
|
||||
enum:
|
||||
- provisioning
|
||||
- ready
|
||||
- deleting
|
||||
- deleted
|
||||
- failed
|
||||
TemplateId:
|
||||
type: string
|
||||
minLength: 1
|
||||
maxLength: 48
|
||||
pattern: ^[a-z0-9][a-z0-9-]{0,47}$
|
||||
description: Identifier of a lab template known to the provisioner, such as `mikrotik-ospf-pair`. Templates are part of the provisioner build; the request never carries node images, commands, or configuration.
|
||||
LabFailureReason:
|
||||
type: string
|
||||
description: |-
|
||||
Why a lab failed. None of the reasons depends on the person who uses the lab.
|
||||
|
||||
- provisioning_failed: LXD refused or failed an operation of the provisioning.
|
||||
- provisioning_timed_out: a node did not answer on its management port within the provisioning timeout.
|
||||
- interrupted: the provisioner process stopped while the lab was provisioning.
|
||||
enum:
|
||||
- provisioning_failed
|
||||
- provisioning_timed_out
|
||||
- interrupted
|
||||
NodeName:
|
||||
type: string
|
||||
minLength: 1
|
||||
maxLength: 15
|
||||
pattern: ^[a-z][a-z0-9-]{0,14}$
|
||||
description: Name of a node inside its template, such as `r1` or `srv`. It is the same in every lab of the template and is not an LXD instance name or a host name.
|
||||
NodeKind:
|
||||
type: string
|
||||
description: |-
|
||||
Guest system of a node.
|
||||
|
||||
- mikrotik: a MikroTik Cloud Hosted Router VM; its console is RouterOS.
|
||||
- ubuntu: a small Ubuntu VM; its console is a Linux login.
|
||||
|
||||
Adding a value is a contract change.
|
||||
enum:
|
||||
- mikrotik
|
||||
- ubuntu
|
||||
LabNode:
|
||||
type: object
|
||||
description: A node of a lab by its template name and kind. It never carries an address, a MAC address, an instance name, or a credential.
|
||||
additionalProperties: false
|
||||
required:
|
||||
- name
|
||||
- kind
|
||||
properties:
|
||||
name:
|
||||
$ref: '#/components/schemas/NodeName'
|
||||
kind:
|
||||
$ref: '#/components/schemas/NodeKind'
|
||||
LabStatus:
|
||||
type: object
|
||||
description: State of a lab after one call. It never contains the seed, a node address, a key, a password, or an LXD object name.
|
||||
additionalProperties: false
|
||||
required:
|
||||
- lab_id
|
||||
- state
|
||||
- template_id
|
||||
- template_version
|
||||
- created_at
|
||||
- expires_at
|
||||
- nodes
|
||||
properties:
|
||||
lab_id:
|
||||
type: string
|
||||
format: uuid
|
||||
state:
|
||||
$ref: '#/components/schemas/LabState'
|
||||
template_id:
|
||||
$ref: '#/components/schemas/TemplateId'
|
||||
template_version:
|
||||
type: integer
|
||||
format: int32
|
||||
minimum: 1
|
||||
maximum: 10000
|
||||
created_at:
|
||||
type: string
|
||||
format: date-time
|
||||
ready_at:
|
||||
type: string
|
||||
format: date-time
|
||||
description: Time the lab became `ready`; absent before.
|
||||
expires_at:
|
||||
type: string
|
||||
format: date-time
|
||||
description: Time the provisioner deletes the lab. It never moves, also not across restarts of the provisioner.
|
||||
deleted_at:
|
||||
type: string
|
||||
format: date-time
|
||||
description: Time the last resource of the lab was removed; absent before.
|
||||
failure_reason:
|
||||
$ref: '#/components/schemas/LabFailureReason'
|
||||
nodes:
|
||||
type: array
|
||||
minItems: 1
|
||||
maxItems: 8
|
||||
description: Nodes of the template in template order.
|
||||
items:
|
||||
$ref: '#/components/schemas/LabNode'
|
||||
LabCreateRequest:
|
||||
type: object
|
||||
description: A lab of one template variant. It has no field for a candidate, account, attempt, task, or company.
|
||||
additionalProperties: false
|
||||
required:
|
||||
- template_id
|
||||
- template_version
|
||||
- seed
|
||||
- ttl_seconds
|
||||
properties:
|
||||
template_id:
|
||||
$ref: '#/components/schemas/TemplateId'
|
||||
template_version:
|
||||
type: integer
|
||||
format: int32
|
||||
minimum: 1
|
||||
maximum: 10000
|
||||
description: Version of the template. The provisioner refuses a version it does not hold, so a lab always matches the variant the backend served.
|
||||
seed:
|
||||
type: string
|
||||
minLength: 64
|
||||
maxLength: 64
|
||||
pattern: ^[0-9a-f]{64}$
|
||||
description: 'Variant seed: 32 random bytes in lowercase hex chosen by the backend for the item instance. The template renders the variant configuration of every node and the checker criteria from it. It is never returned by the provisioner.'
|
||||
ttl_seconds:
|
||||
type: integer
|
||||
format: int32
|
||||
minimum: 300
|
||||
maximum: 14400
|
||||
description: Lifetime of the lab from its creation. The provisioner refuses a value above its configured maximum.
|
||||
ConsoleTokenRequest:
|
||||
type: object
|
||||
additionalProperties: false
|
||||
required:
|
||||
- node
|
||||
properties:
|
||||
node:
|
||||
$ref: '#/components/schemas/NodeName'
|
||||
ConsoleToken:
|
||||
type: object
|
||||
description: 'Single-use console token for one node. The token is a secret of the console gateway: it is never logged, stored by the backend, or passed to a browser.'
|
||||
additionalProperties: false
|
||||
required:
|
||||
- token
|
||||
- node
|
||||
- expires_at
|
||||
- attach_path
|
||||
properties:
|
||||
token:
|
||||
type: string
|
||||
minLength: 43
|
||||
maxLength: 43
|
||||
pattern: ^[A-Za-z0-9_-]{43}$
|
||||
description: 32 random bytes in unpadded base64url.
|
||||
node:
|
||||
$ref: '#/components/schemas/NodeName'
|
||||
expires_at:
|
||||
type: string
|
||||
format: date-time
|
||||
attach_path:
|
||||
type: string
|
||||
maxLength: 128
|
||||
pattern: ^/v1/labs/[0-9a-f-]{36}/console$
|
||||
description: Path of the WebSocket attach on the provisioner origin.
|
||||
CriterionId:
|
||||
type: string
|
||||
minLength: 1
|
||||
maxLength: 32
|
||||
pattern: ^[a-z0-9][a-z0-9_-]{0,31}$
|
||||
description: Opaque identifier of a checker criterion of the template.
|
||||
CriterionResult:
|
||||
type: object
|
||||
additionalProperties: false
|
||||
required:
|
||||
- id
|
||||
- passed
|
||||
properties:
|
||||
id:
|
||||
$ref: '#/components/schemas/CriterionId'
|
||||
passed:
|
||||
type: boolean
|
||||
LabCheckResult:
|
||||
type: object
|
||||
description: 'Result of one check: whether each criterion of the variant holds on the nodes. It carries no node output, address, or configuration text.'
|
||||
additionalProperties: false
|
||||
required:
|
||||
- lab_id
|
||||
- checked_at
|
||||
- score
|
||||
- max_score
|
||||
- criteria
|
||||
properties:
|
||||
lab_id:
|
||||
type: string
|
||||
format: uuid
|
||||
checked_at:
|
||||
type: string
|
||||
format: date-time
|
||||
score:
|
||||
type: integer
|
||||
format: int32
|
||||
minimum: 0
|
||||
maximum: 50
|
||||
description: Number of passed criteria.
|
||||
max_score:
|
||||
type: integer
|
||||
format: int32
|
||||
minimum: 1
|
||||
maximum: 50
|
||||
description: Number of criteria.
|
||||
criteria:
|
||||
type: array
|
||||
minItems: 1
|
||||
maxItems: 50
|
||||
items:
|
||||
$ref: '#/components/schemas/CriterionResult'
|
||||
parameters:
|
||||
LabId:
|
||||
name: lab_id
|
||||
in: path
|
||||
required: true
|
||||
description: Random UUID chosen by the backend for one lab. It is the idempotency key of CreateLab and must not encode a candidate, attempt, or task identifier.
|
||||
schema:
|
||||
type: string
|
||||
format: uuid
|
||||
@@ -0,0 +1,67 @@
|
||||
openapi: 3.2.0
|
||||
info:
|
||||
title: Lincodex Lab Provisioner API
|
||||
version: 0.1.0
|
||||
description: |-
|
||||
Internal API of the lab provisioner `labd`. Only the Go backend calls it;
|
||||
it is never exposed to browsers or to the public network. `labd` is the
|
||||
only component that talks to the LXD API on the app host: the backend
|
||||
never receives the LXD socket, an LXD certificate, or a node address.
|
||||
|
||||
Transport and authentication: `labd` listens on a private address of the
|
||||
app host that only the backend network reaches and serves HTTPS (TLS
|
||||
1.3). Every operation except the health routes requires `Authorization:
|
||||
Bearer <token>`; the token is a shared random secret of at least 32
|
||||
characters that comes from the deployment secret store, never from this
|
||||
repository. A missing or wrong token answers 401 `unauthenticated`. Plain
|
||||
HTTP exists only behind an explicit development switch.
|
||||
|
||||
Data minimization: a lab request carries only a template reference, a
|
||||
variant seed, and a lifetime. It has no candidate, account, attempt,
|
||||
task, or company identifier. The lab ID is a random UUID chosen by the
|
||||
backend for idempotency. Responses never carry node addresses, MAC
|
||||
addresses, bridge or instance names, keys, or passwords: the backend
|
||||
reaches a node only through a console token and learns a lab's state
|
||||
only through these operations.
|
||||
|
||||
Lifecycle: CreateLab reserves capacity and answers immediately with the
|
||||
lab in `provisioning`; `labd` clones the nodes of the template from
|
||||
prepared snapshots, connects them with per-lab L2-only bridges, boots
|
||||
them, and waits until their management ports answer. The caller polls
|
||||
GetLab until `ready`. Every lab has a fixed `expires_at`; `labd` deletes
|
||||
it at that time even after a restart of its own process, and DeleteLab
|
||||
deletes it earlier. A deleted lab stays readable as `deleted` for a
|
||||
bounded time, then answers 404.
|
||||
|
||||
Capacity: the number of concurrent labs follows the host memory budget of
|
||||
`labd`. A request that does not fit answers 503 `lab_pool_busy` with
|
||||
Retry-After and stores nothing; it is a capacity signal, not an
|
||||
infrastructure failure. `labd` does not queue labs.
|
||||
servers:
|
||||
- url: /
|
||||
security:
|
||||
- bearerAuth: []
|
||||
paths:
|
||||
/healthz:
|
||||
$ref: ./routes/healthz.yml
|
||||
/readyz:
|
||||
$ref: ./routes/readyz.yml
|
||||
/v1/labs/{lab_id}:
|
||||
$ref: ./routes/labs.yml
|
||||
/v1/labs/{lab_id}/console-tokens:
|
||||
$ref: ./routes/lab_console_tokens.yml
|
||||
/v1/labs/{lab_id}/check:
|
||||
$ref: ./routes/lab_check.yml
|
||||
components:
|
||||
securitySchemes:
|
||||
bearerAuth:
|
||||
type: http
|
||||
scheme: bearer
|
||||
description: >-
|
||||
Shared random service token sent as `Authorization: Bearer <token>`
|
||||
over TLS. `labd` compares it in constant time and never logs it.
|
||||
Rotation replaces the secret on both sides; there are no per-user
|
||||
tokens.
|
||||
responses:
|
||||
Problem:
|
||||
$ref: ./components/responses.yml#/Problem
|
||||
@@ -0,0 +1,15 @@
|
||||
get:
|
||||
operationId: GetLabdHealthz
|
||||
summary: Check whether the lab provisioner process is responding.
|
||||
security: []
|
||||
tags:
|
||||
- health
|
||||
responses:
|
||||
"200":
|
||||
description: The process is responding.
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: ../components/schemas.yml#/LabdHealthResponse
|
||||
default:
|
||||
$ref: ../components/responses.yml#/Problem
|
||||
@@ -0,0 +1,31 @@
|
||||
parameters:
|
||||
- $ref: ../components/parameters.yml#/LabId
|
||||
post:
|
||||
operationId: CheckLab
|
||||
summary: Run the checker of the template against the nodes of a ready lab.
|
||||
description: |-
|
||||
The checker of the template connects from the host side of the lab
|
||||
management bridge to the nodes (SSH or the RouterOS API) and evaluates
|
||||
the criteria of the variant that the seed selected. It only reads the
|
||||
node state and never changes it, so a repeated call is harmless; the
|
||||
result is not stored by `labd`. The call is synchronous and bounded by
|
||||
the check timeout of the provisioner.
|
||||
|
||||
The result is checker state for the backend only: the backend scores the
|
||||
lab answer with it and never forwards it to the candidate.
|
||||
|
||||
A lab that is not `ready` answers 409 `state_conflict`. When the
|
||||
checker cannot reach a node or the template has no working checker, the
|
||||
provisioner answers 503 `lab_unavailable`: nothing was evaluated, and the
|
||||
outcome is never a failed check.
|
||||
tags:
|
||||
- checks
|
||||
responses:
|
||||
"200":
|
||||
description: The checker evaluated every criterion.
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: ../components/schemas.yml#/LabCheckResult
|
||||
default:
|
||||
$ref: ../components/responses.yml#/Problem
|
||||
@@ -0,0 +1,46 @@
|
||||
parameters:
|
||||
- $ref: ../components/parameters.yml#/LabId
|
||||
post:
|
||||
operationId: CreateLabConsoleToken
|
||||
summary: Issue a short-lived console token for one node of a ready lab.
|
||||
description: |-
|
||||
The token lets the console gateway of the backend attach to the serial
|
||||
console of one node. It is random, single-use, bound to the lab and the
|
||||
node, and valid for at most 120 seconds; `labd` keeps only its SHA-256
|
||||
digest in memory, so a restart invalidates every unused token. The token
|
||||
is never a node password or an SSH key, and the response carries no node
|
||||
address.
|
||||
|
||||
Attaching: the gateway opens a WebSocket to `attach_path` on the same
|
||||
`labd` origin with the service bearer token and sends the console token
|
||||
in the `X-Lab-Console-Token` header. The WebSocket attach is described
|
||||
here as the planned interface; until it is implemented, `labd` answers
|
||||
the attach path with 501 and issuing a token changes nothing else.
|
||||
|
||||
A lab that is not `ready` answers 409 `state_conflict`; an unknown node
|
||||
answers 400 `validation_failed` with the pointer `/node`.
|
||||
tags:
|
||||
- consoles
|
||||
requestBody:
|
||||
required: true
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: ../components/schemas.yml#/ConsoleTokenRequest
|
||||
responses:
|
||||
"201":
|
||||
description: The token was issued.
|
||||
headers:
|
||||
Cache-Control:
|
||||
description: The token must not be stored by any cache.
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
enum:
|
||||
- no-store
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: ../components/schemas.yml#/ConsoleToken
|
||||
default:
|
||||
$ref: ../components/responses.yml#/Problem
|
||||
@@ -0,0 +1,119 @@
|
||||
parameters:
|
||||
- $ref: ../components/parameters.yml#/LabId
|
||||
put:
|
||||
operationId: CreateLab
|
||||
summary: Create a lab from a template and a variant seed.
|
||||
description: |-
|
||||
Idempotent by `lab_id`:
|
||||
|
||||
- a new ID that fits the capacity reserves it, stores the lab, and answers 202 with `state: provisioning`; the nodes are cloned and booted in the background;
|
||||
- the same ID with the same payload answers 200 with the current state of that lab, including `deleted` or `failed`, and never creates a second one;
|
||||
- the same ID with a different payload answers 422 `idempotency_key_reused` and changes nothing;
|
||||
- a new ID that does not fit the memory budget or the lab limit, or arrives while the provisioner is draining, answers 503 `lab_pool_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.
|
||||
An unknown template or template version, or a lifetime above the
|
||||
configured maximum, answers 400 `validation_failed` with a pointer such
|
||||
as `/template_id` or `/ttl_seconds`.
|
||||
|
||||
The lab is deleted at `expires_at` = creation time + `ttl_seconds`, also
|
||||
when it is still provisioning. A lab that fails to provision or does not
|
||||
answer within the provisioning timeout becomes `failed` and its
|
||||
resources are deleted; its capacity returns when they are gone.
|
||||
|
||||
A record of a deleted or failed lab is kept for a bounded retention time;
|
||||
after it, the ID is unknown again and a CreateLab with it starts a new
|
||||
lab.
|
||||
tags:
|
||||
- labs
|
||||
requestBody:
|
||||
required: true
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: ../components/schemas.yml#/LabCreateRequest
|
||||
examples:
|
||||
two_routers:
|
||||
summary: A lab of a networking template for one attempt item
|
||||
value:
|
||||
template_id: mikrotik-ospf-pair
|
||||
template_version: 1
|
||||
seed: 9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08
|
||||
ttl_seconds: 3600
|
||||
responses:
|
||||
"200":
|
||||
description: A lab with this ID and the same payload already exists.
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: ../components/schemas.yml#/LabStatus
|
||||
"202":
|
||||
description: The lab was accepted and is provisioning.
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: ../components/schemas.yml#/LabStatus
|
||||
examples:
|
||||
provisioning:
|
||||
summary: A lab that is being cloned and booted
|
||||
value:
|
||||
lab_id: 2f1c7a52-0d3e-4b8e-9b61-3c7b1f2e9a40
|
||||
state: provisioning
|
||||
template_id: mikrotik-ospf-pair
|
||||
template_version: 1
|
||||
created_at: "2026-10-11T09:00:00Z"
|
||||
expires_at: "2026-10-11T10:00:00Z"
|
||||
nodes:
|
||||
- name: r1
|
||||
kind: mikrotik
|
||||
- name: r2
|
||||
kind: mikrotik
|
||||
"503":
|
||||
$ref: ../components/responses.yml#/LabPoolBusy
|
||||
default:
|
||||
$ref: ../components/responses.yml#/Problem
|
||||
get:
|
||||
operationId: GetLab
|
||||
summary: Read the state of a lab.
|
||||
description: >-
|
||||
Answers 404 `not_found` for an ID the provisioner does not hold,
|
||||
including a lab whose `deleted` record outlived its retention time. The
|
||||
response never contains an address, a key, or an LXD object name.
|
||||
tags:
|
||||
- labs
|
||||
responses:
|
||||
"200":
|
||||
description: The current state of the lab.
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: ../components/schemas.yml#/LabStatus
|
||||
default:
|
||||
$ref: ../components/responses.yml#/Problem
|
||||
delete:
|
||||
operationId: DeleteLab
|
||||
summary: Delete a lab before its timer.
|
||||
description: >-
|
||||
Marks the lab for deletion and answers 202 with `state: deleting`; the
|
||||
provisioner removes its instances and bridges in the background and
|
||||
retries until LXD confirms that they are gone, also across its own
|
||||
restarts. Deleting a lab that is already `deleting` or `deleted`
|
||||
answers 200 with its state and changes nothing. An unknown ID answers
|
||||
404 `not_found`.
|
||||
tags:
|
||||
- labs
|
||||
responses:
|
||||
"200":
|
||||
description: The lab was already being deleted or is deleted.
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: ../components/schemas.yml#/LabStatus
|
||||
"202":
|
||||
description: The lab is being deleted.
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: ../components/schemas.yml#/LabStatus
|
||||
default:
|
||||
$ref: ../components/responses.yml#/Problem
|
||||
@@ -0,0 +1,26 @@
|
||||
get:
|
||||
operationId: GetLabdReadyz
|
||||
summary: Check whether the provisioner can create and delete labs.
|
||||
description: >-
|
||||
Ready means that the lab records were loaded, the startup reconciliation
|
||||
with LXD finished, the LXD API answered the latest probe, and the process
|
||||
is not draining. A provisioner without free capacity is still ready;
|
||||
capacity is reported by CreateLab.
|
||||
security: []
|
||||
tags:
|
||||
- health
|
||||
responses:
|
||||
"200":
|
||||
description: The provisioner is ready.
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: ../components/schemas.yml#/LabdReadinessResponse
|
||||
"503":
|
||||
description: The provisioner is not ready or is draining.
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: ../components/schemas.yml#/LabdReadinessResponse
|
||||
default:
|
||||
$ref: ../components/responses.yml#/Problem
|
||||
Reference in new issue
Block a user