// Code generated by sqlc. DO NOT EDIT. // versions: // sqlc v1.31.1 // source: governance.sql package dbgen import ( "context" "github.com/google/uuid" ) const insertCandidateNotice = `-- name: InsertCandidateNotice :one INSERT INTO aedt_candidate_notices (organization_id, candidate_id, notice_version, data_categories, retention_days, disclosed_by) VALUES (NULLIF(current_setting('app.current_org_id', true), '')::uuid, $1, $2, $3, $4, $5) RETURNING id, organization_id, candidate_id, notice_version, data_categories, retention_days, disclosed_by, disclosed_at ` type InsertCandidateNoticeParams struct { CandidateID uuid.UUID `json:"candidate_id"` NoticeVersion string `json:"notice_version"` DataCategories []byte `json:"data_categories"` RetentionDays int32 `json:"retention_days"` DisclosedBy *uuid.UUID `json:"disclosed_by"` } func (q *Queries) InsertCandidateNotice(ctx context.Context, arg InsertCandidateNoticeParams) (AedtCandidateNotice, error) { row := q.db.QueryRow(ctx, insertCandidateNotice, arg.CandidateID, arg.NoticeVersion, arg.DataCategories, arg.RetentionDays, arg.DisclosedBy, ) var i AedtCandidateNotice err := row.Scan( &i.ID, &i.OrganizationID, &i.CandidateID, &i.NoticeVersion, &i.DataCategories, &i.RetentionDays, &i.DisclosedBy, &i.DisclosedAt, ) return i, err } const listAedtInventory = `-- name: ListAedtInventory :many SELECT id, organization_id, tool_key, display_name, purpose, model_version, active, created_at, updated_at FROM aedt_inventory ORDER BY created_at DESC ` func (q *Queries) ListAedtInventory(ctx context.Context) ([]AedtInventory, error) { rows, err := q.db.Query(ctx, listAedtInventory) if err != nil { return nil, err } defer rows.Close() items := []AedtInventory{} for rows.Next() { var i AedtInventory if err := rows.Scan( &i.ID, &i.OrganizationID, &i.ToolKey, &i.DisplayName, &i.Purpose, &i.ModelVersion, &i.Active, &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 listModelVersions = `-- name: ListModelVersions :many SELECT version, weights, band_cuts, notes, effective_from, created_at FROM aedt_model_versions ORDER BY effective_from DESC ` // 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). func (q *Queries) ListModelVersions(ctx context.Context) ([]AedtModelVersion, error) { rows, err := q.db.Query(ctx, listModelVersions) if err != nil { return nil, err } defer rows.Close() items := []AedtModelVersion{} for rows.Next() { var i AedtModelVersion if err := rows.Scan( &i.Version, &i.Weights, &i.BandCuts, &i.Notes, &i.EffectiveFrom, &i.CreatedAt, ); err != nil { return nil, err } items = append(items, i) } if err := rows.Err(); err != nil { return nil, err } return items, nil } const retentionDueCandidates = `-- name: RetentionDueCandidates :many SELECT c.id FROM candidates c WHERE c.anonymized_at IS NULL AND ( SELECT max(sm.decided_at) FROM slate_members sm WHERE sm.candidate_id = c.id AND sm.decided_at IS NOT NULL ) < now() - make_interval(days => $1::int) LIMIT 500 ` // 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. func (q *Queries) RetentionDueCandidates(ctx context.Context, dollar_1 int32) ([]uuid.UUID, error) { rows, err := q.db.Query(ctx, retentionDueCandidates, dollar_1) if err != nil { return nil, err } defer rows.Close() items := []uuid.UUID{} for rows.Next() { var id uuid.UUID if err := rows.Scan(&id); err != nil { return nil, err } items = append(items, id) } if err := rows.Err(); err != nil { return nil, err } return items, nil } const upsertAedtInventory = `-- name: UpsertAedtInventory :one INSERT INTO aedt_inventory (organization_id, tool_key, display_name, purpose, model_version) VALUES (NULLIF(current_setting('app.current_org_id', true), '')::uuid, $1, $2, $3, $4) ON CONFLICT (organization_id, tool_key) DO UPDATE SET display_name = EXCLUDED.display_name, purpose = EXCLUDED.purpose, model_version = EXCLUDED.model_version, updated_at = now() RETURNING id, organization_id, tool_key, display_name, purpose, model_version, active, created_at, updated_at ` type UpsertAedtInventoryParams struct { ToolKey string `json:"tool_key"` DisplayName string `json:"display_name"` Purpose string `json:"purpose"` ModelVersion *string `json:"model_version"` } func (q *Queries) UpsertAedtInventory(ctx context.Context, arg UpsertAedtInventoryParams) (AedtInventory, error) { row := q.db.QueryRow(ctx, upsertAedtInventory, arg.ToolKey, arg.DisplayName, arg.Purpose, arg.ModelVersion, ) var i AedtInventory err := row.Scan( &i.ID, &i.OrganizationID, &i.ToolKey, &i.DisplayName, &i.Purpose, &i.ModelVersion, &i.Active, &i.CreatedAt, &i.UpdatedAt, ) return i, err }