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

@@ -628,6 +628,32 @@ func (UnimplementedHandler) GetMyAssessmentResult(ctx context.Context, params Ge
return r, ht.ErrNotImplemented
}
// GetMyCardPreview implements GetMyCardPreview operation.
//
// 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.
//
// GET /api/v1/me/privacy/preview
func (UnimplementedHandler) GetMyCardPreview(ctx context.Context) (r GetMyCardPreviewRes, _ error) {
return r, ht.ErrNotImplemented
}
// GetMyInvitation implements GetMyInvitation operation.
//
// Requires the session cookie of a candidate account. The candidate comes from the session; the
@@ -662,6 +688,30 @@ func (UnimplementedHandler) GetMyInvitation(ctx context.Context, params GetMyInv
return r, ht.ErrNotImplemented
}
// GetMyPrivacySettings implements GetMyPrivacySettings operation.
//
// 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.
//
// GET /api/v1/me/privacy
func (UnimplementedHandler) GetMyPrivacySettings(ctx context.Context) (r GetMyPrivacySettingsRes, _ error) {
return r, ht.ErrNotImplemented
}
// GetMyProfile implements GetMyProfile operation.
//
// Requires the session cookie of a candidate account. The candidate comes from the session, never from
@@ -878,6 +928,72 @@ func (UnimplementedHandler) GetSpecializationCatalog(ctx context.Context) (r *Sp
return r, ht.ErrNotImplemented
}
// HideOrganization implements HideOrganization operation.
//
// 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).
//
// PUT /api/v1/me/privacy/hidden-organizations/{org_id}
func (UnimplementedHandler) HideOrganization(ctx context.Context, params HideOrganizationParams) (r HideOrganizationRes, _ error) {
return r, ht.ErrNotImplemented
}
// ListMyCardAccessHistory implements ListMyCardAccessHistory operation.
//
// 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.
//
// GET /api/v1/me/privacy/access-history
func (UnimplementedHandler) ListMyCardAccessHistory(ctx context.Context, params ListMyCardAccessHistoryParams) (r ListMyCardAccessHistoryRes, _ error) {
return r, ht.ErrNotImplemented
}
// ListMyConsents implements ListMyConsents operation.
//
// Requires the session cookie of a candidate or an employer account. The subject comes from the
@@ -910,6 +1026,25 @@ func (UnimplementedHandler) ListMyConsents(ctx context.Context, params ListMyCon
return r, ht.ErrNotImplemented
}
// ListMyHiddenOrganizations implements ListMyHiddenOrganizations operation.
//
// 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.
//
// GET /api/v1/me/privacy/hidden-organizations
func (UnimplementedHandler) ListMyHiddenOrganizations(ctx context.Context, params ListMyHiddenOrganizationsParams) (r ListMyHiddenOrganizationsRes, _ error) {
return r, ht.ErrNotImplemented
}
// ListMyInvitations implements ListMyInvitations operation.
//
// Requires the session cookie of a candidate account. The candidate comes from the session, never from
@@ -963,6 +1098,27 @@ func (UnimplementedHandler) ListMyOrganizations(ctx context.Context, params List
return r, ht.ErrNotImplemented
}
// ListMyPrivacyHistory implements ListMyPrivacyHistory operation.
//
// 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.
//
// GET /api/v1/me/privacy/history
func (UnimplementedHandler) ListMyPrivacyHistory(ctx context.Context, params ListMyPrivacyHistoryParams) (r ListMyPrivacyHistoryRes, _ error) {
return r, ht.ErrNotImplemented
}
// ListMySupportCases implements ListMySupportCases operation.
//
// Requires the session cookie of a candidate or an employer account. Returns a page of the cases that
@@ -1311,6 +1467,96 @@ func (UnimplementedHandler) SendOrganizationInvitation(ctx context.Context, req
return r, ht.ErrNotImplemented
}
// SetMyPublication implements SetMyPublication operation.
//
// 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.
//
// PUT /api/v1/me/privacy/publication
func (UnimplementedHandler) SetMyPublication(ctx context.Context, req *PublicationUpdate) (r SetMyPublicationRes, _ error) {
return r, ht.ErrNotImplemented
}
// SetMySearchStatus implements SetMySearchStatus operation.
//
// 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).
//
// PUT /api/v1/me/privacy/search-status
func (UnimplementedHandler) SetMySearchStatus(ctx context.Context, req *SearchStatusUpdate) (r SetMySearchStatusRes, _ error) {
return r, ht.ErrNotImplemented
}
// SubmitMyAssessmentAnswer implements SubmitMyAssessmentAnswer operation.
//
// Requires the session cookie of a candidate account, the CSRF token of that session in X-CSRF-Token,
@@ -1371,6 +1617,27 @@ func (UnimplementedHandler) SubmitMyAssessmentAnswer(ctx context.Context, req *A
return r, ht.ErrNotImplemented
}
// UnhideOrganization implements UnhideOrganization operation.
//
// 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).
//
// DELETE /api/v1/me/privacy/hidden-organizations/{org_id}
func (UnimplementedHandler) UnhideOrganization(ctx context.Context, params UnhideOrganizationParams) (r UnhideOrganizationRes, _ error) {
return r, ht.ErrNotImplemented
}
// UpdateOrganization implements UpdateOrganization operation.
//
// Requires the session cookie of an employer account with an active membership in `org_id`, the CSRF