// Code generated by sqlc. DO NOT EDIT. // versions: // sqlc v1.31.1 package dbgen import ( "context" "github.com/google/uuid" ) type Querier interface { AddCandidateCertification(ctx context.Context, arg AddCandidateCertificationParams) error AddCandidateCustomerExperience(ctx context.Context, arg AddCandidateCustomerExperienceParams) error AddCandidateSkill(ctx context.Context, arg AddCandidateSkillParams) error AddRequiredCertification(ctx context.Context, arg AddRequiredCertificationParams) error AddRequiredSkill(ctx context.Context, arg AddRequiredSkillParams) error AddSlateMember(ctx context.Context, arg AddSlateMemberParams) (SlateMember, error) // Right to erasure as anonymize in place: wipe the identifying PII while KEEPING the row so the de // identified scored outcomes (slate_members) and the demographic bucket survive for the adverse impact // record. Once the name, email, contact, and resume vector are gone the row is no longer personal data, // so erasure is satisfied and the compliance history is preserved. Idempotent on anonymized_at. AnonymizeCandidate(ctx context.Context, id uuid.UUID) (int64, error) // The first of two human steps. Set status to approved and record the approver and approved_at, but ONLY when // the proposal is still pending, so a double submit or a concurrent approval cannot move an already decided // proposal. Returns the row only on a real transition; zero rows means it was not pending. Migrator pool. ApproveProposalTx(ctx context.Context, arg ApproveProposalTxParams) (CurationProposal, error) AwardsSyncMeta(ctx context.Context) (AwardsSyncMetaRow, error) // A tiny RLS scoped probe: how many candidate_mission_tags rows exist for the caller's tenant. The WS7 // retrieval branch uses it to decide between the structured tagged query (when the tenant has been backfilled // by the tagging pass) and the WS6 text filter fallback (when it has not), so a not yet tagged tenant keeps // exact WS6 behavior. RLS scopes the count to the caller's org, so it never observes another tenant's tags. CountCandidateMissionTags(ctx context.Context) (int64, error) CreateCandidate(ctx context.Context, arg CreateCandidateParams) (Candidate, error) CreateOpportunity(ctx context.Context, arg CreateOpportunityParams) (Opportunity, error) // W3 AI Staffing Recommendations queries. Reads are RLS scoped by the app.current_org_id policy, so a // bare SELECT only ever sees the caller's org; writes pass organization_id explicitly and the RLS WITH // CHECK validates it matches the session org. No query here names the eeo schema, and none can: the // generated code is built only from public schema queries. CreateRecommendationRun(ctx context.Context, arg CreateRecommendationRunParams) (RecommendationRun, error) CreateRequirement(ctx context.Context, arg CreateRequirementParams) (Requirement, error) CreateSlate(ctx context.Context, arg CreateSlateParams) (Slate, error) CreateStaffingRecommendation(ctx context.Context, arg CreateStaffingRecommendationParams) (StaffingRecommendation, error) CreateUser(ctx context.Context, arg CreateUserParams) (User, error) DeleteExternalCandidate(ctx context.Context, id uuid.UUID) (int64, error) // Right to erasure: when a candidate is anonymized or sourced-erased, their recommendation rows are // removed (anonymize in place does not delete the candidate row, so this is explicit, mirroring the // ai_memory cleanup). DeleteRecommendationsForCandidate(ctx context.Context, candidateID *uuid.UUID) error // Erasure must also remove slate placements of the sourced person; slate_members has no ON DELETE rule // so the candidate delete would otherwise fail. RLS scopes this to the caller's org. DeleteSlateMembersForCandidate(ctx context.Context, candidateID uuid.UUID) error DetachSourcingLog(ctx context.Context, candidateID *uuid.UUID) error // Identity resolution blocking key 1: an exact (case insensitive) email match in the same org. Email is // the strongest identity signal, so a sourced lead with a known email merges into the existing person. FindCandidateByEmail(ctx context.Context, arg FindCandidateByEmailParams) (uuid.UUID, error) // Identity resolution blocking key 2: same normalized full name AND same normalized location in the org. // Name alone is too weak (two John Smiths); name plus location is a defensible second signal. The caller // only invokes this with a non empty location. FindCandidateByNameLocation(ctx context.Context, arg FindCandidateByNameLocationParams) (uuid.UUID, error) // Idempotency guard for the proposal generator: returns the existing proposal for a (from_skill_id, // to_skill_id, relation) triple that is still pending or already approved, so the generator never creates a // duplicate suggestion for a pair a human is already deciding or has already decided. A rejected proposal is // intentionally NOT matched here, so a human who rejected a pair can see it proposed again if the evidence // recurs (the human stays in control either way). Migrator pool, the global table. GetActiveProposalForPair(ctx context.Context, arg GetActiveProposalForPairParams) (GetActiveProposalForPairRow, error) GetCandidate(ctx context.Context, id uuid.UUID) (Candidate, error) GetCandidateEvaluation(ctx context.Context, arg GetCandidateEvaluationParams) (CandidateEvaluation, error) // The hard spend gate read. It returns the most recent ledger row for one (model_version, tenant_id) budget // key, which carries the running accumulated RDP after every release composed so far. The gate adds the // candidate release's per order RDP to this accumulation, reconverts to epsilon at the configured delta, and // refuses the release (writing nothing) if it would exceed the budget. coalesce maps a NULL tenant_id (the // cross tenant cohort) onto the fixed nil uuid so the cross tenant releases share one budget key space, the // same convention the aggregates table uses. Ordered released_at then id descending so the newest composed // accumulation is row one; zero rows means this is the first release on a fresh budget. dp_budget_ledger is a // global migrator owned table the app role can only SELECT, so this read runs through the migrator pool. GetLatestDpBudgetLedger(ctx context.Context, arg GetLatestDpBudgetLedgerParams) (DpBudgetLedger, error) GetOpportunity(ctx context.Context, id uuid.UUID) (Opportunity, error) GetOpportunityRecord(ctx context.Context, id uuid.UUID) (OpportunityRecord, error) GetOrganization(ctx context.Context, id uuid.UUID) (Organization, error) // Read one proposal by id for the approve and verify handlers. Migrator pool, the global table. GetProposal(ctx context.Context, id uuid.UUID) (CurationProposal, error) GetRequirement(ctx context.Context, id uuid.UUID) (Requirement, error) // One requirement with its backing opportunity value, provenance, and status, for the gap view. The // service uses deleted_at and the opportunity status to 404 a requirement that is not a real open gap. GetRequirementWithValue(ctx context.Context, id uuid.UUID) (GetRequirementWithValueRow, error) GetSamOpportunity(ctx context.Context, noticeID string) (SamOpportunity, error) GetSkillByName(ctx context.Context, name string) (Skill, error) GetSlate(ctx context.Context, id uuid.UUID) (Slate, error) // PK tiebreaker => total order [review SQLC-5] // The frozen decision record for one member: the full per component trace, rationale, and gap summary // for the audit and candidate facing explanation. GetSlateMember(ctx context.Context, arg GetSlateMemberParams) (SlateMember, error) // Locks the row for the decision path so two concurrent decisions on the same recommendation serialize; // the service checks existence (else 404) and status (else 409) under this lock before deciding. GetStaffingRecommendationForUpdate(ctx context.Context, id uuid.UUID) (StaffingRecommendation, error) GetUser(ctx context.Context, id uuid.UUID) (User, error) GetUserByEmail(ctx context.Context, lower string) (User, error) // audit_logs is append-only (enforced by trigger); only INSERT/SELECT are granted. InsertAuditLog(ctx context.Context, arg InsertAuditLogParams) (InsertAuditLogRow, error) // Bench import compliance log. The import command (cmd/import-bench) writes one row per committed // record with the operator provided legal basis. Tenant scoped under RLS (an org sees only its own). InsertBenchImportLog(ctx context.Context, arg InsertBenchImportLogParams) error InsertCandidateNotice(ctx context.Context, arg InsertCandidateNoticeParams) (AedtCandidateNotice, error) // Create a pending curation proposal. Never auto applied and never auto rejected: status defaults to pending, // approver and approved_at stay NULL until a human acts. Migrator pool only, because curation_proposals is a // global migrator owned table the app role can only SELECT. InsertCurationProposal(ctx context.Context, arg InsertCurationProposalParams) (CurationProposal, error) // Record one differential privacy release in the append only budget ledger. The gate inserts this ONLY after // it has confirmed the release stays within budget, so a persisted row is by construction an in budget, // already audited release. rdp_orders is the jsonb map of Renyi order to the per order accumulated RDP at // this release; accumulated_rdp is the running RDP over the worst case (max over the grid converted) used for // the human readable summary; epsilon_at_delta is the converted epsilon (the min over orders) at the target // delta; delta is that target; contributing_tenant_count is the number of live non test distinct // organizations in the cohort, sourced from the production flag, never a literal. The spent epsilon columns // are numeric so the audit record is bit stable while the grid math ran in float64. dp_budget_ledger is a // global migrator owned table the app role can only SELECT, so this write runs through the migrator pool. InsertDpBudgetLedger(ctx context.Context, arg InsertDpBudgetLedgerParams) (DpBudgetLedger, error) InsertSourcingLog(ctx context.Context, arg InsertSourcingLogParams) error // Identity resolution merge: link a sourced lead to an existing candidate. Sets the external id and // backfills headline and years ONLY where the existing row is empty or lower, never clobbering curated // bench data. Source is intentionally left unchanged so a verified bench person stays a bench person. LinkSourcedCandidate(ctx context.Context, arg LinkSourcedCandidateParams) error ListAedtInventory(ctx context.Context) ([]AedtInventory, error) // Every organization id, ordered by id for a byte stable backfill iteration. Read by the BYPASSRLS // migrator role in the tag-missions backfill ONLY to enumerate which tenant contexts to run; the tag // writes themselves run as the application role inside each org's RunInTenantTx, never the migrator bypass. ListAllOrganizationIDs(ctx context.Context) ([]uuid.UUID, error) // audit_logs has NO RLS policy by design. Bind the read to the validated session GUC (NOT a // caller supplied org param) so it inherits the same fail closed default deny as every RLS table, // a missing or wrong org can no longer leak another tenant's trail. Run inside RunInTenantTx so the GUC // is set [review AUDIT-2/RLS-3]. ListAuditLogsForOrg(ctx context.Context, arg ListAuditLogsForOrgParams) ([]AuditLog, error) // Incumbents and similar awards for a NAICS, largest first (excludes Galapagos own awards). ListAwardsByNaics(ctx context.Context, arg ListAwardsByNaicsParams) ([]UsaspendingAward, error) // Minimal projection of the global usaspending_awards catalog for the missionclass sync pass: the // generated_internal_id (the record_id the tag and incumbent role tables key on), plus the description, // naics_description, and naics_code the classifier reads. Ordered by generated_internal_id for byte // stable iteration. ListAwardsForClassify(ctx context.Context) ([]ListAwardsForClassifyRow, error) ListBlsWages(ctx context.Context) ([]BlsWage, error) ListCandidateCertifications(ctx context.Context, candidateID uuid.UUID) ([]string, error) ListCandidateCustomerExperience(ctx context.Context, candidateID uuid.UUID) ([]string, error) ListCandidateSkills(ctx context.Context, candidateID uuid.UUID) ([]ListCandidateSkillsRow, error) // id is a unique trailing sort key so created_at ties give a total order and stable LIMIT/OFFSET paging. ListCandidates(ctx context.Context, arg ListCandidatesParams) ([]Candidate, error) // Tenant candidates tagged with a given mission code, RLS scoped to the caller's org through the join on // candidate_mission_tags. id is the trailing unique sort key so created_at ties give a total order and // stable LIMIT paging, the AEDT reproducibility mandate. ListCandidatesByMission(ctx context.Context, arg ListCandidatesByMissionParams) ([]Candidate, error) // Available (staffable) candidates first, most recently updated next, so the workforce intelligence // surface leads with the talent you can deploy and newly staffed or sourced people are always scored. // The trailing id makes the order total, so the same set is selected before the LIMIT cut every run. ListCandidatesForIntel(ctx context.Context, limit int32) ([]Candidate, error) // Tenant projection the Phase 5a tagging service classifies: each live candidate id, its headline, and the // candidate's skill names joined by single spaces into one text blob. RLS scopes the read to the caller's // org through the candidates row, and the LEFT JOIN keeps a candidate with no skills (the headline still // classifies). headline is coerced to empty text so a NULL never aborts the aggregation. Ordered by id so // the pass iterates byte stably and a re run is reproducible, the AEDT mandate. ListCandidatesForMissionTagging(ctx context.Context) ([]ListCandidatesForMissionTaggingRow, error) // A candidate is committed to a requirement when they are an approved slate member (the source of truth) // or have an approved W3 ASSIGN that has not yet flowed to a slate (provisional commitment). The gap view // reads this so a committed candidate is classified REASSIGN, never a duplicate ASSIGN. ListCommitments(ctx context.Context) ([]ListCommitmentsRow, error) // The persisted screenMATCH qualifications for one requirement, joined to the candidate name and // availability, best first. missionMATCH "who can support this mission today" reads this STORED // artifact rather than rescore the pool. Both tables are RLS scoped, so the join cannot cross tenants. ListEvaluationsForRequirement(ctx context.Context, requirementID uuid.UUID) ([]ListEvaluationsForRequirementRow, error) // id is the unique trailing sort key so created_at ties leave a total order and the LIMIT cut is stable. ListExternalCandidates(ctx context.Context, limit int32) ([]ListExternalCandidatesRow, error) // Galapagos own past performance, largest first. ListGalapagosAwards(ctx context.Context, lim int32) ([]UsaspendingAward, error) // Incumbent labor mix mined from award text, joined to its parent USASpending award so each role carries // the award identity (recipient_name, pop_end_date) and its evidence phrase, the traceability the WS7 // acceptance criterion requires. The recompete signal is pop_end_date: awards whose period of performance // is ending are the recompete relevant ones, so rows are ordered by pop_end_date soonest first, then by // the award generated_internal_id and the labor_category as trailing unique tiebreakers for byte stable // output, the AEDT reproducibility mandate. Awards with no pop_end_date sort last. Global reference data, // app SELECT only. The optional pop_end_before bound (NULL means no bound) lets the caller scope to a // recompete window without changing the default which returns the soonest ending awards first. ListIncumbentRolesByRecompete(ctx context.Context, arg ListIncumbentRolesByRecompeteParams) ([]ListIncumbentRolesByRecompeteRow, error) // All mission tags for one global record, ordered by mission code with the record id as a trailing unique // tiebreaker so the output is byte stable for fixed inputs, the AEDT reproducibility mandate. ListMissionTagsForRecord(ctx context.Context, arg ListMissionTagsForRecordParams) ([]FederalMissionTag, error) // AEDT governance: model version registry, the org AEDT inventory, candidate notices, and the // retention sweep. All on the app pool under RLS (the eeo schema is reached only by the compliance // pool, never here). ListModelVersions(ctx context.Context) ([]AedtModelVersion, error) // Only requirements whose opportunity is open, plus standalone requirements (NULL opportunity_id), // mirroring the Command Center predicate (o.id IS NULL OR o.status='open'). The LEFT JOIN selects r.* // so the row type stays Requirement. Used by the Opportunity Fit Engine, which scores only OPEN ones. ListOpenRequirements(ctx context.Context, arg ListOpenRequirementsParams) ([]Requirement, error) // Open requirements with their backing opportunity dollar value and its provenance, for the portfolio // value function. A standalone requirement (no opportunity) has a null value and is handled by the // documented value fallback in the optimizer. ListOpenRequirementsWithValue(ctx context.Context, arg ListOpenRequirementsWithValueParams) ([]ListOpenRequirementsWithValueRow, error) ListOpportunities(ctx context.Context, arg ListOpportunitiesParams) ([]Opportunity, error) // Optional filters (NULL array = no filter). Soonest closing first, then most recently posted, then id // as a unique tiebreaker so the order is deterministic. Text equality filters compare upper() on both // sides; the service upper cases the params so casing drift cannot silently zero out results. The // optional missions filter keeps a record only when a federal_mission_tag links it to one of the named // mission codes; a NULL missions array means no mission filter, so the default path is unchanged. ListOpportunityRecords(ctx context.Context, arg ListOpportunityRecordsParams) ([]OpportunityRecord, error) // Minimal projection of the global opportunity_records catalog for the missionclass sync pass: the id // carried as text (the record_id federal_mission_tags keys on), plus the title, psc, and naics the // deterministic classifier reads. Ordered by id so the pass iterates byte stably and a re run is // reproducible, the AEDT mandate. Migrator role reads the global catalog directly. ListOpportunityRecordsForClassify(ctx context.Context) ([]ListOpportunityRecordsForClassifyRow, error) // The /compliance surface of proposals awaiting the first human step. Migrator pool, the global table, gated // behind the compliance or operator role at the handler. Ordered oldest first so the queue is a stable list. ListPendingProposals(ctx context.Context) ([]CurationProposal, error) // The current bench watch: pending recommendations from proactive runs, capped and paginated. ListProactiveRecommendations(ctx context.Context, arg ListProactiveRecommendationsParams) ([]StaffingRecommendation, error) ListRequiredCertifications(ctx context.Context, requirementID uuid.UUID) ([]string, error) ListRequiredSkills(ctx context.Context, requirementID uuid.UUID) ([]ListRequiredSkillsRow, error) // id is a unique trailing sort key so the order is total: ties on created_at no longer leave the // LIMIT/OFFSET cut and the downstream Best Fit pick nondeterministic. ListRequirements(ctx context.Context, arg ListRequirementsParams) ([]Requirement, error) // Tenant projection the Phase 5a tagging service classifies for requirements: each live requirement id, its // title, its labor_category (coerced to empty when NULL), and the required skill names joined by single // spaces. RLS scopes the read to the caller's org; the LEFT JOIN keeps a requirement with no required // skills (the title and labor category still classify). Ordered by id for byte stable, reproducible // iteration, the AEDT mandate. ListRequirementsForMissionTagging(ctx context.Context) ([]ListRequirementsForMissionTaggingRow, error) ListRequirementsForOpportunity(ctx context.Context, opportunityID *uuid.UUID) ([]Requirement, error) // Minimal projection of the cached sam_opportunities catalog for the missionclass sync pass: the // notice_id (the record_id award_incumbent_roles keys on for a SAM notice), plus the description_url and // the resource_links the attachment fetcher needs to mine the incumbent labor mix. Ordered by notice_id // for byte stable iteration. ListSamForClassify(ctx context.Context) ([]ListSamForClassifyRow, error) // All filters are optional (NULL array / NULL scalar = "no filter"). active_only defaults true at the // handler. Soonest-closing first, then most-recently-posted. // Text equality filters are case-insensitive (upper() both sides; the service upper-cases the params) // so casing drift from SAM's path text can't silently zero out results [review COR-3]. The title search // is a literal substring (position()), NOT a LIKE pattern, so q's %/_/\ are matched literally and a // trailing backslash can't 500 the request [review COR-1]. Past-deadline / null-deadline notices sort // to the bottom so the feed leads with what's still open [review COR-2]. ListSamOpportunities(ctx context.Context, arg ListSamOpportunitiesParams) ([]SamOpportunity, error) ListSkills(ctx context.Context, arg ListSkillsParams) ([]Skill, error) // The WS8 in tenant teaching read. It returns ONLY the contents free craft evidence the producer folds // into scrub.TeachingSignal counts: the reviewer decision on each slate member, the stored sub scores that // reveal a clearance gap (clearance_score) or an experience shortfall (experience_score), the frozen gap // summary, and the matched skills evidence (per skill similarity and whether the match was exact or a // semantic substitution) from the candidate's persisted evaluation. It carries NO name, NO email, NO free // text resume, only the decision label, the scores, and the jsonb match evidence the engine itself froze. // // Both slate_members and candidate_evaluations are RLS scoped, and the producer runs this inside // RunInTenantTx on the app pool, so the join is scoped to the caller's org by Postgres Row Level Security // and can never read another tenant's decisions. candidate_evaluations is LEFT joined on the pair // (organization_id, candidate_id, requirement_id): a slate member that was never screened through // screenMATCH has no stored evaluation, so the matched skills evidence is then NULL and the producer folds // only what slate_members alone supports (the clearance and experience patterns), never fabricating a // skill substitution it cannot see. ListSlateDecisionEvidenceForOrg(ctx context.Context) ([]ListSlateDecisionEvidenceForOrgRow, error) ListSlateMembers(ctx context.Context, slateID uuid.UUID) ([]SlateMember, error) // The slate roster joined to the candidate name for the slateMATCH detail and the branded export. Both // tables are RLS scoped to the caller's org, so the join cannot cross tenants. ListSlateMembersWithNames(ctx context.Context, slateID uuid.UUID) ([]ListSlateMembersWithNamesRow, error) ListSlatesForRequirement(ctx context.Context, requirementID uuid.UUID) ([]Slate, error) // id is the unique trailing sort key so collected_at ties leave a total order and the LIMIT cut is stable. ListSourcingLog(ctx context.Context, limit int32) ([]ListSourcingLogRow, error) // Platform/security events with NO org (e.g. failed logins before org resolution). Privileged read // path only, never the per-tenant app path, so these events are not a black hole [review AUDIT-3]. ListSystemAuditLogs(ctx context.Context, arg ListSystemAuditLogsParams) ([]AuditLog, error) // The cross cutting GOVERNANCE CONFIDENCE the proposal generator reads: this tenant's own folded craft counts // for the live in tenant rows (dp_applied false). The generator uses these to confirm a craft pattern is // reliably approved at a band before it ever proposes a curated edge, so the specific recurring pair (read // from the tenant's own evaluations) is only proposed when the contents free aggregate also supports it. // These rows carry NO PII and no candidate id, only the counts. Migrator pool, the global table; the tenant // is passed explicitly because this read is governance confidence, not the RLS scoped evaluation scan. ListTeachingAggregatesForTenant(ctx context.Context, arg ListTeachingAggregatesForTenantParams) ([]TeachingSignalAggregate, error) ListUsers(ctx context.Context, arg ListUsersParams) ([]User, error) // Status guarded: only a pending row can be decided, so a row that was concurrently superseded or // decided returns no row and the service surfaces 409 rather than overwriting a dead or decided row. MarkRecommendationDecision(ctx context.Context, arg MarkRecommendationDecisionParams) (StaffingRecommendation, error) // (phrase, code) pairs that seed the missionclass AliasIndex from real rows. Two unioned sources: every // curated alias whose target skill is a category 'mission_area' skill, and every mission_area skill name // itself. The skill name to code link is mission_areas.spine_term = skills.name, because the mission_area // skills were promoted from the mission_spine terms the mission_areas rows carry. Ordered by phrase then // code for a deterministic build. Global reference data, read by the migrator role. MissionAliasPairs(ctx context.Context) ([]MissionAliasPairsRow, error) OpportunityRecordMeta(ctx context.Context) (OpportunityRecordMetaRow, error) // Band/decision rollup across every slate member under one opportunity's requirements, the source // for GET /proposal-readiness [review COMPL-2]. RLS scopes all three tables to the caller's org. ProposalReadiness(ctx context.Context, opportunityID *uuid.UUID) ([]ProposalReadinessRow, error) // Resolve a skill name to its global skills.id, lower cased and trimmed, so a matched_skills entry that // carries a candidate or required skill NAME but no id can still be turned into the id the proposal and the // staged edge need. The skills table is global reference data the app role may SELECT; the proposal generator // runs this through the same RLS scoped app tx that read the org's evaluations (the read is the only app // pool step, the proposal WRITE goes through the migrator pool). ResolveSkillIDByName(ctx context.Context, btrim string) (uuid.UUID, error) // Candidates whose most recent recorded decision is older than the retention window and whose PII is // not yet anonymized. The de identified slate_members outcomes are retained; only the candidate PII is // wiped (by AnonymizeCandidate). RLS scopes this to the caller's org. RetentionDueCandidates(ctx context.Context, dollar_1 int32) ([]uuid.UUID, error) SamSyncMeta(ctx context.Context) (SamSyncMetaRow, error) // Hybrid retrieval: pgvector cosine kNN fused with full-text rank via Reciprocal Rank Fusion (k=60). // RLS already scopes both legs to the caller's org. $1=query embedding, $2=limit, $3=text query. // The vector arm is MATERIALIZED so the relaxed_order HNSW output is re-sorted by TRUE cosine distance // before it is ranked: under hnsw.iterative_scan = relaxed_order the index returns rows slightly out of // distance order, and ranking them without the re-sort would mis-rank the nearest neighbors at scale // (pgvector 0.8 README; AWS pgvector 0.8 Aurora guidance). Every ORDER BY carries a unique tiebreaker // (id) so results are byte-stable for fixed inputs, the AEDT reproducibility mandate. The caller SETs // LOCAL hnsw.ef_search and hnsw.iterative_scan first. SearchCandidatesHybrid(ctx context.Context, arg SearchCandidatesHybridParams) ([]SearchCandidatesHybridRow, error) // Mission scoped hybrid retrieval (WS6 Option A): identical to SearchCandidatesHybrid, but BOTH arms are // additionally constrained to candidates whose search_tsv matches the mission keyword(s) in mission_query, // so a question can be scoped to a mission area (for example SIGINT) using only candidate text match. The // search_tsv is built from full_name, headline, and location (migration 0002), NOT the resume body. This is // the only mission filter available without structured mission tags: those are WS7 work. It filters on that // TEXT, never on a semantic mission alignment, and that limit is documented in docs/AI_RESEARCH.md. // RLS still scopes both legs to the caller's org; every ORDER BY keeps the unique id tiebreaker so the // output is byte stable for fixed inputs, the AEDT reproducibility mandate. The caller SETs LOCAL // hnsw.ef_search and hnsw.iterative_scan first, exactly as for the unscoped query. SearchCandidatesHybridMission(ctx context.Context, arg SearchCandidatesHybridMissionParams) ([]SearchCandidatesHybridMissionRow, error) // Structured mission scoped hybrid retrieval (WS7 upgrade of the WS6 Option A text filter). It is identical // in shape to SearchCandidatesHybridMission, but the mission constraint on BOTH arms is a STRUCTURED // predicate on candidate_mission_tags (the deterministic classifier output) instead of the search_tsv // mission keyword text match. A candidate is in scope only when a candidate_mission_tags row binds it to the // requested mission_code, so the scope is the real, classified mission of the candidate, not a name or // headline string coincidence. This lifts the WS6 limit (a candidate whose mission is in the resume body but // not in the full_name, headline, or location text is now reachable once the tenant is tagged). The text // query ($text_query) still drives the FTS arm and the embedding arm still drives recall, so only the mission // gate changed. candidate_mission_tags is RLS scoped to the caller's org, so the EXISTS subquery cannot cross // a tenant boundary; the candidates table is RLS scoped too. Every ORDER BY keeps the unique id tiebreaker so // the output is byte stable for fixed inputs, the AEDT reproducibility mandate. The caller SETs LOCAL // hnsw.ef_search and hnsw.iterative_scan first, exactly as for the unscoped and the WS6 text scoped queries. SearchCandidatesHybridMissionTagged(ctx context.Context, arg SearchCandidatesHybridMissionTaggedParams) ([]SearchCandidatesHybridMissionTaggedRow, error) // Cosine nearest-neighbor over the skills ontology (powers semantic skill adjacency). SearchSkillsSemantic(ctx context.Context, arg SearchSkillsSemanticParams) ([]SearchSkillsSemanticRow, error) // An org FSO records HOW a candidate's clearance is known. RLS scopes this to the caller's own org. // verified_at is the date the FSO confirmed it; it is NULL for a self reported indicator. The platform // never verifies a clearance itself, it records the org's authoritative assertion. SetCandidateClearanceProvenance(ctx context.Context, arg SetCandidateClearanceProvenanceParams) (int64, error) // Human-in-the-loop: a person approves/rejects each member, optionally with a note. Never auto-decided. SetSlateMemberDecision(ctx context.Context, arg SetSlateMemberDecisionParams) (SlateMember, error) SoftDeleteCandidate(ctx context.Context, id uuid.UUID) error // Insert the staged, INERT skill_relationships edge that an approval creates. verified_at is left NULL, so the // resolver (which loads only verified_at IS NOT NULL edges) ignores it and no score changes. A SECOND distinct // human action later sets verified_at to activate it. On a conflicting (from, to, relation) that already // exists, do nothing and return the existing row, so an approval is idempotent against a manually seeded edge. // Migrator pool only (skill_relationships is global, the app role has SELECT only). StageSubstitutesForEdge(ctx context.Context, arg StageSubstitutesForEdgeParams) (StageSubstitutesForEdgeRow, error) // A fresh gap run for a requirement supersedes ONLY the prior pending gap rows for that requirement. // Decided rows (approved, rejected, dismissed) are immutable and are never touched. SupersedePendingGap(ctx context.Context, requirementID uuid.UUID) error // A fresh portfolio run supersedes ONLY the prior pending portfolio rows for the org. Decided rows are // immutable. SupersedePendingPortfolio(ctx context.Context) error // A fresh proactive recompute for one candidate supersedes ONLY that candidate's prior pending proactive // rows. Decided rows are immutable. SupersedePendingProactive(ctx context.Context, candidateID *uuid.UUID) error TouchUserLogin(ctx context.Context, id uuid.UUID) error // Writes a precomputed resume embedding onto a candidate, used by the bench import path AFTER the embed // network call has already run in the caller, so the migrator write transaction never holds open across // the inference round trip (the embed lock window rule). The vector is composed from name free structured // tokens only, never raw resume PII. A candidate with a NULL embedding is left embeddable by the // embed-backfill only-missing fallback, so a skipped embed never wedges a row. UpdateCandidateEmbedding(ctx context.Context, arg UpdateCandidateEmbeddingParams) error UpdateSlateStatus(ctx context.Context, arg UpdateSlateStatusParams) (Slate, error) UpsertAedtInventory(ctx context.Context, arg UpsertAedtInventoryParams) (AedtInventory, error) // USASpending awards cache. Global public catalog (no organization_id, outside RLS): reads run off // the pool, writes come from the daily sync (cmd/awards-sync) as the migrator role. UpsertAward(ctx context.Context, arg UpsertAwardParams) error // Idempotent write of an incumbent labor mix row mined from award and solicitation text. ON CONFLICT DO // UPDATE so a re run refreshes the count and evidence for the same record and labor category. UpsertAwardIncumbentRole(ctx context.Context, arg UpsertAwardIncumbentRoleParams) error // BLS OEWS wage baseline cache. Global public catalog (no organization_id, outside RLS): reads run // off the pool, writes come from the weekly rates sync (cmd/rates-sync) as the migrator role. UpsertBlsWage(ctx context.Context, arg UpsertBlsWageParams) error // Upsert the latest screenMATCH qualification for one (candidate, requirement) pair. A fresh screen // overwrites the prior row so there is exactly one current evaluation per pair, which missionMATCH // reads instead of recomputing. evaluated_at is preserved as the first time the pair was screened; // updated_at moves to now() on every rescreen. UpsertCandidateEvaluation(ctx context.Context, arg UpsertCandidateEvaluationParams) error // Idempotent write of a tenant candidate mission tag. RLS scopes the write to the caller's org and the // composite FK guarantees the candidate belongs to that org. ON CONFLICT DO UPDATE keeps the sync pass // repeatable, refreshing the mechanism and evidence for an existing candidate and mission code pair. UpsertCandidateMissionTag(ctx context.Context, arg UpsertCandidateMissionTagParams) error // External candidate sourcing. The import command (cmd/import-candidates) writes as the migrator role // with an explicit organization_id; the delete path runs as the app role inside a tenant tx (RLS). UpsertExternalCandidate(ctx context.Context, arg UpsertExternalCandidateParams) (uuid.UUID, error) // Idempotent write of a global mission tag from the classification sync pass. ON CONFLICT DO UPDATE so a // re run with the same record and mission code refreshes the mechanism, evidence, and confidence rather // than erroring, which keeps the sync pass safely repeatable. Migrator owned, app SELECT only. UpsertFederalMissionTag(ctx context.Context, arg UpsertFederalMissionTagParams) error // Opportunity Intelligence unified records. Global public catalog (no organization_id, outside RLS): // reads run straight off the pool, writes come from cmd/opp-sync as the migrator role. UpsertOpportunityRecord(ctx context.Context, arg UpsertOpportunityRecordParams) error // Idempotent write of a tenant requirement mission tag, same isolation guarantees as the candidate path. UpsertRequirementMissionTag(ctx context.Context, arg UpsertRequirementMissionTagParams) error // SAM.gov opportunities cache. Global public catalog (no organization_id, outside RLS): reads run // straight off the pool, writes come from the daily sync (cmd/sam-sync) as the migrator role. UpsertSamOpportunity(ctx context.Context, arg UpsertSamOpportunityParams) error // COALESCE keeps an existing category or embedding when a caller upserts by name only (for example the // ingest and mission check paths that pass just a skill name), so a later name only upsert never nulls a // category that was set before and an embedding can still be backfilled once it is supplied. UpsertSkill(ctx context.Context, arg UpsertSkillParams) (Skill, error) // Persist one folded per tenant craft aggregate into the global teaching_signal_aggregates table. This is // a GLOBAL migrator owned table (app has SELECT only), so the producer runs this through the migrator pool // seam, never the app role. The unique key is (coalesce(tenant_id, the nil uuid), pattern, band, outcome, // model_version, window_start), so a rerun over the same window for the same tenant refreshes the counts in // place rather than inserting a duplicate, and a forked engine model version lands as a distinct row rather // than silently overwriting a prior version's aggregate. The live in tenant rows always carry tenant_id set // and dp_applied false; the flag on cross tenant path writes tenant_id NULL, dp_applied true rows later. UpsertTeachingSignalAggregate(ctx context.Context, arg UpsertTeachingSignalAggregateParams) error // The second of two human steps. Activate a staged edge by setting verified_at and recording the verifier, // ONLY when it is still unverified, so a double submit cannot re activate or change the verifier of an already // live edge. The resolver reads verified_at IS NOT NULL edges, so this single write is what makes the edge // live across tenants. The engine math is byte identical: only the resolver reference set grew. Migrator pool. VerifyStagedEdge(ctx context.Context, arg VerifyStagedEdgeParams) (VerifyStagedEdgeRow, error) WagesSyncMeta(ctx context.Context) (WagesSyncMetaRow, error) } var _ Querier = (*Queries)(nil)