Recovered source transcript
1// Code generated by sqlc. DO NOT EDIT.
2// versions:
3// sqlc v1.31.1
4
5package dbgen
6
7import (
8 "context"
9
10 "github.com/google/uuid"
11)
12
13type Querier interface {
14 AddCandidateCertification(ctx context.Context, arg AddCandidateCertificationParams) error
15 AddCandidateCustomerExperience(ctx context.Context, arg AddCandidateCustomerExperienceParams) error
16 AddCandidateSkill(ctx context.Context, arg AddCandidateSkillParams) error
17 AddRequiredCertification(ctx context.Context, arg AddRequiredCertificationParams) error
18 AddRequiredSkill(ctx context.Context, arg AddRequiredSkillParams) error
19 AddSlateMember(ctx context.Context, arg AddSlateMemberParams) (SlateMember, error)
20 // Right to erasure as anonymize in place: wipe the identifying PII while KEEPING the row so the de
21 // identified scored outcomes (slate_members) and the demographic bucket survive for the adverse impact
22 // record. Once the name, email, contact, and resume vector are gone the row is no longer personal data,
23 // so erasure is satisfied and the compliance history is preserved. Idempotent on anonymized_at.
24 AnonymizeCandidate(ctx context.Context, id uuid.UUID) (int64, error)
25 // The first of two human steps. Set status to approved and record the approver and approved_at, but ONLY when
26 // the proposal is still pending, so a double submit or a concurrent approval cannot move an already decided
27 // proposal. Returns the row only on a real transition; zero rows means it was not pending. Migrator pool.
28 ApproveProposalTx(ctx context.Context, arg ApproveProposalTxParams) (CurationProposal, error)
29 AwardsSyncMeta(ctx context.Context) (AwardsSyncMetaRow, error)
30 // A tiny RLS scoped probe: how many candidate_mission_tags rows exist for the caller's tenant. The WS7
31 // retrieval branch uses it to decide between the structured tagged query (when the tenant has been backfilled
32 // by the tagging pass) and the WS6 text filter fallback (when it has not), so a not yet tagged tenant keeps
33 // exact WS6 behavior. RLS scopes the count to the caller's org, so it never observes another tenant's tags.
34 CountCandidateMissionTags(ctx context.Context) (int64, error)
35 CreateCandidate(ctx context.Context, arg CreateCandidateParams) (Candidate, error)
36 CreateOpportunity(ctx context.Context, arg CreateOpportunityParams) (Opportunity, error)
37 // W3 AI Staffing Recommendations queries. Reads are RLS scoped by the app.current_org_id policy, so a
38 // bare SELECT only ever sees the caller's org; writes pass organization_id explicitly and the RLS WITH
39 // CHECK validates it matches the session org. No query here names the eeo schema, and none can: the
40 // generated code is built only from public schema queries.
41 CreateRecommendationRun(ctx context.Context, arg CreateRecommendationRunParams) (RecommendationRun, error)
42 CreateRequirement(ctx context.Context, arg CreateRequirementParams) (Requirement, error)
43 CreateSlate(ctx context.Context, arg CreateSlateParams) (Slate, error)
44 CreateStaffingRecommendation(ctx context.Context, arg CreateStaffingRecommendationParams) (StaffingRecommendation, error)
45 CreateUser(ctx context.Context, arg CreateUserParams) (User, error)
46 DeleteExternalCandidate(ctx context.Context, id uuid.UUID) (int64, error)
47 // Right to erasure: when a candidate is anonymized or sourced-erased, their recommendation rows are
48 // removed (anonymize in place does not delete the candidate row, so this is explicit, mirroring the
49 // ai_memory cleanup).
50 DeleteRecommendationsForCandidate(ctx context.Context, candidateID *uuid.UUID) error
51 // Erasure must also remove slate placements of the sourced person; slate_members has no ON DELETE rule
52 // so the candidate delete would otherwise fail. RLS scopes this to the caller's org.
53 DeleteSlateMembersForCandidate(ctx context.Context, candidateID uuid.UUID) error
54 DetachSourcingLog(ctx context.Context, candidateID *uuid.UUID) error
55 // Identity resolution blocking key 1: an exact (case insensitive) email match in the same org. Email is
56 // the strongest identity signal, so a sourced lead with a known email merges into the existing person.
57 FindCandidateByEmail(ctx context.Context, arg FindCandidateByEmailParams) (uuid.UUID, error)
58 // Identity resolution blocking key 2: same normalized full name AND same normalized location in the org.
59 // Name alone is too weak (two John Smiths); name plus location is a defensible second signal. The caller
60 // only invokes this with a non empty location.
61 FindCandidateByNameLocation(ctx context.Context, arg FindCandidateByNameLocationParams) (uuid.UUID, error)
62 // Idempotency guard for the proposal generator: returns the existing proposal for a (from_skill_id,
63 // to_skill_id, relation) triple that is still pending or already approved, so the generator never creates a
64 // duplicate suggestion for a pair a human is already deciding or has already decided. A rejected proposal is
65 // intentionally NOT matched here, so a human who rejected a pair can see it proposed again if the evidence
66 // recurs (the human stays in control either way). Migrator pool, the global table.
67 GetActiveProposalForPair(ctx context.Context, arg GetActiveProposalForPairParams) (GetActiveProposalForPairRow, error)
68 GetCandidate(ctx context.Context, id uuid.UUID) (Candidate, error)
69 GetCandidateEvaluation(ctx context.Context, arg GetCandidateEvaluationParams) (CandidateEvaluation, error)
70 // The hard spend gate read. It returns the most recent ledger row for one (model_version, tenant_id) budget
71 // key, which carries the running accumulated RDP after every release composed so far. The gate adds the
72 // candidate release's per order RDP to this accumulation, reconverts to epsilon at the configured delta, and
73 // refuses the release (writing nothing) if it would exceed the budget. coalesce maps a NULL tenant_id (the
74 // cross tenant cohort) onto the fixed nil uuid so the cross tenant releases share one budget key space, the
75 // same convention the aggregates table uses. Ordered released_at then id descending so the newest composed
76 // accumulation is row one; zero rows means this is the first release on a fresh budget. dp_budget_ledger is a
77 // global migrator owned table the app role can only SELECT, so this read runs through the migrator pool.
78 GetLatestDpBudgetLedger(ctx context.Context, arg GetLatestDpBudgetLedgerParams) (DpBudgetLedger, error)
79 GetOpportunity(ctx context.Context, id uuid.UUID) (Opportunity, error)
80 GetOpportunityRecord(ctx context.Context, id uuid.UUID) (OpportunityRecord, error)
81 GetOrganization(ctx context.Context, id uuid.UUID) (Organization, error)
82 // Read one proposal by id for the approve and verify handlers. Migrator pool, the global table.
83 GetProposal(ctx context.Context, id uuid.UUID) (CurationProposal, error)
84 GetRequirement(ctx context.Context, id uuid.UUID) (Requirement, error)
85 // One requirement with its backing opportunity value, provenance, and status, for the gap view. The
86 // service uses deleted_at and the opportunity status to 404 a requirement that is not a real open gap.
87 GetRequirementWithValue(ctx context.Context, id uuid.UUID) (GetRequirementWithValueRow, error)
88 GetSamOpportunity(ctx context.Context, noticeID string) (SamOpportunity, error)
89 GetSkillByName(ctx context.Context, name string) (Skill, error)
90 GetSlate(ctx context.Context, id uuid.UUID) (Slate, error)
91 // PK tiebreaker => total order [review SQLC-5]
92 // The frozen decision record for one member: the full per component trace, rationale, and gap summary
93 // for the audit and candidate facing explanation.
94 GetSlateMember(ctx context.Context, arg GetSlateMemberParams) (SlateMember, error)
95 // Locks the row for the decision path so two concurrent decisions on the same recommendation serialize;
96 // the service checks existence (else 404) and status (else 409) under this lock before deciding.
97 GetStaffingRecommendationForUpdate(ctx context.Context, id uuid.UUID) (StaffingRecommendation, error)
98 GetUser(ctx context.Context, id uuid.UUID) (User, error)
99 GetUserByEmail(ctx context.Context, lower string) (User, error)
100 // audit_logs is append-only (enforced by trigger); only INSERT/SELECT are granted.
101 InsertAuditLog(ctx context.Context, arg InsertAuditLogParams) (InsertAuditLogRow, error)
102 // Bench import compliance log. The import command (cmd/import-bench) writes one row per committed
103 // record with the operator provided legal basis. Tenant scoped under RLS (an org sees only its own).
104 InsertBenchImportLog(ctx context.Context, arg InsertBenchImportLogParams) error
105 InsertCandidateNotice(ctx context.Context, arg InsertCandidateNoticeParams) (AedtCandidateNotice, error)
106 // Create a pending curation proposal. Never auto applied and never auto rejected: status defaults to pending,
107 // approver and approved_at stay NULL until a human acts. Migrator pool only, because curation_proposals is a
108 // global migrator owned table the app role can only SELECT.
109 InsertCurationProposal(ctx context.Context, arg InsertCurationProposalParams) (CurationProposal, error)
110 // Record one differential privacy release in the append only budget ledger. The gate inserts this ONLY after
111 // it has confirmed the release stays within budget, so a persisted row is by construction an in budget,
112 // already audited release. rdp_orders is the jsonb map of Renyi order to the per order accumulated RDP at
113 // this release; accumulated_rdp is the running RDP over the worst case (max over the grid converted) used for
114 // the human readable summary; epsilon_at_delta is the converted epsilon (the min over orders) at the target
115 // delta; delta is that target; contributing_tenant_count is the number of live non test distinct
116 // organizations in the cohort, sourced from the production flag, never a literal. The spent epsilon columns
117 // are numeric so the audit record is bit stable while the grid math ran in float64. dp_budget_ledger is a
118 // global migrator owned table the app role can only SELECT, so this write runs through the migrator pool.
119 InsertDpBudgetLedger(ctx context.Context, arg InsertDpBudgetLedgerParams) (DpBudgetLedger, error)
120 InsertSourcingLog(ctx context.Context, arg InsertSourcingLogParams) error
121 // Identity resolution merge: link a sourced lead to an existing candidate. Sets the external id and
122 // backfills headline and years ONLY where the existing row is empty or lower, never clobbering curated
123 // bench data. Source is intentionally left unchanged so a verified bench person stays a bench person.
124 LinkSourcedCandidate(ctx context.Context, arg LinkSourcedCandidateParams) error
125 ListAedtInventory(ctx context.Context) ([]AedtInventory, error)
126 // Every organization id, ordered by id for a byte stable backfill iteration. Read by the BYPASSRLS
127 // migrator role in the tag-missions backfill ONLY to enumerate which tenant contexts to run; the tag
128 // writes themselves run as the application role inside each org's RunInTenantTx, never the migrator bypass.
129 ListAllOrganizationIDs(ctx context.Context) ([]uuid.UUID, error)
130 // audit_logs has NO RLS policy by design. Bind the read to the validated session GUC (NOT a
131 // caller supplied org param) so it inherits the same fail closed default deny as every RLS table,
132 // a missing or wrong org can no longer leak another tenant's trail. Run inside RunInTenantTx so the GUC
133 // is set [review AUDIT-2/RLS-3].
134 ListAuditLogsForOrg(ctx context.Context, arg ListAuditLogsForOrgParams) ([]AuditLog, error)
135 // Incumbents and similar awards for a NAICS, largest first (excludes Galapagos own awards).
136 ListAwardsByNaics(ctx context.Context, arg ListAwardsByNaicsParams) ([]UsaspendingAward, error)
137 // Minimal projection of the global usaspending_awards catalog for the missionclass sync pass: the
138 // generated_internal_id (the record_id the tag and incumbent role tables key on), plus the description,
139 // naics_description, and naics_code the classifier reads. Ordered by generated_internal_id for byte
140 // stable iteration.
141 ListAwardsForClassify(ctx context.Context) ([]ListAwardsForClassifyRow, error)
142 ListBlsWages(ctx context.Context) ([]BlsWage, error)
143 ListCandidateCertifications(ctx context.Context, candidateID uuid.UUID) ([]string, error)
144 ListCandidateCustomerExperience(ctx context.Context, candidateID uuid.UUID) ([]string, error)
145 ListCandidateSkills(ctx context.Context, candidateID uuid.UUID) ([]ListCandidateSkillsRow, error)
146 // id is a unique trailing sort key so created_at ties give a total order and stable LIMIT/OFFSET paging.
147 ListCandidates(ctx context.Context, arg ListCandidatesParams) ([]Candidate, error)
148 // Tenant candidates tagged with a given mission code, RLS scoped to the caller's org through the join on
149 // candidate_mission_tags. id is the trailing unique sort key so created_at ties give a total order and
150 // stable LIMIT paging, the AEDT reproducibility mandate.
151 ListCandidatesByMission(ctx context.Context, arg ListCandidatesByMissionParams) ([]Candidate, error)
152 // Available (staffable) candidates first, most recently updated next, so the workforce intelligence
153 // surface leads with the talent you can deploy and newly staffed or sourced people are always scored.
154 // The trailing id makes the order total, so the same set is selected before the LIMIT cut every run.
155 ListCandidatesForIntel(ctx context.Context, limit int32) ([]Candidate, error)
156 // Tenant projection the Phase 5a tagging service classifies: each live candidate id, its headline, and the
157 // candidate's skill names joined by single spaces into one text blob. RLS scopes the read to the caller's
158 // org through the candidates row, and the LEFT JOIN keeps a candidate with no skills (the headline still
159 // classifies). headline is coerced to empty text so a NULL never aborts the aggregation. Ordered by id so
160 // the pass iterates byte stably and a re run is reproducible, the AEDT mandate.
161 ListCandidatesForMissionTagging(ctx context.Context) ([]ListCandidatesForMissionTaggingRow, error)
162 // A candidate is committed to a requirement when they are an approved slate member (the source of truth)
163 // or have an approved W3 ASSIGN that has not yet flowed to a slate (provisional commitment). The gap view
164 // reads this so a committed candidate is classified REASSIGN, never a duplicate ASSIGN.
165 ListCommitments(ctx context.Context) ([]ListCommitmentsRow, error)
166 // The persisted screenMATCH qualifications for one requirement, joined to the candidate name and
167 // availability, best first. missionMATCH "who can support this mission today" reads this STORED
168 // artifact rather than rescore the pool. Both tables are RLS scoped, so the join cannot cross tenants.
169 ListEvaluationsForRequirement(ctx context.Context, requirementID uuid.UUID) ([]ListEvaluationsForRequirementRow, error)
170 // id is the unique trailing sort key so created_at ties leave a total order and the LIMIT cut is stable.
171 ListExternalCandidates(ctx context.Context, limit int32) ([]ListExternalCandidatesRow, error)
172 // Galapagos own past performance, largest first.
173 ListGalapagosAwards(ctx context.Context, lim int32) ([]UsaspendingAward, error)
174 // Incumbent labor mix mined from award text, joined to its parent USASpending award so each role carries
175 // the award identity (recipient_name, pop_end_date) and its evidence phrase, the traceability the WS7
176 // acceptance criterion requires. The recompete signal is pop_end_date: awards whose period of performance
177 // is ending are the recompete relevant ones, so rows are ordered by pop_end_date soonest first, then by
178 // the award generated_internal_id and the labor_category as trailing unique tiebreakers for byte stable
179 // output, the AEDT reproducibility mandate. Awards with no pop_end_date sort last. Global reference data,
180 // app SELECT only. The optional pop_end_before bound (NULL means no bound) lets the caller scope to a
181 // recompete window without changing the default which returns the soonest ending awards first.
182 ListIncumbentRolesByRecompete(ctx context.Context, arg ListIncumbentRolesByRecompeteParams) ([]ListIncumbentRolesByRecompeteRow, error)
183 // All mission tags for one global record, ordered by mission code with the record id as a trailing unique
184 // tiebreaker so the output is byte stable for fixed inputs, the AEDT reproducibility mandate.
185 ListMissionTagsForRecord(ctx context.Context, arg ListMissionTagsForRecordParams) ([]FederalMissionTag, error)
186 // AEDT governance: model version registry, the org AEDT inventory, candidate notices, and the
187 // retention sweep. All on the app pool under RLS (the eeo schema is reached only by the compliance
188 // pool, never here).
189 ListModelVersions(ctx context.Context) ([]AedtModelVersion, error)
190 // Only requirements whose opportunity is open, plus standalone requirements (NULL opportunity_id),
191 // mirroring the Command Center predicate (o.id IS NULL OR o.status='open'). The LEFT JOIN selects r.*
192 // so the row type stays Requirement. Used by the Opportunity Fit Engine, which scores only OPEN ones.
193 ListOpenRequirements(ctx context.Context, arg ListOpenRequirementsParams) ([]Requirement, error)
194 // Open requirements with their backing opportunity dollar value and its provenance, for the portfolio
195 // value function. A standalone requirement (no opportunity) has a null value and is handled by the
196 // documented value fallback in the optimizer.
197 ListOpenRequirementsWithValue(ctx context.Context, arg ListOpenRequirementsWithValueParams) ([]ListOpenRequirementsWithValueRow, error)
198 ListOpportunities(ctx context.Context, arg ListOpportunitiesParams) ([]Opportunity, error)
199 // Optional filters (NULL array = no filter). Soonest closing first, then most recently posted, then id
200 // as a unique tiebreaker so the order is deterministic. Text equality filters compare upper() on both
201 // sides; the service upper cases the params so casing drift cannot silently zero out results. The
202 // optional missions filter keeps a record only when a federal_mission_tag links it to one of the named
203 // mission codes; a NULL missions array means no mission filter, so the default path is unchanged.
204 ListOpportunityRecords(ctx context.Context, arg ListOpportunityRecordsParams) ([]OpportunityRecord, error)
205 // Minimal projection of the global opportunity_records catalog for the missionclass sync pass: the id
206 // carried as text (the record_id federal_mission_tags keys on), plus the title, psc, and naics the
207 // deterministic classifier reads. Ordered by id so the pass iterates byte stably and a re run is
208 // reproducible, the AEDT mandate. Migrator role reads the global catalog directly.
209 ListOpportunityRecordsForClassify(ctx context.Context) ([]ListOpportunityRecordsForClassifyRow, error)
210 // The /compliance surface of proposals awaiting the first human step. Migrator pool, the global table, gated
211 // behind the compliance or operator role at the handler. Ordered oldest first so the queue is a stable list.
212 ListPendingProposals(ctx context.Context) ([]CurationProposal, error)
213 // The current bench watch: pending recommendations from proactive runs, capped and paginated.
214 ListProactiveRecommendations(ctx context.Context, arg ListProactiveRecommendationsParams) ([]StaffingRecommendation, error)
215 ListRequiredCertifications(ctx context.Context, requirementID uuid.UUID) ([]string, error)
216 ListRequiredSkills(ctx context.Context, requirementID uuid.UUID) ([]ListRequiredSkillsRow, error)
217 // id is a unique trailing sort key so the order is total: ties on created_at no longer leave the
218 // LIMIT/OFFSET cut and the downstream Best Fit pick nondeterministic.
219 ListRequirements(ctx context.Context, arg ListRequirementsParams) ([]Requirement, error)
220 // Tenant projection the Phase 5a tagging service classifies for requirements: each live requirement id, its
221 // title, its labor_category (coerced to empty when NULL), and the required skill names joined by single
222 // spaces. RLS scopes the read to the caller's org; the LEFT JOIN keeps a requirement with no required
223 // skills (the title and labor category still classify). Ordered by id for byte stable, reproducible
224 // iteration, the AEDT mandate.
225 ListRequirementsForMissionTagging(ctx context.Context) ([]ListRequirementsForMissionTaggingRow, error)
226 ListRequirementsForOpportunity(ctx context.Context, opportunityID *uuid.UUID) ([]Requirement, error)
227 // Minimal projection of the cached sam_opportunities catalog for the missionclass sync pass: the
228 // notice_id (the record_id award_incumbent_roles keys on for a SAM notice), plus the description_url and
229 // the resource_links the attachment fetcher needs to mine the incumbent labor mix. Ordered by notice_id
230 // for byte stable iteration.
231 ListSamForClassify(ctx context.Context) ([]ListSamForClassifyRow, error)
232 // All filters are optional (NULL array / NULL scalar = "no filter"). active_only defaults true at the
233 // handler. Soonest-closing first, then most-recently-posted.
234 // Text equality filters are case-insensitive (upper() both sides; the service upper-cases the params)
235 // so casing drift from SAM's path text can't silently zero out results [review COR-3]. The title search
236 // is a literal substring (position()), NOT a LIKE pattern, so q's %/_/\ are matched literally and a
237 // trailing backslash can't 500 the request [review COR-1]. Past-deadline / null-deadline notices sort
238 // to the bottom so the feed leads with what's still open [review COR-2].
239 ListSamOpportunities(ctx context.Context, arg ListSamOpportunitiesParams) ([]SamOpportunity, error)
240 ListSkills(ctx context.Context, arg ListSkillsParams) ([]Skill, error)
241 // The WS8 in tenant teaching read. It returns ONLY the contents free craft evidence the producer folds
242 // into scrub.TeachingSignal counts: the reviewer decision on each slate member, the stored sub scores that
243 // reveal a clearance gap (clearance_score) or an experience shortfall (experience_score), the frozen gap
244 // summary, and the matched skills evidence (per skill similarity and whether the match was exact or a
245 // semantic substitution) from the candidate's persisted evaluation. It carries NO name, NO email, NO free
246 // text resume, only the decision label, the scores, and the jsonb match evidence the engine itself froze.
247 //
248 // Both slate_members and candidate_evaluations are RLS scoped, and the producer runs this inside
249 // RunInTenantTx on the app pool, so the join is scoped to the caller's org by Postgres Row Level Security
250 // and can never read another tenant's decisions. candidate_evaluations is LEFT joined on the pair
251 // (organization_id, candidate_id, requirement_id): a slate member that was never screened through
252 // screenMATCH has no stored evaluation, so the matched skills evidence is then NULL and the producer folds
253 // only what slate_members alone supports (the clearance and experience patterns), never fabricating a
254 // skill substitution it cannot see.
255 ListSlateDecisionEvidenceForOrg(ctx context.Context) ([]ListSlateDecisionEvidenceForOrgRow, error)
256 ListSlateMembers(ctx context.Context, slateID uuid.UUID) ([]SlateMember, error)
257 // The slate roster joined to the candidate name for the slateMATCH detail and the branded export. Both
258 // tables are RLS scoped to the caller's org, so the join cannot cross tenants.
259 ListSlateMembersWithNames(ctx context.Context, slateID uuid.UUID) ([]ListSlateMembersWithNamesRow, error)
260 ListSlatesForRequirement(ctx context.Context, requirementID uuid.UUID) ([]Slate, error)
261 // id is the unique trailing sort key so collected_at ties leave a total order and the LIMIT cut is stable.
262 ListSourcingLog(ctx context.Context, limit int32) ([]ListSourcingLogRow, error)
263 // Platform/security events with NO org (e.g. failed logins before org resolution). Privileged read
264 // path only, never the per-tenant app path, so these events are not a black hole [review AUDIT-3].
265 ListSystemAuditLogs(ctx context.Context, arg ListSystemAuditLogsParams) ([]AuditLog, error)
266 // The cross cutting GOVERNANCE CONFIDENCE the proposal generator reads: this tenant's own folded craft counts
267 // for the live in tenant rows (dp_applied false). The generator uses these to confirm a craft pattern is
268 // reliably approved at a band before it ever proposes a curated edge, so the specific recurring pair (read
269 // from the tenant's own evaluations) is only proposed when the contents free aggregate also supports it.
270 // These rows carry NO PII and no candidate id, only the counts. Migrator pool, the global table; the tenant
271 // is passed explicitly because this read is governance confidence, not the RLS scoped evaluation scan.
272 ListTeachingAggregatesForTenant(ctx context.Context, arg ListTeachingAggregatesForTenantParams) ([]TeachingSignalAggregate, error)
273 ListUsers(ctx context.Context, arg ListUsersParams) ([]User, error)
274 // Status guarded: only a pending row can be decided, so a row that was concurrently superseded or
275 // decided returns no row and the service surfaces 409 rather than overwriting a dead or decided row.
276 MarkRecommendationDecision(ctx context.Context, arg MarkRecommendationDecisionParams) (StaffingRecommendation, error)
277 // (phrase, code) pairs that seed the missionclass AliasIndex from real rows. Two unioned sources: every
278 // curated alias whose target skill is a category 'mission_area' skill, and every mission_area skill name
279 // itself. The skill name to code link is mission_areas.spine_term = skills.name, because the mission_area
280 // skills were promoted from the mission_spine terms the mission_areas rows carry. Ordered by phrase then
281 // code for a deterministic build. Global reference data, read by the migrator role.
282 MissionAliasPairs(ctx context.Context) ([]MissionAliasPairsRow, error)
283 OpportunityRecordMeta(ctx context.Context) (OpportunityRecordMetaRow, error)
284 // Band/decision rollup across every slate member under one opportunity's requirements, the source
285 // for GET /proposal-readiness [review COMPL-2]. RLS scopes all three tables to the caller's org.
286 ProposalReadiness(ctx context.Context, opportunityID *uuid.UUID) ([]ProposalReadinessRow, error)
287 // Resolve a skill name to its global skills.id, lower cased and trimmed, so a matched_skills entry that
288 // carries a candidate or required skill NAME but no id can still be turned into the id the proposal and the
289 // staged edge need. The skills table is global reference data the app role may SELECT; the proposal generator
290 // runs this through the same RLS scoped app tx that read the org's evaluations (the read is the only app
291 // pool step, the proposal WRITE goes through the migrator pool).
292 ResolveSkillIDByName(ctx context.Context, btrim string) (uuid.UUID, error)
293 // Candidates whose most recent recorded decision is older than the retention window and whose PII is
294 // not yet anonymized. The de identified slate_members outcomes are retained; only the candidate PII is
295 // wiped (by AnonymizeCandidate). RLS scopes this to the caller's org.
296 RetentionDueCandidates(ctx context.Context, dollar_1 int32) ([]uuid.UUID, error)
297 SamSyncMeta(ctx context.Context) (SamSyncMetaRow, error)
298 // Hybrid retrieval: pgvector cosine kNN fused with full-text rank via Reciprocal Rank Fusion (k=60).
299 // RLS already scopes both legs to the caller's org. $1=query embedding, $2=limit, $3=text query.
300 // The vector arm is MATERIALIZED so the relaxed_order HNSW output is re-sorted by TRUE cosine distance
301 // before it is ranked: under hnsw.iterative_scan = relaxed_order the index returns rows slightly out of
302 // distance order, and ranking them without the re-sort would mis-rank the nearest neighbors at scale
303 // (pgvector 0.8 README; AWS pgvector 0.8 Aurora guidance). Every ORDER BY carries a unique tiebreaker
304 // (id) so results are byte-stable for fixed inputs, the AEDT reproducibility mandate. The caller SETs
305 // LOCAL hnsw.ef_search and hnsw.iterative_scan first.
306 SearchCandidatesHybrid(ctx context.Context, arg SearchCandidatesHybridParams) ([]SearchCandidatesHybridRow, error)
307 // Mission scoped hybrid retrieval (WS6 Option A): identical to SearchCandidatesHybrid, but BOTH arms are
308 // additionally constrained to candidates whose search_tsv matches the mission keyword(s) in mission_query,
309 // so a question can be scoped to a mission area (for example SIGINT) using only candidate text match. The
310 // search_tsv is built from full_name, headline, and location (migration 0002), NOT the resume body. This is
311 // the only mission filter available without structured mission tags: those are WS7 work. It filters on that
312 // TEXT, never on a semantic mission alignment, and that limit is documented in docs/AI_RESEARCH.md.
313 // RLS still scopes both legs to the caller's org; every ORDER BY keeps the unique id tiebreaker so the
314 // output is byte stable for fixed inputs, the AEDT reproducibility mandate. The caller SETs LOCAL
315 // hnsw.ef_search and hnsw.iterative_scan first, exactly as for the unscoped query.
316 SearchCandidatesHybridMission(ctx context.Context, arg SearchCandidatesHybridMissionParams) ([]SearchCandidatesHybridMissionRow, error)
317 // Structured mission scoped hybrid retrieval (WS7 upgrade of the WS6 Option A text filter). It is identical
318 // in shape to SearchCandidatesHybridMission, but the mission constraint on BOTH arms is a STRUCTURED
319 // predicate on candidate_mission_tags (the deterministic classifier output) instead of the search_tsv
320 // mission keyword text match. A candidate is in scope only when a candidate_mission_tags row binds it to the
321 // requested mission_code, so the scope is the real, classified mission of the candidate, not a name or
322 // headline string coincidence. This lifts the WS6 limit (a candidate whose mission is in the resume body but
323 // not in the full_name, headline, or location text is now reachable once the tenant is tagged). The text
324 // query ($text_query) still drives the FTS arm and the embedding arm still drives recall, so only the mission
325 // gate changed. candidate_mission_tags is RLS scoped to the caller's org, so the EXISTS subquery cannot cross
326 // a tenant boundary; the candidates table is RLS scoped too. Every ORDER BY keeps the unique id tiebreaker so
327 // the output is byte stable for fixed inputs, the AEDT reproducibility mandate. The caller SETs LOCAL
328 // hnsw.ef_search and hnsw.iterative_scan first, exactly as for the unscoped and the WS6 text scoped queries.
329 SearchCandidatesHybridMissionTagged(ctx context.Context, arg SearchCandidatesHybridMissionTaggedParams) ([]SearchCandidatesHybridMissionTaggedRow, error)
330 // Cosine nearest-neighbor over the skills ontology (powers semantic skill adjacency).
331 SearchSkillsSemantic(ctx context.Context, arg SearchSkillsSemanticParams) ([]SearchSkillsSemanticRow, error)
332 // An org FSO records HOW a candidate's clearance is known. RLS scopes this to the caller's own org.
333 // verified_at is the date the FSO confirmed it; it is NULL for a self reported indicator. The platform
334 // never verifies a clearance itself, it records the org's authoritative assertion.
335 SetCandidateClearanceProvenance(ctx context.Context, arg SetCandidateClearanceProvenanceParams) (int64, error)
336 // Human-in-the-loop: a person approves/rejects each member, optionally with a note. Never auto-decided.
337 SetSlateMemberDecision(ctx context.Context, arg SetSlateMemberDecisionParams) (SlateMember, error)
338 SoftDeleteCandidate(ctx context.Context, id uuid.UUID) error
339 // Insert the staged, INERT skill_relationships edge that an approval creates. verified_at is left NULL, so the
340 // resolver (which loads only verified_at IS NOT NULL edges) ignores it and no score changes. A SECOND distinct
341 // human action later sets verified_at to activate it. On a conflicting (from, to, relation) that already
342 // exists, do nothing and return the existing row, so an approval is idempotent against a manually seeded edge.
343 // Migrator pool only (skill_relationships is global, the app role has SELECT only).
344 StageSubstitutesForEdge(ctx context.Context, arg StageSubstitutesForEdgeParams) (StageSubstitutesForEdgeRow, error)
345 // A fresh gap run for a requirement supersedes ONLY the prior pending gap rows for that requirement.
346 // Decided rows (approved, rejected, dismissed) are immutable and are never touched.
347 SupersedePendingGap(ctx context.Context, requirementID uuid.UUID) error
348 // A fresh portfolio run supersedes ONLY the prior pending portfolio rows for the org. Decided rows are
349 // immutable.
350 SupersedePendingPortfolio(ctx context.Context) error
351 // A fresh proactive recompute for one candidate supersedes ONLY that candidate's prior pending proactive
352 // rows. Decided rows are immutable.
353 SupersedePendingProactive(ctx context.Context, candidateID *uuid.UUID) error
354 TouchUserLogin(ctx context.Context, id uuid.UUID) error
355 // Writes a precomputed resume embedding onto a candidate, used by the bench import path AFTER the embed
356 // network call has already run in the caller, so the migrator write transaction never holds open across
357 // the inference round trip (the embed lock window rule). The vector is composed from name free structured
358 // tokens only, never raw resume PII. A candidate with a NULL embedding is left embeddable by the
359 // embed-backfill only-missing fallback, so a skipped embed never wedges a row.
360 UpdateCandidateEmbedding(ctx context.Context, arg UpdateCandidateEmbeddingParams) error
361 UpdateSlateStatus(ctx context.Context, arg UpdateSlateStatusParams) (Slate, error)
362 UpsertAedtInventory(ctx context.Context, arg UpsertAedtInventoryParams) (AedtInventory, error)
363 // USASpending awards cache. Global public catalog (no organization_id, outside RLS): reads run off
364 // the pool, writes come from the daily sync (cmd/awards-sync) as the migrator role.
365 UpsertAward(ctx context.Context, arg UpsertAwardParams) error
366 // Idempotent write of an incumbent labor mix row mined from award and solicitation text. ON CONFLICT DO
367 // UPDATE so a re run refreshes the count and evidence for the same record and labor category.
368 UpsertAwardIncumbentRole(ctx context.Context, arg UpsertAwardIncumbentRoleParams) error
369 // BLS OEWS wage baseline cache. Global public catalog (no organization_id, outside RLS): reads run
370 // off the pool, writes come from the weekly rates sync (cmd/rates-sync) as the migrator role.
371 UpsertBlsWage(ctx context.Context, arg UpsertBlsWageParams) error
372 // National OEWS wage expansion upsert, keyed on the natural key (occupation_code, area, metric), the
373 // UNIQUE added in migration 0035. Used by cmd/oews-national-sync for the area='US' national rows: a
374 // second run updates the value in place and inserts nothing new. Idempotent.
375 UpsertBlsWageByOcc(ctx context.Context, arg UpsertBlsWageByOccParams) error
376 // Upsert the latest screenMATCH qualification for one (candidate, requirement) pair. A fresh screen
377 // overwrites the prior row so there is exactly one current evaluation per pair, which missionMATCH
378 // reads instead of recomputing. evaluated_at is preserved as the first time the pair was screened;
379 // updated_at moves to now() on every rescreen.
380 UpsertCandidateEvaluation(ctx context.Context, arg UpsertCandidateEvaluationParams) error
381 // Idempotent write of a tenant candidate mission tag. RLS scopes the write to the caller's org and the
382 // composite FK guarantees the candidate belongs to that org. ON CONFLICT DO UPDATE keeps the sync pass
383 // repeatable, refreshing the mechanism and evidence for an existing candidate and mission code pair.
384 UpsertCandidateMissionTag(ctx context.Context, arg UpsertCandidateMissionTagParams) error
385 // External candidate sourcing. The import command (cmd/import-candidates) writes as the migrator role
386 // with an explicit organization_id; the delete path runs as the app role inside a tenant tx (RLS).
387 UpsertExternalCandidate(ctx context.Context, arg UpsertExternalCandidateParams) (uuid.UUID, error)
388 // Idempotent write of a global mission tag from the classification sync pass. ON CONFLICT DO UPDATE so a
389 // re run with the same record and mission code refreshes the mechanism, evidence, and confidence rather
390 // than erroring, which keeps the sync pass safely repeatable. Migrator owned, app SELECT only.
391 UpsertFederalMissionTag(ctx context.Context, arg UpsertFederalMissionTagParams) error
392 // Opportunity Intelligence unified records. Global public catalog (no organization_id, outside RLS):
393 // reads run straight off the pool, writes come from cmd/opp-sync as the migrator role.
394 UpsertOpportunityRecord(ctx context.Context, arg UpsertOpportunityRecordParams) error
395 // Idempotent write of a tenant requirement mission tag, same isolation guarantees as the candidate path.
396 UpsertRequirementMissionTag(ctx context.Context, arg UpsertRequirementMissionTagParams) error
397 // SAM.gov opportunities cache. Global public catalog (no organization_id, outside RLS): reads run
398 // straight off the pool, writes come from the daily sync (cmd/sam-sync) as the migrator role.
399 UpsertSamOpportunity(ctx context.Context, arg UpsertSamOpportunityParams) error
400 // COALESCE keeps an existing category or embedding when a caller upserts by name only (for example the
401 // ingest and mission check paths that pass just a skill name), so a later name only upsert never nulls a
402 // category that was set before and an embedding can still be backfilled once it is supplied.
403 UpsertSkill(ctx context.Context, arg UpsertSkillParams) (Skill, error)
404 // Persist one folded per tenant craft aggregate into the global teaching_signal_aggregates table. This is
405 // a GLOBAL migrator owned table (app has SELECT only), so the producer runs this through the migrator pool
406 // seam, never the app role. The unique key is (coalesce(tenant_id, the nil uuid), pattern, band, outcome,
407 // model_version, window_start), so a rerun over the same window for the same tenant refreshes the counts in
408 // place rather than inserting a duplicate, and a forked engine model version lands as a distinct row rather
409 // than silently overwriting a prior version's aggregate. The live in tenant rows always carry tenant_id set
410 // and dp_applied false; the flag on cross tenant path writes tenant_id NULL, dp_applied true rows later.
411 UpsertTeachingSignalAggregate(ctx context.Context, arg UpsertTeachingSignalAggregateParams) error
412 // The second of two human steps. Activate a staged edge by setting verified_at and recording the verifier,
413 // ONLY when it is still unverified, so a double submit cannot re activate or change the verifier of an already
414 // live edge. The resolver reads verified_at IS NOT NULL edges, so this single write is what makes the edge
415 // live across tenants. The engine math is byte identical: only the resolver reference set grew. Migrator pool.
416 VerifyStagedEdge(ctx context.Context, arg VerifyStagedEdgeParams) (VerifyStagedEdgeRow, error)
417 WagesSyncMeta(ctx context.Context) (WagesSyncMetaRow, error)
418}
419
420var _ Querier = (*Queries)(nil)
421