ThatAIguyA world of ideas

THE CONSCIOUSNESS ATLAS
Read. Experiment. Follow the evidence.

ConsciousnessLearn · Explore · Joseph Anady

Janady13/missionmatch / internal/platform/sourcing/ingest_bench.go

Source identity, revision, and recovered contents.

GitHub sourceSource text recovered

Source identity

FieldRecorded value
Source typeGitHub source
Original recordJanady13/missionmatch / internal/platform/sourcing/ingest_bench.go
DateNot specified in source
RepositoryJanady13/missionmatch
Revision720d47fae476b0d38477ae4401697d372b1ea2bc
Branchfeature/opportunity-to-outcome
Path or archive memberinternal/platform/sourcing/ingest_bench.go
Original SHA-256b531cc600cd151d44d81aca607bd8e97b58f7130333961bcf40b2c336a524a95
Git blob SHAee9bda866211b4092f31ecc95e0fdbbb256d9c05
Reading-copy SHA-256b531cc600cd151d44d81aca607bd8e97b58f7130333961bcf40b2c336a524a95

Original source ↗

Every recorded occurrence

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

Original recordBranch or archiveRevision / identifierOriginal location
Janady13/missionmatch / internal/platform/sourcing/ingest_bench.gofeature/opportunity-to-outcome720d47fae476b0d38477ae4401697d372b1ea2bcOpen original
Janady13/missionmatch / internal/platform/sourcing/ingest_bench.gocollision-deconfliction4ee5a09972608ed89f8377c6665542d5f450f0a6Open original
Janady13/missionmatch / internal/platform/sourcing/ingest_bench.gom5-price-to-win41000ad30fff4129fdaf5ec84e15ba14c27d4890Open original
Janady13/missionmatch / internal/platform/sourcing/ingest_bench.gomaster1e9249840a4302ec82e123b9c9cb6f75badea3e4Open original
Janady13/missionmatch / internal/platform/sourcing/ingest_bench.gomag-substrateb82c7100a492dec67dfd1eda6b3f53def859be35Open original
Janady13/missionmatch / internal/platform/sourcing/ingest_bench.gotime-to-fill-survivalb66e1e505863d4f17741a4b9ede73509e45bd6c6Open original
Janady13/missionmatch / internal/platform/sourcing/ingest_bench.gographrag-foundationb0ddeb9f633fd138d09309d1a17b7d13bc3a67f7Open original
Janady13/missionmatch / internal/platform/sourcing/ingest_bench.gows9-bench-ingestionf585a9ef32fa554663ce1fba9a414a54b6e49cf0Open original
Janady13/missionmatch / internal/platform/sourcing/ingest_bench.gopresentation-readinesseb574acaa29d71ce4d0f852572e87c275c79fdb7Open original
Janady13/missionmatch / internal/platform/sourcing/ingest_bench.govendor-intelligencefe9796a19c261951d3f2565206c0c1b5ac294465Open original
Janady13/missionmatch / internal/platform/sourcing/ingest_bench.gophase2-connectorse038d4c687aec16f8bd9bc4d907eea14d91f8704Open original
Janady13/missionmatch / internal/platform/sourcing/ingest_bench.gofeature/aioe-upgrade2178e7298d0e5d9af83afa12402fd587f0ba6ed8Open original
Janady13/missionmatch / internal/platform/sourcing/ingest_bench.gocapture-readinessbae6af7cb2997e819174a9e9cfff5e16067a1975Open original

Recovered source transcript

