feat(consent): add versioned append-only consent ledger C1-C5

This commit is contained in:
shira committed 2026-10-06 14:52:33 +03:00
1 parent 008254e44a
commit de49f93b0b
64 files changed
+9244 -132

No files matched your search

+18
View File
@@ -465,6 +465,24 @@ Planned, additive: the counter offer and the company answer, reading earlier ter
No new problem code is added: the `ProblemCode` enum is copied byte-for-byte into the ML contract, and `version_conflict` and `state_conflict` cover the stale terms and the state conflicts.
### Consents
The `consent` tag covers the consent ledger of the current account (PRD FR01, FR12, and 7.3): the independent consents C1-C5 with their text versions, sources, states, and revocations. The read operation is in the contract; its handler is not implemented yet, so it answers 401 `unauthenticated` until sessions exist (`v1.DenyAllSecurity`). The storage behind it exists (TASK-062, see [ARCHITECTURE.md](../docs/en/ARCHITECTURE.md#consent-ledger)).
| Method and path | operationId | Security | Success | Specific errors |
| --- | --- | --- | --- | --- |
| `GET /api/v1/me/consents` | `ListMyConsents` | session | 200 `ConsentRecordList`, `Cache-Control: no-store` | 400, 401 |
- Purposes (`ConsentPurposeCode`): `c1` personal data processing, `c2` publication of the candidate card, `c3` automatic categorization, `c4` transfer of selected contacts to one organization, `c5` import of FSP results. `ConsentPurpose` stays the subset whose text is public before registration (`c1`), so `GetConsentText` does not widen.
- The subject comes from the session; no parameter names an account, so the response holds only the caller's own records. A page lists records newest grant first with cursor pagination; the optional `state` filter takes `active`, `superseded`, or `revoked`, and an unknown value answers 400 with the pointer `/state`.
- A `ConsentRecord` has the purpose, the accepted `text_version`, the `source` (`registration`, `consent_settings`, or `invitation_acceptance`), `granted_at`, the computed `state`, and `revoked_at` with `revocation_source` (`consent_settings` or `support_request`). A `c4` record also names the `organization` (`ConsentOrganization`, whose `name` is the snapshot the consent text showed, so a later rename does not change it), the contact `fields` (`ContactFieldKind`), the `invitation_id`, and the `invitation_terms_version`; they are null for every other purpose. A `c2` record proves the consent to the publication text; which fields were published, and when, is evidence of the publication history (TASK-088), and a field scope on `c2` records would be an additive change. The record never carries a contact value, the subject, or the text hash: the server stores the SHA-256 of exactly the text the subject saw, and the client never sends or receives it, as for C1 at registration.
- The ledger is append-only. A newer text version of a purpose is a new record and the earlier one becomes `superseded` without any change; a revocation stamps the unrevoked records of the purpose, and for `c4` of one organization, once; a later grant is a new record, and a revoked `c4` of an invitation never comes back. Purposes are independent.
- Planned, additive: granting C1, C2, C3, and C5 in the consent settings (TASK-063) and revoking any purpose with its consequences (TASK-064), as new operations of this tag; C1 at registration and C4 in `AcceptMyInvitation` already have their own operations. The C4 permission to pass data on to an ATS and the C4 of an application (PRD Q9) are planned as an additive flag and an additional `source` value.
Open legal item: whether `c2` is a consent to the distribution of personal data under article 10.1 of 152-FZ, which requires its own consent with the categories of data.
No new problem code is added: the contract reuses `validation_failed` and `unauthenticated`. `TestConsentSchemaValidationPrecedesImplementation`, `TestConsentAccessBeforeImplementation`, and `TestConsentDTOsCarryNoHashSubjectOrContact` pin the generated server, and `frontend/src/shared/api/consent-contract.test.ts` pins the generated Zod rules and, at the type level, the absence of hash, subject, and contact fields.
### Generator checks
`testdata/openapi-3.2.0.yml` contains test operations that use the components above: pagination, Idempotency-Key, If-Match, ETag, and problem responses. ogen does not resolve external references, so the fixture keeps copies of the api/core components; `scripts/test_contract_copies.py` (part of `make -C api check`) checks that they, the fixture responses, and the ML `Problem` copy match api/core.
+18
View File
@@ -465,6 +465,24 @@ ML-сервис отвечает на ошибки той же схемой `Pro
Новый код ошибки не добавлен: enum `ProblemCode` побайтно копируется в ML-контракт, а `version_conflict` и `state_conflict` покрывают устаревшие условия и конфликты состояния.
### Согласия
Тег `consent` описывает журнал согласий текущего аккаунта (FR01, FR12 и 7.3 в PRD): независимые согласия C1-C5 с версиями текстов, источниками, состояниями и отзывами. Операция чтения есть в контракте, но ее обработчик еще не реализован, поэтому до появления сессий она отвечает 401 `unauthenticated` (`v1.DenyAllSecurity`). Хранение за ней уже есть (TASK-062, см. [ARCHITECTURE.md](../docs/ru/ARCHITECTURE.md#журнал-согласий)).
| Метод и путь | operationId | Защита | Успех | Конкретные ошибки |
| --- | --- | --- | --- | --- |
| `GET /api/v1/me/consents` | `ListMyConsents` | сессия | 200 `ConsentRecordList`, `Cache-Control: no-store` | 400, 401 |
- Цели (`ConsentPurposeCode`): `c1` - обработка персональных данных, `c2` - публикация карточки кандидата, `c3` - автоматическая категоризация, `c4` - передача выбранных контактов одной организации, `c5` - импорт результатов ФСП. `ConsentPurpose` остается подмножеством, текст которого доступен до регистрации (`c1`), поэтому `GetConsentText` не расширяется.
- Субъект берется из сессии; ни один параметр не называет аккаунт, поэтому ответ содержит только собственные записи вызывающего. Страница перечисляет записи от новой выдачи к старой с курсорной пагинацией; необязательный фильтр `state` принимает `active`, `superseded` или `revoked`, а неизвестное значение отвечает 400 с указателем `/state`.
- `ConsentRecord` содержит цель, принятую `text_version`, `source` (`registration`, `consent_settings` или `invitation_acceptance`), `granted_at`, вычисленное `state`, а также `revoked_at` и `revocation_source` (`consent_settings` или `support_request`). Запись `c4` дополнительно называет `organization` (`ConsentOrganization`, где `name` - снимок названия из текста согласия, поэтому последующее переименование его не меняет), поля контакта `fields` (`ContactFieldKind`), `invitation_id` и `invitation_terms_version`; для остальных целей они равны null. Запись `c2` доказывает согласие с текстом публикации; какие поля и когда опубликованы - доказательства истории публикации (TASK-088), а scope полей в записях `c2` был бы аддитивным изменением. Запись никогда не содержит значения контакта, субъекта или хэш текста: сервер хранит SHA-256 ровно того текста, который видел субъект, а клиент его не отправляет и не получает, как и для C1 при регистрации.
- Журнал только дополняется. Новая версия текста цели - новая запись, а прежняя становится `superseded` без изменений; отзыв один раз ставит отметку на неотозванные записи цели, а для `c4` - одной организации; последующая выдача - новая запись, и отозванное `c4` приглашения не возвращается. Цели независимы.
- Запланировано, аддитивно: выдача C1, C2, C3 и C5 в настройках согласий (TASK-063) и отзыв любой цели с последствиями (TASK-064) новыми операциями этого тега; у C1 при регистрации и C4 в `AcceptMyInvitation` уже есть свои операции. Разрешение C4 на передачу данных в ATS и C4 при отклике (Q9 в PRD) запланированы как аддитивный флаг и дополнительное значение `source`.
Открытый юридический вопрос: является ли `c2` согласием на распространение персональных данных по статье 10.1 152-ФЗ, которое требует отдельного согласия с категориями данных.
Новый код problem не добавляется: контракт использует `validation_failed` и `unauthenticated`. `TestConsentSchemaValidationPrecedesImplementation`, `TestConsentAccessBeforeImplementation` и `TestConsentDTOsCarryNoHashSubjectOrContact` закрепляют сгенерированный сервер, а `frontend/src/shared/api/consent-contract.test.ts` - сгенерированные правила Zod и, на уровне типов, отсутствие полей хэша, субъекта и контактов.
### Проверки генераторов
`testdata/openapi-3.2.0.yml` содержит тестовые операции с перечисленными компонентами: пагинацией, Idempotency-Key, If-Match, ETag и problem-ответами. ogen не разрешает внешние ссылки, поэтому фикстура хранит копии компонентов api/core; `scripts/test_contract_copies.py` (входит в `make -C api check`) проверяет, что они, ответы фикстуры и ML-копия `Problem` совпадают с api/core.
+59
View File
@@ -3521,3 +3521,62 @@ InvitationSendBlocked:
code: state_conflict
detail: The resource is in a state that does not allow this operation.
trace_id: 5b6c7d8e-9f0a-4b1c-8d2e-4f5a6b7c8d9e
ConsentRecordListPage:
summary: The whole consent history of a candidate on one page
description: C1 was accepted at registration and again for a newer text version, so the first record is superseded; the version c1-2026-10-05 is an illustration, since the migration publishes only c1-2026-10-01 so far. C2 was granted and revoked. C4 was given in the acceptance of one invitation with the email only; the organization name is the one the consent text showed.
value:
items:
- id: 01928f7a-9c0d-7e1f-8a2b-3c4d5e6f7a80
purpose: c4
state: active
text_version: c4-2026-10-01
source: invitation_acceptance
granted_at: "2026-10-06T10:15:00Z"
revoked_at: null
revocation_source: null
organization:
id: 01928f7a-1a2b-7c3d-8e4f-5a6b7c8d9e01
name: ООО Пример Платежи
fields:
- email
invitation_id: 01928f7a-7a8b-7c9d-8e0f-1a2b3c4d5e6f
invitation_terms_version: 3
- id: 01928f7a-8b9c-7d0e-9f1a-2b3c4d5e6f70
purpose: c1
state: active
text_version: c1-2026-10-05
source: consent_settings
granted_at: "2026-10-05T12:00:00Z"
revoked_at: null
revocation_source: null
organization: null
fields: null
invitation_id: null
invitation_terms_version: null
- id: 01928f7a-7a8b-7c9d-8e0f-1a2b3c4d5e60
purpose: c2
state: revoked
text_version: c2-2026-10-01
source: consent_settings
granted_at: "2026-10-02T09:00:00Z"
revoked_at: "2026-10-04T18:30:00Z"
revocation_source: consent_settings
organization: null
fields: null
invitation_id: null
invitation_terms_version: null
- id: 01928f7a-6f7a-7b8c-9d0e-1f2a3b4c5d50
purpose: c1
state: superseded
text_version: c1-2026-10-01
source: registration
granted_at: "2026-10-01T08:00:00Z"
revoked_at: null
revocation_source: null
organization: null
fields: null
invitation_id: null
invitation_terms_version: null
page:
has_more: false
next_cursor: null
+168
View File
@@ -1395,6 +1395,174 @@ SpecializationCatalog:
description: Grade scale in ascending order.
items:
$ref: '#/CatalogGrade'
ConsentPurposeCode:
type: string
description: 'One of the independent consents of PRD FR01. A grant or a revocation of one purpose never changes another.
- c1: processing of personal data, given at registration.
- c2: publication of the candidate card. The record proves the consent to the published text; which fields were published and when is evidence of the publication history (TASK-088), not of this record. Adding a field scope to c2 records later is an additive change.
- c3: automatic categorization. Without it the candidate can request a manual assessment by the same rubric.
- c4: transfer of the selected contact data to one organization, currently given only in an invitation acceptance.
- c5: import of FSP results.
ConsentPurpose lists the subset whose text the client may read before an account exists.'
enum:
- c1
- c2
- c3
- c4
- c5
ConsentState:
type: string
description: 'State of a consent record, computed from the ledger.
- active: the consent holds. For c1, c2, c3, and c5 it is the newest unrevoked record of its purpose; every unrevoked c4 record is active, one per accepted invitation.
- superseded: the subject later accepted another text version of the same purpose and has not revoked either. The record stays as evidence for its own time; it never applies to c4.
- revoked: the consent was revoked. The record keeps its grant and its one revocation time; a later grant is a new record and never reopens it.'
enum:
- active
- superseded
- revoked
ConsentSource:
type: string
description: 'Where the subject gave the consent.
- registration: the c1 acceptance of RegisterAccount.
- consent_settings: the consent settings of the account, for c1, c2, c3, and c5 (planned, TASK-063 and TASK-064).
- invitation_acceptance: the c4 acceptance of AcceptMyInvitation.
A c4 given when sending an application (PRD Q9) is planned as an additional value.'
enum:
- registration
- consent_settings
- invitation_acceptance
ConsentRevocationSource:
type: string
description: 'Who recorded a revocation.
- consent_settings: the subject revoked the consent in the product.
- support_request: an operator recorded a revocation that the subject requested through support.'
enum:
- consent_settings
- support_request
ConsentOrganization:
type: object
description: Organization of a c4 consent as the consent recorded it. `name` is a snapshot of the name that the shown consent text carried at the time of the consent, and the stored text hash proves that text with this name; a later rename of the organization does not change it, so it can differ from the current name.
additionalProperties: false
required:
- id
- name
properties:
id:
type: string
format: uuid
description: Identifier of the organization.
name:
type: string
minLength: 1
maxLength: 200
description: Name of the organization in the consent text at the time of the consent. Plain text; clients show it as text, never as HTML.
ConsentRecord:
type: object
description: 'One record of the consent ledger as its subject reads it: the purpose, the text version the subject accepted, where and when the consent was given, its state, and the revocation. A c4 record also names the organization, the contact fields, and the invitation with its terms version; these fields are null for every other purpose. The server also stores the SHA-256 hash of exactly the text the subject saw, which a client never sends or receives.'
additionalProperties: false
required:
- id
- purpose
- state
- text_version
- source
- granted_at
- revoked_at
- revocation_source
- organization
- fields
- invitation_id
- invitation_terms_version
properties:
id:
type: string
format: uuid
description: Identifier of the record.
purpose:
$ref: '#/ConsentPurposeCode'
state:
$ref: '#/ConsentState'
text_version:
description: Version of the consent text that the subject accepted.
allOf:
- $ref: '#/ConsentTextVersion'
source:
$ref: '#/ConsentSource'
granted_at:
$ref: '#/Timestamp'
revoked_at:
description: Moment of the revocation, or null unless `state` is `revoked`.
oneOf:
- $ref: '#/Timestamp'
- type: 'null'
revocation_source:
description: Who recorded the revocation, or null unless `state` is `revoked`.
oneOf:
- $ref: '#/ConsentRevocationSource'
- type: 'null'
organization:
description: Organization that a c4 consent allows to read the fields, with the name the consent text showed, or null for every other purpose.
oneOf:
- $ref: '#/ConsentOrganization'
- type: 'null'
fields:
type:
- array
- 'null'
minItems: 1
maxItems: 4
uniqueItems: true
description: Contact fields that a c4 consent covers, or null for every other purpose. One kind never implies another.
items:
$ref: '#/ContactFieldKind'
invitation_id:
type:
- string
- 'null'
format: uuid
description: Invitation whose acceptance gave a c4 consent, or null for every other purpose.
invitation_terms_version:
description: Terms version that the acceptance accepted, or null for every other purpose.
oneOf:
- $ref: '#/InvitationTermsVersion'
- type: 'null'
ConsentRecordList:
type: object
description: One page of the consent ledger of the current account, newest grant first.
additionalProperties: false
required:
- items
- page
properties:
items:
type: array
maxItems: 100
description: Records of the page.
items:
$ref: '#/ConsentRecord'
page:
$ref: '#/PageInfo'
ContactFieldKind:
type: string
description: 'Kind of personal data that the consent C4 can disclose to one organization (PRD FR01 and FR12). The candidate selects each kind separately; one kind never implies another.
@@ -0,0 +1,182 @@
schemas:
ConsentPurposeCode:
type: string
description: |-
One of the independent consents of PRD FR01. A grant or a revocation of one purpose never changes another.
- c1: processing of personal data, given at registration.
- c2: publication of the candidate card. The record proves the consent to the published text; which fields were published and when is evidence of the publication history (TASK-088), not of this record. Adding a field scope to c2 records later is an additive change.
- c3: automatic categorization. Without it the candidate can request a manual assessment by the same rubric.
- c4: transfer of the selected contact data to one organization, currently given only in an invitation acceptance.
- c5: import of FSP results.
ConsentPurpose lists the subset whose text the client may read before an account exists.
enum:
- c1
- c2
- c3
- c4
- c5
ConsentState:
type: string
description: |-
State of a consent record, computed from the ledger.
- active: the consent holds. For c1, c2, c3, and c5 it is the newest unrevoked record of its purpose; every unrevoked c4 record is active, one per accepted invitation.
- superseded: the subject later accepted another text version of the same purpose and has not revoked either. The record stays as evidence for its own time; it never applies to c4.
- revoked: the consent was revoked. The record keeps its grant and its one revocation time; a later grant is a new record and never reopens it.
enum:
- active
- superseded
- revoked
ConsentSource:
type: string
description: |-
Where the subject gave the consent.
- registration: the c1 acceptance of RegisterAccount.
- consent_settings: the consent settings of the account, for c1, c2, c3, and c5 (planned, TASK-063 and TASK-064).
- invitation_acceptance: the c4 acceptance of AcceptMyInvitation.
A c4 given when sending an application (PRD Q9) is planned as an additional value.
enum:
- registration
- consent_settings
- invitation_acceptance
ConsentRevocationSource:
type: string
description: |-
Who recorded a revocation.
- consent_settings: the subject revoked the consent in the product.
- support_request: an operator recorded a revocation that the subject requested through support.
enum:
- consent_settings
- support_request
ConsentOrganization:
type: object
description: >-
Organization of a c4 consent as the consent recorded it. `name` is a
snapshot of the name that the shown consent text carried at the time
of the consent, and the stored text hash proves that text with this
name; a later rename of the organization does not change it, so it
can differ from the current name.
additionalProperties: false
required:
- id
- name
properties:
id:
type: string
format: uuid
description: Identifier of the organization.
name:
type: string
minLength: 1
maxLength: 200
description: >-
Name of the organization in the consent text at the time of the
consent. Plain text; clients show it as text, never as HTML.
ConsentRecord:
type: object
description: >-
One record of the consent ledger as its subject reads it: the purpose,
the text version the subject accepted, where and when the consent was
given, its state, and the revocation. A c4 record also names the
organization, the contact fields, and the invitation with its terms
version; these fields are null for every other purpose. The server
also stores the SHA-256 hash of exactly the text the subject saw,
which a client never sends or receives.
additionalProperties: false
required:
- id
- purpose
- state
- text_version
- source
- granted_at
- revoked_at
- revocation_source
- organization
- fields
- invitation_id
- invitation_terms_version
properties:
id:
type: string
format: uuid
description: Identifier of the record.
purpose:
$ref: "#/schemas/ConsentPurposeCode"
state:
$ref: "#/schemas/ConsentState"
text_version:
description: Version of the consent text that the subject accepted.
allOf:
- $ref: "./identity_schemas.yml#/schemas/ConsentTextVersion"
source:
$ref: "#/schemas/ConsentSource"
granted_at:
$ref: "./common_schemas.yml#/schemas/Timestamp"
revoked_at:
description: Moment of the revocation, or null unless `state` is `revoked`.
oneOf:
- $ref: "./common_schemas.yml#/schemas/Timestamp"
- type: "null"
revocation_source:
description: Who recorded the revocation, or null unless `state` is `revoked`.
oneOf:
- $ref: "#/schemas/ConsentRevocationSource"
- type: "null"
organization:
description: >-
Organization that a c4 consent allows to read the fields, with the
name the consent text showed, or null for every other purpose.
oneOf:
- $ref: "#/schemas/ConsentOrganization"
- type: "null"
fields:
type:
- array
- "null"
minItems: 1
maxItems: 4
uniqueItems: true
description: >-
Contact fields that a c4 consent covers, or null for every other
purpose. One kind never implies another.
items:
$ref: "./contact_grant_schemas.yml#/schemas/ContactFieldKind"
invitation_id:
type:
- string
- "null"
format: uuid
description: >-
Invitation whose acceptance gave a c4 consent, or null for every
other purpose.
invitation_terms_version:
description: >-
Terms version that the acceptance accepted, or null for every
other purpose.
oneOf:
- $ref: "./invitation_schemas.yml#/schemas/InvitationTermsVersion"
- type: "null"
ConsentRecordList:
type: object
description: >-
One page of the consent ledger of the current account, newest grant
first.
additionalProperties: false
required:
- items
- page
properties:
items:
type: array
maxItems: 100
description: Records of the page.
items:
$ref: "#/schemas/ConsentRecord"
page:
$ref: "./common_schemas.yml#/schemas/PageInfo"
+264
View File
@@ -21,6 +21,8 @@ tags:
description: 'Hiring needs of an organization: requirements with their confirmation state and provenance, immutable versions, readiness, and category recommendations. Access comes only from an active membership in the organization; a need never requires a vacancy.'
- name: invitation
description: 'Invitations from an organization to one candidate: drafts with complete terms, immutable terms versions, sending, the candidate''s inbox, acceptance with the consent C4, structured declines, withdrawal and cancellation, and the contact grant. Contacts are readable only through an active grant, in a response separate from the terms.'
- name: consent
description: 'The consent ledger of the current account: the independent consents C1-C5 with their text versions, sources, states, and revocations. The ledger is append-only and returns only the caller''s own records.'
- name: support
description: 'Support cases of the current account: questions, complaints, appeals of a grade or an anti-cheat decision, and manual assessment requests. The author sees the number, the status, the response target, the decision, and the public history; moderators and internal notes stay hidden.'
paths:
@@ -1809,6 +1811,52 @@ paths:
$ref: '#/components/responses/TooManyRequests'
default:
$ref: '#/components/responses/Problem'
/api/v1/me/consents:
get:
operationId: ListMyConsents
summary: List the consents of the current account with their history.
description: |-
Requires the session cookie of a candidate or an employer account. The subject comes from the session, never from a request parameter, so the response holds only the caller's own consents: no request can name another account, and records of other accounts are never listed. Returns a page of the consent ledger of the account, newest grant first with the identifier as the tie-breaker, with cursor pagination.
The ledger is append-only. Every grant is a record with its purpose, the accepted text version, the source, and the grant time; the server also stores the hash of exactly the text the subject saw. A newer text version of the same purpose is a new record, and the earlier one becomes `superseded` without any change. A revocation stamps every unrevoked record of the purpose, and for c4 of one organization, once; a later grant is a new record. Purposes are independent.
Without `state` the page lists the whole history; `state=active` lists the consents that hold now, one per purpose for c1, c2, c3, and c5 and one per accepted invitation for c4. A c4 record names the organization with the name its consent text showed (a snapshot that a later rename does not change), the selected contact fields, and the invitation with its terms version; it never carries a contact value. A c2 record proves the consent to the publication text; the published field set and its changes are evidence of the publication history (TASK-088).
Granting c1, c2, c3, and c5 in the consent settings and revoking any purpose are planned operations of this tag (TASK-063 and TASK-064); c1 is given at registration and c4 only in AcceptMyInvitation.
Access: a missing, unknown, expired, or revoked session answers 401 unauthenticated. A malformed `limit`, `cursor`, or `state` answers 400 validation_failed.
security:
- sessionCookie: []
tags:
- consent
parameters:
- name: state
in: query
required: false
description: Lists only the records in this state; omit it for the whole history.
schema:
$ref: '#/components/schemas/ConsentState'
- $ref: '#/components/parameters/PageLimit'
- $ref: '#/components/parameters/PageCursor'
responses:
'200':
description: A page of the consent ledger of the current account.
headers:
Cache-Control:
$ref: '#/components/headers/CacheControlNoStore'
content:
application/json:
schema:
$ref: '#/components/schemas/ConsentRecordList'
examples:
history:
$ref: '#/components/examples/ConsentRecordListPage'
'400':
$ref: '#/components/responses/ValidationFailed'
'401':
$ref: '#/components/responses/Unauthenticated'
default:
$ref: '#/components/responses/Problem'
/api/v1/me/support-cases:
get:
operationId: ListMySupportCases
@@ -6236,6 +6284,163 @@ components:
oneOf:
- $ref: '#/components/schemas/ContactTelegramUsername'
- type: 'null'
ConsentPurposeCode:
type: string
description: |-
One of the independent consents of PRD FR01. A grant or a revocation of one purpose never changes another.
- c1: processing of personal data, given at registration.
- c2: publication of the candidate card. The record proves the consent to the published text; which fields were published and when is evidence of the publication history (TASK-088), not of this record. Adding a field scope to c2 records later is an additive change.
- c3: automatic categorization. Without it the candidate can request a manual assessment by the same rubric.
- c4: transfer of the selected contact data to one organization, currently given only in an invitation acceptance.
- c5: import of FSP results.
ConsentPurpose lists the subset whose text the client may read before an account exists.
enum:
- c1
- c2
- c3
- c4
- c5
ConsentState:
type: string
description: |-
State of a consent record, computed from the ledger.
- active: the consent holds. For c1, c2, c3, and c5 it is the newest unrevoked record of its purpose; every unrevoked c4 record is active, one per accepted invitation.
- superseded: the subject later accepted another text version of the same purpose and has not revoked either. The record stays as evidence for its own time; it never applies to c4.
- revoked: the consent was revoked. The record keeps its grant and its one revocation time; a later grant is a new record and never reopens it.
enum:
- active
- superseded
- revoked
ConsentSource:
type: string
description: |-
Where the subject gave the consent.
- registration: the c1 acceptance of RegisterAccount.
- consent_settings: the consent settings of the account, for c1, c2, c3, and c5 (planned, TASK-063 and TASK-064).
- invitation_acceptance: the c4 acceptance of AcceptMyInvitation.
A c4 given when sending an application (PRD Q9) is planned as an additional value.
enum:
- registration
- consent_settings
- invitation_acceptance
ConsentRevocationSource:
type: string
description: |-
Who recorded a revocation.
- consent_settings: the subject revoked the consent in the product.
- support_request: an operator recorded a revocation that the subject requested through support.
enum:
- consent_settings
- support_request
ConsentOrganization:
type: object
description: Organization of a c4 consent as the consent recorded it. `name` is a snapshot of the name that the shown consent text carried at the time of the consent, and the stored text hash proves that text with this name; a later rename of the organization does not change it, so it can differ from the current name.
additionalProperties: false
required:
- id
- name
properties:
id:
type: string
format: uuid
description: Identifier of the organization.
name:
type: string
minLength: 1
maxLength: 200
description: Name of the organization in the consent text at the time of the consent. Plain text; clients show it as text, never as HTML.
ConsentRecord:
type: object
description: 'One record of the consent ledger as its subject reads it: the purpose, the text version the subject accepted, where and when the consent was given, its state, and the revocation. A c4 record also names the organization, the contact fields, and the invitation with its terms version; these fields are null for every other purpose. The server also stores the SHA-256 hash of exactly the text the subject saw, which a client never sends or receives.'
additionalProperties: false
required:
- id
- purpose
- state
- text_version
- source
- granted_at
- revoked_at
- revocation_source
- organization
- fields
- invitation_id
- invitation_terms_version
properties:
id:
type: string
format: uuid
description: Identifier of the record.
purpose:
$ref: '#/components/schemas/ConsentPurposeCode'
state:
$ref: '#/components/schemas/ConsentState'
text_version:
description: Version of the consent text that the subject accepted.
allOf:
- $ref: '#/components/schemas/ConsentTextVersion'
source:
$ref: '#/components/schemas/ConsentSource'
granted_at:
$ref: '#/components/schemas/Timestamp'
revoked_at:
description: Moment of the revocation, or null unless `state` is `revoked`.
oneOf:
- $ref: '#/components/schemas/Timestamp'
- type: 'null'
revocation_source:
description: Who recorded the revocation, or null unless `state` is `revoked`.
oneOf:
- $ref: '#/components/schemas/ConsentRevocationSource'
- type: 'null'
organization:
description: Organization that a c4 consent allows to read the fields, with the name the consent text showed, or null for every other purpose.
oneOf:
- $ref: '#/components/schemas/ConsentOrganization'
- type: 'null'
fields:
type:
- array
- 'null'
minItems: 1
maxItems: 4
uniqueItems: true
description: Contact fields that a c4 consent covers, or null for every other purpose. One kind never implies another.
items:
$ref: '#/components/schemas/ContactFieldKind'
invitation_id:
type:
- string
- 'null'
format: uuid
description: Invitation whose acceptance gave a c4 consent, or null for every other purpose.
invitation_terms_version:
description: Terms version that the acceptance accepted, or null for every other purpose.
oneOf:
- $ref: '#/components/schemas/InvitationTermsVersion'
- type: 'null'
ConsentRecordList:
type: object
description: One page of the consent ledger of the current account, newest grant first.
additionalProperties: false
required:
- items
- page
properties:
items:
type: array
maxItems: 100
description: Records of the page.
items:
$ref: '#/components/schemas/ConsentRecord'
page:
$ref: '#/components/schemas/PageInfo'
HealthResponse:
type: object
additionalProperties: false
@@ -10012,6 +10217,65 @@ components:
granted_at: '2026-10-06T15:00:00Z'
revoked_at: '2026-10-07T10:00:00Z'
revocation_reason: participation_cancelled
ConsentRecordListPage:
summary: The whole consent history of a candidate on one page
description: C1 was accepted at registration and again for a newer text version, so the first record is superseded; the version c1-2026-10-05 is an illustration, since the migration publishes only c1-2026-10-01 so far. C2 was granted and revoked. C4 was given in the acceptance of one invitation with the email only; the organization name is the one the consent text showed.
value:
items:
- id: 01928f7a-9c0d-7e1f-8a2b-3c4d5e6f7a80
purpose: c4
state: active
text_version: c4-2026-10-01
source: invitation_acceptance
granted_at: '2026-10-06T10:15:00Z'
revoked_at: null
revocation_source: null
organization:
id: 01928f7a-1a2b-7c3d-8e4f-5a6b7c8d9e01
name: ООО Пример Платежи
fields:
- email
invitation_id: 01928f7a-7a8b-7c9d-8e0f-1a2b3c4d5e6f
invitation_terms_version: 3
- id: 01928f7a-8b9c-7d0e-9f1a-2b3c4d5e6f70
purpose: c1
state: active
text_version: c1-2026-10-05
source: consent_settings
granted_at: '2026-10-05T12:00:00Z'
revoked_at: null
revocation_source: null
organization: null
fields: null
invitation_id: null
invitation_terms_version: null
- id: 01928f7a-7a8b-7c9d-8e0f-1a2b3c4d5e60
purpose: c2
state: revoked
text_version: c2-2026-10-01
source: consent_settings
granted_at: '2026-10-02T09:00:00Z'
revoked_at: '2026-10-04T18:30:00Z'
revocation_source: consent_settings
organization: null
fields: null
invitation_id: null
invitation_terms_version: null
- id: 01928f7a-6f7a-7b8c-9d0e-1f2a3b4c5d50
purpose: c1
state: superseded
text_version: c1-2026-10-01
source: registration
granted_at: '2026-10-01T08:00:00Z'
revoked_at: null
revocation_source: null
organization: null
fields: null
invitation_id: null
invitation_terms_version: null
page:
has_more: false
next_cursor: null
SupportCaseListPage:
summary: The last page of the case summaries of the current account
value:
+21
View File
@@ -40,6 +40,11 @@ tags:
withdrawal and cancellation, and the contact grant. Contacts are
readable only through an active grant, in a response separate from
the terms.
- name: consent
description: >-
The consent ledger of the current account: the independent consents
C1-C5 with their text versions, sources, states, and revocations. The
ledger is append-only and returns only the caller's own records.
- name: support
description: >-
Support cases of the current account: questions, complaints, appeals
@@ -112,6 +117,8 @@ paths:
$ref: ./routes/candidate_invitation_decline.yml
/api/v1/me/invitations/{invitation_id}/cancel:
$ref: ./routes/candidate_invitation_cancel.yml
/api/v1/me/consents:
$ref: ./routes/consents.yml
/api/v1/me/support-cases:
$ref: ./routes/support_cases.yml
/api/v1/me/support-cases/{case_id}:
@@ -578,6 +585,20 @@ components:
$ref: ./components/schemas.yml#/ContactFullName
ContactDisclosure:
$ref: ./components/schemas.yml#/ContactDisclosure
ConsentPurposeCode:
$ref: ./components/schemas.yml#/ConsentPurposeCode
ConsentState:
$ref: ./components/schemas.yml#/ConsentState
ConsentSource:
$ref: ./components/schemas.yml#/ConsentSource
ConsentRevocationSource:
$ref: ./components/schemas.yml#/ConsentRevocationSource
ConsentOrganization:
$ref: ./components/schemas.yml#/ConsentOrganization
ConsentRecord:
$ref: ./components/schemas.yml#/ConsentRecord
ConsentRecordList:
$ref: ./components/schemas.yml#/ConsentRecordList
parameters:
IdempotencyKey:
$ref: ./components/parameters.yml#/IdempotencyKey
+45
View File
@@ -0,0 +1,45 @@
get:
operationId: ListMyConsents
summary: List the consents of the current account with their history.
description: |-
Requires the session cookie of a candidate or an employer account. The subject comes from the session, never from a request parameter, so the response holds only the caller's own consents: no request can name another account, and records of other accounts are never listed. Returns a page of the consent ledger of the account, newest grant first with the identifier as the tie-breaker, with cursor pagination.
The ledger is append-only. Every grant is a record with its purpose, the accepted text version, the source, and the grant time; the server also stores the hash of exactly the text the subject saw. A newer text version of the same purpose is a new record, and the earlier one becomes `superseded` without any change. A revocation stamps every unrevoked record of the purpose, and for c4 of one organization, once; a later grant is a new record. Purposes are independent.
Without `state` the page lists the whole history; `state=active` lists the consents that hold now, one per purpose for c1, c2, c3, and c5 and one per accepted invitation for c4. A c4 record names the organization with the name its consent text showed (a snapshot that a later rename does not change), the selected contact fields, and the invitation with its terms version; it never carries a contact value. A c2 record proves the consent to the publication text; the published field set and its changes are evidence of the publication history (TASK-088).
Granting c1, c2, c3, and c5 in the consent settings and revoking any purpose are planned operations of this tag (TASK-063 and TASK-064); c1 is given at registration and c4 only in AcceptMyInvitation.
Access: a missing, unknown, expired, or revoked session answers 401 unauthenticated. A malformed `limit`, `cursor`, or `state` answers 400 validation_failed.
security:
- sessionCookie: []
tags:
- consent
parameters:
- name: state
in: query
required: false
description: Lists only the records in this state; omit it for the whole history.
schema:
$ref: ../components/schemas.yml#/ConsentState
- $ref: ../components/parameters.yml#/PageLimit
- $ref: ../components/parameters.yml#/PageCursor
responses:
"200":
description: A page of the consent ledger of the current account.
headers:
Cache-Control:
$ref: ../components/headers.yml#/CacheControlNoStore
content:
application/json:
schema:
$ref: ../components/schemas.yml#/ConsentRecordList
examples:
history:
$ref: ../components/examples.yml#/ConsentRecordListPage
"400":
$ref: ../components/responses.yml#/ValidationFailed
"401":
$ref: ../components/responses.yml#/Unauthenticated
default:
$ref: ../components/responses.yml#/Problem