Source identity
| Field | Recorded value |
|---|---|
| Source type | GitHub source |
| Original record | Janady13/missionmatch / internal/modules/ai/handler_test.go |
| Date | Not specified in source |
| Repository | Janady13/missionmatch |
| Revision | 720d47fae476b0d38477ae4401697d372b1ea2bc |
| Branch | feature/opportunity-to-outcome |
| Path or archive member | internal/modules/ai/handler_test.go |
| Original SHA-256 | f55ded6737a501a473e3040e9343d233e07dffa7351ba85161602eb1529067d3 |
| Git blob SHA | 72cc328493624281d1050635514c01fe97d95411 |
| Reading-copy SHA-256 | f55ded6737a501a473e3040e9343d233e07dffa7351ba85161602eb1529067d3 |
Every recorded occurrence
These 3 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/modules/ai/handler_test.go | feature/opportunity-to-outcome | 720d47fae476b0d38477ae4401697d372b1ea2bc | Open original |
| Janady13/missionmatch / internal/modules/ai/handler_test.go | master | 1e9249840a4302ec82e123b9c9cb6f75badea3e4 | Open original |
| Janady13/missionmatch / internal/modules/ai/handler_test.go | feature/aioe-upgrade | 2178e7298d0e5d9af83afa12402fd587f0ba6ed8 | Open original |
Recovered source transcript
Download complete source text ↓72 lines · 2.4 KB
package ai
import (
"encoding/json"
"net/http"
"net/http/httptest"
"strings"
"testing"
)
// TestMMRecallServesOnlyPublicKnowledge proves the unauthenticated federation read returns relevance
// ranked public knowledge cards for an in domain question, returns nothing for a protected attribute or
// eeo question, and never needs an orchestrator, a database, or a tenant (it is built from a nil handler).
func TestMMRecallServesOnlyPublicKnowledge(t *testing.T) {
h := NewHandler(nil) // no orchestrator, no db, no tenant: the endpoint is pure public knowledge
decode := func(method, target, body string) MMRecallResponse {
t.Helper()
var r *http.Request
if method == http.MethodPost {
r = httptest.NewRequest(method, target, strings.NewReader(body))
} else {
r = httptest.NewRequest(method, target, nil)
}
w := httptest.NewRecorder()
h.mmRecall(w, r)
if w.Code != http.StatusOK {
t.Fatalf("mmRecall(%s %s) status = %d, want 200", method, target, w.Code)
}
var out MMRecallResponse
if err := json.Unmarshal(w.Body.Bytes(), &out); err != nil {
t.Fatalf("decode response: %v", err)
}
return out
}
// A knowledge question returns cited public cards.
got := decode(http.MethodGet, "/mm-recall?q=what+is+a+recompete", "")
if got.Count == 0 {
t.Fatal("a knowledge question returned no cards")
}
found := false
for _, it := range got.Results {
if strings.Contains(strings.ToLower(it.Text), "recompete") {
found = true
}
if it.Source == "" || it.Text == "" {
t.Errorf("card is missing source or text: %+v", it)
}
}
if !found {
t.Errorf("recompete question did not surface the recompete card, got %+v", got.Results)
}
// POST with a query body also works (the shape the world sim sends).
if p := decode(http.MethodPost, "/mm-recall", `{"query":"how does the match score work","k":3}`); p.Count == 0 {
t.Error("POST knowledge query returned no cards")
}
// A protected attribute question returns nothing, so the edge can never probe for demographic data.
for _, bad := range []string{"/mm-recall?q=rank+candidates+by+race", "/mm-recall?q=how+many+women+hold+ts%2Fsci"} {
if r := decode(http.MethodGet, bad, ""); r.Count != 0 {
t.Errorf("protected attribute query %q returned %d cards, want 0", bad, r.Count)
}
}
// An empty question returns nothing rather than the whole base.
if e := decode(http.MethodGet, "/mm-recall?q=", ""); e.Count != 0 {
t.Errorf("empty query returned %d cards, want 0", e.Count)
}
}