ThatAIguyA world of ideas

THE CONSCIOUSNESS ATLAS
Read. Experiment. Follow the evidence.

ConsciousnessLearn · Explore · Joseph Anady

Janady13/missionmatch / internal/modules/governance/service.go

Source identity, revision, and recovered contents.

GitHub sourceSource text recovered

Source identity

FieldRecorded value
Source typeGitHub source
Original recordJanady13/missionmatch / internal/modules/governance/service.go
DateNot specified in source
RepositoryJanady13/missionmatch
Revision09015496d565a172bcaa15cfe9a8e4b072b13df0
Branchworkstream-b-screenmatch
Path or archive memberinternal/modules/governance/service.go
Original SHA-256726e98b41df979b116924af7122467ff97be928ed97d84db0823926c8fe9832c
Git blob SHA7b9927abc3229e0ffd7b6436c4a8b695bf7edf63
Reading-copy SHA-256726e98b41df979b116924af7122467ff97be928ed97d84db0823926c8fe9832c

Original source ↗

Every recorded occurrence

These 21 records contain identical original source bytes. Their paths and revisions remain part of the archive.

Original recordBranch or archiveRevision / identifierOriginal location
Janady13/missionmatch / internal/modules/governance/service.goworkstream-b-screenmatch09015496d565a172bcaa15cfe9a8e4b072b13df0Open original
Janady13/missionmatch / internal/modules/governance/service.goworkstream-a-opportunity-intelligence1675031db74316e100782d063e9eda1a597fe3a1Open original
Janady13/missionmatch / internal/modules/governance/service.goworkstream-d-command-center255e7d1d420abf5e277d0cd8c9b14f6f72b6acb9Open original
Janady13/missionmatch / internal/modules/governance/service.goworkstream-d-missionmatch3be46ba89edb737182075a2b320509b42dc916f8Open original
Janady13/missionmatch / internal/modules/governance/service.goworkstream-e-dataflow-deploy433815a042f9741411e60fa553fe72143e9b10dbOpen original
Janady13/missionmatch / internal/modules/governance/service.goworkstream-e-commercial-stubs4437da660539284a400ee380b9b427a300c369eeOpen original
Janady13/missionmatch / internal/modules/governance/service.goworkstream-c-slatematch5cd60c918301b46ecd6ed3e03e20c395da0062e2Open original
Janady13/missionmatch / internal/modules/governance/service.goai-intelligence-layer5d5ddff70393a197c5f54a45280bb5dd42b24755Open original
Janady13/missionmatch / internal/modules/governance/service.goruthless-debug-sweepb7d742f8f032984be3817efffa3eb8b13b651c1fOpen original
Janady13/missionmatch / internal/modules/governance/service.goworkstream-b-sam-contract-awardsd5101cceb98e70000cebb31d3e7ac73d747d3a6dOpen original
Janady13/missionmatch / internal/modules/governance/service.goworkstream-a-shared-coree0de03ac3a1ec826bd15d0e048e3b02baa23eeffOpen original
Janady13/missionmatch / internal/modules/governance/service.goworkstream-c-slatematch5cd60c918301b46ecd6ed3e03e20c395da0062e2Open original
Janady13/missionmatch / internal/modules/governance/service.goworkstream-d-command-center255e7d1d420abf5e277d0cd8c9b14f6f72b6acb9Open original
Janady13/missionmatch / internal/modules/governance/service.goworkstream-e-dataflow-deploy433815a042f9741411e60fa553fe72143e9b10dbOpen original
Janady13/missionmatch / internal/modules/governance/service.goruthless-debug-sweepb7d742f8f032984be3817efffa3eb8b13b651c1fOpen original
Janady13/missionmatch / internal/modules/governance/service.goai-intelligence-layer5d5ddff70393a197c5f54a45280bb5dd42b24755Open original
Janady13/missionmatch / internal/modules/governance/service.goworkstream-a-opportunity-intelligence1675031db74316e100782d063e9eda1a597fe3a1Open original
Janady13/missionmatch / internal/modules/governance/service.goworkstream-b-screenmatch09015496d565a172bcaa15cfe9a8e4b072b13df0Open original
Janady13/missionmatch / internal/modules/governance/service.goworkstream-e-commercial-stubs4437da660539284a400ee380b9b427a300c369eeOpen original
Janady13/missionmatch / internal/modules/governance/service.goworkstream-d-missionmatch3be46ba89edb737182075a2b320509b42dc916f8Open original
Janady13/missionmatch / internal/modules/governance/service.goworkstream-b-sam-contract-awardsd5101cceb98e70000cebb31d3e7ac73d747d3a6dOpen original

