feat(assessment): record capture hints and keep one window per attempt

This commit is contained in:
shira committed 2026-10-11 13:16:52 +03:00
1 parent c975a0d506
commit bb917bf62e
108 files changed
+6649 -139

No files matched your search

+143
View File
@@ -1014,6 +1014,8 @@ paths:
If the attempt deadline or session budget has passed, this command commits the due terminal transition and returns the resulting attempt. A pending practice submitted before the limit is graded first. `GetMyAssessmentAttempt` and `GetMyAssessmentResult` remain read-only: they never start a session or commit a due transition. A background transition may persist a due outcome independently; after that, this command returns the stored terminal attempt without changing it.
One page at a time. While another page holds the work session of this attempt (HoldMyAssessmentWorkSession), a request from a different `X-Attempt-Client`, or from none, answers 409 `state_conflict` and changes nothing; the client tells the candidate that the attempt is open in another window. That refusal is not stored under the Idempotency-Key, because it lasts only until the other page closes or stops renewing. A real attempt that nobody holds is not refused.
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. An employer account answers 403 forbidden; no operation gives an employer answers, qualification evidence, or attempt history.
security:
- sessionCookie: []
@@ -1023,6 +1025,7 @@ paths:
parameters:
- $ref: '#/components/parameters/AssessmentAttemptId'
- $ref: '#/components/parameters/IdempotencyKey'
- $ref: '#/components/parameters/AttemptClient'
requestBody:
required: true
content:
@@ -1116,6 +1119,81 @@ paths:
$ref: '#/components/responses/TooManyRequests'
default:
$ref: '#/components/responses/Problem'
/api/v1/me/assessment-attempts/{attempt_id}/work-session:
put:
operationId: HoldMyAssessmentWorkSession
summary: Hold the single active work session of a real assessment attempt for this page.
description: |-
Requires a candidate session, its CSRF token in X-CSRF-Token, an allowed Origin, and the `X-Attempt-Client` header of the page. A real attempt (`root` or `corrective`) allows one open page at a time. The page that works on the attempt calls this operation when the candidate starts or resumes work and then repeats it every `renew_after_seconds`; each call holds the work session until `held_until`.
- If nobody holds the work session, the previous holder released it, or its hold expired, the page becomes the holder and the answer is 200.
- If the same page holds it, the hold is renewed and the answer is 200.
- If another page holds it, the answer is 409 `state_conflict` and nothing changes: the second page is refused until the first one releases the session (ReleaseMyAssessmentWorkSession) or stops renewing and its hold expires. The client tells the candidate that the attempt is open in another window and does not show the task.
The same 409 answers a terminal or expired attempt and a `demo_express` attempt, which has no protected work session. The hold is a one-page-at-a-time rule, not a lock on the candidate: a candidate who closes a page, reloads, or opens the attempt on another device can continue when the hold is released or has expired (at most two minutes after the last renewal). It is not a security boundary: a client that never calls this operation is refused only while another page holds the session. The server stores one-way keyed digests of the page identifier and of the User-Agent, bound to the attempt; it never stores or returns either value. A change of the User-Agent digest during an attempt is a weak server signal for a manual review, never an automatic decision.
Order of checks: session (401), CSRF and Origin (403 csrf_check_failed), request validation (400), account scenario (403 forbidden), the attempt (404 not_found for an unknown attempt or one of another candidate), then the hold (409 state_conflict).
security:
- sessionCookie: []
sessionCsrf: []
tags:
- assessment
parameters:
- $ref: '#/components/parameters/AssessmentAttemptId'
- $ref: '#/components/parameters/AttemptClientRequired'
responses:
'200':
description: The page holds the work session until `held_until`.
headers:
Cache-Control:
$ref: '#/components/headers/CacheControlNoStore'
content:
application/json:
schema:
$ref: '#/components/schemas/AssessmentWorkSession'
'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'
default:
$ref: '#/components/responses/Problem'
delete:
operationId: ReleaseMyAssessmentWorkSession
summary: Release the work session that this page holds.
description: |-
Requires a candidate session, its CSRF token in X-CSRF-Token, an allowed Origin, and the `X-Attempt-Client` header of the page. The page calls it when it closes, so that the candidate can open the attempt in another window at once instead of waiting for the hold to expire. The request is idempotent and reveals nothing: it answers 204 whether this page held the session, another page holds it (which stays held), nobody held it, or the attempt is not held at all, and a repeat after a lost response succeeds. A page that is killed without calling it loses the hold within two minutes.
Order of checks: session (401), CSRF and Origin (403 csrf_check_failed), request validation (400), account scenario (403 forbidden), the attempt (404 not_found for an unknown attempt or one of another candidate), then the release (204).
security:
- sessionCookie: []
sessionCsrf: []
tags:
- assessment
parameters:
- $ref: '#/components/parameters/AssessmentAttemptId'
- $ref: '#/components/parameters/AttemptClientRequired'
responses:
'204':
description: This page no longer holds the work session.
headers:
Cache-Control:
$ref: '#/components/headers/CacheControlNoStore'
'400':
$ref: '#/components/responses/ValidationFailed'
'401':
$ref: '#/components/responses/Unauthenticated'
'403':
$ref: '#/components/responses/CsrfCheckFailedOrForbidden'
'404':
$ref: '#/components/responses/NotFound'
default:
$ref: '#/components/responses/Problem'
/api/v1/me/assessment-attempts/{attempt_id}/answers:
post:
operationId: SubmitMyAssessmentAnswer
@@ -1129,6 +1207,8 @@ paths:
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.
One page at a time. While another page holds the work session of this attempt (HoldMyAssessmentWorkSession), a request from a different `X-Attempt-Client`, or from none, answers 409 `state_conflict` and stores nothing, so a second window cannot answer. That refusal is not stored under the Idempotency-Key and is checked before the stored answer is replayed.
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.
@@ -1146,6 +1226,7 @@ paths:
parameters:
- $ref: '#/components/parameters/AssessmentAttemptId'
- $ref: '#/components/parameters/IdempotencyKey'
- $ref: '#/components/parameters/AttemptClient'
requestBody:
required: true
content:
@@ -5806,6 +5887,7 @@ components:
- $ref: '#/components/schemas/AssessmentFocusLossSignal'
- $ref: '#/components/schemas/AssessmentClipboardSignal'
- $ref: '#/components/schemas/AssessmentFullscreenExitSignal'
- $ref: '#/components/schemas/AssessmentCaptureSignal'
discriminator:
propertyName: kind
mapping:
@@ -5814,6 +5896,8 @@ components:
paste: '#/components/schemas/AssessmentClipboardSignal'
cut: '#/components/schemas/AssessmentClipboardSignal'
fullscreen_exit: '#/components/schemas/AssessmentFullscreenExitSignal'
screenshot_key: '#/components/schemas/AssessmentCaptureSignal'
devtools_open: '#/components/schemas/AssessmentCaptureSignal'
AssessmentFocusLossSignal:
type: object
additionalProperties: false
@@ -10773,6 +10857,40 @@ components:
- task_language
- root_attempt_id
- chain_deadline
AssessmentCaptureSignal:
type: object
description: 'A hint that the screen may be captured or inspected. `screenshot_key` is a key or key combination that the browser saw and that usually takes a screenshot (PrintScreen, Cmd+Shift+3, 4, or 5 on macOS, Win+Shift+S); `devtools_open` is the result of a heuristic that guesses that the developer tools are open (a docked panel changes the window size, or the console reads an object). Both are weak: a browser does not see every screenshot, an operating system can take one without a key the page sees, a phone photo is invisible to the page, and the heuristic gives false positives. They lead to attention in a manual review at most, never to a score change, and they carry no measurement.'
additionalProperties: false
required:
- kind
- item_instance_id
- occurred_at
properties:
kind:
type: string
enum:
- screenshot_key
- devtools_open
item_instance_id:
$ref: '#/components/schemas/AssessmentItemId'
occurred_at:
$ref: '#/components/schemas/Timestamp'
AssessmentWorkSession:
type: object
description: The work session of a real attempt that the calling page holds. It is a one-page-at-a-time rule for the attempt, not a score or a signal, and it changes no result.
additionalProperties: false
required:
- held_until
- renew_after_seconds
properties:
held_until:
$ref: '#/components/schemas/Timestamp'
renew_after_seconds:
type: integer
format: int32
minimum: 1
maximum: 3600
description: How often the page repeats the hold. It is well below the hold time, so a page whose timer is slowed down in the background still renews before its hold expires.
AssessmentFinalizeConflictProblem:
type: object
description: A finalize state conflict. `pending_item_ids` is present only when the attempt still has required questions without answers; it is omitted for other state conflicts and idempotency conflicts.
@@ -11719,6 +11837,31 @@ components:
type: string
format: uuid
example: 01928f7a-8b9c-7d0e-9f1a-2b3c4d5e6f70
AttemptClient:
name: X-Attempt-Client
in: header
required: false
description: |-
Random identifier that one open page of the assessment attempt generates when it loads and keeps until it closes, 16 to 64 characters of `A-Za-z0-9_-`. It names the page that holds the single active work session of the attempt (see HoldMyAssessmentWorkSession). The server keeps only a one-way keyed digest bound to the attempt, never the value.
A request that omits the header counts as one anonymous client. It is refused with 409 `state_conflict` while another page holds the work session, and it is accepted while nobody does, so a client that predates the header keeps working until a page holds the session.
schema:
type: string
minLength: 16
maxLength: 64
pattern: ^[A-Za-z0-9_-]+$
example: 7mK2pQx9Rt4vWc1Zb8NfYd3Ha6Js0LeG
AttemptClientRequired:
name: X-Attempt-Client
in: header
required: true
description: The page identifier described at AttemptClient. It is required here because the operation exists to hold or release the work session of one page.
schema:
type: string
minLength: 16
maxLength: 64
pattern: ^[A-Za-z0-9_-]+$
example: 7mK2pQx9Rt4vWc1Zb8NfYd3Ha6Js0LeG
CandidateHandle:
name: candidate_handle
in: path