feat(api): add candidate assessment attempt contract
This commit is contained in:
1 parent
6c86c4e559
commit
565ef8d4f5
100 files changed
+30314
-74
No files matched your search
@@ -35,6 +35,91 @@ type Handler interface {
|
||||
//
|
||||
// POST /api/v1/identity/email-verifications
|
||||
ConfirmEmail(ctx context.Context, req *EmailVerificationRequest) (ConfirmEmailRes, error)
|
||||
// CreateMyAssessmentAttempt implements CreateMyAssessmentAttempt 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 category, a specialization of the
|
||||
// questionnaire and a target grade, and the task language. The server picks the mode from the
|
||||
// published bank, `demo_basic` or `adaptive`, and fixes the policy, bank, and algorithm versions, the
|
||||
// time and session limits, and the item variants in one transaction; the client never sends a mode, a
|
||||
// seed, or a version. Creation starts session 1. The self-assessed grade only chooses where the test
|
||||
// starts and adds no points. An adaptive retest starts from the previous ability estimate of the
|
||||
// specialization, adjusted for the time passed, so a new attempt adds evidence instead of starting the
|
||||
// measurement over.
|
||||
//
|
||||
// A specialization has at most one active attempt. A new attempt cannot start while one is active,
|
||||
// during a retry or promotion interval or past the attempt limit of the policy, or when the bank is
|
||||
// insufficient; each answers 409 state_conflict and creates nothing, not even a placeholder attempt.
|
||||
// GetMyAssessmentAvailability tells which case applies and when a blocked attempt opens. After a
|
||||
// failure, including the first test, a lower grade can be tested at once. An attempt that ends as
|
||||
// `expired` or with the reason `practice_incomplete` counts toward the attempt limit and starts the
|
||||
// same-grade retry interval; one that ends as `insufficient_bank` or with the reason
|
||||
// `sandbox_unavailable` counts toward neither.
|
||||
//
|
||||
// The limits are server-side: `expires_at` and `sessions` come from the policy version, the client
|
||||
// clock never extends them, and after them the attempt accepts no command. Within them the attempt is
|
||||
// also bounded by the item limit of the policy.
|
||||
//
|
||||
// Idempotency: a retry with the same key and body within 24 hours replays the stored 201 or 409
|
||||
// state_conflict response and creates nothing, so a lost response never creates a second attempt. A
|
||||
// different body with the same key answers 422 idempotency_key_reused. 400 is never stored, so a
|
||||
// corrected retry is evaluated again.
|
||||
//
|
||||
// Order of checks: session (401), CSRF and Origin (403 csrf_check_failed), request validation (400),
|
||||
// account scenario (403 forbidden for an employer), the Idempotency-Key (422, 409
|
||||
// idempotency_in_progress, replay), domain rules (400 with a pointer, for example `/specialization`
|
||||
// for a specialization that is not in the questionnaire or `/task_language` for a language that the
|
||||
// bank does not offer), then availability (409 state_conflict). The rate limit can answer 429 with
|
||||
// Retry-After before any of them; it is not stored.
|
||||
//
|
||||
// POST /api/v1/me/assessment-attempts
|
||||
CreateMyAssessmentAttempt(ctx context.Context, req *AssessmentAttemptCreate, params CreateMyAssessmentAttemptParams) (CreateMyAssessmentAttemptRes, error)
|
||||
// FinalizeMyAssessmentAttempt implements FinalizeMyAssessmentAttempt 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. Finalize always answers with the attempt, never with the
|
||||
// result: the decision may continue the attempt, and one response type keeps that unambiguous for
|
||||
// every generated client. When the returned state is `completed`, the client reads the result with
|
||||
// GetMyAssessmentResult.
|
||||
//
|
||||
// Allowed in `ready_to_finalize`, where every required part is done, and in
|
||||
// `additional_practice_pending` while the additional practice is `not_started` or `failed`. The server
|
||||
// decides from the stored answers with the policy, bank, and algorithm versions fixed at creation:
|
||||
//
|
||||
// - `demo_basic` compares the raw score with the pass mark of the recorded basic grading policy and
|
||||
// completes the attempt. It never offers an additional practice.
|
||||
// - `adaptive` applies the probability bands of the recorded policy. Confirmation or rejection
|
||||
// completes the attempt. A probability in the band below confirmation (0.50 to below 0.80 in the
|
||||
// demo policy) on the first finalize, while time and sessions remain, completes nothing: the server
|
||||
// appends an `additional` practice, moves the attempt to `additional_practice_pending`, and answers
|
||||
// 200 with it. The additional practice continues the same attempt, keeps its limits, and spends no
|
||||
// new attempt. The next finalize, after its verdict, decides with the added evidence; a probability
|
||||
// still below confirmation gives `not_confirmed`. An attempt offers at most one additional
|
||||
// practice.
|
||||
// - Finalize in `additional_practice_pending` declines the offer and gives `not_confirmed` with the
|
||||
// current evidence. A retry of the first finalize with a new key cannot decline by accident: it
|
||||
// carries the version from before the offer and answers 412.
|
||||
//
|
||||
// A failed attempt never lowers a confirmed grade. Repeats return the same outcome: a retry with the
|
||||
// same Idempotency-Key replays the stored response, and a finalize of a `completed` attempt answers
|
||||
// 200 with that attempt even with a new key or an older `expected_version`; the result is computed
|
||||
// once. When `expires_at` passes or the session limit is reached, the server finalizes
|
||||
// `ready_to_finalize` itself, without offering an additional practice, so a finalize after that also
|
||||
// answers 200 with the `completed` attempt.
|
||||
//
|
||||
// An attempt in `in_progress` or `practice_pending`, one with a practice verdict `pending`, or one
|
||||
// that ended as `expired` or `insufficient_bank` answers 409 state_conflict. The problem does not list
|
||||
// what is unfinished; the attempt shows it in `state`, `progress`, `current_item`, and `practices`. A
|
||||
// stale `expected_version` answers 412 version_conflict, the repository status for a stale version.
|
||||
//
|
||||
// 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 (404 not_found, after any due transition), the repeat on a `completed` attempt (200),
|
||||
// the version (412), then the state (409 state_conflict). 404 and 409 state_conflict are stored under
|
||||
// the key; 400 and 412 are not.
|
||||
//
|
||||
// POST /api/v1/me/assessment-attempts/{attempt_id}/finalize
|
||||
FinalizeMyAssessmentAttempt(ctx context.Context, req *AssessmentFinalization, params FinalizeMyAssessmentAttemptParams) (FinalizeMyAssessmentAttemptRes, error)
|
||||
// GetConsentText implements GetConsentText operation.
|
||||
//
|
||||
// Public operation without a session. Returns the current text of a consent that is given before an
|
||||
@@ -71,6 +156,71 @@ type Handler interface {
|
||||
//
|
||||
// GET /api/v1/healthz
|
||||
GetHealthz(ctx context.Context) (*HealthResponse, error)
|
||||
// GetMyAssessmentAttempt implements GetMyAssessmentAttempt operation.
|
||||
//
|
||||
// Requires the session cookie of a candidate account. Returns the attempt with its state, fixed
|
||||
// versions, time and session limits, progress, the item to answer now, and the practices. A reload, a
|
||||
// retried request, or a new session returns the same item instance with the same text and option
|
||||
// order; a lost connection never creates a new attempt. The response never says whether an earlier
|
||||
// answer was correct and never contains answer keys, item scores, family or variant identifiers,
|
||||
// seeds, hidden checks, or anti-cheat signals.
|
||||
//
|
||||
// Reading an active attempt counts as activity: after the previous session ended it starts the next
|
||||
// session, and when that would exceed the session limit it starts none and the attempt becomes
|
||||
// `expired`. Before it answers, the server commits any transition that is due, with a new version:
|
||||
// past `expires_at`, `ready_to_finalize` becomes `completed`, an unsubmitted additional practice is
|
||||
// declined and the attempt becomes `completed`, and the other active states become `expired`; a
|
||||
// practice still `pending` is graded first. The client polls this operation while a practice is
|
||||
// `pending`. Reading a terminal attempt changes nothing.
|
||||
//
|
||||
// The attempt must belong to the candidate of the session: an attempt of another candidate answers 404
|
||||
// not_found, the same as an unknown identifier, so identifiers cannot be probed. An employer account
|
||||
// answers 403 forbidden; no operation gives an employer the answers or the attempt history.
|
||||
//
|
||||
// GET /api/v1/me/assessment-attempts/{attempt_id}
|
||||
GetMyAssessmentAttempt(ctx context.Context, params GetMyAssessmentAttemptParams) (GetMyAssessmentAttemptRes, error)
|
||||
// GetMyAssessmentAvailability implements GetMyAssessmentAvailability operation.
|
||||
//
|
||||
// Requires the session cookie of a candidate account; the candidate comes from the session. For each
|
||||
// specialization of the questionnaire, returns the confirmed grade, the active attempt, and for every
|
||||
// grade whether an attempt can start now, in which mode, and with which limits: the time limit, the
|
||||
// session limit, the item limit, and whether a code practice is required. The client shows them before
|
||||
// the start, together with the method and the signals that are collected, and resumes an active
|
||||
// attempt by `active_attempt_id`, for example after it lost the response of CreateMyAssessmentAttempt.
|
||||
//
|
||||
// `insufficient_bank` is the state of a category whose bank is not published or has too few families
|
||||
// that this candidate has not seen; the server limits attempts instead of repeating families.
|
||||
// `cooldown` carries the date when the attempt opens, so the client can explain a blocked attempt with
|
||||
// that date and offer support. Specializations and their retry intervals are independent. Attempts
|
||||
// that ended as `insufficient_bank` or with the reason `sandbox_unavailable` are platform limitations
|
||||
// and never cause a `cooldown`.
|
||||
//
|
||||
// A missing, unknown, expired, or revoked session answers 401 unauthenticated; an employer account
|
||||
// answers 403 forbidden.
|
||||
//
|
||||
// GET /api/v1/me/assessment-availability
|
||||
GetMyAssessmentAvailability(ctx context.Context) (GetMyAssessmentAvailabilityRes, error)
|
||||
// GetMyAssessmentResult implements GetMyAssessmentResult operation.
|
||||
//
|
||||
// Requires the session cookie of a candidate account. Returns the immutable result of a terminal
|
||||
// attempt: `completed`, `expired`, or `insufficient_bank`. It records the mode, the policy, bank, and
|
||||
// algorithm versions, the decision, the previously confirmed grade, the calibration status and
|
||||
// limitations of the method, the uncertainty where the method computes it, the practice verdicts, the
|
||||
// weak domains, the working time as a separate label, and the next steps that the server allows. A
|
||||
// later policy, bank, or algorithm version never changes it.
|
||||
//
|
||||
// Fields that the method does not compute are null and never zero: a `demo_basic` result has null
|
||||
// `uncertainty` and `strength`. The result never contains answers, per-item correctness, answer keys,
|
||||
// seeds, hidden checks, or anti-cheat signals.
|
||||
//
|
||||
// An active attempt answers 409 state_conflict; an attempt in `additional_practice_pending` is active
|
||||
// and has no result yet. The server first commits any due transition, so an attempt past its limits is
|
||||
// read as terminal. An attempt of another candidate answers 404 not_found, the same as an unknown
|
||||
// identifier. An employer account answers 403 forbidden; employers see only the current category
|
||||
// through a separate projection, never this result or the attempt history.
|
||||
//
|
||||
// GET /api/v1/me/assessment-attempts/{attempt_id}/result
|
||||
GetMyAssessmentResult(ctx context.Context, params GetMyAssessmentResultParams) (GetMyAssessmentResultRes, error)
|
||||
// GetMyQuestionnaire implements GetMyQuestionnaire operation.
|
||||
//
|
||||
// Requires the session cookie of a candidate account. The candidate comes from the session, never from
|
||||
@@ -234,6 +384,63 @@ type Handler interface {
|
||||
//
|
||||
// PUT /api/v1/me/questionnaire
|
||||
SaveMyQuestionnaire(ctx context.Context, req *CandidateQuestionnaireUpdate) (SaveMyQuestionnaireRes, error)
|
||||
// SubmitMyAssessmentAnswer implements SubmitMyAssessmentAnswer 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 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.
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// Practice: an answer with format `practice` submits the solution of the main or the additional
|
||||
// practice. It is stored, and the sandbox runs it asynchronously against the hidden check groups; the
|
||||
// response shows the practice `pending`, and the client polls GetMyAssessmentAttempt for the verdict.
|
||||
// Only the score 0-3 and the pass state of each group are shown, never the checks, error output, or
|
||||
// seeds. Every outcome caused by the solution, such as a compilation error, a crash, or a time or
|
||||
// memory limit, is a `finished` verdict. A `failed` verdict means only that the sandbox infrastructure
|
||||
// could not run it; it consumes nothing. After `finished` the practice accepts no other solution, so
|
||||
// hidden group results cannot be used to tune it. Debug runs of the candidate's own tests and the
|
||||
// public examples are unlimited apart from the sandbox rate limit and never show hidden group results;
|
||||
// they are planned as a separate operation.
|
||||
//
|
||||
// Repeats and conflicts, per item:
|
||||
//
|
||||
// - A retry with the same Idempotency-Key and body within 24 hours replays the stored response.
|
||||
// - Sending the answer already stored for the item again, even with a new key or an older
|
||||
// `expected_version`, stores nothing, keeps the version, and answers 200 with the current attempt.
|
||||
// Each answer format defines equality: sets for `option_ids` and `line_numbers`, the exact sequence
|
||||
// for `element_ids`, numeric equality for `number`, identical text without normalization for `text`
|
||||
// and `config`, and the same language with identical source for a practice.
|
||||
// - A different answer for an item that already has one answers 409 state_conflict when
|
||||
// `expected_version` is current; with a stale version the version check comes first and answers
|
||||
// 412.
|
||||
// - Exception for a practice whose latest verdict is `failed`: the repeat rule does not apply. A
|
||||
// submission with the same or a different solution, with the current `expected_version`, queues it
|
||||
// again and advances the version.
|
||||
//
|
||||
// Optimistic concurrency: `expected_version` must equal the current attempt version, otherwise the
|
||||
// server answers 412 version_conflict and stores nothing; the client reads the attempt again. 412 is
|
||||
// the repository status for a stale version, also used by SaveMyQuestionnaire; 409 state_conflict is
|
||||
// kept for commands that the attempt state does not allow at the current version.
|
||||
//
|
||||
// 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 (404 not_found for an unknown attempt or one of another candidate; the server first
|
||||
// commits any due transition such as expiry, and the request counts as activity for the session
|
||||
// limit), the repeat of the stored answer (200, skipped for a practice whose latest verdict is
|
||||
// `failed`), the version (412), the state (409 state_conflict: the attempt is terminal, the item is
|
||||
// not current, the item has a different answer, or the practice verdict is pending or finished), then
|
||||
// the answer against the item (400 with a pointer such as `/answer/format` or `/answer/option_ids/0`).
|
||||
// Following the Idempotency-Key convention, 404 and 409 state_conflict are stored under the key and
|
||||
// replayed; 400, 412, 429, and 5xx are not. The rate limit can answer 429 with Retry-After before any
|
||||
// check.
|
||||
//
|
||||
// POST /api/v1/me/assessment-attempts/{attempt_id}/answers
|
||||
SubmitMyAssessmentAnswer(ctx context.Context, req *AssessmentAnswerSubmission, params SubmitMyAssessmentAnswerParams) (SubmitMyAssessmentAnswerRes, error)
|
||||
// NewError creates *ProblemStatusCode from error returned by handler.
|
||||
//
|
||||
// Used for common default response.
|
||||
|
||||
Reference in new issue
Block a user