Source identity
| Field | Recorded value |
|---|---|
| Source type | GitHub source |
| Original record | Janady13/missionmatch / internal/integration/hybrid_search_tagged_integration_test.go |
| Date | Not specified in source |
| Repository | Janady13/missionmatch |
| Revision | 720d47fae476b0d38477ae4401697d372b1ea2bc |
| Branch | feature/opportunity-to-outcome |
| Path or archive member | internal/integration/hybrid_search_tagged_integration_test.go |
| Original SHA-256 | a64bca25c2d0a483eca536d5231906662eca54f82f77cc178f307948df2e1b49 |
| Git blob SHA | 3bfda9042be0cdf3c202fe0c493eb9219d8a0978 |
| Reading-copy SHA-256 | a64bca25c2d0a483eca536d5231906662eca54f82f77cc178f307948df2e1b49 |
Every recorded occurrence
These 15 records contain identical original source bytes. Their paths and revisions remain part of the archive.
| Original record | Branch or archive | Revision / identifier | Original location |
|---|---|---|---|
| Janady13/missionmatch / internal/integration/hybrid_search_tagged_integration_test.go | feature/opportunity-to-outcome | 720d47fae476b0d38477ae4401697d372b1ea2bc | Open original |
| Janady13/missionmatch / internal/integration/hybrid_search_tagged_integration_test.go | collision-deconfliction | 4ee5a09972608ed89f8377c6665542d5f450f0a6 | Open original |
| Janady13/missionmatch / internal/integration/hybrid_search_tagged_integration_test.go | m5-price-to-win | 41000ad30fff4129fdaf5ec84e15ba14c27d4890 | Open original |
| Janady13/missionmatch / internal/integration/hybrid_search_tagged_integration_test.go | master | 1e9249840a4302ec82e123b9c9cb6f75badea3e4 | Open original |
| Janady13/missionmatch / internal/integration/hybrid_search_tagged_integration_test.go | ws8-teaching-loop | c823f0fb6bb2aba0f39001eb6de96f4000d9321f | Open original |
| Janady13/missionmatch / internal/integration/hybrid_search_tagged_integration_test.go | mag-substrate | b82c7100a492dec67dfd1eda6b3f53def859be35 | Open original |
| Janady13/missionmatch / internal/integration/hybrid_search_tagged_integration_test.go | time-to-fill-survival | b66e1e505863d4f17741a4b9ede73509e45bd6c6 | Open original |
| Janady13/missionmatch / internal/integration/hybrid_search_tagged_integration_test.go | graphrag-foundation | b0ddeb9f633fd138d09309d1a17b7d13bc3a67f7 | Open original |
| Janady13/missionmatch / internal/integration/hybrid_search_tagged_integration_test.go | ws9-bench-ingestion | f585a9ef32fa554663ce1fba9a414a54b6e49cf0 | Open original |
| Janady13/missionmatch / internal/integration/hybrid_search_tagged_integration_test.go | presentation-readiness | eb574acaa29d71ce4d0f852572e87c275c79fdb7 | Open original |
| Janady13/missionmatch / internal/integration/hybrid_search_tagged_integration_test.go | vendor-intelligence | fe9796a19c261951d3f2565206c0c1b5ac294465 | Open original |
| Janady13/missionmatch / internal/integration/hybrid_search_tagged_integration_test.go | ws7-federal-signal | 6a9f6ce9cfb13345ffb47770d4960e7c2d9c17c2 | Open original |
| Janady13/missionmatch / internal/integration/hybrid_search_tagged_integration_test.go | phase2-connectors | e038d4c687aec16f8bd9bc4d907eea14d91f8704 | Open original |
| Janady13/missionmatch / internal/integration/hybrid_search_tagged_integration_test.go | feature/aioe-upgrade | 2178e7298d0e5d9af83afa12402fd587f0ba6ed8 | Open original |
| Janady13/missionmatch / internal/integration/hybrid_search_tagged_integration_test.go | capture-readiness | bae6af7cb2997e819174a9e9cfff5e16067a1975 | Open original |
Recovered source transcript
Download complete source text ↓132 lines · 5.7 KB
//go:build integration
// WS7 structured mission scoped retrieval, exercised against a REAL Postgres with pgvector, full text, and
// RLS in force. It proves SearchCandidatesHybridMissionTagged gates retrieval on the structured
// candidate_mission_tags predicate, not on candidate text: it seeds two org A candidates whose text would
// BOTH satisfy the WS6 search_tsv mission filter, tags only ONE of them SIGINT in candidate_mission_tags
// (written through the APP pool under org A's context, so the write is RLS scoped), embeds both, runs the
// tagged query, and asserts ONLY the tagged candidate returns. A second org's tagged candidate must never
// leak. This mirrors TestHybridSearchMissionScopeExecutes but for the WS7 structured path. Mission tags are
// never a scoring input and never reach the eeo schema; this test only exercises retrieval scoping and the
// tenancy guarantee. It tests the query directly via dbgen with a deterministic embedding, so it needs no
// inference client.
package integration
import (
"context"
"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 TestSearchCandidatesHybridMissionTaggedStructuredScope(t *testing.T) {
orgA, orgB := seedOrg(t), seedOrg(t)
emb := embeddings.NewDeterministic(384)
// seedTagged seeds a candidate via the migrator (so the headline is set) and returns its id. The headline
// deliberately contains the SIGINT keyword for EVERY seeded candidate, so the WS6 text filter would match
// all of them; only the structured tag, applied selectively below, should narrow the WS7 result.
seed := func(org uuid.UUID, name string) uuid.UUID {
vec, _ := emb.Embed(context.Background(), name+" intelligence analyst")
pv := pgvector.NewVector(vec)
hn := "SIGINT collection and analysis"
c, err := dbgen.New(migrator).CreateCandidate(context.Background(), dbgen.CreateCandidateParams{
OrganizationID: org, 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
}
taggedA := seed(orgA, "Alice Tagged") // org A, will be tagged SIGINT
untaggedA := seed(orgA, "Bob Untagged") // org A, NOT tagged, must be excluded by the structured gate
foreignB := seed(orgB, "Eve Foreign") // org B, tagged SIGINT, must never leak into org A's scope
// Tag only Alice (org A) and Eve (org B) through the APP pool under each org's own context, so each write
// is RLS scoped to that org.
tag := func(org, cand uuid.UUID) {
if err := appDB.RunInTenantTx(ctxOrg(org), func(ctx context.Context, tx pgx.Tx) error {
return dbgen.New(tx).UpsertCandidateMissionTag(ctx, dbgen.UpsertCandidateMissionTagParams{
OrganizationID: org, CandidateID: cand, MissionCode: "SIGINT",
Mechanism: "keyword", Evidence: "signals intelligence",
})
}); err != nil {
t.Fatalf("tag candidate %s for org %s: %v", cand, org, err)
}
}
tag(orgA, taggedA)
tag(orgB, foreignB)
qv := pgvector.NewVector(mustEmbed(emb, "intelligence analyst"))
var rows []dbgen.SearchCandidatesHybridMissionTaggedRow
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).SearchCandidatesHybridMissionTagged(ctx, dbgen.SearchCandidatesHybridMissionTaggedParams{
QueryVector: qv, RowLimit: 10, TextQuery: "intelligence analyst", MissionCode: "SIGINT",
})
return e
})
if err != nil {
t.Fatalf("structured tagged hybrid search failed: %v", err)
}
// Exactly the one tagged org A candidate returns: the untagged org A candidate is excluded by the
// structured gate even though its text matches, and org B's tagged candidate is hidden by RLS.
if len(rows) != 1 {
names := make([]string, len(rows))
for i, r := range rows {
names[i] = r.FullName
}
t.Fatalf("structured tagged scope returned %d rows %v, want exactly the 1 tagged candidate", len(rows), names)
}
got := rows[0]
if got.ID != taggedA {
t.Fatalf("structured tagged scope returned %s (%s), want the tagged candidate %s", got.FullName, got.ID, taggedA)
}
if got.OrganizationID != orgA {
t.Fatalf("structured tagged scope leaked a foreign tenant row: %s (%s)", got.FullName, got.OrganizationID)
}
if got.ID == untaggedA {
t.Fatal("structured tagged scope returned the UNTAGGED org A candidate, the structured gate did not apply")
}
if got.ID == foreignB {
t.Fatal("ISOLATION BREACH: structured tagged scope returned org B's tagged candidate")
}
// The probe the retrieval branch uses must see org A's tag (so the structured path is chosen) and zero
// for an untagged third org (so an un backfilled tenant takes the WS6 fallback).
var nA int64
if err := appDB.RunInTenantTx(ctxOrg(orgA), func(ctx context.Context, tx pgx.Tx) error {
var e error
nA, e = dbgen.New(tx).CountCandidateMissionTags(ctx)
return e
}); err != nil {
t.Fatalf("org A count probe: %v", err)
}
if nA < 1 {
t.Fatalf("CountCandidateMissionTags for org A = %d, want at least 1 so the structured path is chosen", nA)
}
orgC := seedOrg(t)
var nC int64
if err := appDB.RunInTenantTx(ctxOrg(orgC), func(ctx context.Context, tx pgx.Tx) error {
var e error
nC, e = dbgen.New(tx).CountCandidateMissionTags(ctx)
return e
}); err != nil {
t.Fatalf("org C count probe: %v", err)
}
if nC != 0 {
t.Fatalf("CountCandidateMissionTags for an untagged org = %d, want 0 so it falls back to the WS6 text filter", nC)
}
}