package sourcing // Bench ingest extension. This file adds the WS9 bench loader path on top of the sourced lead ingest in // ingest.go, reusing its dedup and structured skills, certs, and agencies writes VERBATIM through the // shared writeStructuredCandidate helper. Three WS9 invariants are encoded here. // // Invariant 3, clearance stays unknown on import. The candidate is written through the SAME // UpsertExternalCandidate path, which hardcodes clearance_level 'unknown', clearance_poly 'none', and // clearance_status 'unknown'. IngestBenchRecord never threads an extracted clearance code to any clearance // column, so a resume regex can never score as a held clearance under the 0.25 clearance weight. A // clearance becomes known only later through an explicit org FSO provenance action. // // Invariant 6, embed is composed and run BEFORE the write transaction. IngestBenchRecord accepts a // PRECOMPUTED resume embedding vector. The embed network round trip happens in the CALLER, outside this // transaction, so a slow inference plane never holds the candidate row lock open across the embed timeout. // A nil vector commits the candidate WITHOUT an embedding, and the embed-backfill only-missing fallback // fills it later, so a skipped or failed embed never wedges a row. // // Invariant 2, mission tags are written through the APP role under RLS, never this migrator transaction. // IngestBenchRecord deliberately writes NO candidate_mission_tags row. TagCandidateMissions is a SEPARATE // function the import command calls AFTER the candidate commits, on the application pool inside // RunInTenantTx, so the RLS WITH CHECK validates the org on every tag insert. import ( "context" "fmt" "github.com/google/uuid" "github.com/jackc/pgx/v5" pgvector "github.com/pgvector/pgvector-go" "github.com/missionworkforce/missionmatch/internal/platform/database/dbgen" "github.com/missionworkforce/missionmatch/internal/platform/extraction" "github.com/missionworkforce/missionmatch/internal/platform/missionclass" "github.com/missionworkforce/missionmatch/internal/platform/tenant" ) // BenchIngestResult is the outcome of ingesting one bench record: the resolved candidate id and whether // the row was a new insert or an enrich of an existing person (a dedup hit). The import command reports // these counts; New false is a dedup enrich, never a duplicate row. type BenchIngestResult struct { CandidateID uuid.UUID New bool // true when a new candidate was inserted, false when an existing person was enriched } // IngestBenchRecord resolves a bench person to a candidate and writes their structured workforce data, the // precomputed resume embedding, and one bench_import_log compliance row, ALL inside the one migrator // transaction the caller already opened (q is base.WithTx(tx)). It is the bench loader sibling of // IngestPerson: it reuses writeStructuredCandidate, so the dedup and the skills, certs, and agency writes // are byte identical to the sourced lead path. // // Clearance is never set here beyond the hardcoded 'unknown' the upsert writes (invariant 3). The embed // is NOT computed here: the caller composes the name free profile and calls inference.Client.Embed BEFORE // opening this transaction, then passes the finished vector(384) as embedding (invariant 6). A nil // embedding commits the candidate without a resume vector. One bench_import_log row is written per committed // record with the operator provided source, file_or_batch, and legal_basis. // // Mission tags are NOT written here (invariant 2): the caller writes candidate_mission_tags on the // application pool inside RunInTenantTx through TagCandidateMissions after this commits. func IngestBenchRecord(ctx context.Context, q *dbgen.Queries, orgID uuid.UUID, sp SourcedPerson, ext extraction.Extractor, embedding *pgvector.Vector, source, fileOrBatch, legalBasis string) (BenchIngestResult, error) { candID, found, err := writeStructuredCandidate(ctx, q, orgID, sp, ext) if err != nil { return BenchIngestResult{}, err } // Invariant 6: write the precomputed vector in the SAME migrator transaction as the candidate, so the // row and its embedding commit atomically. A nil vector skips the write entirely, leaving the row // embeddable by the embed-backfill only-missing fallback; no embed network call happens here. if embedding != nil { if err := q.UpdateCandidateEmbedding(ctx, dbgen.UpdateCandidateEmbeddingParams{Embedding: *embedding, ID: candID}); err != nil { return BenchIngestResult{}, fmt.Errorf("update candidate embedding: %w", err) } } // One compliance row per committed record. candidate_id is set so an org can trace which bench person // each row justifies. source is bench_file or bench_csv (never PDL); legal_basis is operator provided. cid := candID if err := q.InsertBenchImportLog(ctx, dbgen.InsertBenchImportLogParams{ OrganizationID: orgID, CandidateID: &cid, Source: source, FileOrBatch: fileOrBatch, LegalBasis: legalBasis, }); err != nil { return BenchIngestResult{}, fmt.Errorf("insert bench import log: %w", err) } return BenchIngestResult{CandidateID: candID, New: !found}, nil } // candidateMissionTagWriter is the narrow port TagCandidateMissions writes through, so the classification is // unit testable with an injected fake and no database. The production implementation runs the write inside // RunInTenantTx on the application pool, exercising RLS on every tag row. type candidateMissionTagWriter interface { upsertCandidateMissionTags(ctx context.Context, tags []dbgen.UpsertCandidateMissionTagParams) error } // TagCandidateMissions classifies one candidate's headline text and skill names with the deterministic // missionclass.Classify over the prebuilt AliasIndex, then upserts a candidate_mission_tag per Hit through // the APPLICATION pool inside RunInTenantTx (invariant 2). It is a SEPARATE function from IngestBenchRecord // and MUST NOT be called inside the migrator ingest transaction: the import command calls it AFTER the // candidate commits, mirroring cmd/tag-missions exactly. // // The org id stamped on every tag is read from the GUC context set by tenant.WithOrg, NEVER a caller // argument, so the RLS WITH CHECK validates the org on each insert and a tag can never land in another // tenant. The classifier is pure (no DB, no clock, no network), so the only DB touch is the tag write, // which the application role performs under RLS. func TagCandidateMissions(ctx context.Context, appDB *tenant.DB, candidateID uuid.UUID, headlineText string, skillNames []string, idx missionclass.AliasIndex) error { return tagCandidateMissions(ctx, appDBTagWriter{db: appDB}, candidateID, headlineText, skillNames, idx) } // tagCandidateMissions is the inner, writer injected form. It does the pure classification and hands the // resulting params to the writer, so the test exercises the full classify to params mapping with a fake // writer and a fixed AliasIndex and asserts the upsert calls, with no DB. func tagCandidateMissions(ctx context.Context, w candidateMissionTagWriter, candidateID uuid.UUID, headlineText string, skillNames []string, idx missionclass.AliasIndex) error { orgID, err := orgUUIDFromContext(ctx) if err != nil { return err } text := joinNonEmpty(append([]string{headlineText}, skillNames...)...) var tags []dbgen.UpsertCandidateMissionTagParams for _, h := range missionclass.Classify(text, "", "", idx) { tags = append(tags, dbgen.UpsertCandidateMissionTagParams{ OrganizationID: orgID, CandidateID: candidateID, MissionCode: h.Code, Mechanism: h.Mechanism, Evidence: h.Evidence, }) } if err := w.upsertCandidateMissionTags(ctx, tags); err != nil { return fmt.Errorf("sourcing: upsert candidate mission tags: %w", err) } return nil } // appDBTagWriter is the production candidateMissionTagWriter: it writes every tag inside ONE RunInTenantTx // as the application role, so RLS is exercised on each insert and the org comes from the validated GUC. type appDBTagWriter struct{ db *tenant.DB } func (w appDBTagWriter) upsertCandidateMissionTags(ctx context.Context, tags []dbgen.UpsertCandidateMissionTagParams) error { if len(tags) == 0 { return nil } return w.db.RunInTenantTx(ctx, func(ctx context.Context, tx pgx.Tx) error { q := dbgen.New(tx) for _, t := range tags { if err := q.UpsertCandidateMissionTag(ctx, t); err != nil { return err } } return nil }) } // orgUUIDFromContext reads the validated org id from the tenant context and parses it. A missing or // malformed org is a hard error: tagging refuses to run unscoped, mirroring RunInTenantTx fail closed. func orgUUIDFromContext(ctx context.Context) (uuid.UUID, error) { raw, ok := tenant.OrgFromContext(ctx) if !ok { return uuid.Nil, tenant.ErrNoTenant } id, err := uuid.Parse(raw) if err != nil { return uuid.Nil, fmt.Errorf("sourcing: org id in context is not a uuid: %w", err) } return id, nil } // joinNonEmpty joins non empty parts with single spaces into the one blob the classifier reads. Empty parts // are dropped so a missing headline or skill never injects stray whitespace the word boundary matcher would // have to absorb. func joinNonEmpty(parts ...string) string { out := "" for _, p := range parts { if p == "" { continue } if out != "" { out += " " } out += p } return out }

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