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
@@ -253,6 +253,73 @@ func (UnimplementedHandler) CreateMyAssessmentAttempt(ctx context.Context, req A
|
||||
return r, ht.ErrNotImplemented
|
||||
}
|
||||
|
||||
// CreateMyAssessmentLab implements CreateMyAssessmentLab operation.
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// POST /api/v1/me/assessment-attempts/{attempt_id}/labs
|
||||
func (UnimplementedHandler) CreateMyAssessmentLab(ctx context.Context, req *AssessmentLabCreate, params CreateMyAssessmentLabParams) (r CreateMyAssessmentLabRes, _ error) {
|
||||
return r, ht.ErrNotImplemented
|
||||
}
|
||||
|
||||
// CreateMyAssessmentLabConsoleSession implements CreateMyAssessmentLabConsoleSession operation.
|
||||
//
|
||||
// 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).
|
||||
//
|
||||
// POST /api/v1/me/assessment-attempts/{attempt_id}/labs/{lab_id}/console-sessions
|
||||
func (UnimplementedHandler) CreateMyAssessmentLabConsoleSession(ctx context.Context, req *AssessmentLabConsoleSessionCreate, params CreateMyAssessmentLabConsoleSessionParams) (r CreateMyAssessmentLabConsoleSessionRes, _ error) {
|
||||
return r, ht.ErrNotImplemented
|
||||
}
|
||||
|
||||
// CreateMyAssessmentPracticeRun implements CreateMyAssessmentPracticeRun operation.
|
||||
//
|
||||
// Requires the session cookie of a candidate account, the CSRF token of that session in X-CSRF-Token,
|
||||
@@ -725,6 +792,22 @@ func (UnimplementedHandler) GetMyAssessmentAvailability(ctx context.Context) (r
|
||||
return r, ht.ErrNotImplemented
|
||||
}
|
||||
|
||||
// GetMyAssessmentLab implements GetMyAssessmentLab operation.
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// GET /api/v1/me/assessment-attempts/{attempt_id}/labs/{lab_id}
|
||||
func (UnimplementedHandler) GetMyAssessmentLab(ctx context.Context, params GetMyAssessmentLabParams) (r GetMyAssessmentLabRes, _ error) {
|
||||
return r, ht.ErrNotImplemented
|
||||
}
|
||||
|
||||
// GetMyAssessmentPracticeRun implements GetMyAssessmentPracticeRun operation.
|
||||
//
|
||||
// Requires the session cookie of a candidate account. Returns the state of a debug run started with
|
||||
@@ -2252,6 +2335,10 @@ func (UnimplementedHandler) StartMyAssessmentAttemptSession(ctx context.Context,
|
||||
// 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.
|
||||
//
|
||||
@@ -2313,6 +2400,40 @@ func (UnimplementedHandler) SubmitMyAssessmentAnswer(ctx context.Context, req *A
|
||||
return r, ht.ErrNotImplemented
|
||||
}
|
||||
|
||||
// SubmitMyAssessmentLab implements SubmitMyAssessmentLab operation.
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// POST /api/v1/me/assessment-attempts/{attempt_id}/labs/{lab_id}/submission
|
||||
func (UnimplementedHandler) SubmitMyAssessmentLab(ctx context.Context, req *AssessmentLabSubmission, params SubmitMyAssessmentLabParams) (r SubmitMyAssessmentLabRes, _ error) {
|
||||
return r, ht.ErrNotImplemented
|
||||
}
|
||||
|
||||
// UnhideOrganization implements UnhideOrganization operation.
|
||||
//
|
||||
// Requires the session cookie of a candidate account, the CSRF token of that session in X-CSRF-Token,
|
||||
|
||||
Reference in new issue
Block a user