feat(matching): rank with semantic embeddings and explain matches by evidence
This commit is contained in:
1 parent
facc1789b1
commit
24b64d698a
215 files changed
+16951
-327
No files matched your search
@@ -361,6 +361,24 @@ type CandidateProfileOverlapConfirmation struct {
|
||||
SecondEndedOn pgtype.Text
|
||||
}
|
||||
|
||||
type CandidateProjectRepository struct {
|
||||
CandidateID pgtype.UUID
|
||||
RepositoryKey string
|
||||
State string
|
||||
GithubID pgtype.Int8
|
||||
Description pgtype.Text
|
||||
Topics []string
|
||||
Languages []string
|
||||
ReadmeExcerpt pgtype.Text
|
||||
RepositoryEtag pgtype.Text
|
||||
ReadmeEtag pgtype.Text
|
||||
FailureClass pgtype.Text
|
||||
CheckedAt pgtype.Timestamptz
|
||||
RequestedAt pgtype.Timestamptz
|
||||
CreatedAt pgtype.Timestamptz
|
||||
UpdatedAt pgtype.Timestamptz
|
||||
}
|
||||
|
||||
type CandidatePublication struct {
|
||||
UserID pgtype.UUID
|
||||
State string
|
||||
@@ -838,6 +856,22 @@ type ScheduledJob struct {
|
||||
UpdatedAt pgtype.Timestamptz
|
||||
}
|
||||
|
||||
type SemanticVector struct {
|
||||
SubjectKind string
|
||||
SubjectID pgtype.UUID
|
||||
CandidateID pgtype.UUID
|
||||
NeedID pgtype.UUID
|
||||
ModelID string
|
||||
ModelRevision string
|
||||
PromptVersion string
|
||||
ItemKey string
|
||||
ContentSha256 []byte
|
||||
LabelSha256 []byte
|
||||
Dimension int32
|
||||
Vector []byte
|
||||
ComputedAt pgtype.Timestamptz
|
||||
}
|
||||
|
||||
type Session struct {
|
||||
ID pgtype.UUID
|
||||
UserID pgtype.UUID
|
||||
|
||||
@@ -68,11 +68,21 @@ SELECT
|
||||
WHERE category.candidate_id = effective.user_id
|
||||
),
|
||||
'[]'::text
|
||||
) AS confirmed_categories
|
||||
) AS confirmed_categories,
|
||||
COALESCE(
|
||||
(
|
||||
SELECT array_agg(repository.repository_key ORDER BY repository.repository_key)
|
||||
FROM candidate_project_repositories AS repository
|
||||
WHERE
|
||||
repository.candidate_id = effective.user_id
|
||||
AND repository.state = 'verified'
|
||||
),
|
||||
'{}'::text []
|
||||
)::text [] AS verified_repositories
|
||||
FROM candidate_effective_publications AS effective
|
||||
LEFT JOIN candidate_profile_claims AS claim
|
||||
ON claim.user_id = effective.user_id
|
||||
AND claim.kind IN ('stack', 'role', 'experience')
|
||||
AND claim.kind IN ('stack', 'role', 'experience', 'project')
|
||||
LEFT JOIN candidate_questionnaires AS questionnaire
|
||||
ON questionnaire.user_id = effective.user_id
|
||||
WHERE NOT EXISTS (
|
||||
@@ -98,15 +108,18 @@ type ListVisibleCandidateViewSourcesRow struct {
|
||||
WorkFormats []string
|
||||
ParallelPeriodAcknowledgements interface{}
|
||||
ConfirmedCategories interface{}
|
||||
VerifiedRepositories []string
|
||||
}
|
||||
|
||||
// Organization-facing anonymous candidate projection inputs. The calling
|
||||
// usecase has already authorized the active organization membership. This
|
||||
// single statement snapshot filters both revoked/unpublished C2 states and
|
||||
// candidates hidden from this organization before any profile value is read.
|
||||
// The projection reads only stack, declared role, and experience dates. It
|
||||
// deliberately excludes names, contacts, salary, location, soft skills,
|
||||
// employer names, summaries, and imported excerpts. The only assessment data
|
||||
// The projection reads only stack, declared role, experience dates, and
|
||||
// projects with the keys of their verified repositories. It deliberately
|
||||
// excludes names, contacts, salary, location, soft skills, employer names,
|
||||
// summaries, and imported excerpts; the repository address of a project stays
|
||||
// in the private input and never reaches the card. The only assessment data
|
||||
// is the current category (specialization and grade) of the separate current
|
||||
// category table; it carries no attempt, score, review, policy, or history.
|
||||
func (q *Queries) ListVisibleCandidateViewSources(ctx context.Context, organizationID pgtype.UUID) ([]ListVisibleCandidateViewSourcesRow, error) {
|
||||
@@ -132,6 +145,7 @@ func (q *Queries) ListVisibleCandidateViewSources(ctx context.Context, organizat
|
||||
&i.WorkFormats,
|
||||
&i.ParallelPeriodAcknowledgements,
|
||||
&i.ConfirmedCategories,
|
||||
&i.VerifiedRepositories,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -301,11 +315,21 @@ SELECT
|
||||
WHERE category.candidate_id = effective.user_id
|
||||
),
|
||||
'[]'::text
|
||||
) AS confirmed_categories
|
||||
) AS confirmed_categories,
|
||||
COALESCE(
|
||||
(
|
||||
SELECT array_agg(repository.repository_key ORDER BY repository.repository_key)
|
||||
FROM candidate_project_repositories AS repository
|
||||
WHERE
|
||||
repository.candidate_id = effective.user_id
|
||||
AND repository.state = 'verified'
|
||||
),
|
||||
'{}'::text []
|
||||
)::text [] AS verified_repositories
|
||||
FROM candidate_effective_publications AS effective
|
||||
LEFT JOIN candidate_profile_claims AS claim
|
||||
ON claim.user_id = effective.user_id
|
||||
AND claim.kind IN ('stack', 'role', 'experience')
|
||||
AND claim.kind IN ('stack', 'role', 'experience', 'project')
|
||||
LEFT JOIN candidate_questionnaires AS questionnaire
|
||||
ON questionnaire.user_id = effective.user_id
|
||||
WHERE effective.user_id = $1
|
||||
@@ -326,6 +350,7 @@ type ReadCandidateViewSourceForPreviewRow struct {
|
||||
WorkFormats []string
|
||||
ParallelPeriodAcknowledgements interface{}
|
||||
ConfirmedCategories interface{}
|
||||
VerifiedRepositories []string
|
||||
}
|
||||
|
||||
// Read the candidate's current private projection inputs after the caller
|
||||
@@ -354,6 +379,7 @@ func (q *Queries) ReadCandidateViewSourceForPreview(ctx context.Context, candida
|
||||
&i.WorkFormats,
|
||||
&i.ParallelPeriodAcknowledgements,
|
||||
&i.ConfirmedCategories,
|
||||
&i.VerifiedRepositories,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -0,0 +1,206 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.31.1
|
||||
// source: project_repositories.sql
|
||||
|
||||
package sqlc
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/jackc/pgx/v5/pgtype"
|
||||
)
|
||||
|
||||
const deleteUnlinkedCandidateProjectRepositories = `-- name: DeleteUnlinkedCandidateProjectRepositories :exec
|
||||
DELETE FROM candidate_project_repositories
|
||||
WHERE
|
||||
candidate_id = $1
|
||||
AND NOT (repository_key = ANY($2::text []))
|
||||
`
|
||||
|
||||
type DeleteUnlinkedCandidateProjectRepositoriesParams struct {
|
||||
CandidateID pgtype.UUID
|
||||
LinkedKeys []string
|
||||
}
|
||||
|
||||
// Removes the checks of repositories that no project links any more.
|
||||
func (q *Queries) DeleteUnlinkedCandidateProjectRepositories(ctx context.Context, arg DeleteUnlinkedCandidateProjectRepositoriesParams) error {
|
||||
_, err := q.db.Exec(ctx, deleteUnlinkedCandidateProjectRepositories, arg.CandidateID, arg.LinkedKeys)
|
||||
return err
|
||||
}
|
||||
|
||||
const getCandidateProjectRepositoryForUpdate = `-- name: GetCandidateProjectRepositoryForUpdate :one
|
||||
SELECT
|
||||
candidate_id, repository_key, state, github_id, description, topics,
|
||||
languages, readme_excerpt, repository_etag, readme_etag, failure_class,
|
||||
checked_at, requested_at, created_at, updated_at
|
||||
FROM candidate_project_repositories
|
||||
WHERE candidate_id = $1 AND repository_key = $2
|
||||
FOR UPDATE
|
||||
`
|
||||
|
||||
type GetCandidateProjectRepositoryForUpdateParams struct {
|
||||
CandidateID pgtype.UUID
|
||||
RepositoryKey string
|
||||
}
|
||||
|
||||
func (q *Queries) GetCandidateProjectRepositoryForUpdate(ctx context.Context, arg GetCandidateProjectRepositoryForUpdateParams) (CandidateProjectRepository, error) {
|
||||
row := q.db.QueryRow(ctx, getCandidateProjectRepositoryForUpdate, arg.CandidateID, arg.RepositoryKey)
|
||||
var i CandidateProjectRepository
|
||||
err := row.Scan(
|
||||
&i.CandidateID,
|
||||
&i.RepositoryKey,
|
||||
&i.State,
|
||||
&i.GithubID,
|
||||
&i.Description,
|
||||
&i.Topics,
|
||||
&i.Languages,
|
||||
&i.ReadmeExcerpt,
|
||||
&i.RepositoryEtag,
|
||||
&i.ReadmeEtag,
|
||||
&i.FailureClass,
|
||||
&i.CheckedAt,
|
||||
&i.RequestedAt,
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const getLatestRepositoryCheckRequest = `-- name: GetLatestRepositoryCheckRequest :one
|
||||
SELECT MAX(requested_at)::timestamptz AS requested_at
|
||||
FROM candidate_project_repositories
|
||||
WHERE candidate_id = $1
|
||||
`
|
||||
|
||||
// The latest check request of a candidate, for the per-candidate limit.
|
||||
func (q *Queries) GetLatestRepositoryCheckRequest(ctx context.Context, candidateID pgtype.UUID) (pgtype.Timestamptz, error) {
|
||||
row := q.db.QueryRow(ctx, getLatestRepositoryCheckRequest, candidateID)
|
||||
var requested_at pgtype.Timestamptz
|
||||
err := row.Scan(&requested_at)
|
||||
return requested_at, err
|
||||
}
|
||||
|
||||
const listCandidateProjectRepositories = `-- name: ListCandidateProjectRepositories :many
|
||||
|
||||
SELECT
|
||||
candidate_id, repository_key, state, github_id, description, topics,
|
||||
languages, readme_excerpt, repository_etag, readme_etag, failure_class,
|
||||
checked_at, requested_at, created_at, updated_at
|
||||
FROM candidate_project_repositories
|
||||
WHERE candidate_id = $1
|
||||
ORDER BY repository_key
|
||||
`
|
||||
|
||||
// Server checks of the GitHub repositories that candidate projects link.
|
||||
// Every statement is scoped by the candidate.
|
||||
func (q *Queries) ListCandidateProjectRepositories(ctx context.Context, candidateID pgtype.UUID) ([]CandidateProjectRepository, error) {
|
||||
rows, err := q.db.Query(ctx, listCandidateProjectRepositories, candidateID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []CandidateProjectRepository
|
||||
for rows.Next() {
|
||||
var i CandidateProjectRepository
|
||||
if err := rows.Scan(
|
||||
&i.CandidateID,
|
||||
&i.RepositoryKey,
|
||||
&i.State,
|
||||
&i.GithubID,
|
||||
&i.Description,
|
||||
&i.Topics,
|
||||
&i.Languages,
|
||||
&i.ReadmeExcerpt,
|
||||
&i.RepositoryEtag,
|
||||
&i.ReadmeEtag,
|
||||
&i.FailureClass,
|
||||
&i.CheckedAt,
|
||||
&i.RequestedAt,
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const requestCandidateProjectRepositoryCheck = `-- name: RequestCandidateProjectRepositoryCheck :exec
|
||||
INSERT INTO candidate_project_repositories (
|
||||
candidate_id, repository_key, state, requested_at, created_at, updated_at
|
||||
) VALUES (
|
||||
$1, $2, 'pending', $3,
|
||||
$3, $3
|
||||
)
|
||||
ON CONFLICT (candidate_id, repository_key) DO UPDATE
|
||||
SET
|
||||
requested_at = excluded.requested_at,
|
||||
updated_at = GREATEST(candidate_project_repositories.updated_at, excluded.updated_at)
|
||||
`
|
||||
|
||||
type RequestCandidateProjectRepositoryCheckParams struct {
|
||||
CandidateID pgtype.UUID
|
||||
RepositoryKey string
|
||||
RequestedAt pgtype.Timestamptz
|
||||
}
|
||||
|
||||
// A new repository starts pending; a known one only records the request.
|
||||
func (q *Queries) RequestCandidateProjectRepositoryCheck(ctx context.Context, arg RequestCandidateProjectRepositoryCheckParams) error {
|
||||
_, err := q.db.Exec(ctx, requestCandidateProjectRepositoryCheck, arg.CandidateID, arg.RepositoryKey, arg.RequestedAt)
|
||||
return err
|
||||
}
|
||||
|
||||
const saveCandidateProjectRepositoryCheck = `-- name: SaveCandidateProjectRepositoryCheck :exec
|
||||
UPDATE candidate_project_repositories
|
||||
SET
|
||||
state = $1,
|
||||
github_id = $2,
|
||||
description = $3,
|
||||
topics = $4,
|
||||
languages = $5,
|
||||
readme_excerpt = $6,
|
||||
repository_etag = $7,
|
||||
readme_etag = $8,
|
||||
failure_class = $9,
|
||||
checked_at = $10,
|
||||
updated_at = GREATEST(updated_at, $10)
|
||||
WHERE candidate_id = $11 AND repository_key = $12
|
||||
`
|
||||
|
||||
type SaveCandidateProjectRepositoryCheckParams struct {
|
||||
State string
|
||||
GithubID pgtype.Int8
|
||||
Description pgtype.Text
|
||||
Topics []string
|
||||
Languages []string
|
||||
ReadmeExcerpt pgtype.Text
|
||||
RepositoryEtag pgtype.Text
|
||||
ReadmeEtag pgtype.Text
|
||||
FailureClass pgtype.Text
|
||||
CheckedAt pgtype.Timestamptz
|
||||
CandidateID pgtype.UUID
|
||||
RepositoryKey string
|
||||
}
|
||||
|
||||
func (q *Queries) SaveCandidateProjectRepositoryCheck(ctx context.Context, arg SaveCandidateProjectRepositoryCheckParams) error {
|
||||
_, err := q.db.Exec(ctx, saveCandidateProjectRepositoryCheck,
|
||||
arg.State,
|
||||
arg.GithubID,
|
||||
arg.Description,
|
||||
arg.Topics,
|
||||
arg.Languages,
|
||||
arg.ReadmeExcerpt,
|
||||
arg.RepositoryEtag,
|
||||
arg.ReadmeEtag,
|
||||
arg.FailureClass,
|
||||
arg.CheckedAt,
|
||||
arg.CandidateID,
|
||||
arg.RepositoryKey,
|
||||
)
|
||||
return err
|
||||
}
|
||||
@@ -217,9 +217,19 @@ type Querier interface {
|
||||
DeleteExpiredCompanyCardViewQuotaUsage(ctx context.Context, arg DeleteExpiredCompanyCardViewQuotaUsageParams) (int64, error)
|
||||
DeleteMailRequest(ctx context.Context, id pgtype.UUID) (int64, error)
|
||||
DeleteOrganizationRepresentatives(ctx context.Context, organizationID pgtype.UUID) error
|
||||
// Stored embedding vectors. A candidate keeps one set of rows for a model:
|
||||
// the job deletes every other row of the candidate and model before it
|
||||
// inserts the new set, in one transaction. A need keeps the rows of its
|
||||
// latest computed requirements snapshot the same way.
|
||||
DeleteSemanticVectorsOfModel(ctx context.Context, arg DeleteSemanticVectorsOfModelParams) error
|
||||
// Removes every vector of a subject, of any model: a closed card or a need
|
||||
// without requirements keeps no derived data.
|
||||
DeleteSemanticVectorsOfSubject(ctx context.Context, arg DeleteSemanticVectorsOfSubjectParams) error
|
||||
// No raw Idempotency-Key or request body reaches these statements. Failure
|
||||
// responses pass {} as case_snapshot and the CASE stores SQL NULL instead.
|
||||
DeleteSupportCaseCreateOutcome(ctx context.Context, scopeHash []byte) error
|
||||
// Removes the checks of repositories that no project links any more.
|
||||
DeleteUnlinkedCandidateProjectRepositories(ctx context.Context, arg DeleteUnlinkedCandidateProjectRepositoriesParams) error
|
||||
// Deletes one batch of accounts that stayed unverified since before cutoff,
|
||||
// oldest first, with their tokens, sessions, mail requests, mail deliveries
|
||||
// (and through the deliveries their attempts), and consent records. The
|
||||
@@ -314,6 +324,7 @@ type Querier interface {
|
||||
// Reads one hiding of the candidate with the current name of the
|
||||
// organization.
|
||||
GetCandidateHiddenOrganization(ctx context.Context, arg GetCandidateHiddenOrganizationParams) (GetCandidateHiddenOrganizationRow, error)
|
||||
GetCandidateProjectRepositoryForUpdate(ctx context.Context, arg GetCandidateProjectRepositoryForUpdateParams) (CandidateProjectRepository, error)
|
||||
GetConsentText(ctx context.Context, arg GetConsentTextParams) (ConsentText, error)
|
||||
GetContactConsentRecordByInvitation(ctx context.Context, arg GetContactConsentRecordByInvitationParams) (GetContactConsentRecordByInvitationRow, error)
|
||||
// Read the grant of one invitation of one organization. An invitation of
|
||||
@@ -374,6 +385,8 @@ type Querier interface {
|
||||
// resend, which issues its token with the same credentials.
|
||||
GetLatestPendingRegistration(ctx context.Context, arg GetLatestPendingRegistrationParams) (GetLatestPendingRegistrationRow, error)
|
||||
GetLatestPolicyVersion(ctx context.Context, policyKey string) (PolicyVersion, error)
|
||||
// The latest check request of a candidate, for the per-candidate limit.
|
||||
GetLatestRepositoryCheckRequest(ctx context.Context, candidateID pgtype.UUID) (pgtype.Timestamptz, error)
|
||||
// Reads the latest root in a specialization, optionally restricted to grade.
|
||||
GetLatestRootAssessmentAttempt(ctx context.Context, arg GetLatestRootAssessmentAttemptParams) (AssessmentAttempt, error)
|
||||
GetLiveIdempotencyRecord(ctx context.Context, arg GetLiveIdempotencyRecordParams) (IdempotencyRecord, error)
|
||||
@@ -599,6 +612,7 @@ type Querier interface {
|
||||
// moves a deadline. A concurrent insert of the same key waits for the first
|
||||
// transaction and then inserts nothing, or inserts after its rollback.
|
||||
InsertScheduledJob(ctx context.Context, arg InsertScheduledJobParams) (int64, error)
|
||||
InsertSemanticVector(ctx context.Context, arg InsertSemanticVectorParams) error
|
||||
InsertSession(ctx context.Context, arg InsertSessionParams) error
|
||||
// The initial public history is inserted in the caller's case transaction.
|
||||
// Any unique business conflict leaves the transaction usable so the caller can
|
||||
@@ -687,6 +701,9 @@ type Querier interface {
|
||||
// have no delivery and are never listed. The candidate scopes the rows, so
|
||||
// no identifier of another candidate can appear.
|
||||
ListCandidateInvitations(ctx context.Context, arg ListCandidateInvitationsParams) ([]ListCandidateInvitationsRow, error)
|
||||
// The item vectors of the candidates that a search returns, at most a few
|
||||
// dozen candidates.
|
||||
ListCandidateItemVectors(ctx context.Context, arg ListCandidateItemVectorsParams) ([]ListCandidateItemVectorsRow, error)
|
||||
// The same selection for the candidate's own card preview, so the candidate
|
||||
// sees what an organization would read. It is scoped by the owner and runs
|
||||
// after the caller locked the effective C2 and publication; it does not apply
|
||||
@@ -697,6 +714,11 @@ type Querier interface {
|
||||
// read time, and is the current name. The page continues after the
|
||||
// (occurred_at, id) position of the last event of the previous page.
|
||||
ListCandidatePrivacyEvents(ctx context.Context, arg ListCandidatePrivacyEventsParams) ([]ListCandidatePrivacyEventsRow, error)
|
||||
// Server checks of the GitHub repositories that candidate projects link.
|
||||
// Every statement is scoped by the candidate.
|
||||
ListCandidateProjectRepositories(ctx context.Context, candidateID pgtype.UUID) ([]CandidateProjectRepository, error)
|
||||
// The whole-view vectors of the candidates of one search.
|
||||
ListCandidateWholeVectors(ctx context.Context, arg ListCandidateWholeVectorsParams) ([]ListCandidateWholeVectorsRow, error)
|
||||
// One page of the subject's ledger, newest grant first, optionally limited
|
||||
// to one state. Every record query is scoped by the subject, so a caller
|
||||
// never reads or revokes another subject's consent. The state is computed,
|
||||
@@ -721,6 +743,11 @@ type Querier interface {
|
||||
// One bounded newest-first page. Both the organization scope and the tuple
|
||||
// cursor are applied before the limit.
|
||||
ListInvitations(ctx context.Context, arg ListInvitationsParams) ([]ListInvitationsRow, error)
|
||||
// The vectors of a need whose texts match the given digests of the
|
||||
// requirements snapshot that the search renders.
|
||||
ListNeedVectors(ctx context.Context, arg ListNeedVectorsParams) ([]ListNeedVectorsRow, error)
|
||||
// Needs and their current requirements snapshot for the backfill.
|
||||
ListNeedsAfter(ctx context.Context, arg ListNeedsAfterParams) ([]ListNeedsAfterRow, error)
|
||||
// List only the authenticated recipient's rows, optionally narrowed to one
|
||||
// organization context. The caller resolves current source visibility before
|
||||
// returning content.
|
||||
@@ -763,13 +790,22 @@ type Querier interface {
|
||||
// Owner-scoped newest-first list. It omits descriptions, complaint reason,
|
||||
// and event history. The tuple cursor matches the composite sort key.
|
||||
ListOwnedSupportCases(ctx context.Context, arg ListOwnedSupportCasesParams) ([]ListOwnedSupportCasesRow, error)
|
||||
// Candidates with a saved profile for the backfill, in identifier order
|
||||
// after a cursor. The job of a candidate who is not published removes the
|
||||
// stored vectors, so a backfill also cleans up after a closed card.
|
||||
ListProfileCandidatesAfter(ctx context.Context, arg ListProfileCandidatesAfterParams) ([]pgtype.UUID, error)
|
||||
// The digests of the stored rows of a subject and model, for the job that
|
||||
// decides whether anything changed.
|
||||
ListSemanticVectorDigests(ctx context.Context, arg ListSemanticVectorDigestsParams) ([]ListSemanticVectorDigestsRow, error)
|
||||
// Organization-facing anonymous candidate projection inputs. The calling
|
||||
// usecase has already authorized the active organization membership. This
|
||||
// single statement snapshot filters both revoked/unpublished C2 states and
|
||||
// candidates hidden from this organization before any profile value is read.
|
||||
// The projection reads only stack, declared role, and experience dates. It
|
||||
// deliberately excludes names, contacts, salary, location, soft skills,
|
||||
// employer names, summaries, and imported excerpts. The only assessment data
|
||||
// The projection reads only stack, declared role, experience dates, and
|
||||
// projects with the keys of their verified repositories. It deliberately
|
||||
// excludes names, contacts, salary, location, soft skills, employer names,
|
||||
// summaries, and imported excerpts; the repository address of a project stays
|
||||
// in the private input and never reaches the card. The only assessment data
|
||||
// is the current category (specialization and grade) of the separate current
|
||||
// category table; it carries no attempt, score, review, policy, or history.
|
||||
ListVisibleCandidateViewSources(ctx context.Context, organizationID pgtype.UUID) ([]ListVisibleCandidateViewSourcesRow, error)
|
||||
@@ -904,6 +940,10 @@ type Querier interface {
|
||||
LockPublicationForCandidatePreview(ctx context.Context, candidateID pgtype.UUID) (pgtype.UUID, error)
|
||||
// Locks the active registration C1 while its pending registration is applied.
|
||||
LockRegistrationConsentRecord(ctx context.Context, arg LockRegistrationConsentRecordParams) (LockRegistrationConsentRecordRow, error)
|
||||
// Serializes the vector jobs of one subject: a job takes this lock before it
|
||||
// reads the subject, so the job that runs last also read last and its vectors
|
||||
// describe the latest committed state. User requests never take it.
|
||||
LockSemanticSubject(ctx context.Context, lockKey int64) error
|
||||
// Serialize per-owner budget checks even before the first event exists.
|
||||
LockSupportCaseRequestBudget(ctx context.Context, ownerID pgtype.UUID) error
|
||||
// Lock and recheck one candidate's exact current publication only after the
|
||||
@@ -1080,6 +1120,8 @@ type Querier interface {
|
||||
// the job did not cause the failure. The same guard as the completion
|
||||
// applies, one (id, attempt) pair per job. It returns the IDs it released.
|
||||
ReleaseScheduledJobs(ctx context.Context, arg ReleaseScheduledJobsParams) ([]int64, error)
|
||||
// A new repository starts pending; a known one only records the request.
|
||||
RequestCandidateProjectRepositoryCheck(ctx context.Context, arg RequestCandidateProjectRepositoryCheckParams) error
|
||||
// Stores the replay record of a command. A record whose retention has passed
|
||||
// is replaced, so the key is accepted as new after the retention. A live
|
||||
// record is left as it is and nothing is returned; the caller then reads it
|
||||
@@ -1109,6 +1151,7 @@ type Querier interface {
|
||||
// grading policy is read from the immutable opening, and the guard trigger
|
||||
// compares it with the policy captured in the assigned result.
|
||||
SaveCandidateAssessmentCategory(ctx context.Context, arg SaveCandidateAssessmentCategoryParams) (int64, error)
|
||||
SaveCandidateProjectRepositoryCheck(ctx context.Context, arg SaveCandidateProjectRepositoryCheckParams) error
|
||||
SaveCompanyCardViewQuotaUsage(ctx context.Context, arg SaveCompanyCardViewQuotaUsageParams) error
|
||||
SaveInvitationCreationResult(ctx context.Context, arg SaveInvitationCreationResultParams) error
|
||||
// Stores the immutable domain snapshot of a successful create command. The
|
||||
|
||||
@@ -0,0 +1,427 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.31.1
|
||||
// source: semantic.sql
|
||||
|
||||
package sqlc
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/jackc/pgx/v5/pgtype"
|
||||
)
|
||||
|
||||
const deleteSemanticVectorsOfModel = `-- name: DeleteSemanticVectorsOfModel :exec
|
||||
|
||||
DELETE FROM semantic_vectors
|
||||
WHERE
|
||||
subject_kind = $1
|
||||
AND subject_id = $2
|
||||
AND model_id = $3
|
||||
AND model_revision = $4
|
||||
AND prompt_version = $5
|
||||
`
|
||||
|
||||
type DeleteSemanticVectorsOfModelParams struct {
|
||||
SubjectKind string
|
||||
SubjectID pgtype.UUID
|
||||
ModelID string
|
||||
ModelRevision string
|
||||
PromptVersion string
|
||||
}
|
||||
|
||||
// Stored embedding vectors. A candidate keeps one set of rows for a model:
|
||||
// the job deletes every other row of the candidate and model before it
|
||||
// inserts the new set, in one transaction. A need keeps the rows of its
|
||||
// latest computed requirements snapshot the same way.
|
||||
func (q *Queries) DeleteSemanticVectorsOfModel(ctx context.Context, arg DeleteSemanticVectorsOfModelParams) error {
|
||||
_, err := q.db.Exec(ctx, deleteSemanticVectorsOfModel,
|
||||
arg.SubjectKind,
|
||||
arg.SubjectID,
|
||||
arg.ModelID,
|
||||
arg.ModelRevision,
|
||||
arg.PromptVersion,
|
||||
)
|
||||
return err
|
||||
}
|
||||
|
||||
const deleteSemanticVectorsOfSubject = `-- name: DeleteSemanticVectorsOfSubject :exec
|
||||
DELETE FROM semantic_vectors
|
||||
WHERE subject_kind = $1 AND subject_id = $2
|
||||
`
|
||||
|
||||
type DeleteSemanticVectorsOfSubjectParams struct {
|
||||
SubjectKind string
|
||||
SubjectID pgtype.UUID
|
||||
}
|
||||
|
||||
// Removes every vector of a subject, of any model: a closed card or a need
|
||||
// without requirements keeps no derived data.
|
||||
func (q *Queries) DeleteSemanticVectorsOfSubject(ctx context.Context, arg DeleteSemanticVectorsOfSubjectParams) error {
|
||||
_, err := q.db.Exec(ctx, deleteSemanticVectorsOfSubject, arg.SubjectKind, arg.SubjectID)
|
||||
return err
|
||||
}
|
||||
|
||||
const insertSemanticVector = `-- name: InsertSemanticVector :exec
|
||||
INSERT INTO semantic_vectors (
|
||||
subject_kind, subject_id, candidate_id, need_id, model_id, model_revision,
|
||||
prompt_version, item_key, content_sha256, label_sha256, dimension, vector,
|
||||
computed_at
|
||||
) VALUES (
|
||||
$1, $2, $3,
|
||||
$4, $5, $6,
|
||||
$7, $8, $9,
|
||||
$10, $11, $12,
|
||||
$13
|
||||
)
|
||||
`
|
||||
|
||||
type InsertSemanticVectorParams struct {
|
||||
SubjectKind string
|
||||
SubjectID pgtype.UUID
|
||||
CandidateID pgtype.UUID
|
||||
NeedID pgtype.UUID
|
||||
ModelID string
|
||||
ModelRevision string
|
||||
PromptVersion string
|
||||
ItemKey string
|
||||
ContentSha256 []byte
|
||||
LabelSha256 []byte
|
||||
Dimension int32
|
||||
Vector []byte
|
||||
ComputedAt pgtype.Timestamptz
|
||||
}
|
||||
|
||||
func (q *Queries) InsertSemanticVector(ctx context.Context, arg InsertSemanticVectorParams) error {
|
||||
_, err := q.db.Exec(ctx, insertSemanticVector,
|
||||
arg.SubjectKind,
|
||||
arg.SubjectID,
|
||||
arg.CandidateID,
|
||||
arg.NeedID,
|
||||
arg.ModelID,
|
||||
arg.ModelRevision,
|
||||
arg.PromptVersion,
|
||||
arg.ItemKey,
|
||||
arg.ContentSha256,
|
||||
arg.LabelSha256,
|
||||
arg.Dimension,
|
||||
arg.Vector,
|
||||
arg.ComputedAt,
|
||||
)
|
||||
return err
|
||||
}
|
||||
|
||||
const listCandidateItemVectors = `-- name: ListCandidateItemVectors :many
|
||||
SELECT candidate_id, item_key, label_sha256, dimension, vector
|
||||
FROM semantic_vectors
|
||||
WHERE
|
||||
subject_kind = 'candidate'
|
||||
AND item_key <> 'whole'
|
||||
AND model_id = $1
|
||||
AND model_revision = $2
|
||||
AND prompt_version = $3
|
||||
AND candidate_id = ANY($4::uuid [])
|
||||
ORDER BY candidate_id, item_key
|
||||
`
|
||||
|
||||
type ListCandidateItemVectorsParams struct {
|
||||
ModelID string
|
||||
ModelRevision string
|
||||
PromptVersion string
|
||||
CandidateIds []pgtype.UUID
|
||||
}
|
||||
|
||||
type ListCandidateItemVectorsRow struct {
|
||||
CandidateID pgtype.UUID
|
||||
ItemKey string
|
||||
LabelSha256 []byte
|
||||
Dimension int32
|
||||
Vector []byte
|
||||
}
|
||||
|
||||
// The item vectors of the candidates that a search returns, at most a few
|
||||
// dozen candidates.
|
||||
func (q *Queries) ListCandidateItemVectors(ctx context.Context, arg ListCandidateItemVectorsParams) ([]ListCandidateItemVectorsRow, error) {
|
||||
rows, err := q.db.Query(ctx, listCandidateItemVectors,
|
||||
arg.ModelID,
|
||||
arg.ModelRevision,
|
||||
arg.PromptVersion,
|
||||
arg.CandidateIds,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []ListCandidateItemVectorsRow
|
||||
for rows.Next() {
|
||||
var i ListCandidateItemVectorsRow
|
||||
if err := rows.Scan(
|
||||
&i.CandidateID,
|
||||
&i.ItemKey,
|
||||
&i.LabelSha256,
|
||||
&i.Dimension,
|
||||
&i.Vector,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const listCandidateWholeVectors = `-- name: ListCandidateWholeVectors :many
|
||||
SELECT candidate_id, dimension, vector
|
||||
FROM semantic_vectors
|
||||
WHERE
|
||||
subject_kind = 'candidate'
|
||||
AND item_key = 'whole'
|
||||
AND model_id = $1
|
||||
AND model_revision = $2
|
||||
AND prompt_version = $3
|
||||
AND candidate_id = ANY($4::uuid [])
|
||||
ORDER BY candidate_id
|
||||
`
|
||||
|
||||
type ListCandidateWholeVectorsParams struct {
|
||||
ModelID string
|
||||
ModelRevision string
|
||||
PromptVersion string
|
||||
CandidateIds []pgtype.UUID
|
||||
}
|
||||
|
||||
type ListCandidateWholeVectorsRow struct {
|
||||
CandidateID pgtype.UUID
|
||||
Dimension int32
|
||||
Vector []byte
|
||||
}
|
||||
|
||||
// The whole-view vectors of the candidates of one search.
|
||||
func (q *Queries) ListCandidateWholeVectors(ctx context.Context, arg ListCandidateWholeVectorsParams) ([]ListCandidateWholeVectorsRow, error) {
|
||||
rows, err := q.db.Query(ctx, listCandidateWholeVectors,
|
||||
arg.ModelID,
|
||||
arg.ModelRevision,
|
||||
arg.PromptVersion,
|
||||
arg.CandidateIds,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []ListCandidateWholeVectorsRow
|
||||
for rows.Next() {
|
||||
var i ListCandidateWholeVectorsRow
|
||||
if err := rows.Scan(&i.CandidateID, &i.Dimension, &i.Vector); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const listNeedVectors = `-- name: ListNeedVectors :many
|
||||
SELECT item_key, content_sha256, dimension, vector
|
||||
FROM semantic_vectors
|
||||
WHERE
|
||||
subject_kind = 'need'
|
||||
AND need_id = $1
|
||||
AND model_id = $2
|
||||
AND model_revision = $3
|
||||
AND prompt_version = $4
|
||||
AND content_sha256 = ANY($5::bytea [])
|
||||
ORDER BY item_key
|
||||
`
|
||||
|
||||
type ListNeedVectorsParams struct {
|
||||
NeedID pgtype.UUID
|
||||
ModelID string
|
||||
ModelRevision string
|
||||
PromptVersion string
|
||||
ContentDigests [][]byte
|
||||
}
|
||||
|
||||
type ListNeedVectorsRow struct {
|
||||
ItemKey string
|
||||
ContentSha256 []byte
|
||||
Dimension int32
|
||||
Vector []byte
|
||||
}
|
||||
|
||||
// The vectors of a need whose texts match the given digests of the
|
||||
// requirements snapshot that the search renders.
|
||||
func (q *Queries) ListNeedVectors(ctx context.Context, arg ListNeedVectorsParams) ([]ListNeedVectorsRow, error) {
|
||||
rows, err := q.db.Query(ctx, listNeedVectors,
|
||||
arg.NeedID,
|
||||
arg.ModelID,
|
||||
arg.ModelRevision,
|
||||
arg.PromptVersion,
|
||||
arg.ContentDigests,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []ListNeedVectorsRow
|
||||
for rows.Next() {
|
||||
var i ListNeedVectorsRow
|
||||
if err := rows.Scan(
|
||||
&i.ItemKey,
|
||||
&i.ContentSha256,
|
||||
&i.Dimension,
|
||||
&i.Vector,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const listNeedsAfter = `-- name: ListNeedsAfter :many
|
||||
SELECT id, organization_id, requirements_version
|
||||
FROM organization_needs
|
||||
WHERE id > $1
|
||||
ORDER BY id
|
||||
LIMIT $2
|
||||
`
|
||||
|
||||
type ListNeedsAfterParams struct {
|
||||
AfterID pgtype.UUID
|
||||
PageSize int32
|
||||
}
|
||||
|
||||
type ListNeedsAfterRow struct {
|
||||
ID pgtype.UUID
|
||||
OrganizationID pgtype.UUID
|
||||
RequirementsVersion int64
|
||||
}
|
||||
|
||||
// Needs and their current requirements snapshot for the backfill.
|
||||
func (q *Queries) ListNeedsAfter(ctx context.Context, arg ListNeedsAfterParams) ([]ListNeedsAfterRow, error) {
|
||||
rows, err := q.db.Query(ctx, listNeedsAfter, arg.AfterID, arg.PageSize)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []ListNeedsAfterRow
|
||||
for rows.Next() {
|
||||
var i ListNeedsAfterRow
|
||||
if err := rows.Scan(&i.ID, &i.OrganizationID, &i.RequirementsVersion); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const listProfileCandidatesAfter = `-- name: ListProfileCandidatesAfter :many
|
||||
SELECT profiles.user_id
|
||||
FROM candidate_profiles AS profiles
|
||||
WHERE profiles.user_id > $1
|
||||
ORDER BY profiles.user_id
|
||||
LIMIT $2
|
||||
`
|
||||
|
||||
type ListProfileCandidatesAfterParams struct {
|
||||
AfterID pgtype.UUID
|
||||
PageSize int32
|
||||
}
|
||||
|
||||
// Candidates with a saved profile for the backfill, in identifier order
|
||||
// after a cursor. The job of a candidate who is not published removes the
|
||||
// stored vectors, so a backfill also cleans up after a closed card.
|
||||
func (q *Queries) ListProfileCandidatesAfter(ctx context.Context, arg ListProfileCandidatesAfterParams) ([]pgtype.UUID, error) {
|
||||
rows, err := q.db.Query(ctx, listProfileCandidatesAfter, arg.AfterID, arg.PageSize)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []pgtype.UUID
|
||||
for rows.Next() {
|
||||
var user_id pgtype.UUID
|
||||
if err := rows.Scan(&user_id); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, user_id)
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const listSemanticVectorDigests = `-- name: ListSemanticVectorDigests :many
|
||||
SELECT item_key, content_sha256
|
||||
FROM semantic_vectors
|
||||
WHERE
|
||||
subject_kind = $1
|
||||
AND subject_id = $2
|
||||
AND model_id = $3
|
||||
AND model_revision = $4
|
||||
AND prompt_version = $5
|
||||
ORDER BY item_key, content_sha256
|
||||
`
|
||||
|
||||
type ListSemanticVectorDigestsParams struct {
|
||||
SubjectKind string
|
||||
SubjectID pgtype.UUID
|
||||
ModelID string
|
||||
ModelRevision string
|
||||
PromptVersion string
|
||||
}
|
||||
|
||||
type ListSemanticVectorDigestsRow struct {
|
||||
ItemKey string
|
||||
ContentSha256 []byte
|
||||
}
|
||||
|
||||
// The digests of the stored rows of a subject and model, for the job that
|
||||
// decides whether anything changed.
|
||||
func (q *Queries) ListSemanticVectorDigests(ctx context.Context, arg ListSemanticVectorDigestsParams) ([]ListSemanticVectorDigestsRow, error) {
|
||||
rows, err := q.db.Query(ctx, listSemanticVectorDigests,
|
||||
arg.SubjectKind,
|
||||
arg.SubjectID,
|
||||
arg.ModelID,
|
||||
arg.ModelRevision,
|
||||
arg.PromptVersion,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []ListSemanticVectorDigestsRow
|
||||
for rows.Next() {
|
||||
var i ListSemanticVectorDigestsRow
|
||||
if err := rows.Scan(&i.ItemKey, &i.ContentSha256); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const lockSemanticSubject = `-- name: LockSemanticSubject :exec
|
||||
SELECT pg_advisory_xact_lock($1::bigint)
|
||||
`
|
||||
|
||||
// Serializes the vector jobs of one subject: a job takes this lock before it
|
||||
// reads the subject, so the job that runs last also read last and its vectors
|
||||
// describe the latest committed state. User requests never take it.
|
||||
func (q *Queries) LockSemanticSubject(ctx context.Context, lockKey int64) error {
|
||||
_, err := q.db.Exec(ctx, lockSemanticSubject, lockKey)
|
||||
return err
|
||||
}
|
||||
Reference in new issue
Block a user