feat(assessment): watermark the task text of real attempts
This commit is contained in:
1 parent
24b64d698a
commit
c975a0d506
57 files changed
+2429
-92
No files matched your search
@@ -697,6 +697,19 @@ Code: migration `backend/db/migrations/00033_create_assessment_signal_review.sql
|
||||
- When and how. The review never runs in a candidate's transaction. The first accepted answer schedules the job `assessment.signal_review` with the key `<attempt>:deadline`, due one minute after the deadline of the attempt (so an answer committed right at the deadline is in its facts), and finalization schedules `<attempt>:ended`, due at once; both are inserts into `scheduled_jobs` in the transaction of the answer or the finalization, and repeats do nothing. The deadline job also covers an attempt that expires or is abandoned, however and whenever its state changes. A review is a point-in-time evaluation: it describes the facts committed when its job ran, and the job at the deadline runs it again for a finalized attempt, which picks up later matches. The job computes the review of its attempt and refreshes the review of every other attempt that has ended (terminal state or past its deadline) and shares answers with it at the attention level or above, at most 50 per job; a ring of more than 50 attempts that share answers is covered because each member runs its own deadline job and sees the others. An attempt that is still running is flagged by its own job when it ends and sees the other facts then. Writers are ordered by a transaction-scoped advisory lock per review: the job locks the review of every attempt it will write, in ascending attempt order, before it reads any fact, so the later of two jobs over one attempt waits and then reads what the earlier committed (no lost update, and no lock cycle). The times of a review come from the database clock inside the upsert and the update time never falls behind the stored times. Nothing else is locked: the facts are append-only and a job is scheduled after its facts are committed. A failure is retried by the runner with backoff and can never block or change a result; without the worker (`JOBS_ENABLED=false`) reviews wait with their jobs. The only review statement in a candidate's transaction is the insert of the job (and the two counter updates of the answer). The job logs one line with the number of reviews it wrote and its duration, and no answer, address, or candidate. Applicability bound: the share is read from the counters in constant time, but the comparison joins the answers of the attempt with the answers that hold the same values, so its cost grows with the number of holders of popular values, at most 23 items times the holders of each; it is fine for background jobs on populations of up to about 100,000 answers per family and needs sampling or a cap above that.
|
||||
- Limits. Browser signals can be forged or suppressed, so they are a hint only. The client measures of the attempt page (fullscreen, covering the task, blocking copy, selection, print, and paste) stop only the casual route: the task text is in the candidate's browser, so a screenshot, a second device, or an extension takes it out, and they change no score by themselves. A helper such as an LLM on another device is not visible. False positives are possible: a shared or changing network (mobile data, NAT), a reload, two tabs, copying the task text, and coinciding answers of a small answer space. The retention period of these facts, whether collecting them needs a separate consent beyond the notice, and who calibrates the thresholds are not decided.
|
||||
|
||||
### Watermark of the task text
|
||||
|
||||
Implemented for real attempts (root and corrective). A training run (`demo_express`) carries no watermark. The watermark ties a leaked statement, a screenshot, or a photo of the screen back to an attempt so that a person can review it; it does not stop any of them. Code: `backend/internal/domain/assessment_watermark.go` and `assessment_wording.go` (the mark and the table of interchangeable phrases), `backend/internal/usecase/assessment/watermark.go` (`Watermarker`), `Keyring.AssessmentWatermarkSeed` in `usecase/identity/keyring.go`, the hook `AssessmentHandler.WithPresenter` in the HTTP adapter, and `frontend/src/features/assessment-watermark/`.
|
||||
|
||||
- Where the mark is made. Only in the response, never in storage: the stored variant, its reference answer, and the retained idempotent responses stay unmarked, and grading reads the stored variant. Every response that carries an attempt (creation, read, session start, answer, finalize) passes the presenter, so one attempt shows the same code and the same marked text on every read and replay. If the mark cannot be made the response is a 500 and never an unmarked task text.
|
||||
- The key. The seed of an attempt is HMAC-SHA-256 of the attempt identifier under a key derived from `IDENTITY_KEY_SECRET` with its own label (`lincodex/assessment/watermark/v1`); no new secret exists. The code, the invisible mark, and the choice of wordings are all read from this seed on the server, and neither the seed nor the key is sent to a client. Changing `IDENTITY_KEY_SECRET` changes the code and the wordings of every attempt, so a text or a screenshot of an attempt issued before the change can no longer be traced.
|
||||
- Visible channel. `AssessmentAttempt.watermark.code` is 10 symbols of Crockford base32 (50 bits of the seed) shown as `XXXXX-XXXXX`. It is a pseudonym: it holds no name, contact, or identifier of the account and cannot be computed without the secret. The attempt page draws it with the time (UTC, to the minute, from the clock of the device) as a faint tile over the whole task screen: fixed, opacity 0.07, no pointer events, hidden from assistive technology. It survives a screenshot or a photo and is removed by a tool that edits the page.
|
||||
- Invisible channel. The statement carries the same code as 25 base-4 digits and one check digit written in four zero-width characters (U+200B, U+200C, U+200D, U+2060), repeated after the first space and at the start of each following sentence (at most 8 copies), so a copy of a paragraph keeps a whole run and a damaged run is ignored. It survives a copy of the page text, a saved page, and an API response. Many chat, mail, and OCR tools drop zero-width characters, and a retyped text has none.
|
||||
- Wording channel. `assessmentWordingGroups` lists about 18 groups of interchangeable phrases of plain connective prose (`at most` and `no more than` before a number, `is not` and `isn't`, `non-decreasing` and `nondecreasing`, and the like, with Russian groups). Each attempt writes every group in the form its seed picks. The table is append-only because reordering it changes the choice of attempts already served; a group avoids terms that a statement defines and then reuses, and the number groups apply only before a digit. The channel survives retyping and OCR, and it is weak: a statement holds a few groups, and a group is worth about one bit, so it only tells attempts apart that were served the same variant text.
|
||||
- The meaning does not change. The tests compare the canonical text of two attempts that were served one variant (the mark and the phrases removed or mapped back) and find them equal, check that the reference answer belongs to the variant and is not touched by marking, that marking twice gives the same text, and that the number and data tokens of the statement stay in the accessible text.
|
||||
- Accessibility. Some speech synthesizers and braille displays may announce zero-width characters or break a word at them; this was not tested with a real screen reader. The page therefore puts every run of invisible characters in an `aria-hidden` element: the accessibility tree holds the words only (a Playwright check reads the tree with `ariaSnapshot`, and a Vitest check strips the hidden elements from the markup), while the document keeps the characters so that anything copied from it carries the mark. The wordings are ordinary words, and no whitespace variants are used, because a non-breaking space is not guaranteed to be silent everywhere.
|
||||
- What it does not do. A screenshot, a photo of the screen, or retyping cannot be prevented in a browser. The watermark is evidence for a manual review and an appeal, never an automatic decision; no operation shows it to an employer, and the candidate sees only the code of their own attempt.
|
||||
|
||||
### Skill evidence
|
||||
|
||||
Implemented as a stored projection of the immutable assessment results, with two reads: the candidate's own list and the permitted projection of a currently visible card. The match search reads the organization projection (see [Matching and explanations](#matching-and-explanations)); no percentile reads it yet.
|
||||
|
||||
Reference in new issue
Block a user