Source identity
| Field | Recorded value |
|---|---|
| Source type | GitHub source |
| Original record | Janady13/missionmatch / internal/integration/mag_reranker_live_integration_test.go |
| Date | Not specified in source |
| Repository | Janady13/missionmatch |
| Revision | 720d47fae476b0d38477ae4401697d372b1ea2bc |
| Branch | feature/opportunity-to-outcome |
| Path or archive member | internal/integration/mag_reranker_live_integration_test.go |
| Original SHA-256 | 0dac1df9be12ab39ea011f37ffe8ed44efe3cf0ccec9ac9b20763457bfc0fb70 |
| Git blob SHA | 3a370b79279e52ee3a425ddf4bb2d1cf68bf7c7d |
| Reading-copy SHA-256 | 0dac1df9be12ab39ea011f37ffe8ed44efe3cf0ccec9ac9b20763457bfc0fb70 |
Every recorded occurrence
These 10 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/mag_reranker_live_integration_test.go | feature/opportunity-to-outcome | 720d47fae476b0d38477ae4401697d372b1ea2bc | Open original |
| Janady13/missionmatch / internal/integration/mag_reranker_live_integration_test.go | collision-deconfliction | 4ee5a09972608ed89f8377c6665542d5f450f0a6 | Open original |
| Janady13/missionmatch / internal/integration/mag_reranker_live_integration_test.go | master | 1e9249840a4302ec82e123b9c9cb6f75badea3e4 | Open original |
| Janady13/missionmatch / internal/integration/mag_reranker_live_integration_test.go | mag-substrate | b82c7100a492dec67dfd1eda6b3f53def859be35 | Open original |
| Janady13/missionmatch / internal/integration/mag_reranker_live_integration_test.go | time-to-fill-survival | b66e1e505863d4f17741a4b9ede73509e45bd6c6 | Open original |
| Janady13/missionmatch / internal/integration/mag_reranker_live_integration_test.go | presentation-readiness | eb574acaa29d71ce4d0f852572e87c275c79fdb7 | Open original |
| Janady13/missionmatch / internal/integration/mag_reranker_live_integration_test.go | vendor-intelligence | fe9796a19c261951d3f2565206c0c1b5ac294465 | Open original |
| Janady13/missionmatch / internal/integration/mag_reranker_live_integration_test.go | phase2-connectors | e038d4c687aec16f8bd9bc4d907eea14d91f8704 | Open original |
| Janady13/missionmatch / internal/integration/mag_reranker_live_integration_test.go | feature/aioe-upgrade | 2178e7298d0e5d9af83afa12402fd587f0ba6ed8 | Open original |
| Janady13/missionmatch / internal/integration/mag_reranker_live_integration_test.go | capture-readiness | bae6af7cb2997e819174a9e9cfff5e16067a1975 | Open original |
Recovered source transcript
Download complete source text ↓108 lines · 4.9 KB
//go:build integration
// MAG display order re ranker LIVE wiring integration. Proves that slateMATCH GenerateSlate actually APPLIES the
// champion display order re ranker to the member order in the product: under the prior only champion the order
// is the frozen engine order, and once a LEARNED re ranker is promoted the SAME slate comes back in the learned
// order, with the frozen engine total_score of every member UNCHANGED (the re ranker permutes the display order,
// never a score; a human still approves every member).
//
// Run: go test -tags=integration ./internal/integration/ -run MAGRerankerLive -v
// Env: MM_APP_DSN, MM_MIGRATOR_DSN.
package integration
import (
"context"
"testing"
"github.com/missionworkforce/missionmatch/internal/modules/matching"
"github.com/missionworkforce/missionmatch/internal/platform/database/dbgen"
"github.com/missionworkforce/missionmatch/internal/platform/magstore"
)
func TestMAGRerankerLiveGenerateSlateAppliesTheChampionOrder(t *testing.T) {
modelKey := magstore.RerankModelKey
const priorOnlyVersion = 1
ctx := context.Background()
// Reset the re ranker champion to the prior only engine order v1, and restore it on cleanup.
if _, err := magstore.PromoteChampion(ctx, migrator, modelKey, priorOnlyVersion); err != nil {
t.Fatalf("reset reranker champion: %v", err)
}
t.Cleanup(func() {
if _, cerr := magstore.PromoteChampion(ctx, migrator, modelKey, priorOnlyVersion); cerr != nil {
t.Logf("cleanup: could not restore prior only reranker champion: %v", cerr)
}
})
org := seedOrg(t)
// A requirement at secret clearance. Two candidates identical except clearance: the high one exceeds (a 100
// clearance sub score, so the higher engine total), the low one is below (a 0 clearance sub score). The
// engine orders the high clearance candidate first.
req, err := dbgen.New(migrator).CreateRequirement(ctx, dbgen.CreateRequirementParams{
OrganizationID: org, Title: "Reranker Live Role", RequiredLevel: "secret", RequiredPoly: "none",
})
if err != nil {
t.Fatalf("create requirement: %v", err)
}
high := seedCandidate(t, org, "ts_sci", "active", true) // exceeds secret => clearance 100
low := seedCandidate(t, org, "confidential", "active", true) // below secret => clearance 0
svc := matching.NewService(appDB, nil, nil)
// Under the prior only champion the display order is the engine order: the high clearance candidate first.
base, err := svc.GenerateSlate(ctxOrg(org), matching.GenerateSlateInput{RequirementID: req.ID, Name: "base"})
if err != nil {
t.Fatalf("generate base slate: %v", err)
}
if len(base.Members) != 2 {
t.Fatalf("expected 2 members, got %d", len(base.Members))
}
if base.Members[0].CandidateID != high.ID.String() {
t.Fatalf("the engine order must rank the high clearance candidate first, got %s", base.Members[0].CandidateID)
}
baseTotals := map[string]string{}
for _, m := range base.Members {
baseTotals[m.CandidateID] = m.Total
}
t.Logf("engine order: 1=%s 2=%s", base.Members[0].CandidateID, base.Members[1].CandidateID)
// Promote a LEARNED re ranker that inverts clearance (weight minus one on clearance, zero elsewhere), so its
// utility ranks the LOW clearance candidate first, the opposite of the engine.
version, err := magstore.WriteChallenger(ctx, migrator, modelKey, magstore.Challenger{
Family: "pairwise_logistic",
OutputKind: "display_order",
FeatureNames: magstore.RerankFeatureOrder,
Intercept: 0,
Coeffs: []float64{-1, 0, 0, 0, 0, 0}, // minus one on clearance_score, the rest zero
Notes: "test: clearance inverting re ranker for the live wiring proof",
})
if err != nil {
t.Fatalf("write learned challenger: %v", err)
}
if _, err := magstore.PromoteChampion(ctx, migrator, modelKey, version); err != nil {
t.Fatalf("promote learned reranker: %v", err)
}
// Under the learned champion the SAME slate comes back in the learned order: the low clearance candidate now
// surfaces first, the display order flipped.
learned, err := svc.GenerateSlate(ctxOrg(org), matching.GenerateSlateInput{RequirementID: req.ID, Name: "learned"})
if err != nil {
t.Fatalf("generate learned slate: %v", err)
}
if learned.Members[0].CandidateID != low.ID.String() {
t.Fatalf("the learned re ranker must surface the low clearance candidate first, got %s", learned.Members[0].CandidateID)
}
if learned.Members[0].Rank != 1 {
t.Fatalf("the top member must carry display rank 1, got %d", learned.Members[0].Rank)
}
t.Logf("learned order: 1=%s 2=%s (the display order flipped)", learned.Members[0].CandidateID, learned.Members[1].CandidateID)
// The frozen engine total_score of every member is UNCHANGED between the two orders: the re ranker permuted
// the display order only, never a score.
for _, m := range learned.Members {
if base := baseTotals[m.CandidateID]; base != m.Total {
t.Errorf("candidate %s total changed from %s to %s; the re ranker must never change the engine score", m.CandidateID, base, m.Total)
}
}
}