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

+1
View File
@@ -441,6 +441,7 @@ make -C backend assessment-review ARGS='inspect --attempt <uuid> --actor operato
- Every read is recorded in `assessment_review_reads` (attempt ID, actor handle, found or missing, database time) in the same transaction as the read, also when the attempt has no review. The table refuses UPDATE, DELETE, and TRUNCATE. The actor is an audit handle, not authentication: any holder of the database credential can type any handle. Rolling migration 33 back is refused while the audit holds a row; export or resolve it first.
- A band can be missing for a real reason: the policy version of the attempt has no `assessment.signals` section, the review job has not run yet, or the attempt has neither ended nor reached its deadline.
- A review is updated in place when a later attempt matches one of its answers; the policy version and the first evaluation time stay.
- Capture hints and the one-window rule add three counts to this output (`extra_agents`, `client_screenshot_keys`, `client_devtools_opens`) and the reason `extra_agents`; they raise the band only through optional thresholds of the policy section (`client_screenshot_keys_attention`, `client_devtools_attention`, `extra_agents_attention`, `extra_agents_review`), which a version published earlier does not have and the demo policies do not set. The rows that hold them are the same kind of data as the others: keyed digests and counts, and no User-Agent, page identifier, address, or image. A screenshot or a phone photo cannot be prevented or seen, so these signals lead only to a manual check, never to an automatic downgrade ([details](ARCHITECTURE.md#capture-hints-one-open-window-and-what-they-cannot-do)). Rolling migration 50 back is refused while the new events, marks, or counts exist.
- To use thresholds other than the demo values, publish a policy version with an `assessment.signals` section through the policy publisher. `DemoProductPolicyV3` is the demo example and is published only explicitly (the isolated browser fixture does so); the startup seed publishes version 1 only. Attempts that already started keep the version they started with. The demo duplicate thresholds assume a population: a copied pair is flagged only from about 26 answers per family (attention) and 61 (review) at 13 items, or 9 and 14 at 23 items. To try the feature on a smaller stand, publish a policy version with lower `duplicate_bits_attention` and `duplicate_bits_review` (the integration tests use 4 and 6); do not edit the demo policy. A review is a point-in-time evaluation, run again by the job at the deadline. The job logs one line per run with the number of reviews and its duration (`assessment review job finished`).
- The rows hold counts, durations, and keyed digests (HMAC-SHA-256 under keys derived from `IDENTITY_KEY_SECRET`, each with a key version) and no answer text. Rotating the secret keeps the stored rows but makes new fingerprints incomparable with old ones. Deleting an account deletes its attempts and, by cascade, their facts and reviews; the audit rows keep only the attempt ID and the handle. The digests are kept for the lifetime of the attempt; no retention period is defined yet.