Source identity
| Field | Recorded value |
|---|---|
| Source type | GitHub source |
| Original record | Janady13/missionmatch / internal/platform/benchimport/benchimport_test.go |
| Date | Not specified in source |
| Repository | Janady13/missionmatch |
| Revision | 720d47fae476b0d38477ae4401697d372b1ea2bc |
| Branch | feature/opportunity-to-outcome |
| Path or archive member | internal/platform/benchimport/benchimport_test.go |
| Original SHA-256 | 634b6da48ac52c71864c1f768fee0a04e9e2ab287a3c4804b23966c7e5d9ecd5 |
| Git blob SHA | 31411c146bec2063871e2d248aa4a3863601158c |
| Reading-copy SHA-256 | 634b6da48ac52c71864c1f768fee0a04e9e2ab287a3c4804b23966c7e5d9ecd5 |
Every recorded occurrence
These 13 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/platform/benchimport/benchimport_test.go | feature/opportunity-to-outcome | 720d47fae476b0d38477ae4401697d372b1ea2bc | Open original |
| Janady13/missionmatch / internal/platform/benchimport/benchimport_test.go | collision-deconfliction | 4ee5a09972608ed89f8377c6665542d5f450f0a6 | Open original |
| Janady13/missionmatch / internal/platform/benchimport/benchimport_test.go | m5-price-to-win | 41000ad30fff4129fdaf5ec84e15ba14c27d4890 | Open original |
| Janady13/missionmatch / internal/platform/benchimport/benchimport_test.go | master | 1e9249840a4302ec82e123b9c9cb6f75badea3e4 | Open original |
| Janady13/missionmatch / internal/platform/benchimport/benchimport_test.go | mag-substrate | b82c7100a492dec67dfd1eda6b3f53def859be35 | Open original |
| Janady13/missionmatch / internal/platform/benchimport/benchimport_test.go | time-to-fill-survival | b66e1e505863d4f17741a4b9ede73509e45bd6c6 | Open original |
| Janady13/missionmatch / internal/platform/benchimport/benchimport_test.go | graphrag-foundation | b0ddeb9f633fd138d09309d1a17b7d13bc3a67f7 | Open original |
| Janady13/missionmatch / internal/platform/benchimport/benchimport_test.go | ws9-bench-ingestion | f585a9ef32fa554663ce1fba9a414a54b6e49cf0 | Open original |
| Janady13/missionmatch / internal/platform/benchimport/benchimport_test.go | presentation-readiness | eb574acaa29d71ce4d0f852572e87c275c79fdb7 | Open original |
| Janady13/missionmatch / internal/platform/benchimport/benchimport_test.go | vendor-intelligence | fe9796a19c261951d3f2565206c0c1b5ac294465 | Open original |
| Janady13/missionmatch / internal/platform/benchimport/benchimport_test.go | phase2-connectors | e038d4c687aec16f8bd9bc4d907eea14d91f8704 | Open original |
| Janady13/missionmatch / internal/platform/benchimport/benchimport_test.go | feature/aioe-upgrade | 2178e7298d0e5d9af83afa12402fd587f0ba6ed8 | Open original |
| Janady13/missionmatch / internal/platform/benchimport/benchimport_test.go | capture-readiness | bae6af7cb2997e819174a9e9cfff5e16067a1975 | Open original |
Recovered source transcript
Download complete source text ↓258 lines · 9.7 KB
package benchimport
import (
"context"
"os"
"path/filepath"
"reflect"
"strings"
"testing"
"github.com/missionworkforce/missionmatch/internal/platform/extraction"
"github.com/missionworkforce/missionmatch/internal/platform/sourcing"
)
// sampleResume carries a person name and an email (the PII that must never be embedded) alongside the
// structured workforce tokens the mapping is allowed to keep.
const sampleResume = `Jane Q Operator
jane.operator@example.com
(505) 555-0142
Albuquerque, NM
SIGINT Analyst with active TS/SCI clearance and 8 years experience.
Skills: Python, Splunk, SIEM, Incident Response, RMF, ATO.
Certifications: CISSP, CompTIA Security+.
Supported the Air Force and NSA.`
// composeEmbedProfile mirrors the name free embed profile the embed-backfill composer builds (the headline
// is JobTitle or Role plus the first six skills, no name, no email), so the invariant 5 test asserts on the
// exact string the inference plane would see. It is a deliberate mirror of sourcing.buildHeadline plus the
// embed-backfill SQL composition, kept here because the source side composers are unexported.
func composeEmbedProfile(sp sourcing.SourcedPerson) string {
skills := sp.Skills
if len(skills) > 6 {
skills = skills[:6]
}
headline := sp.JobTitle
if headline == "" {
headline = sp.Role
}
if len(skills) > 0 {
if headline != "" {
headline += " | "
}
headline += strings.Join(skills, ", ")
}
headline = strings.TrimSpace(headline)
// The embed profile is the headline plus the skills line only, name free and email free by construction
// (the resume mapping never routes a name or an email into the job title, the role, or any skill).
return strings.Join([]string{
headline,
"skills: " + strings.Join(sp.Skills, ", "),
}, " | ")
}
// TestResumeMappingKeepsPIIOutOfEmbedProfile is the invariant 5 test. It feeds a resume containing a name
// and an email, maps it through the resume source, composes the same name free embed profile the embed
// backfill builds, and asserts the composed string contains NEITHER the name NOR the email. It also
// confirms the name is carried on the candidate name field (so it lands in candidates.full_name) and that
// the clearance code is captured for triage but never placed on a scored field.
func TestResumeMappingKeepsPIIOutOfEmbedProfile(t *testing.T) {
s := resumeSource{ext: extraction.NewDeterministic()}
rec, ok := s.mapResume(context.Background(), sampleResume)
if !ok {
t.Fatal("expected the sample resume to yield a record with signal")
}
const name = "Jane Q Operator"
const email = "jane.operator@example.com"
// The name lands only on the candidate name field.
if rec.FullName != name {
t.Fatalf("expected FullName %q on the candidate name field, got %q", name, rec.FullName)
}
// The name and email never reach the title or any embeddable field on the record.
if strings.Contains(rec.JobTitle, "Jane") || strings.Contains(rec.JobTitle, "@") {
t.Fatalf("a name or email leaked into JobTitle: %q", rec.JobTitle)
}
if rec.Email != email {
t.Fatalf("expected the email captured for dedup only, got %q", rec.Email)
}
sp := rec.ToSourcedPerson()
// SourcedPerson must route the name only to FullName, never to JobTitle or Role.
if sp.FullName != name {
t.Fatalf("expected SourcedPerson.FullName %q, got %q", name, sp.FullName)
}
if strings.Contains(sp.JobTitle, "Jane") || strings.Contains(sp.Role, "Jane") {
t.Fatalf("a name leaked into JobTitle or Role: title=%q role=%q", sp.JobTitle, sp.Role)
}
profile := composeEmbedProfile(sp)
if strings.Contains(profile, name) || strings.Contains(profile, "Jane") {
t.Fatalf("the embed profile contains the person name: %q", profile)
}
if strings.Contains(profile, email) || strings.Contains(profile, "@") {
t.Fatalf("the embed profile contains the email: %q", profile)
}
// Sanity: the structured tokens that SHOULD be embedded are present.
if !strings.Contains(profile, "Python") {
t.Fatalf("expected a structured skill in the embed profile: %q", profile)
}
// Clearance is captured for triage only, never on a scored field. ToSourcedPerson has no clearance
// field, so the code can never reach a clearance column.
if rec.ClearanceCode == "" {
t.Fatalf("expected the clearance code captured for triage, got empty")
}
if hasClearanceField(sp) {
t.Fatal("SourcedPerson must not carry a clearance field")
}
}
// hasClearanceField reflectively asserts SourcedPerson exposes no clearance field, so the triage clearance
// code can never ride into a candidate clearance column through the mapping.
func hasClearanceField(sp sourcing.SourcedPerson) bool {
tp := reflect.TypeOf(sp)
for i := 0; i < tp.NumField(); i++ {
if strings.Contains(strings.ToLower(tp.Field(i).Name), "clearance") {
return true
}
}
return false
}
// TestResumeSourceOverDocextractFixtures runs the resume source over the docextract testdata fixtures so
// the end to end path (read file, extract text, run the extractor, map) is exercised on real files of each
// format. Each fixture carries a title token, so each yields a record with a sanitized JobTitle and no PII.
func TestResumeSourceOverDocextractFixtures(t *testing.T) {
dir := filepath.Join("..", "docextract", "testdata")
if _, err := os.Stat(dir); err != nil {
t.Skipf("docextract testdata not present: %v", err)
}
s := NewResumeSource(extraction.NewDeterministic())
var got []BenchRecord
res, err := s.Resumes(context.Background(), dir, func(rec BenchRecord, file string) error {
got = append(got, rec)
// No fixture file path or content may carry a person name into a title.
if strings.Contains(rec.JobTitle, "@") {
t.Fatalf("an email shaped token reached JobTitle from %s: %q", file, rec.JobTitle)
}
return nil
})
if err != nil {
t.Fatalf("Resumes over fixtures: %v", err)
}
if res.Read == 0 {
t.Fatal("expected to read at least one fixture")
}
// The PDF fixture says SIGINT Analyst and the DOCX says ISSO, both title gazetteer hits, so at least
// one record must carry a sanitized title.
var titled int
for _, r := range got {
if r.JobTitle != "" {
titled++
}
}
if titled == 0 {
t.Fatalf("expected at least one fixture to resolve a sanitized title, mapped %d records", len(got))
}
}
// TestResumeWithSampleFile writes a small sample resume to a temp directory and proves the directory walk
// reads it, extracts it, and maps it to a record with the expected structured tokens and no PII in any
// embeddable field.
func TestResumeWithSampleFile(t *testing.T) {
dir := t.TempDir()
if err := os.WriteFile(filepath.Join(dir, "operator.txt"), []byte(sampleResume), 0o644); err != nil {
t.Fatalf("write sample: %v", err)
}
s := NewResumeSource(extraction.NewDeterministic())
var got BenchRecord
res, err := s.Resumes(context.Background(), dir, func(rec BenchRecord, file string) error {
got = rec
return nil
})
if err != nil {
t.Fatalf("Resumes: %v", err)
}
if res.Mapped != 1 {
t.Fatalf("expected 1 mapped record, got %d (read %d skipped %d)", res.Mapped, res.Read, res.Skipped)
}
if got.JobTitle != "Intelligence Analyst" {
t.Fatalf("expected sanitized title Intelligence Analyst, got %q", got.JobTitle)
}
wantSkills := map[string]bool{"Python": true, "Splunk": true, "SIEM": true}
for s := range wantSkills {
if !containsStr(got.Skills, s) {
t.Fatalf("expected skill %q in %v", s, got.Skills)
}
}
if got.ClearanceCode != "ts_sci" {
t.Fatalf("expected triage clearance code ts_sci, got %q", got.ClearanceCode)
}
}
// splitFieldName splits a CamelCase Go field name into lowercased word segments, so "FullName" becomes
// {"full","name"} and a demographic marker is matched as a whole segment, never as a substring of an
// unrelated workforce word.
func splitFieldName(name string) []string {
var segs []string
var cur []rune
for _, r := range name {
if r >= 'A' && r <= 'Z' && len(cur) > 0 {
segs = append(segs, strings.ToLower(string(cur)))
cur = cur[:0]
}
cur = append(cur, r)
}
if len(cur) > 0 {
segs = append(segs, strings.ToLower(string(cur)))
}
return segs
}
func containsStr(xs []string, s string) bool {
for _, x := range xs {
if x == s {
return true
}
}
return false
}
// TestBenchRecordCarriesNoDemographicField is the structural invariant: BenchRecord must carry no protected
// attribute or close proxy. It asserts field by field that none of the field names matches a demographic
// marker, so a future edit that adds a demographic field fails this test by construction.
func TestBenchRecordCarriesNoDemographicField(t *testing.T) {
// Markers match a field name as a whole, lowercased, underscore split segment, so a workforce field
// like "Agencies" is not flagged by the "age" demographic marker on a substring overlap.
markers := map[string]bool{
"race": true, "ethnicity": true, "gender": true, "sex": true, "age": true, "birth": true,
"dob": true, "veteran": true, "disability": true, "nationalorigin": true, "nationality": true,
"religion": true, "marital": true, "pregnancy": true, "demographic": true, "protected": true,
}
tp := reflect.TypeOf(BenchRecord{})
for i := 0; i < tp.NumField(); i++ {
for _, seg := range splitFieldName(tp.Field(i).Name) {
if markers[seg] {
t.Fatalf("BenchRecord field %q has demographic segment %q", tp.Field(i).Name, seg)
}
}
}
// Document the exact allowed field set so an added field is a deliberate, reviewed change.
want := []string{
"FullName", "Location", "JobTitle", "Skills", "Certs", "Agencies",
"Years", "ClearanceCode", "ExternalID", "Email", "Phone",
}
if tp.NumField() != len(want) {
t.Fatalf("BenchRecord field count changed: got %d want %d, review the no demographic field invariant", tp.NumField(), len(want))
}
for i, w := range want {
if tp.Field(i).Name != w {
t.Fatalf("BenchRecord field %d is %q, expected %q", i, tp.Field(i).Name, w)
}
}
}