diff --git a/.agents/standards/ml.md b/.agents/standards/ml.md index 98d1ad3..18548e8 100644 --- a/.agents/standards/ml.md +++ b/.agents/standards/ml.md @@ -1,6 +1,6 @@ # ML service standard -The ML service is a separate Python HTTP service. Its current role is an operational scaffold with health and readiness routes; there is no model-backed product endpoint yet. +The ML service is a separate Python HTTP service. It serves health and readiness routes and one model-backed endpoint, `POST /v1/embeddings`, with a pinned embedding model baked into its image. Ordinary tests use the deterministic fake encoder; the real model runs only in the marked slow test. Keep the service contract in api/ml/. The Go client uses backend/codegen/ogen-ml.yml and is consumed under backend/internal/adapter/secondary/ml/api/. Python model generation belongs to ml/codegen/pyproject.toml: datamodel-code-generator produces Pydantic v2 models from api/ml/openapi.bundle.yml in ml/src/lincodex_ml/api/models.py. Keep generator dependencies in ml/pyproject.toml and uv.lock; the codegen pyproject contains tool settings only. Health/readiness handlers import generated models instead of maintaining duplicate transport schemas. diff --git a/api/README.en.md b/api/README.en.md index 101e7b7..1d0f3f1 100644 --- a/api/README.en.md +++ b/api/README.en.md @@ -99,7 +99,7 @@ Timestamps use the `Timestamp` schema: `string`, `format: date-time`, UTC with t ### ML service errors -The ML service answers its errors with the same `Problem` schema. Its `ProblemCode` enum keeps the public identity codes so both contracts share one shape, but the service never returns them. FastAPI request validation answers 400 `validation_failed`. An HTTP exception raised inside the service maps by status: 400, 401, 403, 404, 405, 409 (`state_conflict`), 412, 413, 415, 428, 429, and 501 to their codes, 422 to 400 `validation_failed`, any other 4xx to 400 `validation_failed`, and any other 5xx to 500 `internal`. An unhandled exception answers 500 `internal` inside the application, so Starlette does not re-raise it to uvicorn; only its type is logged. The service also routes the uvicorn loggers through its JSON log format, which keeps only the exception type of a record and never its text or traceback. +The ML service answers its errors with the same `Problem` schema. Its `ProblemCode` enum keeps the public identity codes so both contracts share one shape, but the service never returns them. FastAPI request validation answers 400 `validation_failed`. An HTTP exception raised inside the service maps by status: 400, 401, 403, 404, 405, 409 (`state_conflict`), 412, 413, 415, 428, 429, 501, and 503 (`service_unavailable`, while the model is not ready) to their codes, 422 to 400 `validation_failed`, any other 4xx to 400 `validation_failed`, and any other 5xx to 500 `internal`. An unhandled exception answers 500 `internal` inside the application, so Starlette does not re-raise it to uvicorn; only its type is logged. The service also routes the uvicorn loggers through its JSON log format, which keeps only the exception type of a record and never its text or traceback. ### Code runner contract @@ -201,6 +201,7 @@ The `candidate` tag includes implemented `GetMyProfile` and `SaveMyProfile` oper | --- | --- | --- | --- | --- | | `GET /api/v1/me/profile` | `GetMyProfile` | session | 200 `CandidateProfile`, `Cache-Control: no-store` | 401 `unauthenticated`, 403 `forbidden` | | `PUT /api/v1/me/profile` | `SaveMyProfile` | session and CSRF | 200 `CandidateProfile`, `Cache-Control: no-store` | 400 `validation_failed`, 401, 403 `csrf_check_failed` or `forbidden`, 412 `version_conflict` | +| `POST /api/v1/me/profile/repository-checks` | `RequestMyRepositoryChecks` | session and CSRF | 202 `ProfileRepositoryCheckRequest`, `Cache-Control: no-store` | 401, 403 `csrf_check_failed` or `forbidden`, 429 `rate_limited` with Retry-After | Each operation also declares the default problem response. No new problem code is added: the contract uses `validation_failed`, `unauthenticated`, `forbidden`, `csrf_check_failed`, and `version_conflict`. @@ -253,6 +254,8 @@ Open questions for the product owner and legal: `TestCandidateProfileOperationsFollowTheConventions`, `TestCandidateProfileSeparatesSelfAssessedGradeFromConfirmedCategory`, `TestCandidateProfileClaimsCarrySourceAndTrustLevelZero`, `TestPrivateProfileSchemasAreNotMixedWithOrganizationVisibleDTOs`, `TestGeneratedProfileDTOsCarryNoConfirmedGradeInRequests`, `TestProfileSchemaValidationPrecedesImplementation`, and `TestProfileAccessBeforeImplementation` pin the generated server and the bundle, and `frontend/src/shared/api/profile-contract.test.ts` pins the generated Zod rules, the request types without a confirmed grade, and the absence of profile fields from the organization, invitation, and need schemas. + +Projects: the optional `projects` list of the `SaveMyProfile` body (up to 10; an absent list keeps the projects, an empty array removes them) with a title, description, tags, and an address `https://github.com//`; other addresses answer 400 with the pointer `/projects//repository_url`. The `CandidateProfile` response carries `projects[].repository_check` (`pending`, `verified`, `not_found`, `unavailable`). `RequestMyRepositoryChecks` repeats the checks on `api.github.com` at most once per stand interval. Publishing projects on the card is the separate `projects` value of `CardField` (see [architecture](../docs/en/ARCHITECTURE.md#candidate-projects-and-github-repositories)). ### Assessment The `assessment` tag covers the assessment attempts of the current candidate (PRD FR04 and FR05): availability, start and resume, answers including the code practice, finalization, and the result. The operations are in the contract, but their business logic is not implemented: a guest answers 401 `unauthenticated`, and a request with a verified session reaches 501 `not_implemented` after request validation. Unsafe protected operations also require the session-bound CSRF token and exact Origin. @@ -750,9 +753,10 @@ The operation changes nothing and needs no Idempotency-Key; `POST` carries the b - Basis. `MatchSearchByNeed` searches the immutable `requirements_version` snapshot (not the general `version`), and its optional `filters` narrow it; `MatchSearchByBank` searches all organization-visible entries with explicit filters. The response `source` repeats the basis: the need reference, or the bank filters with every key present and null for a filter that was not sent (the stack is sorted). - Entries. Every entry is one candidate specialization under the organization-scoped `candidate_handle`. `main` and `near` hold confirmed categories (`near` when a required skill of the request earns less than 0.25), `unconfirmed` holds the declared specializations, sorted by Fit, then Coverage, then an internal identifier that is never returned. An unconfirmed entry has `category: null`, `strength: null`, and only `fit` and `coverage`. The groups are not one scale, and one handle can be confirmed in one specialization and unconfirmed in another. - Category basis. Each confirmed category of an entry carries `basis` (`synthetic_demo` for a demonstration category). The organization sees a demonstration as such, not as a standard confirmation; the field is required in `MatchCategory`. -- Neutral and unknown values. The semantics component is 0.5 for every entry with `ml_unavailable`; `percentile` is null with `cohort_below_30` and T is 0.5 (no comparable real cohort exists, and demonstration results never form one); domain, freshness, and responsiveness are 0.5 with their flags; competition is 0 and is neither a penalty nor an unknown; a card value that is not published is `null` in `public_context` with `not_in_public_card`. +- Neutral and unknown values. The semantics component is the calibrated cosine of the stored vectors of the need and the card, and 0.5 with `ml_unavailable` without them; `percentile` is null with `cohort_below_30` and T is 0.5 (no comparable real cohort exists, and demonstration results never form one); domain, freshness, and responsiveness are 0.5 with their flags; competition is 0 and is neither a penalty nor an unknown; a card value that is not published is `null` in `public_context` with `not_in_public_card`. - A search is charged like card reads, because an entry carries card content. The whole visible bank is ranked, and each group returns at most `max_results_per_group` entries of the policy version (demo 10, so at most 30 reveals for one search, below the 50 views per day of tier E0); no total is returned. In the order `main`, `near`, `unconfirmed`, each newly revealed candidate counts as one distinct card view of the organization (the same reservation as `GetOrganizationCandidateCard`, so a candidate already viewed inside the window costs nothing again, and repeating the search or opening the card afterwards does not charge twice) and gets one `card_viewed` entry in the access history per search with the fields actually returned. When the allowance ends, the entries already paid for are returned with `truncated: true`, nothing is written for the rest, and no error and no new problem code is returned. `truncated` is also true when a group exceeded its limit and never carries a count. The response `truncated` is required. - No contact, candidate location, salary amount or minimum, raw answer, failed attempt, or reason for withheld data is in any entry; the explanation uses the bounded `MatchEvidenceCode` and `MatchEvidenceState` values only. A deployment whose effective policy has no `matching` section answers an internal error and never ranks with defaults. +- `semantic_evidence` (up to 12, 6 by default) explains a need search: a requirement of the need, the closest item of the published card (`project`, `stack`, `roles`), the band `high` or `medium`, and `repository_verified`. A project is named only by its published title (the card field `projects`), never by the repository address or owner; no model text enters the explanation ([architecture](../docs/en/ARCHITECTURE.md#semantic-layer-and-explanations)). Accepted residual risks: `truncated` is one bit about the size of the visible bank, and the response time grows with it; both are bounded by the group limit and carry no count. When the real comparable cohort of a category reaches the policy minimum, the percentile is still null with the reason `percentile_not_computed` and the search does not fail. A change of the visible cohort during a search repeats it up to three times; two simultaneous searches of one organization are serialized by its quota lock. diff --git a/api/README.md b/api/README.md index d1b352b..e8d8fe3 100644 --- a/api/README.md +++ b/api/README.md @@ -99,7 +99,7 @@ ### Ошибки ML-сервиса -ML-сервис отвечает на ошибки той же схемой `Problem`. Его перечисление `ProblemCode` сохраняет публичные коды identity, чтобы оба контракта имели одну форму, но сервис их никогда не возвращает. Валидация запроса FastAPI дает 400 `validation_failed`. HTTP-исключение внутри сервиса преобразуется по статусу: 400, 401, 403, 404, 405, 409 (`state_conflict`), 412, 413, 415, 428, 429 и 501 - в свои коды, 422 - в 400 `validation_failed`, любой другой 4xx - в 400 `validation_failed`, любой другой 5xx - в 500 `internal`. Необработанное исключение дает 500 `internal` внутри приложения, поэтому Starlette не пробрасывает его в uvicorn; в лог попадает только тип. Сервис также направляет логгеры uvicorn через свой JSON-формат, который сохраняет только тип исключения записи, но не текст и не traceback. +ML-сервис отвечает на ошибки той же схемой `Problem`. Его перечисление `ProblemCode` сохраняет публичные коды identity, чтобы оба контракта имели одну форму, но сервис их никогда не возвращает. Валидация запроса FastAPI дает 400 `validation_failed`. HTTP-исключение внутри сервиса преобразуется по статусу: 400, 401, 403, 404, 405, 409 (`state_conflict`), 412, 413, 415, 428, 429, 501 и 503 (`service_unavailable`, пока модель не готова) - в свои коды, 422 - в 400 `validation_failed`, любой другой 4xx - в 400 `validation_failed`, любой другой 5xx - в 500 `internal`. Необработанное исключение дает 500 `internal` внутри приложения, поэтому Starlette не пробрасывает его в uvicorn; в лог попадает только тип. Сервис также направляет логгеры uvicorn через свой JSON-формат, который сохраняет только тип исключения записи, но не текст и не traceback. ### Контракт исполнителя кода @@ -201,6 +201,7 @@ ML-сервис отвечает на ошибки той же схемой `Pro | --- | --- | --- | --- | --- | | `GET /api/v1/me/profile` | `GetMyProfile` | сессия | 200 `CandidateProfile`, `Cache-Control: no-store` | 401 `unauthenticated`, 403 `forbidden` | | `PUT /api/v1/me/profile` | `SaveMyProfile` | сессия и CSRF | 200 `CandidateProfile`, `Cache-Control: no-store` | 400 `validation_failed`, 401, 403 `csrf_check_failed` или `forbidden`, 412 `version_conflict` | +| `POST /api/v1/me/profile/repository-checks` | `RequestMyRepositoryChecks` | сессия и CSRF | 202 `ProfileRepositoryCheckRequest`, `Cache-Control: no-store` | 401, 403 `csrf_check_failed` или `forbidden`, 429 `rate_limited` с Retry-After | Каждая операция также объявляет problem-ответ `default`. Новый код problem не добавляется: контракт использует `validation_failed`, `unauthenticated`, `forbidden`, `csrf_check_failed` и `version_conflict`. @@ -253,6 +254,8 @@ ML-сервис отвечает на ошибки той же схемой `Pro `TestCandidateProfileOperationsFollowTheConventions`, `TestCandidateProfileSeparatesSelfAssessedGradeFromConfirmedCategory`, `TestCandidateProfileClaimsCarrySourceAndTrustLevelZero`, `TestPrivateProfileSchemasAreNotMixedWithOrganizationVisibleDTOs`, `TestGeneratedProfileDTOsCarryNoConfirmedGradeInRequests`, `TestProfileSchemaValidationPrecedesImplementation` и `TestProfileAccessBeforeImplementation` закрепляют сгенерированный сервер и бандл, а `frontend/src/shared/api/profile-contract.test.ts` - сгенерированные правила Zod, типы запросов без подтвержденного грейда и отсутствие полей профиля в схемах организации, приглашения и потребности. + +Проекты: необязательный в теле `SaveMyProfile` список `projects` (до 10; отсутствие сохраняет проекты, пустой массив удаляет) с названием, описанием, тегами и адресом `https://github.com//`; другие адреса дают 400 с указателем `/projects//repository_url`. Ответ `CandidateProfile` несет `projects[].repository_check` (`pending`, `verified`, `not_found`, `unavailable`). `RequestMyRepositoryChecks` повторяет проверки на `api.github.com` не чаще интервала стенда. Публикация проектов в карточке - отдельное поле `projects` в `CardField` (см. [архитектуру](../docs/ru/ARCHITECTURE.md#проекты-кандидата-и-репозитории-github)). ### Оценка Тег `assessment` описывает попытки оценки текущего кандидата (FR04 и FR05 в PRD): доступность, старт и возобновление, ответы вместе с кодовой практикой, завершение и результат. Операции есть в контракте, но их бизнес-логика еще не реализована: гость получает 401 `unauthenticated`, а запрос с подтвержденной сессией достигает 501 `not_implemented` после проверки запроса. Небезопасные защищенные операции также требуют session-bound CSRF-токен и точный Origin. @@ -750,9 +753,10 @@ ML-сервис отвечает на ошибки той же схемой `Pro - Основание. `MatchSearchByNeed` ищет по неизменяемому снимку `requirements_version` (не по общей `version`), необязательные `filters` сужают его; `MatchSearchByBank` ищет по всем записям, видимым организации, с явными фильтрами. `source` в ответе повторяет основание: ссылку на потребность либо фильтры банка, где присутствует каждый ключ, а неотправленный фильтр равен null (стек отсортирован). - Записи. Каждая запись - одна специализация кандидата под организационным `candidate_handle`. В `main` и `near` лежат подтвержденные категории (`near`, если обязательный навык запроса дает меньше 0.25), в `unconfirmed` - заявленные специализации, отсортированные по Fit, затем Coverage, затем по внутреннему идентификатору, который не возвращается. У неподтвержденной записи `category: null`, `strength: null` и только `fit` и `coverage`. Группы - не одна шкала, и один handle может быть подтвержден по одной специализации и не подтвержден по другой. - Основание категории. Каждая подтвержденная категория записи несет `basis` (`synthetic_demo` для демонстрационной категории). Организация видит демонстрацию как таковую, а не как стандартное подтверждение; поле обязательно в `MatchCategory`. -- Нейтральные и неизвестные значения. Семантика равна 0.5 для каждой записи с `ml_unavailable`; `percentile` равен null с `cohort_below_30`, а T равен 0.5 (сопоставимой реальной когорты нет, демонстрационные результаты ее не образуют); домен, свежесть и своевременность равны 0.5 со своими признаками; соревновательный вклад равен 0 и не является ни штрафом, ни неизвестностью; неопубликованное значение карточки - `null` в `public_context` с `not_in_public_card`. +- Нейтральные и неизвестные значения. Семантика - калиброванный косинус сохраненных векторов потребности и карточки, а без них 0.5 с `ml_unavailable`; `percentile` равен null с `cohort_below_30`, а T равен 0.5 (сопоставимой реальной когорты нет, демонстрационные результаты ее не образуют); домен, свежесть и своевременность равны 0.5 со своими признаками; соревновательный вклад равен 0 и не является ни штрафом, ни неизвестностью; неопубликованное значение карточки - `null` в `public_context` с `not_in_public_card`. - Поиск оплачивается как чтение карточек, потому что запись несет содержимое карточки. Ранжируется весь видимый банк, а каждая группа возвращает не более `max_results_per_group` записей версии политики (демо 10, то есть не более 30 показов за один поиск, меньше 50 просмотров в сутки для уровня E0); итог не возвращается. В порядке `main`, `near`, `unconfirmed` каждый впервые показанный кандидат считается одним уникальным просмотром карточки организации (то же резервирование, что у `GetOrganizationCandidateCard`: кандидат, уже просмотренный в окне, второй раз ничего не стоит, и повтор поиска или последующее открытие карточки не списывает дважды) и получает по одной записи `card_viewed` в истории доступа за поиск с фактически возвращенными полями. Когда лимит заканчивается, возвращаются уже оплаченные записи с `truncated: true`, для остальных ничего не пишется, ошибка и новый код проблемы не возвращаются. `truncated` также истинно, когда группа превысила предел, и никогда не несет число. В ответе `truncated` обязателен. -- Ни в одной записи нет контакта, локации кандидата, суммы или минимума зарплаты, сырого ответа, проваленной попытки и причины скрытых данных; объяснение использует только ограниченные значения `MatchEvidenceCode` и `MatchEvidenceState`. Развертывание, действующая политика которого не содержит раздела `matching`, отвечает внутренней ошибкой и не ранжирует по умолчаниям. +- Ни в одной записи нет контакта, локации кандидата, суммы или минимума зарплаты, сырого ответа, проваленной попытки и причины скрытых данных; объяснение использует только ограниченные значения `MatchEvidenceCode` и `MatchEvidenceState`. +- `semantic_evidence` (до 12, по умолчанию 6) объясняет поиск по потребности: требование потребности, ближайший элемент опубликованной карточки (`project`, `stack`, `roles`), полоса `high` или `medium` и `repository_verified`. Проект назван только опубликованным названием (поле карточки `projects`), без адреса и владельца репозитория; текст модели в объяснение не входит ([архитектура](../docs/ru/ARCHITECTURE.md#семантический-слой-и-объяснения)). Развертывание, действующая политика которого не содержит раздела `matching`, отвечает внутренней ошибкой и не ранжирует по умолчаниям. Принятые остаточные риски: `truncated` - один бит о размере видимого банка, и время ответа растет вместе с ним; оба ограничены пределом группы и не несут числа. Когда реальная сопоставимая когорта категории достигает минимума политики, перцентиль все равно null с причиной `percentile_not_computed`, и поиск не падает. Изменение видимой когорты во время поиска повторяет его до трех раз; два одновременных поиска одной организации сериализуются ее блокировкой квоты. diff --git a/api/core/components/examples.yml b/api/core/components/examples.yml index f661471..288e164 100644 --- a/api/core/components/examples.yml +++ b/api/core/components/examples.yml @@ -4020,6 +4020,7 @@ NewCandidateProfile: experience: [] experience_overlaps: [] soft_skills: [] + projects: [] terms: location: status: unknown @@ -4129,6 +4130,25 @@ BackendCandidateProfile: quote: null extraction_version: null confirmed_at: "2026-10-05T09:30:00Z" + projects: + - title: Payment webhook deduplication service + description: >- + Idempotent receiver for acquirer callbacks with a unique operation + key and an outbox for retries. + stack: + - Go + - PostgreSQL + repository_url: https://github.com/example-org/payments-ledger + repository_check: + state: verified + checked_at: "2026-10-05T09:31:00Z" + status: confirmed + source: + origin: manual + trust_level: 0 + quote: null + extraction_version: null + confirmed_at: "2026-10-05T09:30:00Z" terms: location: status: confirmed @@ -4412,6 +4432,7 @@ PublishedCardPreview: experience_band: "1_3" work_formats: null salary_compatibility: null + projects: null evidence: items: - skill: backend @@ -4438,6 +4459,7 @@ OrganizationAnonymousCandidateCard: experience_band: "1_3" work_formats: null salary_compatibility: null + projects: null ClosedCardPreview: summary: The preview of a closed profile value: diff --git a/api/core/components/examples/matches.yml b/api/core/components/examples/matches.yml index 0ee943a..7d7da17 100644 --- a/api/core/components/examples/matches.yml +++ b/api/core/components/examples/matches.yml @@ -69,6 +69,7 @@ ThreeGroups: state: supports - code: work_conditions_match state: supports + semantic_evidence: [] components: fit: 0.78 coverage: 0.72 @@ -102,6 +103,7 @@ ThreeGroups: state: supports - code: required_skill_evidence state: gap + semantic_evidence: [] components: fit: 0.48 coverage: 0.18 @@ -135,6 +137,7 @@ ThreeGroups: state: declared_only - code: required_skill_evidence state: partial + semantic_evidence: [] components: fit: 0.51 coverage: 0.38 @@ -197,6 +200,7 @@ MLUnavailable: evidence_summary: - code: confirmed_category state: supports + semantic_evidence: [] components: fit: 0.7 coverage: 0.6 @@ -249,6 +253,7 @@ CohortBelow30: evidence_summary: - code: confirmed_category state: supports + semantic_evidence: [] components: fit: 0.62 coverage: 0.55 @@ -301,6 +306,7 @@ Truncated: evidence_summary: - code: confirmed_category state: supports + semantic_evidence: [] components: fit: 0.5 coverage: 0.5 @@ -319,3 +325,78 @@ Truncated: near: [] unconfirmed: [] truncated: true + +SemanticEvidence: + summary: A need search explains an entry with semantic evidence from published card items. + description: >- + Synthetic example. `semantics` is the calibrated cosine of the stored + vectors; each evidence item pairs one confirmed requirement of the need + with the closest published card item. The project is named only by the + title that the candidate published; the repository address never appears. + value: + source: + kind: need + need_id: 4d3a4a1b-4f60-44c1-9dc2-6c8e6c9d4c11 + requirements_version: 3 + groups: + main: + - candidate_handle: cv1_FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + specialization: backend + confirmation_status: confirmed + declared_grade: middle + category: + specialization: backend + grade: middle + basis: synthetic_demo + strength: standard + public_context: + stack: + - kafka + - postgresql + experience_band: "3_6" + work_formats: null + salary_compatibility: null + evidence_summary: + - code: confirmed_category + state: supports + - code: required_skill_evidence + state: declared_only + semantic_evidence: + - requirement_kind: task + requirement_text: Make payment callbacks idempotent + item_kind: project + project_title: Payment webhook deduplication service + repository_verified: true + similarity: high + - requirement_kind: required_skill + requirement_text: Kafka + item_kind: stack + project_title: null + repository_verified: false + similarity: medium + components: + fit: 0.69 + coverage: 0.25 + domain: 0.5 + semantics: 0.92 + percentile: null + competition: 0.0 + freshness: 0.5 + responsiveness: 0.5 + rank_score: 0.59 + unknown_flags: + - component: percentile + reason: cohort_below_30 + - component: freshness + reason: no_freshness_history + - component: responsiveness + reason: no_response_history + - component: work_formats + reason: not_in_public_card + - component: salary_compatibility + reason: not_in_public_card + - component: domain + reason: not_in_public_card + near: [] + unconfirmed: [] + truncated: false diff --git a/api/core/components/schemas.yml b/api/core/components/schemas.yml index a32a0f4..0a718c5 100644 --- a/api/core/components/schemas.yml +++ b/api/core/components/schemas.yml @@ -2267,6 +2267,112 @@ ProfileExperienceItem: $ref: '#/ProfileItemStatus' source: $ref: '#/ProfileClaimSource' +ProfileProjectTitle: + type: string + minLength: 1 + maxLength: 100 + pattern: ^\S(?:.*\S)?$ + description: Name of a project as the candidate wants an organization to read it. It has no leading or trailing whitespace and no line breaks. When the candidate publishes the `projects` card field, the title reaches the anonymous card and match explanations, so it must not contain a name, a contact, or a repository address. Plain text; clients show it as text, never as HTML. +ProfileProjectDescription: + type: string + minLength: 1 + maxLength: 500 + description: What the project does and what the candidate did in it. It may contain line breaks. When the `projects` card field is published it reaches the anonymous card. Plain text; clients show it as text, never as HTML. +ProfileRepositoryUrl: + type: string + minLength: 22 + maxLength: 160 + pattern: ^https://github\.com/[A-Za-z0-9](?:[A-Za-z0-9-]{0,38})/[A-Za-z0-9._-]{1,100}/?$ + description: Address of a public GitHub repository of the project in the form https://github.com//. The server accepts only this host and form, removes a trailing slash and a `.git` suffix, and stores the canonical address. Organizations never receive the address before an accepted invitation, because the owner name can identify the candidate. + examples: + - https://github.com/example-org/payments-ledger +ProfileRepositoryCheckState: + type: string + description: 'Result of the latest server check of a project repository on the public GitHub API. The server only reads public metadata; a check never proves that the candidate wrote the code. + + + - pending: the check is scheduled and has not finished yet. + + - verified: the repository exists and is public. Match explanations may then say that the project is backed by a public repository. + + - not_found: GitHub reports no such public repository; it may be private, renamed to another owner, or deleted. + + - unavailable: GitHub could not be asked, for example because of its rate limit; the server retries later.' + enum: + - pending + - verified + - not_found + - unavailable +ProfileRepositoryCheck: + type: object + description: State of the server check of a project repository. Read-only; no request writes it. The fetched metadata itself (description, topics, languages, and a plain-text README excerpt) is used only for ranking and is never returned or shown. + additionalProperties: false + required: + - state + - checked_at + properties: + state: + $ref: '#/ProfileRepositoryCheckState' + checked_at: + description: Time of the last finished check, or null before the first one. + oneOf: + - $ref: '#/Timestamp' + - type: 'null' +ProfileProjectStack: + type: array + maxItems: 10 + description: Technology tags of the project, each tag at most once without regard to letter case. + items: + $ref: '#/StackTag' +ProfileRepositoryCheckRequest: + type: object + description: Result of a request to check the linked repositories again. + additionalProperties: false + required: + - scheduled + properties: + scheduled: + type: integer + format: int32 + minimum: 0 + maximum: 10 + description: Number of repository checks that the request scheduled. +ProfileProjectItem: + type: object + description: One project of the candidate with its confirmation state and provenance. A project is a claim of trust level 0 that the candidate types; a linked repository adds a separate server check (`repository_check`), never a higher trust level. The project reaches organizations only when the candidate publishes the `projects` card field, and then without the repository address. + additionalProperties: false + required: + - title + - description + - stack + - repository_url + - repository_check + - status + - source + properties: + title: + $ref: '#/ProfileProjectTitle' + description: + description: What the project is about, or null when the candidate gives nothing. + oneOf: + - $ref: '#/ProfileProjectDescription' + - type: 'null' + stack: + $ref: '#/ProfileProjectStack' + repository_url: + description: Canonical repository address, or null when the project links none. + oneOf: + - $ref: '#/ProfileRepositoryUrl' + - type: 'null' + repository_check: + description: The server check of the linked repository, or null when the project links none. + oneOf: + - $ref: '#/ProfileRepositoryCheck' + - type: 'null' + status: + $ref: '#/ProfileItemStatus' + source: + $ref: '#/ProfileClaimSource' ProfileExperienceOverlapStatus: type: string description: Whether the candidate confirmed that two overlapping periods are genuine parallel work. @@ -2354,7 +2460,7 @@ ProfileConfirmedCategory: description: Assessment attempt whose result confirmed the grade. The attempt belongs to the candidate. CandidateProfile: type: object - description: 'The private profile of the current candidate: full name and contacts, stack, roles, work experience, soft skills, and desired terms, each value with its confirmation state and provenance. It is personal data that only the candidate reads. It is never an organization-visible schema: an organization sees a candidate only through the anonymous card and, after an accepted invitation, through the contact grant, and no organization schema refers to this one. + description: 'The private profile of the current candidate: full name and contacts, stack, roles, work experience, soft skills, projects, and desired terms, each value with its confirmation state and provenance. It is personal data that only the candidate reads. It is never an organization-visible schema: an organization sees a candidate only through the anonymous card and, after an accepted invitation, through the contact grant, and no organization schema refers to this one. Every value is a claim of trust level 0. The `self_assessed_grade` of a role is what the candidate says; the `confirmed_categories` list is what assessment results established, and the two are never mixed. A candidate who has not saved the profile gets version 0, every single field `unknown`, empty lists, and null `updated_at`. @@ -2369,6 +2475,7 @@ CandidateProfile: - experience - experience_overlaps - soft_skills + - projects - terms - confirmed_categories - updated_at @@ -2409,6 +2516,12 @@ CandidateProfile: description: Soft skills in the order the candidate gave them, each skill at most once without regard to letter case. items: $ref: '#/ProfileSoftSkillItem' + projects: + type: array + maxItems: 10 + description: Projects in the order the candidate gave them, each repository address at most once. + items: + $ref: '#/ProfileProjectItem' terms: $ref: '#/ProfileTerms' confirmed_categories: @@ -2620,9 +2733,34 @@ ProfileExperienceItemInput: - type: 'null' status: $ref: '#/ProfileItemStatus' +ProfileProjectItemInput: + type: object + description: Decision about one project in a request; see CandidateProfileUpdate for the rules of `status`. The server answers 400 with the pointer of the field for a repository address that is not a GitHub repository address, a repeated repository, or a repeated stack tag. + additionalProperties: false + required: + - title + - description + - stack + - repository_url + - status + properties: + title: + $ref: '#/ProfileProjectTitle' + description: + oneOf: + - $ref: '#/ProfileProjectDescription' + - type: 'null' + stack: + $ref: '#/ProfileProjectStack' + repository_url: + oneOf: + - $ref: '#/ProfileRepositoryUrl' + - type: 'null' + status: + $ref: '#/ProfileItemStatus' CandidateProfileUpdate: type: object - description: 'Complete new state of the candidate profile. It replaces every stored value as a whole: a single field sent as null is unknown and is removed, and a list replaces the stored list. The body is personal data. + description: 'Complete new state of the candidate profile. It replaces every stored value as a whole: a single field sent as null is unknown and is removed, and a list replaces the stored list; only `projects` may be omitted, which keeps the stored projects. The body is personal data. Each value carries a decision `status`. `confirmed` sets a manual value or confirms a stored suggestion; confirming a suggestion with exactly its stored value keeps its origin and quote, and any other value makes the claim manual. `extracted` keeps a stored suggestion unconfirmed and is accepted only with exactly the stored value; any other use answers 400 with the pointer of that status, for example `/stack/1/status`. The provenance, the trust level, and the confirmed categories are not part of the request, and unknown fields are rejected, so a request can neither mark a claim as verified nor write a confirmed grade or a category.' additionalProperties: false @@ -2674,6 +2812,12 @@ CandidateProfileUpdate: description: Soft skills. The server answers 400 with the pointer of a skill that repeats an earlier one without regard to letter case. items: $ref: '#/ProfileSoftSkillItemInput' + projects: + type: array + maxItems: 10 + description: 'Projects. Unlike the other lists this one is optional: a body without `projects` keeps the stored projects unchanged, so a client that does not know the section never deletes it, and an array, including an empty one, replaces the stored list. A new or changed repository address schedules a server check on the public GitHub API after the save commits; the save itself never waits for GitHub.' + items: + $ref: '#/ProfileProjectItemInput' terms: $ref: '#/ProfileTermsInput' DirectionCode: @@ -4946,6 +5090,72 @@ MatchEvidenceSummary: maxItems: 12 items: $ref: '#/MatchEvidenceSummaryItem' +MatchRequirementKind: + type: string + description: Kind of the need requirement that an explanation item answers. + enum: + - required_skill + - desired_skill + - task +MatchSemanticItemKind: + type: string + description: 'Kind of the published card item that matched a requirement. + + + - project: one published project; `project_title` names it. + + - stack: the recognized technology codes of the card. + + - roles: the specializations and grades that the card shows.' + enum: + - project + - stack + - roles +MatchSimilarityBand: + type: string + description: Coarse band of the cosine similarity between the requirement and the matched item under the versioned policy thresholds. `high` and `medium` are the only values; a weaker similarity produces no item. The band is a computed similarity of two texts, not a judgement of the candidate. + enum: + - high + - medium +MatchSemanticEvidence: + type: object + description: 'Why the entry is in the result: one confirmed requirement of the need and the published card item with the highest semantic similarity to it. The server computes it from stored vectors and the versioned thresholds; no model writes text into it. `requirement_text` is the confirmed text of the organization''s own need. `project_title` is the title the candidate published with the `projects` card field and is null for other kinds. No repository address, owner, or fetched repository text is ever part of it.' + additionalProperties: false + required: + - requirement_kind + - requirement_text + - item_kind + - project_title + - repository_verified + - similarity + properties: + requirement_kind: + $ref: '#/MatchRequirementKind' + requirement_text: + type: string + minLength: 1 + maxLength: 300 + description: Confirmed skill name or task text of the need. Plain text; show it as text, never as HTML. + item_kind: + $ref: '#/MatchSemanticItemKind' + project_title: + description: Published project title for `project`, otherwise null. Plain text; show it as text, never as HTML. + oneOf: + - type: string + minLength: 1 + maxLength: 100 + - type: 'null' + repository_verified: + type: boolean + description: True only for a project whose linked repository the latest server check found public on GitHub ("backed by a public repository"). It does not prove authorship. + similarity: + $ref: '#/MatchSimilarityBand' +MatchSemanticEvidenceList: + type: array + description: 'Semantic explanation items in a stable order: `high` before `medium`, then by similarity, then by the order of the requirements in the need. At most the versioned per-entry limit is returned. It is empty for a bank search, while vectors are not ready, when ML is unavailable, and when no requirement reaches a band; `unknown_flags` names `ml_unavailable` when the semantic component itself is unknown.' + maxItems: 12 + items: + $ref: '#/MatchSemanticEvidence' MatchPublicStack: type: array maxItems: 4 @@ -5048,6 +5258,7 @@ MatchConfirmedCandidate: - strength - public_context - evidence_summary + - semantic_evidence - components - unknown_flags properties: @@ -5072,6 +5283,8 @@ MatchConfirmedCandidate: $ref: '#/MatchPublicContext' evidence_summary: $ref: '#/MatchEvidenceSummary' + semantic_evidence: + $ref: '#/MatchSemanticEvidenceList' components: $ref: '#/MatchConfirmedComponents' unknown_flags: @@ -5089,6 +5302,7 @@ MatchUnconfirmedCandidate: - strength - public_context - evidence_summary + - semantic_evidence - components - unknown_flags properties: @@ -5115,6 +5329,8 @@ MatchUnconfirmedCandidate: $ref: '#/MatchPublicContext' evidence_summary: $ref: '#/MatchEvidenceSummary' + semantic_evidence: + $ref: '#/MatchSemanticEvidenceList' components: $ref: '#/MatchUnconfirmedComponents' unknown_flags: @@ -6600,6 +6816,8 @@ CardField: - salary_compatibility: a nullable compatibility outcome with no salary amounts or bounds. + - projects: the projects of the profile with their title, description, stack tags, and whether a linked repository is a public GitHub repository. The titles and descriptions are text that the candidate writes and may identify them; the repository address and its owner never reach an organization through the card. Published projects are also the text that semantic ranking reads and that match explanations name. + - soft_skills, location, and relocation: retained only for compatibility in existing saved sets; they are not returned by the anonymous card. @@ -6617,10 +6835,11 @@ CardField: - location - relocation - work_formats + - projects CardFieldSet: type: array minItems: 0 - maxItems: 9 + maxItems: 10 uniqueItems: true description: Distinct card fields. The server stores them in ascending order of the codes and answers them in that order, whatever order the client sent, so equal sets are equal arrays. items: @@ -6880,9 +7099,41 @@ CandidateSalaryCompatibility: enum: - compatible - not_compatible +CardProject: + type: object + description: One published project as the card shows it. It never carries the repository address, the repository owner, or any text fetched from the repository. + additionalProperties: false + required: + - title + - description + - stack + - repository_verified + properties: + title: + type: string + minLength: 1 + maxLength: 100 + description: Project title as the candidate published it. Plain text; show it as text, never as HTML. + description: + description: Published project description, or null. Plain text; show it as text, never as HTML. + oneOf: + - type: string + minLength: 1 + maxLength: 500 + - type: 'null' + stack: + type: array + maxItems: 10 + description: Published technology tags of the project. + items: + $ref: '#/StackTag' + repository_verified: + type: boolean + description: True when the latest server check found the linked repository on GitHub and it is public. It does not prove that the candidate wrote the code. AnonymousCardContent: type: object - description: The anonymous candidate card as an organization reads it. Only explicitly published values reach it; unconfirmed stack suggestions and unknown values never do. Stack output uses a closed taxonomy. It carries no name, contact, resume text, employer, salary figure, account or profile identifier, and no schema of the private profile or of a contact disclosure is reachable from it; a contact reaches an organization only through the contact grant of an accepted invitation. Each property is null when its field is not published or the candidate has no value for it, so the card does not tell the two apart. The set of properties is closed, and an organization-visible card must never gain a property that identifies the candidate. The search ranking and the full card of an organization's search result are defined by the search contract, which reuses this content. + description: 'The anonymous candidate card as an organization reads it. Only explicitly published values reach it; unconfirmed stack suggestions and unknown values never do. Stack output uses a closed taxonomy. It carries no name, contact, resume text, employer, salary figure, account or profile identifier, and no schema of the private profile or of a contact disclosure is reachable from it; a contact reaches an organization only through the contact grant of an accepted invitation. Each property is null when its field is not published or the candidate has no value for it, so the card does not tell the two apart. The set of properties is closed, and an organization-visible card must never gain a property that identifies the candidate. The one free-text exception is `projects`: the candidate writes it and publishes it by a separate explicit choice, the card never adds the repository address or owner to it, and the client warns that a project title can identify its author. The search ranking + and the full card of an organization''s search result are defined by the search contract, which reuses this content.' additionalProperties: false required: - pseudonym @@ -6892,6 +7143,7 @@ AnonymousCardContent: - experience_band - work_formats - salary_compatibility + - projects properties: pseudonym: type: string @@ -6946,6 +7198,14 @@ AnonymousCardContent: - $ref: '#/CandidateSalaryCompatibility' - type: 'null' description: Nullable compatibility result with no salary values. + projects: + type: + - array + - 'null' + maxItems: 10 + description: 'Published projects in the candidate''s order, or null. Cohort generalization never changes them: they are text the candidate chose to publish, so publishing them can make the card unique.' + items: + $ref: '#/CardProject' CardPreview: type: object description: A private candidate preview computed from the current profile, publication, and consent ledger. Its pseudonym uses a separate preview context and is not an organization's alias. Organization-specific visibility filters and cohort checks can further generalize or suppress the organization-facing card. This read creates no view or history record and never reaches an organization. `card` is null while the profile is closed. `evidence` is what an organization would read in the evidence section of the card, one supporting assessment fact for each category of the card, and is null exactly when `card` is null; the organization-facing section can still be generalized or suppressed. @@ -7190,7 +7450,9 @@ ProblemCode: - internal (500): unexpected server error. - - not_implemented (501): the operation is in the contract but not implemented yet.' + - not_implemented (501): the operation is in the contract but not implemented yet. + + - service_unavailable (503): the service cannot serve the request now, for example while a model loads; retry later.' enum: - validation_failed - verification_token_invalid @@ -7212,6 +7474,7 @@ ProblemCode: - rate_limited - internal - not_implemented + - service_unavailable ProblemFieldError: type: object description: One reason why a request field or parameter is invalid. diff --git a/api/core/components/schemas/candidate_schemas.yml b/api/core/components/schemas/candidate_schemas.yml index a8a2ede..9e837f3 100644 --- a/api/core/components/schemas/candidate_schemas.yml +++ b/api/core/components/schemas/candidate_schemas.yml @@ -515,6 +515,138 @@ schemas: $ref: "#/schemas/ProfileItemStatus" source: $ref: "#/schemas/ProfileClaimSource" + ProfileProjectTitle: + type: string + minLength: 1 + maxLength: 100 + pattern: '^\S(?:.*\S)?$' + description: >- + Name of a project as the candidate wants an organization to read it. It + has no leading or trailing whitespace and no line breaks. When the + candidate publishes the `projects` card field, the title reaches the + anonymous card and match explanations, so it must not contain a name, + a contact, or a repository address. Plain text; clients show it as + text, never as HTML. + ProfileProjectDescription: + type: string + minLength: 1 + maxLength: 500 + description: >- + What the project does and what the candidate did in it. It may contain + line breaks. When the `projects` card field is published it reaches the + anonymous card. Plain text; clients show it as text, never as HTML. + ProfileRepositoryUrl: + type: string + minLength: 22 + maxLength: 160 + pattern: '^https://github\.com/[A-Za-z0-9](?:[A-Za-z0-9-]{0,38})/[A-Za-z0-9._-]{1,100}/?$' + description: >- + Address of a public GitHub repository of the project in the form + https://github.com//. The server accepts only this + host and form, removes a trailing slash and a `.git` suffix, and stores + the canonical address. Organizations never receive the address before + an accepted invitation, because the owner name can identify the + candidate. + examples: + - https://github.com/example-org/payments-ledger + ProfileRepositoryCheckState: + type: string + description: |- + Result of the latest server check of a project repository on the public GitHub API. The server only reads public metadata; a check never proves that the candidate wrote the code. + + - pending: the check is scheduled and has not finished yet. + - verified: the repository exists and is public. Match explanations may then say that the project is backed by a public repository. + - not_found: GitHub reports no such public repository; it may be private, renamed to another owner, or deleted. + - unavailable: GitHub could not be asked, for example because of its rate limit; the server retries later. + enum: + - pending + - verified + - not_found + - unavailable + ProfileRepositoryCheck: + type: object + description: >- + State of the server check of a project repository. Read-only; no + request writes it. The fetched metadata itself (description, topics, + languages, and a plain-text README excerpt) is used only for ranking + and is never returned or shown. + additionalProperties: false + required: + - state + - checked_at + properties: + state: + $ref: "#/schemas/ProfileRepositoryCheckState" + checked_at: + description: Time of the last finished check, or null before the first one. + oneOf: + - $ref: "./common_schemas.yml#/schemas/Timestamp" + - type: "null" + ProfileProjectStack: + type: array + maxItems: 10 + description: >- + Technology tags of the project, each tag at most once without regard to + letter case. + items: + $ref: "./questionnaire_schemas.yml#/schemas/StackTag" + ProfileRepositoryCheckRequest: + type: object + description: Result of a request to check the linked repositories again. + additionalProperties: false + required: + - scheduled + properties: + scheduled: + type: integer + format: int32 + minimum: 0 + maximum: 10 + description: Number of repository checks that the request scheduled. + ProfileProjectItem: + type: object + description: >- + One project of the candidate with its confirmation state and provenance. + A project is a claim of trust level 0 that the candidate types; a + linked repository adds a separate server check (`repository_check`), + never a higher trust level. The project reaches organizations only when + the candidate publishes the `projects` card field, and then without the + repository address. + additionalProperties: false + required: + - title + - description + - stack + - repository_url + - repository_check + - status + - source + properties: + title: + $ref: "#/schemas/ProfileProjectTitle" + description: + description: What the project is about, or null when the candidate gives nothing. + oneOf: + - $ref: "#/schemas/ProfileProjectDescription" + - type: "null" + stack: + $ref: "#/schemas/ProfileProjectStack" + repository_url: + description: Canonical repository address, or null when the project links none. + oneOf: + - $ref: "#/schemas/ProfileRepositoryUrl" + - type: "null" + repository_check: + description: >- + The server check of the linked repository, or null when the project + links none. + oneOf: + - $ref: "#/schemas/ProfileRepositoryCheck" + - type: "null" + status: + $ref: "#/schemas/ProfileItemStatus" + source: + $ref: "#/schemas/ProfileClaimSource" ProfileExperienceOverlapStatus: type: string description: Whether the candidate confirmed that two overlapping periods are genuine parallel work. @@ -622,8 +754,8 @@ schemas: type: object description: >- The private profile of the current candidate: full name and contacts, - stack, roles, work experience, soft skills, and desired terms, each - value with its confirmation state and provenance. It is personal data + stack, roles, work experience, soft skills, projects, and desired + terms, each value with its confirmation state and provenance. It is personal data that only the candidate reads. It is never an organization-visible schema: an organization sees a candidate only through the anonymous card and, after an accepted invitation, through the contact grant, and @@ -650,6 +782,7 @@ schemas: - experience - experience_overlaps - soft_skills + - projects - terms - confirmed_categories - updated_at @@ -698,6 +831,14 @@ schemas: most once without regard to letter case. items: $ref: "#/schemas/ProfileSoftSkillItem" + projects: + type: array + maxItems: 10 + description: >- + Projects in the order the candidate gave them, each repository + address at most once. + items: + $ref: "#/schemas/ProfileProjectItem" terms: $ref: "#/schemas/ProfileTerms" confirmed_categories: @@ -945,12 +1086,42 @@ schemas: - type: "null" status: $ref: "#/schemas/ProfileItemStatus" + ProfileProjectItemInput: + type: object + description: >- + Decision about one project in a request; see CandidateProfileUpdate for + the rules of `status`. The server answers 400 with the pointer of the + field for a repository address that is not a GitHub repository address, + a repeated repository, or a repeated stack tag. + additionalProperties: false + required: + - title + - description + - stack + - repository_url + - status + properties: + title: + $ref: "#/schemas/ProfileProjectTitle" + description: + oneOf: + - $ref: "#/schemas/ProfileProjectDescription" + - type: "null" + stack: + $ref: "#/schemas/ProfileProjectStack" + repository_url: + oneOf: + - $ref: "#/schemas/ProfileRepositoryUrl" + - type: "null" + status: + $ref: "#/schemas/ProfileItemStatus" CandidateProfileUpdate: type: object description: >- Complete new state of the candidate profile. It replaces every stored value as a whole: a single field sent as null is unknown and is removed, - and a list replaces the stored list. The body is personal data. + and a list replaces the stored list; only `projects` may be omitted, + which keeps the stored projects. The body is personal data. Each value carries a decision `status`. `confirmed` sets a manual value or confirms a stored suggestion; confirming a suggestion with exactly @@ -1025,5 +1196,17 @@ schemas: that repeats an earlier one without regard to letter case. items: $ref: "#/schemas/ProfileSoftSkillItemInput" + projects: + type: array + maxItems: 10 + description: >- + Projects. Unlike the other lists this one is optional: a body + without `projects` keeps the stored projects unchanged, so a client + that does not know the section never deletes it, and an array, + including an empty one, replaces the stored list. A new or changed + repository address schedules a server check on the public GitHub + API after the save commits; the save itself never waits for GitHub. + items: + $ref: "#/schemas/ProfileProjectItemInput" terms: $ref: "#/schemas/ProfileTermsInput" diff --git a/api/core/components/schemas/match_schemas.yml b/api/core/components/schemas/match_schemas.yml index 8c3f5da..df4610e 100644 --- a/api/core/components/schemas/match_schemas.yml +++ b/api/core/components/schemas/match_schemas.yml @@ -353,6 +353,91 @@ schemas: maxItems: 12 items: $ref: "#/schemas/MatchEvidenceSummaryItem" + MatchRequirementKind: + type: string + description: Kind of the need requirement that an explanation item answers. + enum: + - required_skill + - desired_skill + - task + MatchSemanticItemKind: + type: string + description: |- + Kind of the published card item that matched a requirement. + + - project: one published project; `project_title` names it. + - stack: the recognized technology codes of the card. + - roles: the specializations and grades that the card shows. + enum: + - project + - stack + - roles + MatchSimilarityBand: + type: string + description: >- + Coarse band of the cosine similarity between the requirement and the + matched item under the versioned policy thresholds. `high` and `medium` + are the only values; a weaker similarity produces no item. The band is + a computed similarity of two texts, not a judgement of the candidate. + enum: + - high + - medium + MatchSemanticEvidence: + type: object + description: >- + Why the entry is in the result: one confirmed requirement of the need + and the published card item with the highest semantic similarity to it. + The server computes it from stored vectors and the versioned + thresholds; no model writes text into it. `requirement_text` is the + confirmed text of the organization's own need. `project_title` is the + title the candidate published with the `projects` card field and is + null for other kinds. No repository address, owner, or fetched + repository text is ever part of it. + additionalProperties: false + required: + - requirement_kind + - requirement_text + - item_kind + - project_title + - repository_verified + - similarity + properties: + requirement_kind: + $ref: "#/schemas/MatchRequirementKind" + requirement_text: + type: string + minLength: 1 + maxLength: 300 + description: Confirmed skill name or task text of the need. Plain text; show it as text, never as HTML. + item_kind: + $ref: "#/schemas/MatchSemanticItemKind" + project_title: + description: Published project title for `project`, otherwise null. Plain text; show it as text, never as HTML. + oneOf: + - type: string + minLength: 1 + maxLength: 100 + - type: "null" + repository_verified: + type: boolean + description: >- + True only for a project whose linked repository the latest server + check found public on GitHub ("backed by a public repository"). It + does not prove authorship. + similarity: + $ref: "#/schemas/MatchSimilarityBand" + MatchSemanticEvidenceList: + type: array + description: >- + Semantic explanation items in a stable order: `high` before `medium`, + then by similarity, then by the order of the requirements in the need. + At most the versioned per-entry limit is returned. It is empty for a + bank search, while vectors are not ready, when ML is unavailable, and + when no requirement reaches a band; `unknown_flags` names + `ml_unavailable` when the semantic component itself is unknown. + maxItems: 12 + items: + $ref: "#/schemas/MatchSemanticEvidence" MatchPublicStack: type: array maxItems: 4 @@ -469,6 +554,7 @@ schemas: - strength - public_context - evidence_summary + - semantic_evidence - components - unknown_flags properties: @@ -493,6 +579,8 @@ schemas: $ref: "#/schemas/MatchPublicContext" evidence_summary: $ref: "#/schemas/MatchEvidenceSummary" + semantic_evidence: + $ref: "#/schemas/MatchSemanticEvidenceList" components: $ref: "#/schemas/MatchConfirmedComponents" unknown_flags: @@ -514,6 +602,7 @@ schemas: - strength - public_context - evidence_summary + - semantic_evidence - components - unknown_flags properties: @@ -540,6 +629,8 @@ schemas: $ref: "#/schemas/MatchPublicContext" evidence_summary: $ref: "#/schemas/MatchEvidenceSummary" + semantic_evidence: + $ref: "#/schemas/MatchSemanticEvidenceList" components: $ref: "#/schemas/MatchUnconfirmedComponents" unknown_flags: diff --git a/api/core/components/schemas/privacy_schemas.yml b/api/core/components/schemas/privacy_schemas.yml index b2e6423..ea6555f 100644 --- a/api/core/components/schemas/privacy_schemas.yml +++ b/api/core/components/schemas/privacy_schemas.yml @@ -34,6 +34,7 @@ schemas: - experience: a coarse total-experience band, without employers, periods, or descriptions. - work_formats: explicitly selected work formats from the private questionnaire. - salary_compatibility: a nullable compatibility outcome with no salary amounts or bounds. + - projects: the projects of the profile with their title, description, stack tags, and whether a linked repository is a public GitHub repository. The titles and descriptions are text that the candidate writes and may identify them; the repository address and its owner never reach an organization through the card. Published projects are also the text that semantic ranking reads and that match explanations name. - soft_skills, location, and relocation: retained only for compatibility in existing saved sets; they are not returned by the anonymous card. Only values that the candidate confirmed ever reach the card: an unconfirmed suggestion (status `extracted`) and an unknown value never do, whatever the field set says. @@ -49,10 +50,11 @@ schemas: - location - relocation - work_formats + - projects CardFieldSet: type: array minItems: 0 - maxItems: 9 + maxItems: 10 uniqueItems: true description: >- Distinct card fields. The server stores them in ascending order of @@ -383,6 +385,47 @@ schemas: enum: - compatible - not_compatible + CardProject: + type: object + description: >- + One published project as the card shows it. It never carries the + repository address, the repository owner, or any text fetched from the + repository. + additionalProperties: false + required: + - title + - description + - stack + - repository_verified + properties: + title: + type: string + minLength: 1 + maxLength: 100 + description: >- + Project title as the candidate published it. Plain text; show it as + text, never as HTML. + description: + description: >- + Published project description, or null. Plain text; show it as text, + never as HTML. + oneOf: + - type: string + minLength: 1 + maxLength: 500 + - type: "null" + stack: + type: array + maxItems: 10 + description: Published technology tags of the project. + items: + $ref: "./questionnaire_schemas.yml#/schemas/StackTag" + repository_verified: + type: boolean + description: >- + True when the latest server check found the linked repository on + GitHub and it is public. It does not prove that the candidate wrote + the code. AnonymousCardContent: type: object description: >- @@ -396,8 +439,11 @@ schemas: invitation. Each property is null when its field is not published or the candidate has no value for it, so the card does not tell the two apart. The set of properties is closed, and an organization-visible - card must never gain a property that identifies the candidate. The - search ranking and the full card of an organization's search result + card must never gain a property that identifies the candidate. The one + free-text exception is `projects`: the candidate writes it and + publishes it by a separate explicit choice, the card never adds the + repository address or owner to it, and the client warns that a project + title can identify its author. The search ranking and the full card of an organization's search result are defined by the search contract, which reuses this content. additionalProperties: false @@ -409,6 +455,7 @@ schemas: - experience_band - work_formats - salary_compatibility + - projects properties: pseudonym: type: string @@ -465,6 +512,17 @@ schemas: - $ref: "#/schemas/CandidateSalaryCompatibility" - type: "null" description: Nullable compatibility result with no salary values. + projects: + type: + - array + - "null" + maxItems: 10 + description: >- + Published projects in the candidate's order, or null. Cohort + generalization never changes them: they are text the candidate + chose to publish, so publishing them can make the card unique. + items: + $ref: "#/schemas/CardProject" CardPreview: type: object description: >- diff --git a/api/core/components/schemas/problem_schemas.yml b/api/core/components/schemas/problem_schemas.yml index 6668c15..bd29634 100644 --- a/api/core/components/schemas/problem_schemas.yml +++ b/api/core/components/schemas/problem_schemas.yml @@ -89,6 +89,7 @@ schemas: - rate_limited (429): too many requests; see Retry-After. - internal (500): unexpected server error. - not_implemented (501): the operation is in the contract but not implemented yet. + - service_unavailable (503): the service cannot serve the request now, for example while a model loads; retry later. enum: - validation_failed - verification_token_invalid @@ -110,6 +111,7 @@ schemas: - rate_limited - internal - not_implemented + - service_unavailable ProblemFieldError: type: object description: One reason why a request field or parameter is invalid. diff --git a/api/core/openapi.bundle.yml b/api/core/openapi.bundle.yml index 9bd06c6..d9c9542 100644 --- a/api/core/openapi.bundle.yml +++ b/api/core/openapi.bundle.yml @@ -699,6 +699,39 @@ paths: $ref: '#/components/responses/ProfileVersionConflict' default: $ref: '#/components/responses/Problem' + /api/v1/me/profile/repository-checks: + post: + operationId: RequestMyRepositoryChecks + summary: Ask the server to check the linked project repositories again. + 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. It schedules a new check of every repository that the current profile links, for example after the candidate made a repository public, and answers 202 with the number of scheduled checks; the checks run in the background and `GetMyProfile` shows their state in `projects[].repository_check`. A profile without linked repositories answers 202 with 0. + + A check reads only public metadata from the public GitHub API (`api.github.com`): whether the repository exists and is public, its description, topics, languages, and the beginning of its README as plain text. The server never fetches any other host, never follows a redirect to another host, and never shows the fetched text; it uses it only for semantic ranking. A verified repository does not prove that the candidate wrote the code. + + The operation is limited per candidate: a second request inside the versioned window answers 429 rate_limited with Retry-After and schedules nothing. A missing, unknown, expired, or revoked session answers 401 unauthenticated; an employer account answers 403 forbidden. + security: + - sessionCookie: [] + sessionCsrf: [] + tags: + - candidate + responses: + '202': + description: The checks are scheduled. + headers: + Cache-Control: + $ref: '#/components/headers/CacheControlNoStore' + content: + application/json: + schema: + $ref: '#/components/schemas/ProfileRepositoryCheckRequest' + '401': + $ref: '#/components/responses/Unauthenticated' + '403': + $ref: '#/components/responses/CsrfCheckFailedOrForbidden' + '429': + $ref: '#/components/responses/TooManyRequests' + default: + $ref: '#/components/responses/Problem' /api/v1/me/assessment-availability: get: operationId: GetMyAssessmentAvailability @@ -1712,7 +1745,9 @@ paths: Every entry is one candidate specialization. A confirmed result in Backend never confirms Networks for the same candidate. The `main`, `near`, and `unconfirmed` arrays are separate groups. A confirmed category with required-skill coverage below 0.25 belongs to `near`; other confirmed entries belong to `main` (FR09). Entries in `unconfirmed` are ordered by Fit, then coverage, then a stable internal tie-breaker that is never returned. Their category and strength remain null, and they have no theta, T, P, or test percentile. The search result uses the organization-scoped opaque `candidate_handle` as its display pseudonym and invitation reference, never a candidate account or profile identifier. - The card context is limited to safe public fields: recognized stack tags, coarse experience, accepted work formats, and coarse salary compatibility. It contains no contact, candidate location, salary amount or minimum, raw answer, arbitrary profile text, or reason for withheld FSP data. Evidence explanations use bounded codes, not free text. When ML is unavailable, semantic similarity uses the neutral 0.5 specified by FR09 and `unknown_flags` names `ml_unavailable`. For fewer than 30 comparable real candidates, the search uses neutral T = 0.5, returns no percentile value, and names `cohort_below_30`. When the comparable real cohort of a category reaches the minimum, the percentile is still not computed (the organization-safe projection carries no theta), T stays the neutral 0.5, the percentile stays null, and `unknown_flags` names `percentile_not_computed`; the search does not fail. + The card context is limited to safe public fields: recognized stack tags, coarse experience, accepted work formats, and coarse salary compatibility. It contains no contact, candidate location, salary amount or minimum, raw answer, arbitrary profile text, or reason for withheld FSP data. Evidence explanations use bounded codes, not free text. + + Semantic similarity `Sem` is the calibrated cosine between the stored vector of the need's confirmed requirements snapshot and the stored vector of the candidate's published card text (roles, recognized stack, and published projects with the public metadata of their verified repositories). The search never calls the ML service: vectors are computed in the background after a change, and an entry whose vectors are missing, stale for the current model, or not computed because ML is unavailable uses the neutral 0.5 and names `ml_unavailable` in `unknown_flags`. `semantic_evidence` lists, for a need search, the confirmed requirements whose closest published card item reaches a similarity band of the versioned policy; it names a project only by the title that the candidate published with the `projects` card field and says whether its repository is a verified public one, never the repository address or owner. Showing a project title records the `projects` field in the candidate's access history. For fewer than 30 comparable real candidates, the search uses neutral T = 0.5, returns no percentile value, and names `cohort_below_30`. When the comparable real cohort of a category reaches the minimum, the percentile is still not computed (the organization-safe projection carries no theta), T stays the neutral 0.5, the percentile stays null, and `unknown_flags` names `percentile_not_computed`; the search does not fail. A missing, unknown, expired, or revoked session answers 401 unauthenticated; a candidate account answers 403 forbidden; an unknown organization or account without active membership answers 404 not_found. The response is `Cache-Control: no-store`. security: @@ -1754,6 +1789,8 @@ paths: $ref: '#/components/examples/CohortBelow30' truncated: $ref: '#/components/examples/Truncated' + semantic_evidence: + $ref: '#/components/examples/SemanticEvidence' '400': $ref: '#/components/responses/ValidationFailed' '401': @@ -3643,6 +3680,7 @@ components: - rate_limited (429): too many requests; see Retry-After. - internal (500): unexpected server error. - not_implemented (501): the operation is in the contract but not implemented yet. + - service_unavailable (503): the service cannot serve the request now, for example while a model loads; retry later. enum: - validation_failed - verification_token_invalid @@ -3664,6 +3702,7 @@ components: - rate_limited - internal - not_implemented + - service_unavailable ProblemFieldError: type: object description: One reason why a request field or parameter is invalid. @@ -4755,7 +4794,7 @@ components: CandidateProfile: type: object description: |- - The private profile of the current candidate: full name and contacts, stack, roles, work experience, soft skills, and desired terms, each value with its confirmation state and provenance. It is personal data that only the candidate reads. It is never an organization-visible schema: an organization sees a candidate only through the anonymous card and, after an accepted invitation, through the contact grant, and no organization schema refers to this one. + The private profile of the current candidate: full name and contacts, stack, roles, work experience, soft skills, projects, and desired terms, each value with its confirmation state and provenance. It is personal data that only the candidate reads. It is never an organization-visible schema: an organization sees a candidate only through the anonymous card and, after an accepted invitation, through the contact grant, and no organization schema refers to this one. Every value is a claim of trust level 0. The `self_assessed_grade` of a role is what the candidate says; the `confirmed_categories` list is what assessment results established, and the two are never mixed. A candidate who has not saved the profile gets version 0, every single field `unknown`, empty lists, and null `updated_at`. The profile is manual by nature and complete without a file: no field requires a resume, the ML service, or an FSP account, and a candidate with none of them has the same fields. Work formats live in the questionnaire; a candidate's assessment starts from the questionnaire, not from this profile. additionalProperties: false @@ -4768,6 +4807,7 @@ components: - experience - experience_overlaps - soft_skills + - projects - terms - confirmed_categories - updated_at @@ -4808,6 +4848,12 @@ components: description: Soft skills in the order the candidate gave them, each skill at most once without regard to letter case. items: $ref: '#/components/schemas/ProfileSoftSkillItem' + projects: + type: array + maxItems: 10 + description: Projects in the order the candidate gave them, each repository address at most once. + items: + $ref: '#/components/schemas/ProfileProjectItem' terms: $ref: '#/components/schemas/ProfileTerms' confirmed_categories: @@ -5022,7 +5068,7 @@ components: CandidateProfileUpdate: type: object description: |- - Complete new state of the candidate profile. It replaces every stored value as a whole: a single field sent as null is unknown and is removed, and a list replaces the stored list. The body is personal data. + Complete new state of the candidate profile. It replaces every stored value as a whole: a single field sent as null is unknown and is removed, and a list replaces the stored list; only `projects` may be omitted, which keeps the stored projects. The body is personal data. Each value carries a decision `status`. `confirmed` sets a manual value or confirms a stored suggestion; confirming a suggestion with exactly its stored value keeps its origin and quote, and any other value makes the claim manual. `extracted` keeps a stored suggestion unconfirmed and is accepted only with exactly the stored value; any other use answers 400 with the pointer of that status, for example `/stack/1/status`. The provenance, the trust level, and the confirmed categories are not part of the request, and unknown fields are rejected, so a request can neither mark a claim as verified nor write a confirmed grade or a category. additionalProperties: false required: @@ -5073,6 +5119,12 @@ components: description: Soft skills. The server answers 400 with the pointer of a skill that repeats an earlier one without regard to letter case. items: $ref: '#/components/schemas/ProfileSoftSkillItemInput' + projects: + type: array + maxItems: 10 + description: 'Projects. Unlike the other lists this one is optional: a body without `projects` keeps the stored projects unchanged, so a client that does not know the section never deletes it, and an array, including an empty one, replaces the stored list. A new or changed repository address schedules a server check on the public GitHub API after the save commits; the save itself never waits for GitHub.' + items: + $ref: '#/components/schemas/ProfileProjectItemInput' terms: $ref: '#/components/schemas/ProfileTermsInput' AssessmentMode: @@ -9291,6 +9343,7 @@ components: - experience: a coarse total-experience band, without employers, periods, or descriptions. - work_formats: explicitly selected work formats from the private questionnaire. - salary_compatibility: a nullable compatibility outcome with no salary amounts or bounds. + - projects: the projects of the profile with their title, description, stack tags, and whether a linked repository is a public GitHub repository. The titles and descriptions are text that the candidate writes and may identify them; the repository address and its owner never reach an organization through the card. Published projects are also the text that semantic ranking reads and that match explanations name. - soft_skills, location, and relocation: retained only for compatibility in existing saved sets; they are not returned by the anonymous card. Only values that the candidate confirmed ever reach the card: an unconfirmed suggestion (status `extracted`) and an unknown value never do, whatever the field set says. @@ -9306,10 +9359,11 @@ components: - location - relocation - work_formats + - projects CardFieldSet: type: array minItems: 0 - maxItems: 9 + maxItems: 10 uniqueItems: true description: Distinct card fields. The server stores them in ascending order of the codes and answers them in that order, whatever order the client sent, so equal sets are equal arrays. items: @@ -9526,7 +9580,7 @@ components: $ref: '#/components/schemas/EvidenceBasis' AnonymousCardContent: type: object - description: The anonymous candidate card as an organization reads it. Only explicitly published values reach it; unconfirmed stack suggestions and unknown values never do. Stack output uses a closed taxonomy. It carries no name, contact, resume text, employer, salary figure, account or profile identifier, and no schema of the private profile or of a contact disclosure is reachable from it; a contact reaches an organization only through the contact grant of an accepted invitation. Each property is null when its field is not published or the candidate has no value for it, so the card does not tell the two apart. The set of properties is closed, and an organization-visible card must never gain a property that identifies the candidate. The search ranking and the full card of an organization's search result are defined by the search contract, which reuses this content. + description: 'The anonymous candidate card as an organization reads it. Only explicitly published values reach it; unconfirmed stack suggestions and unknown values never do. Stack output uses a closed taxonomy. It carries no name, contact, resume text, employer, salary figure, account or profile identifier, and no schema of the private profile or of a contact disclosure is reachable from it; a contact reaches an organization only through the contact grant of an accepted invitation. Each property is null when its field is not published or the candidate has no value for it, so the card does not tell the two apart. The set of properties is closed, and an organization-visible card must never gain a property that identifies the candidate. The one free-text exception is `projects`: the candidate writes it and publishes it by a separate explicit choice, the card never adds the repository address or owner to it, and the client warns that a project title can identify its author. The search ranking and the full card of an organization''s search result are defined by the search contract, which reuses this content.' additionalProperties: false required: - pseudonym @@ -9536,6 +9590,7 @@ components: - experience_band - work_formats - salary_compatibility + - projects properties: pseudonym: type: string @@ -9590,6 +9645,14 @@ components: - $ref: '#/components/schemas/CandidateSalaryCompatibility' - type: 'null' description: Nullable compatibility result with no salary values. + projects: + type: + - array + - 'null' + maxItems: 10 + description: 'Published projects in the candidate''s order, or null. Cohort generalization never changes them: they are text the candidate chose to publish, so publishing them can make the card unique.' + items: + $ref: '#/components/schemas/CardProject' CardPreview: type: object description: A private candidate preview computed from the current profile, publication, and consent ledger. Its pseudonym uses a separate preview context and is not an organization's alias. Organization-specific visibility filters and cohort checks can further generalize or suppress the organization-facing card. This read creates no view or history record and never reaches an organization. `card` is null while the profile is closed. `evidence` is what an organization would read in the evidence section of the card, one supporting assessment fact for each category of the card, and is null exactly when `card` is null; the organization-facing section can still be generalized or suppressed. @@ -10102,6 +10165,134 @@ components: minLength: 1 maxLength: 128 description: Password chosen for the registration that issued the code. The server applies NFKC normalization and the login length bounds, without reapplying the current new-registration blocklist. + ProfileProjectTitle: + type: string + minLength: 1 + maxLength: 100 + pattern: ^\S(?:.*\S)?$ + description: Name of a project as the candidate wants an organization to read it. It has no leading or trailing whitespace and no line breaks. When the candidate publishes the `projects` card field, the title reaches the anonymous card and match explanations, so it must not contain a name, a contact, or a repository address. Plain text; clients show it as text, never as HTML. + ProfileProjectDescription: + type: string + minLength: 1 + maxLength: 500 + description: What the project does and what the candidate did in it. It may contain line breaks. When the `projects` card field is published it reaches the anonymous card. Plain text; clients show it as text, never as HTML. + ProfileProjectStack: + type: array + maxItems: 10 + description: Technology tags of the project, each tag at most once without regard to letter case. + items: + $ref: '#/components/schemas/StackTag' + ProfileRepositoryUrl: + type: string + minLength: 22 + maxLength: 160 + pattern: ^https://github\.com/[A-Za-z0-9](?:[A-Za-z0-9-]{0,38})/[A-Za-z0-9._-]{1,100}/?$ + description: Address of a public GitHub repository of the project in the form https://github.com//. The server accepts only this host and form, removes a trailing slash and a `.git` suffix, and stores the canonical address. Organizations never receive the address before an accepted invitation, because the owner name can identify the candidate. + examples: + - https://github.com/example-org/payments-ledger + ProfileRepositoryCheckState: + type: string + description: |- + Result of the latest server check of a project repository on the public GitHub API. The server only reads public metadata; a check never proves that the candidate wrote the code. + + - pending: the check is scheduled and has not finished yet. + - verified: the repository exists and is public. Match explanations may then say that the project is backed by a public repository. + - not_found: GitHub reports no such public repository; it may be private, renamed to another owner, or deleted. + - unavailable: GitHub could not be asked, for example because of its rate limit; the server retries later. + enum: + - pending + - verified + - not_found + - unavailable + ProfileRepositoryCheck: + type: object + description: State of the server check of a project repository. Read-only; no request writes it. The fetched metadata itself (description, topics, languages, and a plain-text README excerpt) is used only for ranking and is never returned or shown. + additionalProperties: false + required: + - state + - checked_at + properties: + state: + $ref: '#/components/schemas/ProfileRepositoryCheckState' + checked_at: + description: Time of the last finished check, or null before the first one. + oneOf: + - $ref: '#/components/schemas/Timestamp' + - type: 'null' + ProfileProjectItem: + type: object + description: One project of the candidate with its confirmation state and provenance. A project is a claim of trust level 0 that the candidate types; a linked repository adds a separate server check (`repository_check`), never a higher trust level. The project reaches organizations only when the candidate publishes the `projects` card field, and then without the repository address. + additionalProperties: false + required: + - title + - description + - stack + - repository_url + - repository_check + - status + - source + properties: + title: + $ref: '#/components/schemas/ProfileProjectTitle' + description: + description: What the project is about, or null when the candidate gives nothing. + oneOf: + - $ref: '#/components/schemas/ProfileProjectDescription' + - type: 'null' + stack: + $ref: '#/components/schemas/ProfileProjectStack' + repository_url: + description: Canonical repository address, or null when the project links none. + oneOf: + - $ref: '#/components/schemas/ProfileRepositoryUrl' + - type: 'null' + repository_check: + description: The server check of the linked repository, or null when the project links none. + oneOf: + - $ref: '#/components/schemas/ProfileRepositoryCheck' + - type: 'null' + status: + $ref: '#/components/schemas/ProfileItemStatus' + source: + $ref: '#/components/schemas/ProfileClaimSource' + ProfileProjectItemInput: + type: object + description: Decision about one project in a request; see CandidateProfileUpdate for the rules of `status`. The server answers 400 with the pointer of the field for a repository address that is not a GitHub repository address, a repeated repository, or a repeated stack tag. + additionalProperties: false + required: + - title + - description + - stack + - repository_url + - status + properties: + title: + $ref: '#/components/schemas/ProfileProjectTitle' + description: + oneOf: + - $ref: '#/components/schemas/ProfileProjectDescription' + - type: 'null' + stack: + $ref: '#/components/schemas/ProfileProjectStack' + repository_url: + oneOf: + - $ref: '#/components/schemas/ProfileRepositoryUrl' + - type: 'null' + status: + $ref: '#/components/schemas/ProfileItemStatus' + ProfileRepositoryCheckRequest: + type: object + description: Result of a request to check the linked repositories again. + additionalProperties: false + required: + - scheduled + properties: + scheduled: + type: integer + format: int32 + minimum: 0 + maximum: 10 + description: Number of repository checks that the request scheduled. AssessmentRealMode: type: string description: Server-selected mode available to a real category assessment. @@ -11031,6 +11222,70 @@ components: maxItems: 12 items: $ref: '#/components/schemas/MatchEvidenceSummaryItem' + MatchRequirementKind: + type: string + description: Kind of the need requirement that an explanation item answers. + enum: + - required_skill + - desired_skill + - task + MatchSemanticItemKind: + type: string + description: |- + Kind of the published card item that matched a requirement. + + - project: one published project; `project_title` names it. + - stack: the recognized technology codes of the card. + - roles: the specializations and grades that the card shows. + enum: + - project + - stack + - roles + MatchSimilarityBand: + type: string + description: Coarse band of the cosine similarity between the requirement and the matched item under the versioned policy thresholds. `high` and `medium` are the only values; a weaker similarity produces no item. The band is a computed similarity of two texts, not a judgement of the candidate. + enum: + - high + - medium + MatchSemanticEvidence: + type: object + description: 'Why the entry is in the result: one confirmed requirement of the need and the published card item with the highest semantic similarity to it. The server computes it from stored vectors and the versioned thresholds; no model writes text into it. `requirement_text` is the confirmed text of the organization''s own need. `project_title` is the title the candidate published with the `projects` card field and is null for other kinds. No repository address, owner, or fetched repository text is ever part of it.' + additionalProperties: false + required: + - requirement_kind + - requirement_text + - item_kind + - project_title + - repository_verified + - similarity + properties: + requirement_kind: + $ref: '#/components/schemas/MatchRequirementKind' + requirement_text: + type: string + minLength: 1 + maxLength: 300 + description: Confirmed skill name or task text of the need. Plain text; show it as text, never as HTML. + item_kind: + $ref: '#/components/schemas/MatchSemanticItemKind' + project_title: + description: Published project title for `project`, otherwise null. Plain text; show it as text, never as HTML. + oneOf: + - type: string + minLength: 1 + maxLength: 100 + - type: 'null' + repository_verified: + type: boolean + description: True only for a project whose linked repository the latest server check found public on GitHub ("backed by a public repository"). It does not prove authorship. + similarity: + $ref: '#/components/schemas/MatchSimilarityBand' + MatchSemanticEvidenceList: + type: array + description: 'Semantic explanation items in a stable order: `high` before `medium`, then by similarity, then by the order of the requirements in the need. At most the versioned per-entry limit is returned. It is empty for a bank search, while vectors are not ready, when ML is unavailable, and when no requirement reaches a band; `unknown_flags` names `ml_unavailable` when the semantic component itself is unknown.' + maxItems: 12 + items: + $ref: '#/components/schemas/MatchSemanticEvidence' MatchScore: type: number format: double @@ -11133,6 +11388,7 @@ components: - strength - public_context - evidence_summary + - semantic_evidence - components - unknown_flags properties: @@ -11157,6 +11413,8 @@ components: $ref: '#/components/schemas/MatchPublicContext' evidence_summary: $ref: '#/components/schemas/MatchEvidenceSummary' + semantic_evidence: + $ref: '#/components/schemas/MatchSemanticEvidenceList' components: $ref: '#/components/schemas/MatchConfirmedComponents' unknown_flags: @@ -11194,6 +11452,7 @@ components: - strength - public_context - evidence_summary + - semantic_evidence - components - unknown_flags properties: @@ -11220,6 +11479,8 @@ components: $ref: '#/components/schemas/MatchPublicContext' evidence_summary: $ref: '#/components/schemas/MatchEvidenceSummary' + semantic_evidence: + $ref: '#/components/schemas/MatchSemanticEvidenceList' components: $ref: '#/components/schemas/MatchUnconfirmedComponents' unknown_flags: @@ -11286,6 +11547,37 @@ components: - remote - office - hybrid + CardProject: + type: object + description: One published project as the card shows it. It never carries the repository address, the repository owner, or any text fetched from the repository. + additionalProperties: false + required: + - title + - description + - stack + - repository_verified + properties: + title: + type: string + minLength: 1 + maxLength: 100 + description: Project title as the candidate published it. Plain text; show it as text, never as HTML. + description: + description: Published project description, or null. Plain text; show it as text, never as HTML. + oneOf: + - type: string + minLength: 1 + maxLength: 500 + - type: 'null' + stack: + type: array + maxItems: 10 + description: Published technology tags of the project. + items: + $ref: '#/components/schemas/StackTag' + repository_verified: + type: boolean + description: True when the latest server check found the linked repository on GitHub and it is public. It does not prove that the candidate wrote the code. parameters: IdempotencyKey: name: Idempotency-Key @@ -12436,6 +12728,7 @@ components: experience: [] experience_overlaps: [] soft_skills: [] + projects: [] terms: location: status: unknown @@ -12538,6 +12831,23 @@ components: quote: null extraction_version: null confirmed_at: '2026-10-05T09:30:00Z' + projects: + - title: Payment webhook deduplication service + description: Idempotent receiver for acquirer callbacks with a unique operation key and an outbox for retries. + stack: + - Go + - PostgreSQL + repository_url: https://github.com/example-org/payments-ledger + repository_check: + state: verified + checked_at: '2026-10-05T09:31:00Z' + status: confirmed + source: + origin: manual + trust_level: 0 + quote: null + extraction_version: null + confirmed_at: '2026-10-05T09:30:00Z' terms: location: status: confirmed @@ -14704,6 +15014,7 @@ components: state: supports - code: work_conditions_match state: supports + semantic_evidence: [] components: fit: 0.78 coverage: 0.72 @@ -14737,6 +15048,7 @@ components: state: supports - code: required_skill_evidence state: gap + semantic_evidence: [] components: fit: 0.48 coverage: 0.18 @@ -14770,6 +15082,7 @@ components: state: declared_only - code: required_skill_evidence state: partial + semantic_evidence: [] components: fit: 0.51 coverage: 0.38 @@ -14830,6 +15143,7 @@ components: evidence_summary: - code: confirmed_category state: supports + semantic_evidence: [] components: fit: 0.7 coverage: 0.6 @@ -14881,6 +15195,7 @@ components: evidence_summary: - code: confirmed_category state: supports + semantic_evidence: [] components: fit: 0.62 coverage: 0.55 @@ -14930,6 +15245,7 @@ components: evidence_summary: - code: confirmed_category state: supports + semantic_evidence: [] components: fit: 0.5 coverage: 0.5 @@ -14948,6 +15264,76 @@ components: near: [] unconfirmed: [] truncated: true + SemanticEvidence: + summary: A need search explains an entry with semantic evidence from published card items. + description: Synthetic example. `semantics` is the calibrated cosine of the stored vectors; each evidence item pairs one confirmed requirement of the need with the closest published card item. The project is named only by the title that the candidate published; the repository address never appears. + value: + source: + kind: need + need_id: 4d3a4a1b-4f60-44c1-9dc2-6c8e6c9d4c11 + requirements_version: 3 + groups: + main: + - candidate_handle: cv1_FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF + specialization: backend + confirmation_status: confirmed + declared_grade: middle + category: + specialization: backend + grade: middle + basis: synthetic_demo + strength: standard + public_context: + stack: + - kafka + - postgresql + experience_band: '3_6' + work_formats: null + salary_compatibility: null + evidence_summary: + - code: confirmed_category + state: supports + - code: required_skill_evidence + state: declared_only + semantic_evidence: + - requirement_kind: task + requirement_text: Make payment callbacks idempotent + item_kind: project + project_title: Payment webhook deduplication service + repository_verified: true + similarity: high + - requirement_kind: required_skill + requirement_text: Kafka + item_kind: stack + project_title: null + repository_verified: false + similarity: medium + components: + fit: 0.69 + coverage: 0.25 + domain: 0.5 + semantics: 0.92 + percentile: null + competition: 0 + freshness: 0.5 + responsiveness: 0.5 + rank_score: 0.59 + unknown_flags: + - component: percentile + reason: cohort_below_30 + - component: freshness + reason: no_freshness_history + - component: responsiveness + reason: no_response_history + - component: work_formats + reason: not_in_public_card + - component: salary_compatibility + reason: not_in_public_card + - component: domain + reason: not_in_public_card + near: [] + unconfirmed: [] + truncated: false OrganizationAnonymousCandidateCard: summary: An anonymous card currently visible to one organization description: The alias is scoped to the reading organization; no contact values are included. @@ -14965,6 +15351,7 @@ components: experience_band: '1_3' work_formats: null salary_compatibility: null + projects: null OrganizationCandidateEvidence: summary: The one supporting assessment fact of the category on the card value: @@ -16414,6 +16801,7 @@ components: experience_band: '1_3' work_formats: null salary_compatibility: null + projects: null evidence: items: - skill: backend diff --git a/api/core/openapi.yml b/api/core/openapi.yml index 8d8497a..3ceeb8c 100644 --- a/api/core/openapi.yml +++ b/api/core/openapi.yml @@ -119,6 +119,8 @@ paths: $ref: ./routes/candidate_questionnaire.yml /api/v1/me/profile: $ref: ./routes/candidate_profile.yml + /api/v1/me/profile/repository-checks: + $ref: ./routes/candidate_profile_repository_checks.yml /api/v1/me/assessment-availability: $ref: ./routes/candidate_assessment_availability.yml /api/v1/me/assessment-results: diff --git a/api/core/routes/candidate_profile_repository_checks.yml b/api/core/routes/candidate_profile_repository_checks.yml new file mode 100644 index 0000000..9405647 --- /dev/null +++ b/api/core/routes/candidate_profile_repository_checks.yml @@ -0,0 +1,32 @@ +post: + operationId: RequestMyRepositoryChecks + summary: Ask the server to check the linked project repositories again. + 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. It schedules a new check of every repository that the current profile links, for example after the candidate made a repository public, and answers 202 with the number of scheduled checks; the checks run in the background and `GetMyProfile` shows their state in `projects[].repository_check`. A profile without linked repositories answers 202 with 0. + + A check reads only public metadata from the public GitHub API (`api.github.com`): whether the repository exists and is public, its description, topics, languages, and the beginning of its README as plain text. The server never fetches any other host, never follows a redirect to another host, and never shows the fetched text; it uses it only for semantic ranking. A verified repository does not prove that the candidate wrote the code. + + The operation is limited per candidate: a second request inside the versioned window answers 429 rate_limited with Retry-After and schedules nothing. A missing, unknown, expired, or revoked session answers 401 unauthenticated; an employer account answers 403 forbidden. + security: + - sessionCookie: [] + sessionCsrf: [] + tags: + - candidate + responses: + "202": + description: The checks are scheduled. + headers: + Cache-Control: + $ref: ../components/headers.yml#/CacheControlNoStore + content: + application/json: + schema: + $ref: ../components/schemas.yml#/ProfileRepositoryCheckRequest + "401": + $ref: ../components/responses.yml#/Unauthenticated + "403": + $ref: ../components/responses.yml#/CsrfCheckFailedOrForbidden + "429": + $ref: ../components/responses.yml#/TooManyRequests + default: + $ref: ../components/responses.yml#/Problem diff --git a/api/core/routes/matches.yml b/api/core/routes/matches.yml index 613739a..b67237e 100644 --- a/api/core/routes/matches.yml +++ b/api/core/routes/matches.yml @@ -10,7 +10,9 @@ post: Every entry is one candidate specialization. A confirmed result in Backend never confirms Networks for the same candidate. The `main`, `near`, and `unconfirmed` arrays are separate groups. A confirmed category with required-skill coverage below 0.25 belongs to `near`; other confirmed entries belong to `main` (FR09). Entries in `unconfirmed` are ordered by Fit, then coverage, then a stable internal tie-breaker that is never returned. Their category and strength remain null, and they have no theta, T, P, or test percentile. The search result uses the organization-scoped opaque `candidate_handle` as its display pseudonym and invitation reference, never a candidate account or profile identifier. - The card context is limited to safe public fields: recognized stack tags, coarse experience, accepted work formats, and coarse salary compatibility. It contains no contact, candidate location, salary amount or minimum, raw answer, arbitrary profile text, or reason for withheld FSP data. Evidence explanations use bounded codes, not free text. When ML is unavailable, semantic similarity uses the neutral 0.5 specified by FR09 and `unknown_flags` names `ml_unavailable`. For fewer than 30 comparable real candidates, the search uses neutral T = 0.5, returns no percentile value, and names `cohort_below_30`. When the comparable real cohort of a category reaches the minimum, the percentile is still not computed (the organization-safe projection carries no theta), T stays the neutral 0.5, the percentile stays null, and `unknown_flags` names `percentile_not_computed`; the search does not fail. + The card context is limited to safe public fields: recognized stack tags, coarse experience, accepted work formats, and coarse salary compatibility. It contains no contact, candidate location, salary amount or minimum, raw answer, arbitrary profile text, or reason for withheld FSP data. Evidence explanations use bounded codes, not free text. + + Semantic similarity `Sem` is the calibrated cosine between the stored vector of the need's confirmed requirements snapshot and the stored vector of the candidate's published card text (roles, recognized stack, and published projects with the public metadata of their verified repositories). The search never calls the ML service: vectors are computed in the background after a change, and an entry whose vectors are missing, stale for the current model, or not computed because ML is unavailable uses the neutral 0.5 and names `ml_unavailable` in `unknown_flags`. `semantic_evidence` lists, for a need search, the confirmed requirements whose closest published card item reaches a similarity band of the versioned policy; it names a project only by the title that the candidate published with the `projects` card field and says whether its repository is a verified public one, never the repository address or owner. Showing a project title records the `projects` field in the candidate's access history. For fewer than 30 comparable real candidates, the search uses neutral T = 0.5, returns no percentile value, and names `cohort_below_30`. When the comparable real cohort of a category reaches the minimum, the percentile is still not computed (the organization-safe projection carries no theta), T stays the neutral 0.5, the percentile stays null, and `unknown_flags` names `percentile_not_computed`; the search does not fail. A missing, unknown, expired, or revoked session answers 401 unauthenticated; a candidate account answers 403 forbidden; an unknown organization or account without active membership answers 404 not_found. The response is `Cache-Control: no-store`. security: @@ -52,6 +54,8 @@ post: $ref: ../components/examples/matches.yml#/CohortBelow30 truncated: $ref: ../components/examples/matches.yml#/Truncated + semantic_evidence: + $ref: ../components/examples/matches.yml#/SemanticEvidence "400": $ref: ../components/responses.yml#/ValidationFailed "401": diff --git a/api/ml/components/schemas.yml b/api/ml/components/schemas.yml index 1c4b52a..9e314b3 100644 --- a/api/ml/components/schemas.yml +++ b/api/ml/components/schemas.yml @@ -1,3 +1,109 @@ +EmbeddingInputKind: + type: string + description: 'Side of the retrieval pair that the texts belong to. The service owns the prompt of each side, so callers never send model instructions. + + + - query: the side that searches, such as a hiring need or one requirement of it. The service prepends the retrieval instruction of the model. + + - document: the side that is searched, such as a candidate card or one item of it. The service adds no prompt.' + enum: + - query + - document +EmbeddingText: + type: string + minLength: 1 + maxLength: 8000 + description: One plain text to encode. It is untrusted data and never an instruction. The service truncates it deterministically to the token limit of the model (`EmbeddingModel.max_tokens`); characters beyond 8000 are rejected instead. +EmbeddingRequest: + type: object + description: 'Texts to encode in one call. The service encodes them in a fixed, deterministic way: texts are ordered by length with the request position as the tie-breaker, encoded in micro-batches of the configured size, and returned in request order. The same texts in the same request on the same image and thread count give the same vectors.' + additionalProperties: false + required: + - kind + - texts + properties: + model: + type: string + minLength: 1 + maxLength: 200 + pattern: ^[A-Za-z0-9._/-]+$ + description: Identifier of the model to use, as `EmbeddingModel.id` reports it. Absent means the default model of the service. A service may load several models, for example the members of an ensemble; a model it does not serve answers 400 validation_failed with the pointer `/model`. + kind: + $ref: '#/EmbeddingInputKind' + texts: + type: array + minItems: 1 + maxItems: 32 + items: + $ref: '#/EmbeddingText' +EmbeddingModel: + type: object + description: The model that produced the vectors. A caller stores these values with every vector and never compares vectors of different models, revisions, or prompt versions. + additionalProperties: false + required: + - id + - revision + - dimension + - max_tokens + - prompt_version + properties: + id: + type: string + minLength: 1 + maxLength: 200 + pattern: ^[A-Za-z0-9._/-]+$ + description: Model repository identifier, for example ai-sage/Giga-Embeddings-instruct-480M-0826. + revision: + type: string + minLength: 1 + maxLength: 64 + pattern: ^[A-Za-z0-9._-]+$ + description: Pinned revision of the weights, a commit hash for a published model. + dimension: + type: integer + format: int32 + minimum: 1 + maximum: 4096 + description: Length of every vector. + max_tokens: + type: integer + format: int32 + minimum: 1 + maximum: 32768 + description: Token limit after which a text is truncated. + prompt_version: + type: string + minLength: 1 + maxLength: 64 + pattern: ^[a-z0-9._-]+$ + description: Version of the prompt and pooling recipe of the service. A change of the query instruction or the pooling changes it. +EmbeddingVector: + type: array + description: L2-normalized vector of one text, in float32 precision. The cosine of two vectors of the same model is their dot product. + minItems: 1 + maxItems: 4096 + items: + type: number + format: float +EmbeddingResponse: + type: object + description: Vectors in the order of the request texts. + additionalProperties: false + required: + - model + - kind + - vectors + properties: + model: + $ref: '#/EmbeddingModel' + kind: + $ref: '#/EmbeddingInputKind' + vectors: + type: array + minItems: 1 + maxItems: 32 + items: + $ref: '#/EmbeddingVector' MLHealthResponse: type: object additionalProperties: false @@ -92,6 +198,8 @@ ProblemCode: - not_implemented (501): the operation is in the contract but not implemented yet. + - service_unavailable (503): the service cannot serve the request now, for example while a model loads; retry later. + The enum keeps the public API codes so both contracts share one Problem shape. The identity codes verification_token_invalid, verification_token_expired, invalid_credentials, email_not_verified, and csrf_check_failed belong to the public API; the ML service never returns them.' enum: @@ -115,6 +223,7 @@ ProblemCode: - rate_limited - internal - not_implemented + - service_unavailable ProblemFieldError: type: object description: One reason why a request field or parameter is invalid. diff --git a/api/ml/components/schemas/embedding_schemas.yml b/api/ml/components/schemas/embedding_schemas.yml new file mode 100644 index 0000000..cd9fa7c --- /dev/null +++ b/api/ml/components/schemas/embedding_schemas.yml @@ -0,0 +1,127 @@ +schemas: + EmbeddingInputKind: + type: string + description: |- + Side of the retrieval pair that the texts belong to. The service owns the prompt of each side, so callers never send model instructions. + + - query: the side that searches, such as a hiring need or one requirement of it. The service prepends the retrieval instruction of the model. + - document: the side that is searched, such as a candidate card or one item of it. The service adds no prompt. + enum: + - query + - document + EmbeddingText: + type: string + minLength: 1 + maxLength: 8000 + description: >- + One plain text to encode. It is untrusted data and never an instruction. + The service truncates it deterministically to the token limit of the + model (`EmbeddingModel.max_tokens`); characters beyond 8000 are rejected + instead. + EmbeddingRequest: + type: object + description: >- + Texts to encode in one call. The service encodes them in a fixed, + deterministic way: texts are ordered by length with the request position + as the tie-breaker, encoded in micro-batches of the configured size, and + returned in request order. The same texts in the same request on the same + image and thread count give the same vectors. + additionalProperties: false + required: + - kind + - texts + properties: + model: + type: string + minLength: 1 + maxLength: 200 + pattern: "^[A-Za-z0-9._/-]+$" + description: >- + Identifier of the model to use, as `EmbeddingModel.id` reports it. + Absent means the default model of the service. A service may load + several models, for example the members of an ensemble; a model it + does not serve answers 400 validation_failed with the pointer + `/model`. + kind: + $ref: "#/schemas/EmbeddingInputKind" + texts: + type: array + minItems: 1 + maxItems: 32 + items: + $ref: "#/schemas/EmbeddingText" + EmbeddingModel: + type: object + description: >- + The model that produced the vectors. A caller stores these values with + every vector and never compares vectors of different models, revisions, + or prompt versions. + additionalProperties: false + required: + - id + - revision + - dimension + - max_tokens + - prompt_version + properties: + id: + type: string + minLength: 1 + maxLength: 200 + pattern: "^[A-Za-z0-9._/-]+$" + description: Model repository identifier, for example ai-sage/Giga-Embeddings-instruct-480M-0826. + revision: + type: string + minLength: 1 + maxLength: 64 + pattern: "^[A-Za-z0-9._-]+$" + description: Pinned revision of the weights, a commit hash for a published model. + dimension: + type: integer + format: int32 + minimum: 1 + maximum: 4096 + description: Length of every vector. + max_tokens: + type: integer + format: int32 + minimum: 1 + maximum: 32768 + description: Token limit after which a text is truncated. + prompt_version: + type: string + minLength: 1 + maxLength: 64 + pattern: "^[a-z0-9._-]+$" + description: >- + Version of the prompt and pooling recipe of the service. A change of + the query instruction or the pooling changes it. + EmbeddingVector: + type: array + description: >- + L2-normalized vector of one text, in float32 precision. The cosine of two + vectors of the same model is their dot product. + minItems: 1 + maxItems: 4096 + items: + type: number + format: float + EmbeddingResponse: + type: object + description: Vectors in the order of the request texts. + additionalProperties: false + required: + - model + - kind + - vectors + properties: + model: + $ref: "#/schemas/EmbeddingModel" + kind: + $ref: "#/schemas/EmbeddingInputKind" + vectors: + type: array + minItems: 1 + maxItems: 32 + items: + $ref: "#/schemas/EmbeddingVector" diff --git a/api/ml/components/schemas/problem_schemas.yml b/api/ml/components/schemas/problem_schemas.yml index 60b4213..8c6b2a2 100644 --- a/api/ml/components/schemas/problem_schemas.yml +++ b/api/ml/components/schemas/problem_schemas.yml @@ -86,6 +86,7 @@ schemas: - rate_limited (429): too many requests; see Retry-After. - internal (500): unexpected server error. - not_implemented (501): the operation is in the contract but not implemented yet. + - service_unavailable (503): the service cannot serve the request now, for example while a model loads; retry later. The enum keeps the public API codes so both contracts share one Problem shape. The identity codes verification_token_invalid, verification_token_expired, invalid_credentials, email_not_verified, and csrf_check_failed belong to the public API; the ML service never returns them. enum: @@ -109,6 +110,7 @@ schemas: - rate_limited - internal - not_implemented + - service_unavailable ProblemFieldError: type: object description: One reason why a request field or parameter is invalid. diff --git a/api/ml/openapi.bundle.yml b/api/ml/openapi.bundle.yml index 5888edd..3a525e3 100644 --- a/api/ml/openapi.bundle.yml +++ b/api/ml/openapi.bundle.yml @@ -43,6 +43,38 @@ paths: $ref: '#/components/schemas/MLReadinessResponse' default: $ref: '#/components/responses/Problem' + /v1/embeddings: + post: + operationId: CreateMLEmbeddings + summary: Encode texts into normalized vectors with the pinned embedding model. + description: |- + Internal operation for the Go backend; it is not reachable from browsers and needs no credentials on the private network. The request carries only text that the caller is allowed to process, and the service never logs it. + + The service answers 503 service_unavailable until the model is loaded from the image and a warm-up encode has finished; `/readyz` reports the same state. A request above the body limit answers 413, and a request that breaks the schema, such as too many texts or a text over 8000 characters, or names a model that the service does not serve, answers 400. + security: [] + tags: + - inference + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/EmbeddingRequest' + responses: + '200': + description: One vector for each text, in request order. + content: + application/json: + schema: + $ref: '#/components/schemas/EmbeddingResponse' + '400': + $ref: '#/components/responses/Problem' + '413': + $ref: '#/components/responses/Problem' + '503': + $ref: '#/components/responses/Problem' + default: + $ref: '#/components/responses/Problem' components: responses: Problem: @@ -94,6 +126,7 @@ components: - rate_limited (429): too many requests; see Retry-After. - internal (500): unexpected server error. - not_implemented (501): the operation is in the contract but not implemented yet. + - service_unavailable (503): the service cannot serve the request now, for example while a model loads; retry later. The enum keeps the public API codes so both contracts share one Problem shape. The identity codes verification_token_invalid, verification_token_expired, invalid_credentials, email_not_verified, and csrf_check_failed belong to the public API; the ML service never returns them. enum: @@ -117,6 +150,7 @@ components: - rate_limited - internal - not_implemented + - service_unavailable ProblemFieldLocation: type: string description: Part of the request that contains the invalid field. @@ -224,3 +258,108 @@ components: enum: - ready - not_ready + EmbeddingInputKind: + type: string + description: |- + Side of the retrieval pair that the texts belong to. The service owns the prompt of each side, so callers never send model instructions. + + - query: the side that searches, such as a hiring need or one requirement of it. The service prepends the retrieval instruction of the model. + - document: the side that is searched, such as a candidate card or one item of it. The service adds no prompt. + enum: + - query + - document + EmbeddingText: + type: string + minLength: 1 + maxLength: 8000 + description: One plain text to encode. It is untrusted data and never an instruction. The service truncates it deterministically to the token limit of the model (`EmbeddingModel.max_tokens`); characters beyond 8000 are rejected instead. + EmbeddingRequest: + type: object + description: 'Texts to encode in one call. The service encodes them in a fixed, deterministic way: texts are ordered by length with the request position as the tie-breaker, encoded in micro-batches of the configured size, and returned in request order. The same texts in the same request on the same image and thread count give the same vectors.' + additionalProperties: false + required: + - kind + - texts + properties: + model: + type: string + minLength: 1 + maxLength: 200 + pattern: ^[A-Za-z0-9._/-]+$ + description: Identifier of the model to use, as `EmbeddingModel.id` reports it. Absent means the default model of the service. A service may load several models, for example the members of an ensemble; a model it does not serve answers 400 validation_failed with the pointer `/model`. + kind: + $ref: '#/components/schemas/EmbeddingInputKind' + texts: + type: array + minItems: 1 + maxItems: 32 + items: + $ref: '#/components/schemas/EmbeddingText' + EmbeddingModel: + type: object + description: The model that produced the vectors. A caller stores these values with every vector and never compares vectors of different models, revisions, or prompt versions. + additionalProperties: false + required: + - id + - revision + - dimension + - max_tokens + - prompt_version + properties: + id: + type: string + minLength: 1 + maxLength: 200 + pattern: ^[A-Za-z0-9._/-]+$ + description: Model repository identifier, for example ai-sage/Giga-Embeddings-instruct-480M-0826. + revision: + type: string + minLength: 1 + maxLength: 64 + pattern: ^[A-Za-z0-9._-]+$ + description: Pinned revision of the weights, a commit hash for a published model. + dimension: + type: integer + format: int32 + minimum: 1 + maximum: 4096 + description: Length of every vector. + max_tokens: + type: integer + format: int32 + minimum: 1 + maximum: 32768 + description: Token limit after which a text is truncated. + prompt_version: + type: string + minLength: 1 + maxLength: 64 + pattern: ^[a-z0-9._-]+$ + description: Version of the prompt and pooling recipe of the service. A change of the query instruction or the pooling changes it. + EmbeddingVector: + type: array + description: L2-normalized vector of one text, in float32 precision. The cosine of two vectors of the same model is their dot product. + minItems: 1 + maxItems: 4096 + items: + type: number + format: float + EmbeddingResponse: + type: object + description: Vectors in the order of the request texts. + additionalProperties: false + required: + - model + - kind + - vectors + properties: + model: + $ref: '#/components/schemas/EmbeddingModel' + kind: + $ref: '#/components/schemas/EmbeddingInputKind' + vectors: + type: array + minItems: 1 + maxItems: 32 + items: + $ref: '#/components/schemas/EmbeddingVector' diff --git a/api/ml/openapi.yml b/api/ml/openapi.yml index 103ba29..e749fac 100644 --- a/api/ml/openapi.yml +++ b/api/ml/openapi.yml @@ -9,6 +9,8 @@ paths: $ref: ./routes/healthz.yml /readyz: $ref: ./routes/readyz.yml + /v1/embeddings: + $ref: ./routes/embeddings.yml components: responses: Problem: diff --git a/api/ml/routes/embeddings.yml b/api/ml/routes/embeddings.yml new file mode 100644 index 0000000..3c03fdd --- /dev/null +++ b/api/ml/routes/embeddings.yml @@ -0,0 +1,31 @@ +post: + operationId: CreateMLEmbeddings + summary: Encode texts into normalized vectors with the pinned embedding model. + description: |- + Internal operation for the Go backend; it is not reachable from browsers and needs no credentials on the private network. The request carries only text that the caller is allowed to process, and the service never logs it. + + The service answers 503 service_unavailable until the model is loaded from the image and a warm-up encode has finished; `/readyz` reports the same state. A request above the body limit answers 413, and a request that breaks the schema, such as too many texts or a text over 8000 characters, or names a model that the service does not serve, answers 400. + security: [] + tags: + - inference + requestBody: + required: true + content: + application/json: + schema: + $ref: ../components/schemas.yml#/EmbeddingRequest + responses: + "200": + description: One vector for each text, in request order. + content: + application/json: + schema: + $ref: ../components/schemas.yml#/EmbeddingResponse + "400": + $ref: ../components/responses.yml#/Problem + "413": + $ref: ../components/responses.yml#/Problem + "503": + $ref: ../components/responses.yml#/Problem + default: + $ref: ../components/responses.yml#/Problem diff --git a/api/testdata/openapi-3.2.0.yml b/api/testdata/openapi-3.2.0.yml index 522461c..b00f460 100644 --- a/api/testdata/openapi-3.2.0.yml +++ b/api/testdata/openapi-3.2.0.yml @@ -252,6 +252,7 @@ components: - rate_limited (429): too many requests; see Retry-After. - internal (500): unexpected server error. - not_implemented (501): the operation is in the contract but not implemented yet. + - service_unavailable (503): the service cannot serve the request now, for example while a model loads; retry later. enum: - validation_failed - verification_token_invalid @@ -273,6 +274,7 @@ components: - rate_limited - internal - not_implemented + - service_unavailable ProblemFieldError: type: object description: One reason why a request field or parameter is invalid. diff --git a/backend/Makefile b/backend/Makefile index 6a7ab3b..6603023 100644 --- a/backend/Makefile +++ b/backend/Makefile @@ -58,13 +58,21 @@ assessment-category-attest-build: ## Build the local category attestation operat $(GO) build -buildvcs=false -trimpath -o bin/assessment-category-attest ./cmd/assessment-category-attest .PHONY: policy-publish policy-publish-build -policy-publish: ## Add the demo matching section to the product policy (set ARGS) +policy-publish: ## Add the demo matching or semantic matching section to the product policy (set ARGS) $(GO) run ./cmd/policy-publish $(ARGS) policy-publish-build: ## Build the local policy publication operator command @mkdir -p bin $(GO) build -buildvcs=false -trimpath -o bin/policy-publish ./cmd/policy-publish +.PHONY: semantic-backfill semantic-backfill-build +semantic-backfill: ## Schedule vector jobs for existing candidates and needs (set ARGS) + $(GO) run ./cmd/semantic-backfill $(ARGS) + +semantic-backfill-build: ## Build the local semantic backfill operator command + @mkdir -p bin + $(GO) build -buildvcs=false -trimpath -o bin/semantic-backfill ./cmd/semantic-backfill + .PHONY: demo-seed demo-seed-build demo-seed: ## Seed, check, or count the isolated demo stand; needs DEMO_MODE=isolated (set ARGS) $(GO) run ./cmd/demo-seed $(ARGS) diff --git a/backend/README.en.md b/backend/README.en.md index 89592c7..b8fe112 100644 --- a/backend/README.en.md +++ b/backend/README.en.md @@ -143,7 +143,7 @@ The candidate reads the facts at `GET /api/v1/me/evidence` (`usecase/evidence/re ## Match search -`POST /api/v1/organizations/{org_id}/matches` ranks the organization-visible candidate bank without ML (`usecase/matching/`). It runs in one transaction: `candidateview.Service.ListVisibleCards` applies the checks of a card read (verified employer, locked active membership, `ListVisibleCandidateViewSources` over `candidate_effective_publications` with `NOT EXISTS` over the hidden organizations, the account, C2, and publication locks, and the anonymous projection with its minimum cohort of five), the need snapshot is read by `requirements_version`, and the permitted evidence comes only from `ListOrganizationFacts`. The usecase repeats the owner role check; the HTTP boundary lists the operation in `ownerCompanyOperations`. A search is charged like card reads: each group is cut to the policy limit, and each candidate returned is reserved through the company quota port and recorded in the access history with the returned fields (`candidateview.SearchViews`); when the allowance ends the response is cut and flagged `truncated`. The operator publishes the matching section with `make policy-publish ARGS='matching --actor operator:'` (`cmd/policy-publish`), see [DEPLOY](../docs/en/DEPLOY.md#match-search-policy-on-a-stand). +`POST /api/v1/organizations/{org_id}/matches` ranks the organization-visible candidate bank without ML (`usecase/matching/`). It runs in one transaction: `candidateview.Service.ListVisibleCards` applies the checks of a card read (verified employer, locked active membership, `ListVisibleCandidateViewSources` over `candidate_effective_publications` with `NOT EXISTS` over the hidden organizations, the account, C2, and publication locks, and the anonymous projection with its minimum cohort of five), the need snapshot is read by `requirements_version`, and the permitted evidence comes only from `ListOrganizationFacts`. The usecase repeats the owner role check; the HTTP boundary lists the operation in `ownerCompanyOperations`. A search is charged like card reads: each group is cut to the policy limit, and each candidate returned is reserved through the company quota port and recorded in the access history with the returned fields (`candidateview.SearchViews`); when the allowance ends the response is cut and flagged `truncated`. The operator publishes the matching section with `make policy-publish ARGS='matching --actor operator:'` (`cmd/policy-publish`), the semantic section with `ARGS='semantic --actor operator:'`, and schedules vectors for existing data with `make semantic-backfill ARGS='all --run