Recovered source transcript

// Package governance is the AEDT governance surface: the model version registry, the org AEDT // inventory, the candidate notice and disclosure record, the retention sweep, and the audit read. It // runs on the app pool under RLS and never touches the eeo schema (that is the compliance pool's job). package governance import ( "context" "encoding/json" "errors" "github.com/google/uuid" "github.com/jackc/pgx/v5" "github.com/missionworkforce/missionmatch/internal/platform/audit" "github.com/missionworkforce/missionmatch/internal/platform/database/dbgen" "github.com/missionworkforce/missionmatch/internal/platform/tenant" ) // ErrNoDatabase is returned when no app pool is configured. var ErrNoDatabase = errors.New("governance: no database configured") // Service implements the AEDT governance operations. type Service struct { db *tenant.DB aud *audit.Writer retentionDays int } // NewService builds the service. retentionDays is the configured retention window for identifiable // screening artifacts after a decision. func NewService(db *tenant.DB, aud *audit.Writer, retentionDays int) *Service { return &Service{db: db, aud: aud, retentionDays: retentionDays} } func (s *Service) ok() error { if s.db == nil || s.db.Pool == nil { return ErrNoDatabase } return nil } // ListModelVersions returns the scoring model registry: each version with the weights and band cuts it // used, so a frozen decision is reproducible against the version that produced it. func (s *Service) ListModelVersions(ctx context.Context) ([]dbgen.AedtModelVersion, error) { if err := s.ok(); err != nil { return nil, err } var out []dbgen.AedtModelVersion err := s.db.RunInTenantTx(ctx, func(ctx context.Context, tx pgx.Tx) error { var e error out, e = dbgen.New(tx).ListModelVersions(ctx) return e }) return out, err } // ListInventory returns the org's register of automated employment decision tools in use. func (s *Service) ListInventory(ctx context.Context) ([]dbgen.AedtInventory, error) { if err := s.ok(); err != nil { return nil, err } var out []dbgen.AedtInventory err := s.db.RunInTenantTx(ctx, func(ctx context.Context, tx pgx.Tx) error { var e error out, e = dbgen.New(tx).ListAedtInventory(ctx) return e }) return out, err } // InventoryInput registers or updates one AEDT tool in the org inventory. type InventoryInput struct { ToolKey string `json:"tool_key"` DisplayName string `json:"display_name"` Purpose string `json:"purpose"` ModelVersion string `json:"model_version"` } // UpsertInventory records a tool in the org inventory and audits the change. func (s *Service) UpsertInventory(ctx context.Context, in InventoryInput) (dbgen.AedtInventory, error) { if err := s.ok(); err != nil { return dbgen.AedtInventory{}, err } var row dbgen.AedtInventory err := s.db.RunInTenantTx(ctx, func(ctx context.Context, tx pgx.Tx) error { var mv *string if in.ModelVersion != "" { mv = &in.ModelVersion } r, e := dbgen.New(tx).UpsertAedtInventory(ctx, dbgen.UpsertAedtInventoryParams{ ToolKey: in.ToolKey, DisplayName: in.DisplayName, Purpose: in.Purpose, ModelVersion: mv, }) if e != nil { return e } row = r return s.audit(ctx, tx, audit.Event{Action: "aedt.inventory.recorded", EntityType: "aedt_tool", EntityID: in.ToolKey}) }) return row, err } // NoticeInput records that a candidate was given the AEDT notice and disclosure. type NoticeInput struct { NoticeVersion string `json:"notice_version"` DataCategories []string `json:"data_categories"` } // RecordNotice writes the candidate notice and disclosure record on the tenant tx and audits it. The // candidate consent itself lives in the unreadable eeo schema; this is the public schema disclosure // that the notice was provided. func (s *Service) RecordNotice(ctx context.Context, candidateID uuid.UUID, in NoticeInput) (dbgen.AedtCandidateNotice, error) { if err := s.ok(); err != nil { return dbgen.AedtCandidateNotice{}, err } cats := in.DataCategories if len(cats) == 0 { cats = DefaultDataCategories } catJSON, _ := json.Marshal(cats) var row dbgen.AedtCandidateNotice err := s.db.RunInTenantTx(ctx, func(ctx context.Context, tx pgx.Tx) error { r, e := dbgen.New(tx).InsertCandidateNotice(ctx, dbgen.InsertCandidateNoticeParams{ CandidateID: candidateID, NoticeVersion: in.NoticeVersion, DataCategories: catJSON, RetentionDays: int32(s.retentionDays), DisclosedBy: actorPtr(ctx), }) if e != nil { return e } row = r return s.audit(ctx, tx, audit.Event{Action: "aedt.candidate.notice_disclosed", EntityType: "candidate", EntityID: candidateID.String()}) }) return row, err } // RunRetention anonymizes the org's candidates whose most recent decision is older than the retention // window, wiping PII while keeping the de identified outcomes. It returns the number anonymized and // audits each. This is the on demand, RLS scoped sweep; a platform wide scheduled sweep needs a // privileged cross org enumeration and is a separate, flagged enhancement. func (s *Service) RunRetention(ctx context.Context) (int, error) { if err := s.ok(); err != nil { return 0, err } count := 0 err := s.db.RunInTenantTx(ctx, func(ctx context.Context, tx pgx.Tx) error { q := dbgen.New(tx) due, e := q.RetentionDueCandidates(ctx, int32(s.retentionDays)) if e != nil { return e } for _, id := range due { rows, e := q.AnonymizeCandidate(ctx, id) if e != nil { return e } if rows > 0 { count++ // Purge the qualification child data too so the retention sweep leaves no child PII, // matching the on demand erasure. The frozen slate_members outcomes are untouched. for _, stmt := range []string{ `DELETE FROM candidate_skills WHERE candidate_id = $1`, `DELETE FROM candidate_certifications WHERE candidate_id = $1`, `DELETE FROM candidate_customer_experience WHERE candidate_id = $1`, } { if _, e := tx.Exec(ctx, stmt, id); e != nil { return e } } if e := s.audit(ctx, tx, audit.Event{Action: "retention.candidate.anonymized", EntityType: "candidate", EntityID: id.String()}); e != nil { return e } } } return nil }) return count, err } // ListAudit returns the org's audit trail (org isolated through the GUC bound query, not a Go filter). func (s *Service) ListAudit(ctx context.Context, limit, offset int32) ([]dbgen.AuditLog, error) { if err := s.ok(); err != nil { return nil, err } if limit <= 0 || limit > 500 { limit = 100 } var out []dbgen.AuditLog err := s.db.RunInTenantTx(ctx, func(ctx context.Context, tx pgx.Tx) error { var e error out, e = dbgen.New(tx).ListAuditLogsForOrg(ctx, dbgen.ListAuditLogsForOrgParams{Limit: limit, Offset: offset}) return e }) return out, err } // audit records a governance event on the caller's tenant tx and returns the write error so the // caller fails closed: a mutation that cannot be audited rolls back, matching the auth, sourcing, and // matching modules and the append only audit contract. func (s *Service) audit(ctx context.Context, tx pgx.Tx, e audit.Event) error { if s.aud == nil { return nil } e.ActorUserID = actorPtr(ctx) return s.aud.OnTx(ctx, tx, e) } func actorPtr(ctx context.Context) *uuid.UUID { if p, ok := tenant.UserFromContext(ctx); ok { if id, err := uuid.Parse(p.UserID); err == nil { return &id } } return nil } // DefaultDataCategories is the AEDT disclosure list: the categories of data the scoring tools assess. // It is the single source of truth for the candidate notice, reused by the Mission Check result so the // in modal disclosure names exactly what governance records. None of these is a demographic attribute. var DefaultDataCategories = []string{ "clearance self reported indicator", "skills", "certifications", "customer agency experience", "years of experience", "work location and availability", }

Search equations, builds, manuscript text, and recovered sources.