feat(visibility): add the candidate publication, hiding and search status contract

This commit is contained in:
shira committed 2026-10-07 00:15:52 +03:00
1 parent 4436f626a3
commit 0529601021
87 files changed
+21456 -83

No files matched your search

+34
View File
@@ -0,0 +1,34 @@
get:
operationId: GetMyPrivacySettings
summary: Read the visibility settings of the current candidate.
description: |-
Requires the session cookie of a candidate account. The candidate comes from the session, never from a request parameter. Returns the publication of the candidate card, the search status, and the number of hidden organizations in one read. The response is `Cache-Control: no-store`.
A profile is closed by default. A candidate who never published reads `publication.state` `closed` with `closed_reason` `never_published`, an empty field set, and version 0; creating or saving the profile (`SaveMyProfile`) never publishes it, and no operation of the profile, the questionnaire, or an assessment changes these settings. The C2 consent, the search status, and the hidden organizations are three independent settings: the C2 record in the consent ledger proves that the candidate accepted the publication text, the publication records which fields are published, and the search status is a statement of the candidate that is not a consent. A change of one never changes another, and none of them ever makes the candidate more visible by itself: the search status lapses to the non-public `not_looking`, a revoked C2 closes the card, and a new C2 grant publishes nothing.
A missing, unknown, expired, or revoked session answers 401 unauthenticated; an employer account answers 403 forbidden.
security:
- sessionCookie: []
tags:
- privacy
responses:
"200":
description: The visibility settings of the current candidate.
headers:
Cache-Control:
$ref: ../components/headers.yml#/CacheControlNoStore
content:
application/json:
schema:
$ref: ../components/schemas.yml#/PrivacySettings
examples:
new_candidate:
$ref: ../components/examples.yml#/NewCandidatePrivacySettings
published_and_looking:
$ref: ../components/examples.yml#/PublishedCandidatePrivacySettings
"401":
$ref: ../components/responses.yml#/Unauthenticated
"403":
$ref: ../components/responses.yml#/Forbidden
default:
$ref: ../components/responses.yml#/Problem
@@ -0,0 +1,39 @@
get:
operationId: ListMyCardAccessHistory
summary: List the accesses of organizations to the card of the current candidate.
description: |-
Requires the session cookie of a candidate account. The candidate comes from the session, so the response holds only accesses to the caller's own card. Returns a page, newest first with the record identifier as the tie-breaker, with cursor pagination. The response is `Cache-Control: no-store`.
An access is a view of the anonymous card by an organization (`card_viewed`) or a read of the contacts through an active contact grant (`contact_read`). Reading the history is not an access and writes nothing. A view of the card by an organization that has no invitation relation with the candidate carries `organization` null, so the candidate sees that the card was viewed without learning a company that they cannot otherwise see; a contact read always names the organization, because the candidate accepted its invitation. The entries carry no search query, filter, or ranking of the organization, and no organization the candidate hides ever appears as a viewer, because a hidden organization cannot read the card.
The storage of accesses is planned with the card and contact operations of the organization side (TASK-185 and the contact read of the invitation contract); until then the operation answers 501 not_implemented after the session and request checks.
A missing, unknown, expired, or revoked session answers 401 unauthenticated; an employer account answers 403 forbidden. A malformed `limit` or `cursor` answers 400 validation_failed.
security:
- sessionCookie: []
tags:
- privacy
parameters:
- $ref: ../components/parameters.yml#/PageLimit
- $ref: ../components/parameters.yml#/PageCursor
responses:
"200":
description: A page of the accesses to the card of the current candidate.
headers:
Cache-Control:
$ref: ../components/headers.yml#/CacheControlNoStore
content:
application/json:
schema:
$ref: ../components/schemas.yml#/CardAccessList
examples:
page:
$ref: ../components/examples.yml#/CardAccessListPage
"400":
$ref: ../components/responses.yml#/ValidationFailed
"401":
$ref: ../components/responses.yml#/Unauthenticated
"403":
$ref: ../components/responses.yml#/Forbidden
default:
$ref: ../components/responses.yml#/Problem
@@ -0,0 +1,81 @@
put:
operationId: HideOrganization
summary: Hide the candidate profile from one organization.
description: |-
Requires the session cookie of a candidate account, the CSRF token of that session in X-CSRF-Token, and an allowed Origin. The request has no body: the path names the organization and the candidate comes from the session. The hiding is a record that belongs to the candidate and references the organization; it changes neither the C2 consent, nor the publication, nor the search status.
The operation sets a state, so it is idempotent and needs no Idempotency-Key: hiding an organization that is already hidden answers 200 with the existing record and its original `hidden_at`, changes nothing, and writes no history record. There is one record per candidate and organization.
Anti-enumeration: an organization that does not exist and an organization that the candidate cannot see answer the same 404 not_found, with the same body and without a timing or an error code that tells them apart, so the operation is not a way to ask whether an identifier belongs to an organization. The candidate can see an organization that has sent them an invitation, and the organizations that a candidate lookup will list (planned; see the open questions of the contract). The response names the organization only after that check, with its current name. The identifiers are random, the general rate limit applies and can answer 429 with Retry-After before any check, and the record never reveals to an organization that a candidate hides it.
A candidate hides at most 1000 organizations; hiding one more answers 409 state_conflict with the entry `{in: path, pointer: /org_id, code: limit_reached}` in `errors`, which tells it apart from other conflicts, and changes nothing, and a repeat of an existing hiding is never refused for the limit.
Hiding an organization that holds an active contact grant of the candidate revokes that grant with the reason `visibility_closed` in the same transaction (planned together with the invitation operations). Lifting the hiding never reopens a grant.
Order of checks: session (401), CSRF and Origin (403 csrf_check_failed), request validation of the path (400), account scenario (403 forbidden for an employer), the organization and its visibility to the candidate (404 not_found), then the repeat (200), then the limit (409 state_conflict). Like every visibility change, hiding needs a verified email (a usecase requirement).
security:
- sessionCookie: []
sessionCsrf: []
tags:
- privacy
parameters:
- $ref: ../components/parameters.yml#/HiddenOrganizationId
responses:
"200":
description: >-
The organization is hidden from the candidate profile: the new record
or the one that existed.
headers:
Cache-Control:
$ref: ../components/headers.yml#/CacheControlNoStore
content:
application/json:
schema:
$ref: ../components/schemas.yml#/HiddenOrganization
examples:
hidden:
$ref: ../components/examples.yml#/HiddenOrganizationRecord
"400":
$ref: ../components/responses.yml#/ValidationFailed
"401":
$ref: ../components/responses.yml#/Unauthenticated
"403":
$ref: ../components/responses.yml#/CsrfCheckFailedOrForbidden
"404":
$ref: ../components/responses.yml#/NotFound
"409":
$ref: ../components/responses.yml#/HiddenOrganizationLimit
"429":
$ref: ../components/responses.yml#/TooManyRequests
default:
$ref: ../components/responses.yml#/Problem
delete:
operationId: UnhideOrganization
summary: Lift the hiding of the candidate profile from one organization.
description: |-
Requires the session cookie of a candidate account, the CSRF token of that session in X-CSRF-Token, and an allowed Origin. Deletes the hiding record of the candidate for the organization in the path. The request is idempotent: it answers 204 whether the organization was hidden, was not hidden, or does not exist, so the operation reveals nothing about the organization, and a repeat after a lost response succeeds. The record is deleted, the settings history keeps the event `organization_unhidden` only when a record was deleted.
Lifting the hiding makes the candidate readable by that organization again only if the profile is published and the organization otherwise may read it. It changes neither the C2 consent, nor the publication, nor the search status, and it never reopens a contact grant that the hiding closed.
Order of checks: session (401), CSRF and Origin (403 csrf_check_failed), request validation of the path (400), account scenario (403 forbidden for an employer), then the deletion (204).
security:
- sessionCookie: []
sessionCsrf: []
tags:
- privacy
parameters:
- $ref: ../components/parameters.yml#/HiddenOrganizationId
responses:
"204":
description: The organization is not hidden from the candidate profile.
headers:
Cache-Control:
$ref: ../components/headers.yml#/CacheControlNoStore
"400":
$ref: ../components/responses.yml#/ValidationFailed
"401":
$ref: ../components/responses.yml#/Unauthenticated
"403":
$ref: ../components/responses.yml#/CsrfCheckFailedOrForbidden
default:
$ref: ../components/responses.yml#/Problem
@@ -0,0 +1,37 @@
get:
operationId: ListMyHiddenOrganizations
summary: List the organizations that the candidate hides the profile from.
description: |-
Requires the session cookie of a candidate account. The candidate comes from the session, so the response holds only the caller's own records and no request can name another account. Returns a page of the hidden organizations, newest first with the organization identifier as the tie-breaker, with cursor pagination. The response is `Cache-Control: no-store`.
The records belong to the candidate. An organization never reads them, never learns that it is hidden, and sees a hidden candidate exactly as it sees one who is not published: no search result, no card, no contact read.
A missing, unknown, expired, or revoked session answers 401 unauthenticated; an employer account answers 403 forbidden. A malformed `limit` or `cursor` answers 400 validation_failed.
security:
- sessionCookie: []
tags:
- privacy
parameters:
- $ref: ../components/parameters.yml#/PageLimit
- $ref: ../components/parameters.yml#/PageCursor
responses:
"200":
description: A page of the hidden organizations of the current candidate.
headers:
Cache-Control:
$ref: ../components/headers.yml#/CacheControlNoStore
content:
application/json:
schema:
$ref: ../components/schemas.yml#/HiddenOrganizationList
examples:
page:
$ref: ../components/examples.yml#/HiddenOrganizationListPage
"400":
$ref: ../components/responses.yml#/ValidationFailed
"401":
$ref: ../components/responses.yml#/Unauthenticated
"403":
$ref: ../components/responses.yml#/Forbidden
default:
$ref: ../components/responses.yml#/Problem
@@ -0,0 +1,37 @@
get:
operationId: ListMyPrivacyHistory
summary: List the changes of the visibility settings of the current candidate.
description: |-
Requires the session cookie of a candidate account. The candidate comes from the session, so the response holds only the caller's own records. Returns a page of the settings history, newest first with the event identifier as the tie-breaker, with cursor pagination. The response is `Cache-Control: no-store`.
The history is append-only evidence of what the candidate published, hid, and announced, and when. A publication event keeps the published fields and the C2 record behind them, which is what the consent ledger deliberately does not carry (the C2 record proves the consent to the text, not the field set). A revocation of C2 and a lapse of the search status are computed and are not events here; the consent history shows the revocation. The history never contains a profile value.
A missing, unknown, expired, or revoked session answers 401 unauthenticated; an employer account answers 403 forbidden. A malformed `limit` or `cursor` answers 400 validation_failed.
security:
- sessionCookie: []
tags:
- privacy
parameters:
- $ref: ../components/parameters.yml#/PageLimit
- $ref: ../components/parameters.yml#/PageCursor
responses:
"200":
description: A page of the settings history of the current candidate.
headers:
Cache-Control:
$ref: ../components/headers.yml#/CacheControlNoStore
content:
application/json:
schema:
$ref: ../components/schemas.yml#/PrivacyEventList
examples:
page:
$ref: ../components/examples.yml#/PrivacyEventListPage
"400":
$ref: ../components/responses.yml#/ValidationFailed
"401":
$ref: ../components/responses.yml#/Unauthenticated
"403":
$ref: ../components/responses.yml#/Forbidden
default:
$ref: ../components/responses.yml#/Problem
@@ -0,0 +1,34 @@
get:
operationId: GetMyCardPreview
summary: Preview the anonymous card that organizations would read.
description: |-
Requires the session cookie of a candidate account. Returns the card exactly as an organization that the candidate does not hide the profile from would read it now, built from the current profile, the current publication, and the consent ledger. The response is `Cache-Control: no-store`.
The preview is a private read for the candidate: it creates no view, leaves no access record, and is never shown to an organization. While the profile is closed `card` is null. `card` is `AnonymousCardContent`, whose schema reaches no private profile schema, no contact, and no identifier of the candidate: it has no name, email, phone, Telegram name, employer, salary figure, or account or profile identifier, and each property is null when it is not published or has no value, so a reader cannot tell the two apart. Only the fields in `fields` are filled, and only with values that the candidate confirmed: an unconfirmed suggestion and an unknown value never appear. A free text value that looks like a contact (an email address, a phone number, a URL, a Telegram link, an @handle) is dropped from the card, so the preview shows exactly what an organization would read. The self-assessed grade is not a category and never appears; categories come only from assessment results.
A missing, unknown, expired, or revoked session answers 401 unauthenticated; an employer account answers 403 forbidden.
security:
- sessionCookie: []
tags:
- privacy
responses:
"200":
description: The anonymous card as organizations would read it now.
headers:
Cache-Control:
$ref: ../components/headers.yml#/CacheControlNoStore
content:
application/json:
schema:
$ref: ../components/schemas.yml#/CardPreview
examples:
published:
$ref: ../components/examples.yml#/PublishedCardPreview
closed:
$ref: ../components/examples.yml#/ClosedCardPreview
"401":
$ref: ../components/responses.yml#/Unauthenticated
"403":
$ref: ../components/responses.yml#/Forbidden
default:
$ref: ../components/responses.yml#/Problem
@@ -0,0 +1,56 @@
put:
operationId: SetMyPublication
summary: Publish or close the anonymous candidate card.
description: |-
Requires the session cookie of a candidate account, the CSRF token of that session in X-CSRF-Token, and an allowed Origin. The body is the complete new publication setting: `state` `published` with the non-empty set of card fields, or `closed` with an empty set. It changes only the publication; the search status and the hidden organizations stay as they were.
Publication is not a consent and does not duplicate one. The consent C2 lives in the consent ledger (`ListMyConsents`); this setting refers to it. Publishing requires an active, unrevoked C2 record of the account and binds the publication to that record, so a client sends no consent identifier and cannot forge one. Without one the server answers 409 state_conflict with the entry `{in: body, pointer: /state, code: consent_required}` in `errors`, which tells it apart from every other conflict, and changes nothing: the client gives C2 first (planned in the consent settings, TASK-063) and then publishes. The server takes the C2 record under a share lock in the transaction that writes the publication, so a revocation that races with a publication either commits first (the publication is refused) or closes the card right after. A revocation of C2 closes the card at once, because `state` is computed from the unrevoked record; a later C2 grant never reopens it, and the candidate publishes again under the new record. The revocation path itself (TASK-064) closes the stored publication and revokes the contact grants in its own transaction. A closing sent over a stored publication whose C2 was revoked is a real change: it stores the closing, records `publication_closed`, and revokes the grants as any closing does. Publishing, like every visibility change, needs a verified email (a usecase requirement; the unverified account cleanup deletes only accounts without such records). Publishing never adds a field that the body did not name, and a new `CardField` value is never published for a candidate who did not choose it.
The field set contains only the groups of `CardField`. The full name, contacts, and the lowest salary have no value there, so no body can publish them. Only values that the candidate confirmed ever reach the card. Contacts reach an organization only through the contact grant (C4), and a profile that is published or closed changes none of the grants that exist; closing the publication, and hiding an organization that holds a grant, revoke the contact grants concerned with the reason `visibility_closed` in the same transaction as the change (planned together with the operations, see the invitation contract).
Optimistic concurrency uses `expected_version` in the body: the client sends the `version` it read, 0 for the first publication. If it is not the current version the server answers 412 version_conflict and changes nothing. The version travels in the body rather than in If-Match because the generated client cannot read the ETag header yet. A body that equals the stored setting changes nothing, keeps the version, and answers 200 even when `expected_version` is older, so a retry after a lost response succeeds without an Idempotency-Key. A version above the current one never existed and always answers 412. Every change is recorded in the settings history with its time, the fields, and the C2 record.
Order of checks: session (401), CSRF and Origin (403 csrf_check_failed), request validation (400), account scenario (403 forbidden for an employer), a version above the current one (412), rules that depend on the body alone (400), an unchanged body (200), a stale version (412), then the active C2 for a publication (409 state_conflict). The schema rejects an unknown field, a repeated or unknown card field, and more fields than there are groups; a published state with no field, and a closed state with a field, answer 400 validation_failed with the pointer `/fields`. Error bodies never repeat a submitted value.
security:
- sessionCookie: []
sessionCsrf: []
tags:
- privacy
requestBody:
required: true
content:
application/json:
schema:
$ref: ../components/schemas.yml#/PublicationUpdate
examples:
publish:
$ref: ../components/examples.yml#/PublicationUpdatePublish
close:
$ref: ../components/examples.yml#/PublicationUpdateClose
responses:
"200":
description: >-
The saved publication with its new version, or the current one when
the body changes nothing.
headers:
Cache-Control:
$ref: ../components/headers.yml#/CacheControlNoStore
content:
application/json:
schema:
$ref: ../components/schemas.yml#/Publication
examples:
published:
$ref: ../components/examples.yml#/PublishedPublication
"400":
$ref: ../components/responses.yml#/PrivacyValidationFailed
"401":
$ref: ../components/responses.yml#/Unauthenticated
"403":
$ref: ../components/responses.yml#/CsrfCheckFailedOrForbidden
"409":
$ref: ../components/responses.yml#/PublicationConsentRequired
"412":
$ref: ../components/responses.yml#/PrivacyVersionConflict
default:
$ref: ../components/responses.yml#/Problem
@@ -0,0 +1,54 @@
put:
operationId: SetMySearchStatus
summary: Set or confirm the search status of the current candidate.
description: |-
Requires the session cookie of a candidate account, the CSRF token of that session in X-CSRF-Token, and an allowed Origin. The body is the complete new status: `looking` ("Ищу") or `not_looking`. The status is a statement of the candidate and never a consent. It changes neither the C2 consent, nor the publication, nor the hidden organizations, and it does not close or open any contact grant; a candidate whose profile is closed who sets `looking` becomes visible to no one.
`looking` stores the moment of the confirmation and a lapse time. The server takes the interval from the `search_status` section of the effective product policy (30 days in the demo policy, `searching_confirmation_interval_days`), stores the policy version it used, and fixes the lapse time then, so a later policy change moves no stored time. Setting `looking` again is the confirmation: it replaces the confirmation time with now and advances the version, also after a lapse. The body carries no time, interval, or policy version.
After the lapse time the status holds as `not_looking` with `lapsed` true on the next read. The lapse is computed and written nowhere, so it needs no job, it can never make the candidate more visible, and it never touches the publication or the hidden organizations. A reminder before the lapse is a planned notification, not a part of this operation.
Optimistic concurrency uses `expected_version` in the body, 0 for a candidate who never set the status; a stale or non-existent version answers 412 version_conflict and changes nothing. `not_looking` over a stored `not_looking` changes nothing and answers 200 even with a stale version. `looking` always changes the stored confirmation, so a retry of a confirmation whose response was lost with the old version answers 412 and the client reads the status again.
Order of checks: session (401), CSRF and Origin (403 csrf_check_failed), request validation (400), account scenario (403 forbidden for an employer), a version above the current one (412), an unchanged `not_looking` (200), then a stale version (412).
security:
- sessionCookie: []
sessionCsrf: []
tags:
- privacy
requestBody:
required: true
content:
application/json:
schema:
$ref: ../components/schemas.yml#/SearchStatusUpdate
examples:
looking:
$ref: ../components/examples.yml#/SearchStatusUpdateLooking
responses:
"200":
description: >-
The saved search status with its new version, or the current one
when the body changes nothing.
headers:
Cache-Control:
$ref: ../components/headers.yml#/CacheControlNoStore
content:
application/json:
schema:
$ref: ../components/schemas.yml#/SearchStatus
examples:
looking:
$ref: ../components/examples.yml#/LookingSearchStatus
lapsed:
$ref: ../components/examples.yml#/LapsedSearchStatus
"400":
$ref: ../components/responses.yml#/PrivacyValidationFailed
"401":
$ref: ../components/responses.yml#/Unauthenticated
"403":
$ref: ../components/responses.yml#/CsrfCheckFailedOrForbidden
"412":
$ref: ../components/responses.yml#/PrivacyVersionConflict
default:
$ref: ../components/responses.yml#/Problem