ThatAIguyA world of ideas

THE CONSCIOUSNESS ATLAS
Read. Experiment. Follow the evidence.

ConsciousnessLearn · Explore · Joseph Anady

Janady13/missionmatch / internal/integration/retrieval_snippet_integration_test.go

Source identity, revision, and recovered contents.

GitHub sourceSource text recovered

Source identity

FieldRecorded value
Source typeGitHub source
Original recordJanady13/missionmatch / internal/integration/retrieval_snippet_integration_test.go
DateNot specified in source
RepositoryJanady13/missionmatch
Revision720d47fae476b0d38477ae4401697d372b1ea2bc
Branchfeature/opportunity-to-outcome
Path or archive memberinternal/integration/retrieval_snippet_integration_test.go
Original SHA-25650c62c8edbc3951c0832cf9244a3533703020f5241c53ad7a53a6dad260351f9
Git blob SHAd98d969e3e3447a91aabbf555de5bd31b3101f6e
Reading-copy SHA-25650c62c8edbc3951c0832cf9244a3533703020f5241c53ad7a53a6dad260351f9

Original source ↗

Every recorded occurrence

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

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

Recovered source transcript

//go:build integration // Snippet on the hit, exercised against a REAL Postgres with pgvector, full text, and RLS in force. It // proves the added ts_headline snippet expression on the hybrid retrieval query: a candidate seeded with a // distinctive headline term, retrieved under RLS with that term as the text query, comes back with a non // empty Snippet that contains the matched term, so the faithfulness gate and the narration can cite WHY the // candidate matched, the matched TEXT, not only the name. It also proves the degrade contract: a pure // semantic query (an empty text query, so an empty tsquery) still returns hits through the vector arm with // an empty, no highlight snippet and no error. The snippet is built over the SAME text the search_tsv is // built from and bound to the SAME tsquery the full text leg already uses, so it never diverges from the // query that produced the match. This tests the query directly via dbgen with a deterministic embedding, so // it needs no inference client, exactly like the sibling hybrid search tests. package integration import ( "context" "strings" "testing" "github.com/google/uuid" "github.com/jackc/pgx/v5" "github.com/pgvector/pgvector-go" "github.com/missionworkforce/missionmatch/internal/platform/database/dbgen" "github.com/missionworkforce/missionmatch/internal/platform/embeddings" ) func TestHybridSearchSnippetOnHit(t *testing.T) { orgA := seedOrg(t) emb := embeddings.NewDeterministic(384) // A distinctive headline term that the snippet must surface. It lives in the headline, one of the three // fields the search_tsv (and the matching ts_headline source text) is built from in migration 0002. const term = "cryptanalysis" seed := func(name, headline string) uuid.UUID { vec, _ := emb.Embed(context.Background(), name+" "+headline) pv := pgvector.NewVector(vec) hn := headline c, err := dbgen.New(migrator).CreateCandidate(context.Background(), dbgen.CreateCandidateParams{ OrganizationID: orgA, FullName: name, Headline: &hn, ClearanceLevel: "top_secret", ClearancePoly: "none", ClearanceStatus: "active", Available: true, ResumeEmbedding: &pv, }) if err != nil { t.Fatalf("seed candidate %q: %v", name, err) } return c.ID } wantID := seed("Alice Analyst", "Senior cryptanalysis lead for SIGINT collection") seed("Bob Builder", "Kubernetes and AWS platform engineer") // A text matching query: the FTS leg matches Alice on the term, so her snippet must surface it. var rows []dbgen.SearchCandidatesHybridRow qv := pgvector.NewVector(mustEmbed(emb, term)) err := appDB.RunInTenantTx(ctxOrg(orgA), func(ctx context.Context, tx pgx.Tx) error { if _, e := tx.Exec(ctx, "SET LOCAL hnsw.ef_search = 200"); e != nil { return e } var e error rows, e = dbgen.New(tx).SearchCandidatesHybrid(ctx, dbgen.SearchCandidatesHybridParams{ Column1: qv, Limit: 10, WebsearchToTsquery: term, }) return e }) if err != nil { t.Fatalf("hybrid search with snippet failed: %v", err) } var found *dbgen.SearchCandidatesHybridRow for i := range rows { if rows[i].ID == wantID { found = &rows[i] } if rows[i].OrganizationID != orgA { t.Fatalf("hybrid search leaked a foreign tenant row: %s", rows[i].OrganizationID) } } if found == nil { t.Fatalf("the term matching candidate %s was not retrieved for query %q", wantID, term) } if strings.TrimSpace(found.Snippet) == "" { t.Fatalf("the text matching hit has an empty snippet; the matched span was not attached") } if !strings.Contains(strings.ToLower(found.Snippet), term) { t.Fatalf("the snippet %q does not contain the matched term %q", found.Snippet, term) } // The degrade contract: a pure semantic query (an empty text query yields an empty tsquery) must still // return hits through the vector arm, with an empty, no highlight snippet, and no error. ts_headline on an // empty tsquery returns an unhighlighted head, never an error, so an empty snippet is a valid result. var semRows []dbgen.SearchCandidatesHybridRow err = appDB.RunInTenantTx(ctxOrg(orgA), func(ctx context.Context, tx pgx.Tx) error { if _, e := tx.Exec(ctx, "SET LOCAL hnsw.ef_search = 200"); e != nil { return e } var e error semRows, e = dbgen.New(tx).SearchCandidatesHybrid(ctx, dbgen.SearchCandidatesHybridParams{ Column1: qv, Limit: 10, WebsearchToTsquery: "", }) return e }) if err != nil { t.Fatalf("pure semantic (empty query) hybrid search must not error, got: %v", err) } if len(semRows) == 0 { t.Fatal("pure semantic search returned no rows; the vector arm should still recall the seeded candidates") } for _, r := range semRows { if r.OrganizationID != orgA { t.Fatalf("semantic search leaked a foreign tenant row: %s", r.OrganizationID) } if strings.TrimSpace(r.Snippet) != "" { t.Fatalf("a pure semantic hit must carry an empty snippet (no tsquery to highlight), got %q for %s", r.Snippet, r.FullName) } } }

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