Go backend
Русский | English
The main service uses Go, chi, and Clean Architecture. It currently provides health checks, identity and server-side sessions, the consent ledger and settings, and PostgreSQL, Redis, and SeaweedFS adapters; the remaining hiring workflows are still to be implemented.
cmd/app/is the entry point;internal/bootstrap/wires dependencies and manages startup.internal/contains domain types, use cases, ports, and primary/secondary adapters.config/holds application settings;pkg/is for shared helper packages.db/andcodegen/hold SQL queries, migrations, and generator configuration.integration_test/checks real dependencies through Testcontainers.
From the repository root, make -C backend check runs the main checks and make -C backend test-int runs integration tests with Docker. Use make -C backend help for all commands.
Server sessions
Registration, email confirmation, login, GET /api/v1/identity/me, GET /api/v1/identity/sessions/current, and DELETE /api/v1/identity/sessions/current are implemented. The session boundary authenticates every operation protected by the OpenAPI contract; handwritten handlers can read a principal containing the user ID and verified-email state resolved from the PostgreSQL session. Unknown, expired, revoked, or unverified sessions answer 401 unauthenticated. Contract operations without an implemented business handler answer 501 after the security boundary and request validation succeed. An unknown email and an incorrect password return the same 401 invalid_credentials; correct credentials for an unverified account return 403 email_not_verified at login.
Sessions are stored in PostgreSQL. The browser receives a __Host-lincodex_session cookie with Secure, HttpOnly, SameSite=Strict, Path=/, and no Domain; the database stores only the token hash. The default idle timeout is 24 hours and the absolute lifetime is 168 hours. Configure them with IDENTITY_SESSION_IDLE_TIMEOUT and IDENTITY_SESSION_ABSOLUTE_LIFETIME; the idle timeout cannot exceed the absolute lifetime.
Every unsafe public identity operation (RegisterAccount, ResendEmailVerification, ConfirmEmail, ConfirmEmailByCode, and Login) requires exactly one Origin header matching APP_PUBLIC_URL. Unsafe session operations also require the session-bound HMAC token in X-CSRF-Token; all API instances must use the same IDENTITY_KEY_SECRET. Origin checks do not trust Host or forwarded headers. A wrong Origin or CSRF token returns 403 and leaves a valid session intact; successful logout revokes it on the server and clears the cookie. Login limits apply separately by client address and normalized email: IDENTITY_CLIENT_HOURLY_LIMIT defaults to 30 attempts per hour and IDENTITY_LOGIN_EMAIL_HOURLY_LIMIT defaults to 10 attempts per hour.
HTTP-flow tests with PostgreSQL and Redis are part of make -C backend test-int; compile the integration suite without starting containers with make -C backend test-int-compile.
Consent ledger and settings
Only the current C1 text is public for registration. A verified user can read current C1/C2/C3/C5 texts before granting them in settings and can page through their own consent history. C1 can be granted by either account scenario; C2, C3, and C5 are candidate-only. Mutations require explicit acceptance, the exact Origin, and session-bound CSRF.
Revoking C2 makes the publication effectively closed and hides its fields through the ledger-backed read in the same transaction; the stored publication stays linked to the revoked record, so a later C2 grant cannot reopen it. Revoking C3 does not block account, profile, or manual-assessment requests through support. Revoking C5 immediately closes the gate for future imports and writes an outbox intent; there is no external FSP adapter yet. C4 revocation is limited to one organization and uses the stored contact scope; in the same transaction it closes the grants that name the revoked records, and C2 revocation closes every contact grant of the candidate. A C1 request revokes consent and creates a durable deletion-request record with an outbox intent; repeats return the same active record, and the account is not deleted synchronously.
make -C backend test-int runs the full HTTP flow with PostgreSQL and Redis. TestConsentSettingsOverHTTP covers texts, history, grants, revocation effects, and the C1 deletion request.
Organizations
POST /api/v1/organizations, GET /api/v1/organizations/{org_id}, and PATCH /api/v1/organizations/{org_id} are implemented. A verified employer creates the organization and its active owner membership in one transaction, starting at e0 with basis confirmed_email. Every read checks active owner membership. Only the active owner can edit; the version advances on change and the verification level is preserved.
The same Idempotency-Key and body replay the original 201 snapshot within 24 hours, even after profile edits. Migration 00019_create_organization_creation_results.sql stores that snapshot separately from the live organization. The 24 hours define the logical replay window. Bounded opportunistic cleanup runs on successful creates; physical deletion can occur later, and removes the snapshot with its generic idempotency record. GET /api/v1/me/organizations paginates the current employer's active memberships. Invitation routes enforce the common owner check; the draft operations and the send are described under Invitation drafts, and the other organization invitation operations answer 501 after that check.
TestOrganizationCreationAndOwnerEditingOverHTTP checks concurrent replay, rollback on owner insertion failure, cross-account denial, persisted reads after rebuilding the API, and reuse of an expired key against PostgreSQL.
The organization joins the holding of the owner account: CreateWithOwner creates the holding (table holdings, migration 00041_create_holdings.sql) in the same transaction when the account creates its first organization. The E0 invitation and card-view limits are shared by all E0 organizations of the holding; the pool and lock rules are described in Company quotas. TestHoldings covers the shared pool, account isolation, concurrent reservations, and concurrent creation, and TestHoldingsMigrationBackfillsFoundersAndGuardsRollback covers the backfill and the guarded rollback.
TestCompanyContextChecksLiveOwnerMembershipAndListsOwnOrganizations covers company isolation, candidate denial even with a manually inserted membership, denial for other roles, pagination, and owner revocation with the same cookie. A company in the active-membership directory does not grant owner authority; the server checks the role on every request.
Organization needs
Organization needs have transaction-bound PostgreSQL storage through UnitOfWork.Needs(). Migration 00023_create_organization_needs.sql adds a current-version pointer and immutable snapshots scoped by organization. Creation starts at version 1. A changed snapshot advances the version with compare-and-swap; a losing writer gets a version conflict. The HTTP contract uses 412 for that conflict.
The owner-scoped create, read, list, and update operations live in internal/adapter/primary/http/v1/need.go. Every operation checks the current verified employer account and locks its active owner membership in the transaction. List cursors carry both account and organization scope. Creates retain the original public response for the 24-hour idempotency window, even after a later edit.
Source text is parsed locally by deterministic rules into unconfirmed suggestions. Unknown or ambiguous values remain unknown. Confirming a stored suggestion preserves its origin; a manual replacement records a manual origin. Editing source text preserves confirmed values, and removing a suggestion prevents later extraction from silently restoring it. Readiness is derived from confirmed requirements. Category recommendations currently report not_available without confirmed skills and pending otherwise; the category recommendation calculator is not implemented yet.
requirements_version identifies the snapshot where confirmed requirements last changed. Editing only the title, source text, or unconfirmed suggestions leaves that reference unchanged. Domain no-ops preserve both versions. Snapshots preserve provenance, reject oversized content, and use UTC microsecond timestamps. Current and historical reads require the organization ID; immutable history rejects ordinary UPDATE and DELETE. Down migration removes both tables and their history, so it is destructive after data has been written.
TestOrganizationNeedsStorage exercises actual PostgreSQL isolation, history, concurrent updates, transaction rollback, immutable snapshots, and storage bounds. The caller must perform the existing active-owner check in the same business operation; storage scope alone does not grant company access.
Migration 00026_create_organization_need_creation_results.sql adds create-response storage and 8 KiB of database representation headroom for JSONB whitespace. The compact domain snapshot limit remains 256 KiB. Its down migration refuses to discard live replay results or restore the previous database bound over larger stored snapshots. Check those conditions before rollback; it does not remove need history to make a downgrade succeed.
Invitation drafts
The organization side of the invitation draft is implemented: GET and POST /api/v1/organizations/{org_id}/invitations and GET and PATCH /api/v1/organizations/{org_id}/invitations/{invitation_id} (usecase/invitation/, adapter/primary/http/v1/invitation.go). Withdrawal, the salary raise, the contact read, the acceptance, and the cancellation still answer 501 after the common checks. A draft is invisible to the candidate and writes no inbox entry, event, or quota usage.
Migration 00037_create_invitations.sql adds invitations, the immutable invitation_terms_versions, the append-only invitation_events (one audit event for each committed version), and invitation_creation_results (the original response of an idempotent create). Money is whole rubles in bigint; domain.SalaryRange is the one implementation of the range rule for needs and invitations, and the terms table repeats it in constraints (bounds and step, A < B, a width of 10% to 40% in integer arithmetic), so no other writer can store a range the API refuses. A change of the terms appends the next terms version; the earlier one cannot be updated or deleted. The candidate is stored as an internal candidate_id and shown only as the organization-scoped card handle. The down migration refuses while any invitation exists and never deletes one. The tables, decisions, locks, and what is not implemented are in architecture; the contract is in api/README.en.md.
candidateview.Service.ResolveCandidateHandle resolves the handle in the create transaction with the checks of a card read (membership, effective C2 publication, hiding of the organization, minimum cohort) and charges no quota. An unknown handle, a handle of another organization, a hidden or unpublished candidate, and a suppressed card give the same 400 at /candidate_handle. The create is idempotent for 24 hours and replays the stored 201. An update answers 200 for a body that changes nothing, then compares the version (412), then the state (409), then the rules (400). Both commands take the organization lock before the membership and invitation locks. salary_fit is not_available until the limit against probing the minimum exists.
The integration tests TestOrganizationInvitationDraftsOverHTTP (the router, sessions, CSRF, cohort and hiding fixtures, money boundaries, package conditions, handle refusals, replay, anti-enumeration, listing and cursors, versions and immutable terms, need links, the state conflict, concurrent updates, concurrent creates and updates of one organization without a deadlock, and no candidate value in responses, stored terms, or logs), TestInvitationRepositoryStoresVersionsAndRefusesLostUpdates, TestInvitationTablesRefuseMoneyAndHistoryViolations (the constraints and triggers by direct SQL), and TestInvitationMigrationRollbackKeepsStoredInvitations run against a real PostgreSQL.
Sending is implemented: POST /api/v1/organizations/{org_id}/invitations/{invitation_id}/send (usecase/invitation/send.go) and the candidate's list GET /api/v1/me/invitations (usecase/invitation/candidate_inbox.go). One transaction takes the organization lock, the owner membership, the key, and the invitation row, checks the version and the state, resolves the stored candidate through the card visibility barrier again (409 when hidden, C2 revoked, or suppressed), charges the organization quota through companyquota.Service.ReserveInvitation (429 with Retry-After), moves the draft to delivered with response_deadline_at = delivered_at + response_period_days, appends the delivered audit event, and writes the outbox events invitation.delivered and notification.mail_requested (usecase/notification/invitation.go). A success therefore means the invitation is already in the candidate's list; the notification and the email follow through the consumers, and neither they nor their retries change the deadline. A repeat with the same key replays the stored outcome, and a send of a delivered invitation answers 200 with its current state without a second charge. Migration 00038_send_invitations.sql adds the delivered event kind, invitation_send_results (the 200, 404, or 409 kept under the key), and the foreign key from company_invitation_quota_usage to invitations; its rollback refuses while a delivery event or a stored outcome exists. Details are in architecture. TestOrganizationInvitationSendOverHTTP and TestInvitationSendMigrationKeepsDeliveriesAndKeysQuotaUsage cover it against a real PostgreSQL.
The limit of invitations that wait for an answer per need, the 30-day pause after a decline, and the expiry at the deadline are implemented. The send checks the limit (max_pending_per_need) and the pause (repeat_after_decline_days) of the effective policy before it charges the quota, and answers 409 state_conflict; in the same transaction it schedules the job invitation.response_deadline at the response deadline. The handler usecase/invitation/expire.go moves a waiting invitation to expired with the reason invitation_timeout, and the candidate commands apply the due expiry first at or after the deadline. Migration 00043_expire_invitations.sql adds the event kind expired without an actor, the trigger invitations_guard_expiry, the partial indexes, and the jobs of invitations that were delivered before it. Details are in the architecture. TestInvitationPendingLimitAdmitsOneOfTwoConcurrentSendsOverPostgres, TestInvitationPauseAfterADeclineHoldsForThirtyDaysOverPostgres, TestInvitationAcceptAtTheDeadlineRacesTheExpiryJobOverPostgres, and TestInvitationExpiryMigrationBackfillsDeadlineJobsAndGuardsExpiries cover it against a real PostgreSQL.
The candidate's read, view, decline, and acceptance are implemented: GET /api/v1/me/invitations/{invitation_id}, POST .../view, and POST .../decline (usecase/invitation/view.go and decline.go). The read records no view and applies only the due expiry; the view moves delivered to viewed before the deadline, keeps the deadline, applies the due expiry at or after it, and otherwise answers with the invitation as it is; the decline moves delivered, viewed, or the planned counter to declined before the deadline with a reason and an optional comment and creates no consent or grant. The view and the acceptance lock only the invitation row; the decline also takes the organization lock to order the pause of the pair. The commands append the audit events viewed and declined. A late decline answers 409 after the due expiry, and a declined invitation has contact_consent and contact_grant null. Migration 00039_answer_invitations.sql adds the event kinds, the state rules of the view and the answer, invitation_declines (the reason and the comment, which the organization never reads), and invitation_decline_results (the outcome under the key); its rollback refuses while a view, a decline, or an outcome exists. Details are in architecture. TestCandidateInvitationViewAndDeclineOverHTTP and TestInvitationAnswerMigrationGuardsAnswersAndRefusesRollback cover it against a real PostgreSQL.
The candidate's acceptance is implemented: POST /api/v1/me/invitations/{invitation_id}/accept (usecase/invitation/accept.go). One transaction locks the invitation row, moves a delivered or viewed invitation before its deadline to accepted at the invitation version and the terms version that the candidate read, records the consent C4 through consent.Service.GrantContact (the published text and the selected fields), stores the contact grant of exactly the selected fields in contact_grants, and appends the audit event accepted. A stale version answers 412 and is not stored; the consent rules answer 400 with a pointer under /consent_c4; a repeat answers the stored acceptance, and another field set answers 409 state_conflict. Acceptance never publishes the profile or lifts a hiding: the grant is readable only while the organization may read the profile. Migration 00040_accept_invitations.sql adds the event kind, the grant table with composite keys that tie it to the invitation, the candidate, and the C4 record, the outcome table, and a refusal of rollback while an acceptance exists. Details are in architecture. TestCandidateInvitationAcceptOverHTTP and TestInvitationAcceptMigrationGuardsAcceptancesAndRefusesRollback cover it against a real PostgreSQL.
The contact read is implemented: GET /api/v1/organizations/{org_id}/invitations/{invitation_id}/contacts (usecase/invitation/contacts.go, handler adapter/primary/http/v1/contacts.go). It is owner only. Each request rechecks, under locks, the membership, the C4 record, the grant and its fields, and the visibility of the publication, and every closed case answers 404 not_found. A successful read writes one contact_read row to candidate_card_access_events and consumes no card-view quota. Revoking C4 closes the grants that name its records, revoking C2 or closing the publication closes every grant of the candidate, and hiding an organization closes its grants; unhiding or publishing again never reopens them. Migration 00042_index_contact_grants_by_candidate.sql adds the index of those closings. Details are in architecture. TestOrganizationContactReadsAndRevocationOverHTTP covers it against a real PostgreSQL.
Support cases
Verified accounts can create and list their own cases at /api/v1/me/support-cases and read a case by its ID. Ownership is independent of access to a disputed action. Object references contain only a type and ID; the server checks their scope and does not copy private object content. Employers can submit general support requests. Candidates can also request manual assessment without a prior attempt or C3 consent. Such a request waits for an expert and does not assign a grade or grant consent.
A manual request pins the current published rubric for its specialization and grade. The API shows the grading-policy version; private references retain the exact category opening and immutable family-version manifest. Later publications do not change an existing case's rubric. Without one unambiguous current rubric, the version remains null and the case waits for an expert.
Creation requires an explicit support section in the effective product policy. DemoProductPolicyV2 includes it; normal startup still seeds only the immutable V1 policy. The demo targets are five business days for support, complaints, and manual assessment, and ten for appeals. The versioned calendar counts UTC weekdays without public holidays and does not pause while waiting for the user. These are operational targets, not legal deadlines.
The account-wide rolling request limit is checked under a database lock before idempotent replay. Valid retries consume that request budget and return the original creation response during the 24-hour window. A 429 response includes Retry-After. GET and list show the current status, public history, and current overdue flag. Migration 00025_create_support_cases.sql stores immutable events and replay results; rollback removes these records and is destructive.
The manual assessment rules live in internal/usecase/supportcase/manual_assessment.go: the request neither reads nor changes consent, creates no attempt, and writes no grade or category, and a prior attempt is optional and may have failed.
TestManualAssessmentRequestAfterC3Refusal goes through the real router: granting and revoking C3, a request before the first test with a pinned rubric, a request without a published rubric (rubric_version is null), and requests after a failed and after a confirmed attempt. The test compares the consent ledger and events, attempts, and immutable results before and after the request, and checks that a repeat with a new key leaves one open case.
TestSupportCasesOverHTTP covers real sessions, owner isolation, typed-reference checks, replay, manual assessment without C3, and request limits. TestSupportCaseRequestBudgetSerializesTimestampWithOwnerLock checks concurrent requests and clock ordering. Expert processing and references to not-yet-implemented invitations or anti-cheat reviews remain unavailable.
Candidate questionnaire
Verified candidates can read and replace their own questionnaire through GET/PUT /api/v1/me/questionnaire. The questionnaire has a separate version and stores self-assessment, work formats, optional experience totals, and one or two specializations. It cannot assign confirmed grades. An identical retry returns the saved record without advancing its version; a stale changed body returns 412, as specified by the API contract. Concurrent identical writes also return the same winning record.
Saving advances onboarding only from candidate_questionnaire to candidate_assessment, in the same transaction. Other saved steps stay unchanged. Consent settings do not yet complete the consent onboarding step.
The public specialization catalog derives readiness from the current published bank, current policy, and an immutable reviewed mapping tied to the exact category opening and published-family manifest. Legacy openings without a mapping remain unavailable. Policy changes or family retirement invalidate readiness until a new reviewed opening is made; previously saved answers remain readable. Operator names are self-declared review metadata, not an authenticated operator identity.
TestCandidateQuestionnaireOverHTTP covers persistence, account isolation, version races, rollback, conditional onboarding, and changing bank availability. Company quota storage and its calling contract are described in Company quotas.
Assessment attempts
A candidate creates an attempt through POST /api/v1/me/assessment-attempts, reads it by ID, and resumes work through POST /api/v1/me/assessment-attempts/{attempt_id}/sessions. Real assessment requires current C3 consent; the owner's attempt history remains readable after revocation. GET neither consumes sessions nor changes state. A command with a stale version returns 412.
Creation pins the policy, bank and algorithm versions, the published family manifest, and generated question instances. The API response excludes answer keys, seeds, and private rubrics. Root-attempt quota is candidate-wide; retry and promotion intervals apply per specialization. A corrective attempt retains its root and the original chain deadline. Training demo_express uses a separate explicitly published bank and consumes no real-assessment quota.
Repeating a command with the same key and body returns its stored response for 24 hours. Reusing a key with another body returns 422; an unavailable bank or exhausted quota returns 409 state_conflict. PostgreSQL serializes quota checks and session updates, and domain time is read after lock waits. Migration 24 adds attempts, question instances, training bindings, and stored command responses; rolling it back deletes these records.
Answer submission evaluates the frozen server key and stores each answer once. Numeric comparison preserves the JSON number token without floating-point rounding; order answers must include every task exactly once. Finalization rejects unfinished required questions with their IDs, then stores the raw basic score, policy rationale, version pins, and result projection in one transaction. Reads use that immutable result. Duration does not add points, trailing seed items are unscored, and express results contain no qualification score. Migration 29 refuses rollback while command or result records depend on it. A basic threshold is not evidence of calibration.
Demonstration category. Finalizing a real attempt writes a version 2 result: the immutable document gains a category decision and the grade in force at the moment of the decision (migration 31). A demo_express result stays a version 1 record without these fields and never creates a category. The decision depends on the basic_pass_mark_bp threshold of the policy version pinned to the attempt; the HTTP handler sets no parameter. A current category row (candidate_assessment_categories, one per candidate and specialization) appears only when all of the following hold: ASSESSMENT_DEMO_CATEGORIES_ENABLED is on (off by default; turn it on only on a synthetic stand), the pinned policy is a complete demonstration policy with demo_basic (its threshold is the policy's own basic_pass_mark_bp), the result is confirmed, and an operator attestation exists for the exact category opening, catalog manifest, and policy version (assessment_synthetic_category_reviews, source = synthetic_demo). Otherwise the decision is stored as not_eligible or not_confirmed. A candidate and specialization lock serializes promotions; the database accepts only a strict upgrade, forbids deletion and manual replacement of the source, and a current category always points at a stored version 2 result of the same candidate. A failure, an equal grade, or a lower grade keep the category in force, and both attempts stay in the history.
The candidate reads the history through GET /api/v1/me/assessment-results (usecase/assessment/category_history.go): own root and corrective results only, paged by a cursor that a server HMAC binds to the candidate. An employer gets no history; a separate projection of the current category is part of the visible-candidate query (privacy_cohort.sql) and selects only the specialization and grade, so the anonymous card shows the category with strength standard when the candidate published the categories field. A change of the current policy changes no stored result or category; opened categories are bound to the policy they were opened under, so no attempt is created after a new policy version until the categories are opened again. The attestation is created by the local command make -C backend assessment-category-attest (see DEPLOY.md). Calibration of the threshold is not implemented.
Assessment signals
The candidate-only POST /api/v1/me/assessment-attempts/{attempt_id}/signals accepts batches of focus-loss durations, clipboard event byte counts, and fullscreen exits. It stores no clipboard or answer content (size_bytes is the UTF-8 byte count of the pasted text plus file sizes, computed on the device, for a paste, and an approximate selection length in UTF-16 code units, with the text unread, for copy and cut) and supports no camera, microphone, screenshot, or screen recording. Events are bound to the owned real attempt and one of its frozen items; training attempts do not accept them. New batches require current C3 and an active attempt.
The operation limits the body to 32 KiB, each batch to 50 events, new receipts to 30 per minute per attempt, and stored events to 10,000 per attempt. Capacity is checked for the whole batch. A saturated receipt accepts zero events; idempotent replay returns the original receipt without consuming the receipt budget. Client timestamps are untrusted metadata: a timestamp outside five minutes before the attempt's creation to five minutes after database time rejects the whole batch with 400, so the client moves its timestamps to server time using the Date header; rate windows use database time. Migration 28 cascades event, batch, and receipt deletion with the attempt. Existing consent retention constraints still prevent physical account deletion; this cascade does not implement account erasure. Interpretation of these signals is separate work.
The notice about the collected signals is stored separately. GET and PUT /api/v1/me/assessment-signal-notice read and write the candidate's acknowledgement of a text version (usecase/assessment/signal_notice.go, table assessment_signal_notice_acknowledgements, migration 34). The server sets the text version (CurrentSignalNoticeVersion, now 2: version 2 added the measures the page applies during an attempt to the signal list); an acknowledgement is stored per version, so one given for version 1 stays stored but never counts for version 2 and a new text needs no migration. A PUT with another version answers 409 and stores nothing, and a repeat keeps the time of the first acknowledgement. The acknowledgement is not a consent: the signal operation does not read it and still requires current C3, so the notice cannot be used to hide a consent. Attempt creation does not check the acknowledgement on the server; the candidate screen enforces the requirement. Rows are deleted by cascade with the user.
Anonymous profile projection
The organization-scoped projection uses purpose-separated HMAC aliases, a closed skill taxonomy, coarse experience bands, and explicitly selected publication fields. Confirmed categories and self-assessed grades remain separate. It excludes contacts, employer names, free text, exact salary, and account identifiers. Overlapping work periods count once.
The repository filters current C2 publication and hidden organizations before building the cohort. Complete visible feature combinations with fewer than five candidates are generalized or suppressed. This reduces identification risk; it does not guarantee anonymity. The private owner-preview alias uses a separate purpose. Category and salary compatibility inputs remain absent until their authoritative source supplies them; missing evidence is never inferred from a claimed grade.
Candidates read settings at GET /api/v1/me/privacy, preview at GET /api/v1/me/privacy/preview, change history at GET /api/v1/me/privacy/history, and card views at GET /api/v1/me/privacy/access-history. Hidden organizations are listed at GET /api/v1/me/privacy/hidden-organizations and changed through PUT/DELETE /api/v1/me/privacy/hidden-organizations/{org_id}. Publication and search status use PUT /api/v1/me/privacy/publication and PUT /api/v1/me/privacy/search-status. The data is scoped to the candidate in the current session, responses use Cache-Control: no-store, and writes require the session CSRF token and an exact allowed Origin. C2, publication, search status, and hidden organizations are independent: changing one does not enable another. Search status is a statement by the candidate, not consent.
An employer with a verified account and active membership reads a card through GET /api/v1/organizations/{org_id}/candidate-cards/{candidate_handle}. Each request rechecks membership, current C2, publication, organization hiding, and the minimum cohort; a successful view and quota use are recorded in one transaction. A closed, revoked, hidden, or suppressed card is indistinguishable from an unknown handle. Candidates can see successful card views in their access history. Contact reads and C4 grant management are not available yet; cards never contain contact details.
Skill evidence
A confirmed real assessment result leaves one fact of skill evidence per attempt, written by the database in the same transaction that stores the result (migration 35, the trigger on assessment_attempt_results, and the function skill_evidence_project_assessment_result). The migration also projects the results that already exist. An express run, a failed attempt, and a result without a reviewed category source leave no fact. The skills of an event are tags of its fact, so several tags are still one fact, and an online assessment without a reliable identity confirmation has trust 1.
The candidate reads the facts at GET /api/v1/me/evidence (usecase/evidence/read.go, query ListCandidateEvidenceFacts); an employer reads the permitted projection at GET /api/v1/organizations/{org_id}/candidate-cards/{candidate_handle}/evidence, which runs the checks of the card read (candidateview.Service.AuthorizeCategoriesSection: membership, effective C2 publication, hiding, minimum cohort, quota, access audit) and then the statement ListOrganizationVisibleEvidence (effective publication view, NOT EXISTS over the hidden organizations, the categories field, visible measurements, one fact for each category of the card that supports its confirmed grade, an allowlist of six columns: skill, grade, trust, basis, calibration, year). The preview of the candidate (GetMyCardPreview) shows the same section through ListCandidatePreviewEvidence. The reads touch only the two evidence tables; backend/db/evidence_queries_test.go fails when an evidence query names a result, attempt, answer, signal, or review table. The facts, the tags, and the rules are described in architecture. The integration test TestSkillEvidenceOverHTTP runs against a real PostgreSQL and covers the fact tied to its result with trust 1, two more tags on one event, an express run and a failed attempt, paging, the organization projection with C2 granted and revoked, a hidden organization, a hidden fact, a card without categories, tags that can join a fact only in its creating transaction, the erasure of an account with facts through both cascade paths, the refusal to roll the migration back while a fact is hidden, and the rebuild after the migration is rolled back and applied again.
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:<handle>' (cmd/policy-publish), the semantic section with ARGS='semantic --actor operator:<handle>', and schedules vectors for existing data with make semantic-backfill ARGS='all --run <label>' (cmd/semantic-backfill), see DEPLOY and semantic matching. The search itself never calls ML: it reads the vectors that the semantic.candidate and semantic.need jobs compute (usecase/semantic/).
Each entry is one candidate specialization. Scores use the matching section of the effective product policy (domain.MatchingPolicy, demo version DemoProductPolicyV4); a policy without the section makes the search fail closed. The arithmetic is integer (micro units for components, basis points for shares), so the order is reproducible: confirmed groups sort by S, then coverage, then the internal candidate identifier; the unconfirmed group by Fit, then coverage, then the identifier, and it never computes theta, T, P, a percentile, or S. The explanation and the unknown flags are built from the same computed contributions. The model, the neutral values, and what is not implemented are described in architecture.
The integration test TestMatchSearchOverHTTP runs against a real PostgreSQL through the real router, the profile, consent, publication, need, organization, and assessment operations: hidden candidates and two organizations, a need and its edited requirements, repeated identical responses, one handle confirmed in Backend and unconfirmed in Networks, a profile published without a grade and removed by a C2 revocation, a candidate alone in its cohort, no contact or identifier in the body, the charge and the access history of a search, an organization with an allowance smaller than its bank, the group limit, the access denials, and the policy without the section. The browser fixture questionnaire-fixture publishes DemoProductPolicyV4, so a local stand has the matching section.
See architecture and development.
Internal notifications
The inbox stores a reference to a delivered event for one recipient (notification_inbox_events, migrations 32 and 36), never its text. The consumer notification_inbox (usecase/notification/inbox_handler.go) writes the row in the transaction of its dedup marker; the key (recipient_user_id, event_id) keeps one row per recipient and event, and an event ID that returns with other metadata is rejected. The row exists whether or not an email was sent, and nothing in the handler reads mail state.
The text is resolved when the list is read (usecase/notification/inbox.go, inbox_content.go): InboxService authorizes the cabinet in the read transaction (a verified candidate for GET /api/v1/me/notifications; a verified employer with an active membership for GET /api/v1/organizations/{org_id}/notifications), then asks the resolver of each item's source type for the content that the recipient may see now. A source that is gone or hidden leaves the item in the list without content. The mark (POST .../{notification_id}/read) keeps the first read time and reads no source. A foreign, cross-organization, or unknown item answers 404.
A producer appends an invitation.delivered event with the payload recipient_user_id and organization_id and registers a resolver for its source; the send of an invitation does so, and the synthetic notification.synthetic_delivered event exercises the path and has no product meaning. The contract is in docs/en/ARCHITECTURE.md and api/README.en.md.