package ai import "testing" func TestMissionFromQuestion(t *testing.T) { cases := []struct { name string question string want string }{ {"acronym sigint", "Who has SIGINT experience and a TS clearance?", "SIGINT"}, {"spelled signals intelligence", "find candidates with signals intelligence background", "SIGINT"}, {"geoint acronym", "show me GEOINT analysts", "GEOINT"}, {"geospatial intelligence phrase", "which candidate has geospatial intelligence work", "GEOINT"}, {"humint", "list humint collectors", "HUMINT"}, {"masint", "top MASINT engineers", "MASINT"}, {"osint", "best osint researcher", "OSINT"}, {"open source intelligence phrase", "who did open source intelligence", "OSINT"}, {"satellite c2", "find satellite c2 operators", "Satellite C2"}, {"satellite command and control phrase", "candidates with satellite command and control", "Satellite C2"}, {"cross domain solution", "who built a cross domain solution", "Cross Domain Solution"}, {"comsec", "comsec custodian needed", "COMSEC"}, {"communications security phrase", "communications security specialist", "COMSEC"}, {"tempest", "tempest testing engineer", "TEMPEST"}, {"electronic warfare phrase", "electronic warfare officer", "Electronic Warfare"}, {"no mission", "who has a Secret clearance in Hawaii", ""}, {"empty", "", ""}, // A bare acronym must match on a word boundary, never inside another word. {"no false positive inside word", "candidates in Washington with cdsa tooling", ""}, // Deterministic first match when two missions are named: mission_spine order wins (SIGINT before GEOINT). {"deterministic first match", "needs both geoint and sigint", "SIGINT"}, // A multi word form tolerates extra whitespace or a line break between tokens. {"phrase double space", "find satellite command and control operators", "Satellite C2"}, {"phrase newline", "candidates with open source\nintelligence", "OSINT"}, } for _, tc := range cases { t.Run(tc.name, func(t *testing.T) { got := MissionFromQuestion(tc.question) if got != tc.want { t.Fatalf("MissionFromQuestion(%q) = %q, want %q", tc.question, got, tc.want) } }) } } // TestMissionCodeForTerm pins the term to code map (the bridge from the WS6 keyword to the WS7 structured // candidate_mission_tags.mission_code) to the mission_areas vocabulary, covering all ten terms, the multi // word terms whose code differs from the term, and the no match case. func TestMissionCodeForTerm(t *testing.T) { cases := []struct { term string want string }{ {"SIGINT", "SIGINT"}, {"GEOINT", "GEOINT"}, {"HUMINT", "HUMINT"}, {"MASINT", "MASINT"}, {"OSINT", "OSINT"}, {"Satellite C2", "SAT_C2"}, {"Cross Domain Solution", "CDS"}, {"COMSEC", "COMSEC"}, {"TEMPEST", "TEMPEST"}, {"Electronic Warfare", "EW"}, {"", ""}, {"not a mission", ""}, } for _, tc := range cases { if got := MissionCodeForTerm(tc.term); got != tc.want { t.Fatalf("MissionCodeForTerm(%q) = %q, want %q", tc.term, got, tc.want) } } // The map must cover exactly the ten missions, no more, no fewer, so it cannot silently drift from the // mission_areas vocabulary. if len(missionTermToCode) != 10 { t.Fatalf("missionTermToCode has %d entries, want 10", len(missionTermToCode)) } } // TestMissionCodeFromQuestion proves the question to code path detects the mission exactly as the WS6 // MissionFromQuestion does and then maps to the structured code, including the multi word missions and the // no mission case. func TestMissionCodeFromQuestion(t *testing.T) { cases := []struct { question string want string }{ {"Who has SIGINT experience and a TS clearance?", "SIGINT"}, {"find candidates with signals intelligence background", "SIGINT"}, {"find satellite c2 operators", "SAT_C2"}, {"candidates with satellite command and control", "SAT_C2"}, {"who built a cross domain solution", "CDS"}, {"electronic warfare officer", "EW"}, {"who has a Secret clearance in Hawaii", ""}, {"", ""}, // Deterministic first match: mission_spine order wins (SIGINT before GEOINT) then maps to its code. {"needs both geoint and sigint", "SIGINT"}, } for _, tc := range cases { if got := MissionCodeFromQuestion(tc.question); got != tc.want { t.Fatalf("MissionCodeFromQuestion(%q) = %q, want %q", tc.question, got, tc.want) } } }