feat(profile): persist candidate edits and enforce company access

This commit is contained in:
TakuyaYagam1 committed 2026-10-07 14:15:16 +03:00
1 parent 3ab6bd91a3
commit 73c7caa225
67 files changed
+5286 -229

No files matched your search

+87 -8
View File
@@ -552,6 +552,8 @@ paths:
Every value carries its confirmation state and provenance, and every claim has trust level 0. The self-assessed grade of a role is separate from `confirmed_categories`, which only assessment results establish and which no request writes. The profile needs no file, no ML extraction, and no FSP account.
`experience_overlaps` lists every pair of entries whose inclusive month ranges overlap. Its indices refer to this response's `experience` array and are scoped to the same `version`; each pair is either `needs_confirmation` or `confirmed`.
A missing, unknown, expired, or revoked session answers 401 unauthenticated; an employer account answers 403 forbidden.
security:
- sessionCookie: []
@@ -584,7 +586,7 @@ paths:
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 state of every field and list; see CandidateProfileUpdate for the decisions that it carries. It replaces the stored profile as a whole.
Every field is optional in substance: a profile can be saved with any subset filled and the rest null or empty, so no value requires a resume, the ML service, an FSP account, or any other file or link. Which fields are needed to leave the onboarding step candidate_profile is an open product question that this contract does not decide; a save on that step advancing the account to candidate_questionnaire is planned.
Every field is optional in substance: a profile can be saved with any subset filled and the rest null or empty, so no value requires a resume, the ML service, an FSP account, or any other file or link. A successful save advances an account whose current onboarding step is candidate_profile to candidate_questionnaire, including a no-op save; it never moves a later step backwards. This update is atomic with the profile and its history.
Provenance is the server's: a value typed in the form is `manual`, confirming a stored suggestion keeps its origin, and every claim keeps trust level 0. The body has no origin, trust level, confirmation time, confirmed grade, or category, and unknown fields are rejected. A self-assessed grade never becomes a confirmed grade or a category.
@@ -594,7 +596,9 @@ paths:
The save replaces the stored claims as a whole. A suggestion that an import stored and that the client did not render and send back with the decision `extracted` is dropped by the save; a client therefore sends every suggestion that it received, and a client that read an older version gets 412 instead of silently dropping a suggestion it never saw.
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), domain rules that depend on the body alone (400), then the rules that depend on the stored claims against the version: a decision `extracted` for a value that is not a stored suggestion answers 412 when `expected_version` is stale, because another save may have confirmed that value, and 400 when it is current; an unchanged body (200); any other change over a stale version (412). The schema rejects an unknown field, an unknown specialization or grade, a phone number outside E.164, a Telegram username without the leading @, an email that is not an address, a month outside `YYYY-MM`, a salary that is not a positive multiple of 1000, and more items than a list allows. The server also rejects a repeated tag, skill, or role specialization, a period that ends before it starts or lies in the future, and a decision `extracted` for a value that is not a stored suggestion, with 400 validation_failed and pointers to the items, for example `/roles/1/specialization` or `/stack/1/status`. Error bodies never repeat a submitted value.
Experience periods use inclusive calendar months. An overlap is allowed only when `confirmed_parallel_periods` explicitly acknowledges that the two date ranges are genuine parallel work. Each acknowledgement names two distinct experience indices and repeats their exact normalized `started_on` and `ended_on` values; both indices and periods must match the submitted array and `expected_version`. A new or changed period needs an acknowledgement in that PUT. The server carries an earlier acknowledgement only when the same two indices still contain the same dates; reordering or changing either date requires a new acknowledgement. Editing other experience fields does not invalidate a matching date-pair acknowledgement. A missing acknowledgement answers 400 with pointers to the period fields and changes nothing. Duplicate, out-of-range, self, and non-overlapping acknowledgements are invalid.
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), domain rules that depend on the body alone (400), then the rules that depend on the stored claims against the version: a decision `extracted` for a value that is not a stored suggestion answers 412 when `expected_version` is stale, because another save may have confirmed that value, and 400 when it is current; an unchanged body (200); any other change over a stale version (412). The schema rejects an unknown field, an unknown specialization or grade, a phone number outside E.164, a Telegram username without the leading @, an email that is not an address, a month outside `YYYY-MM`, a salary that is not a positive multiple of 1000, and more items than a list allows. The server also rejects a repeated tag, skill, or role specialization, a period that ends before it starts or lies in the future, a changed overlap without explicit confirmation, and a decision `extracted` for a value that is not a stored suggestion, with 400 validation_failed and pointers to the items, for example `/roles/1/specialization` or `/stack/1/status`. Error bodies never repeat a submitted value.
security:
- sessionCookie: []
sessionCsrf: []
@@ -1152,15 +1156,13 @@ paths:
/api/v1/organizations/{org_id}:
get:
operationId: GetOrganization
summary: Read an organization of which the caller is a member.
summary: Read an organization managed by the caller.
description: |-
Requires the session cookie of an employer account with an active membership in `org_id`. The organization comes from the path and is checked against the membership that the server holds for the session account on every request; the identifier itself grants nothing.
Requires the session cookie of a verified employer account with an active owner membership in `org_id`. The organization comes from the path and is checked against the membership that the server holds for the session account on every request; the identifier itself grants nothing.
Returns the profile with its current `version`, the verification level (`verification`), and the card as a candidate sees it (`candidate_card`). The verification level is always the one the server holds: it never rises because the profile is complete, because the organization has members, or because of an email domain. The role of the caller is not part of this resource; ListMyOrganizations returns it with the membership.
In the MVP the profile is readable by any active member; every member is an owner, because the operations that add members are planned. The roles of PRD FR07 that read a company card without managing it change no field of this contract.
Access: a missing, unknown, expired, or revoked session answers 401 unauthenticated; a candidate account answers 403 forbidden; an account without an active membership in the organization, including a `suspended`, `removed`, or `left` one, and an unknown organization all answer 404 not_found, so organizations cannot be enumerated. A malformed `org_id` answers 400 validation_failed with the path pointer.
Access: a missing, unknown, expired, or revoked session answers 401 unauthenticated; a candidate account answers 403 forbidden; an account without an active membership in the organization, including a `suspended`, `removed`, or `left` one, and an unknown organization all answer 404 not_found, so organizations cannot be enumerated. An active member whose role is not `owner` answers 403 forbidden. A malformed `org_id` answers 400 validation_failed with the path pointer.
security:
- sessionCookie: []
tags:
@@ -4067,6 +4069,68 @@ components:
$ref: '#/components/schemas/ProfileItemStatus'
source:
$ref: '#/components/schemas/ProfileClaimSource'
ProfileExperienceOverlapStatus:
type: string
description: Whether the candidate confirmed that two overlapping periods are genuine parallel work.
enum:
- needs_confirmation
- confirmed
ProfileExperienceOverlap:
type: object
description: One pair of work history entries whose inclusive month ranges overlap. The indices refer to the experience array in this profile version. `confirmed` records an explicit acknowledgement for this pair of dates; otherwise the pair needs confirmation before a changed profile can be saved.
additionalProperties: false
required:
- first_index
- second_index
- status
properties:
first_index:
type: integer
minimum: 0
maximum: 19
second_index:
type: integer
minimum: 1
maximum: 19
status:
$ref: '#/components/schemas/ProfileExperienceOverlapStatus'
ProfileExperiencePeriod:
type: object
description: The exact month range of an experience entry, copied into a confirmation.
additionalProperties: false
required:
- started_on
- ended_on
properties:
started_on:
$ref: '#/components/schemas/ProfileYearMonth'
ended_on:
description: Last month of work, or null when the period is open-ended.
oneOf:
- $ref: '#/components/schemas/ProfileYearMonth'
- type: 'null'
ProfileParallelPeriodConfirmation:
type: object
description: Explicit acknowledgement that the two indexed experience periods are genuine parallel work. The indices and exact ranges must match the submitted experience array; expected_version binds the acknowledgement to the profile version the candidate read.
additionalProperties: false
required:
- first_index
- second_index
- first_period
- second_period
properties:
first_index:
type: integer
minimum: 0
maximum: 19
second_index:
type: integer
minimum: 1
maximum: 19
first_period:
$ref: '#/components/schemas/ProfileExperiencePeriod'
second_period:
$ref: '#/components/schemas/ProfileExperiencePeriod'
ProfileConfirmedCategory:
type: object
description: 'A category that an assessment result confirmed: the specialization with the confirmed grade. It is read-only and derived by the server from the assessment results of the candidate; no request carries it and the profile storage holds no such column, so neither a form nor an import can write a confirmed grade. It is separate from the claims of the profile and from the self-assessed grades in `roles`.'
@@ -4101,6 +4165,7 @@ components:
- stack
- roles
- experience
- experience_overlaps
- soft_skills
- terms
- confirmed_categories
@@ -4130,6 +4195,12 @@ components:
description: Work history entries in the order the candidate gave them.
items:
$ref: '#/components/schemas/ProfileExperienceItem'
experience_overlaps:
type: array
maxItems: 190
description: Every pair of overlapping experience periods, with its confirmation status. The indices refer to this version's experience array.
items:
$ref: '#/components/schemas/ProfileExperienceOverlap'
soft_skills:
type: array
maxItems: 10
@@ -4389,6 +4460,12 @@ components:
description: Work history entries.
items:
$ref: '#/components/schemas/ProfileExperienceItemInput'
confirmed_parallel_periods:
type: array
maxItems: 190
description: Explicit acknowledgements for overlapping periods. Each pair must use distinct in-range indices and repeat the exact normalized started_on and ended_on values of those entries in this body. A changed or reordered period needs a new acknowledgement. The server retains a previous acknowledgement only for the same indices and dates. Duplicate pairs and pairs that do not overlap are rejected.
items:
$ref: '#/components/schemas/ProfileParallelPeriodConfirmation'
soft_skills:
type: array
maxItems: 10
@@ -9756,7 +9833,7 @@ components:
version_conflict:
$ref: '#/components/examples/VersionConflict'
ProfileValidationFailed:
description: 'The body does not match the contract or violates a profile rule: an unknown field such as confirmed_grade, category, trust_level, or source, a phone number outside E.164, a Telegram username without the leading @, an email that is not an address, a month outside the YYYY-MM format, a salary that is not a positive multiple of 1000, more items than a list allows, a repeated tag, skill, or role specialization, a period that ends before it starts or lies in the future, a decision extracted for a value that is not a stored suggestion, or a missing or invalid expected_version; code validation_failed with body pointers. A missing nested field has its own pointer with the code required; an unknown field points at the object that contains it, a failure inside an array element points at the array, and only a malformed document, an unknown top-level field, or an unknown top-level variant points at the whole body. Nothing was changed. The problem never repeats a submitted value, because the body is personal data.'
description: 'The body does not match the contract or violates a profile rule: an unknown field such as confirmed_grade, category, trust_level, or source, a phone number outside E.164, a Telegram username without the leading @, an email that is not an address, a month outside the YYYY-MM format, a salary that is not a positive multiple of 1000, more items than a list allows, a repeated tag, skill, or role specialization, a period that ends before it starts or lies in the future, a decision extracted for a value that is not a stored suggestion, an overlapping experience period without an explicit date-pair acknowledgement, or a missing or invalid expected_version; code validation_failed with body pointers. A missing nested field has its own pointer with the code required; an unknown field points at the object that contains it, a failure inside an array element points at the array, and only a malformed document, an unknown top-level field, or an unknown top-level variant points at the whole body. Nothing was changed. The problem never repeats a submitted value, because the body is personal data.'
content:
application/problem+json:
schema:
@@ -10480,6 +10557,7 @@ components:
stack: []
roles: []
experience: []
experience_overlaps: []
soft_skills: []
terms:
location:
@@ -10573,6 +10651,7 @@ components:
quote: null
extraction_version: null
confirmed_at: '2026-10-05T09:30:00Z'
experience_overlaps: []
soft_skills:
- skill: Mentoring
status: confirmed