Source identity
| Field | Recorded value |
|---|---|
| Source type | GitHub source |
| Original record | Janady13/missionmatch / internal/integration/graph_wage_integration_test.go |
| Date | Not specified in source |
| Repository | Janady13/missionmatch |
| Revision | 720d47fae476b0d38477ae4401697d372b1ea2bc |
| Branch | feature/opportunity-to-outcome |
| Path or archive member | internal/integration/graph_wage_integration_test.go |
| Original SHA-256 | 9bbad7b000e0d2168f952d173bc7fbb2cd323d02e61196cc7b223365348d6d8d |
| Git blob SHA | f8cfd0ecb08599219b89edf7a27b23ebbff5e6a5 |
| Reading-copy SHA-256 | 9bbad7b000e0d2168f952d173bc7fbb2cd323d02e61196cc7b223365348d6d8d |
Every recorded occurrence
These 11 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/graph_wage_integration_test.go | feature/opportunity-to-outcome | 720d47fae476b0d38477ae4401697d372b1ea2bc | Open original |
| Janady13/missionmatch / internal/integration/graph_wage_integration_test.go | collision-deconfliction | 4ee5a09972608ed89f8377c6665542d5f450f0a6 | Open original |
| Janady13/missionmatch / internal/integration/graph_wage_integration_test.go | m5-price-to-win | 41000ad30fff4129fdaf5ec84e15ba14c27d4890 | Open original |
| Janady13/missionmatch / internal/integration/graph_wage_integration_test.go | master | 1e9249840a4302ec82e123b9c9cb6f75badea3e4 | Open original |
| Janady13/missionmatch / internal/integration/graph_wage_integration_test.go | mag-substrate | b82c7100a492dec67dfd1eda6b3f53def859be35 | Open original |
| Janady13/missionmatch / internal/integration/graph_wage_integration_test.go | time-to-fill-survival | b66e1e505863d4f17741a4b9ede73509e45bd6c6 | Open original |
| Janady13/missionmatch / internal/integration/graph_wage_integration_test.go | presentation-readiness | eb574acaa29d71ce4d0f852572e87c275c79fdb7 | Open original |
| Janady13/missionmatch / internal/integration/graph_wage_integration_test.go | vendor-intelligence | fe9796a19c261951d3f2565206c0c1b5ac294465 | Open original |
| Janady13/missionmatch / internal/integration/graph_wage_integration_test.go | phase2-connectors | e038d4c687aec16f8bd9bc4d907eea14d91f8704 | Open original |
| Janady13/missionmatch / internal/integration/graph_wage_integration_test.go | feature/aioe-upgrade | 2178e7298d0e5d9af83afa12402fd587f0ba6ed8 | Open original |
| Janady13/missionmatch / internal/integration/graph_wage_integration_test.go | capture-readiness | bae6af7cb2997e819174a9e9cfff5e16067a1975 | Open original |
Recovered source transcript
Download complete source text ↓238 lines · 11.3 KB
//go:build integration
package integration
import (
"context"
"strings"
"testing"
"github.com/google/uuid"
"github.com/jackc/pgx/v5"
"github.com/missionworkforce/missionmatch/internal/modules/ai"
"github.com/missionworkforce/missionmatch/internal/platform/audit"
)
// seedWageBand inserts one bls_wages metric row as the migrator (the global public wage reference the app role
// may only read), keyed by a unique series id per run so parallel runs do not collide. It carries the SOC
// occupation code, the OEWS area code (HI or NM), the metric (annual_mean or annual_median), and the dollar
// value, the columns the M5 wage band read pivots.
func seedWageBand(t *testing.T, seriesID, soc, occTitle, role, area, areaName, metric, value string) {
t.Helper()
if _, err := migrator.Exec(context.Background(),
`INSERT INTO bls_wages
(series_id, occupation_code, occupation_title, role, area, area_name, metric, period_year, value, raw)
VALUES ($1, $2, $3, $4, $5, $6, $7, '2025', $8::numeric, '{}'::jsonb)
ON CONFLICT (occupation_code, area, metric)
DO UPDATE SET series_id = EXCLUDED.series_id, occupation_title = EXCLUDED.occupation_title,
role = EXCLUDED.role, area_name = EXCLUDED.area_name, period_year = EXCLUDED.period_year,
value = EXCLUDED.value`,
seriesID, soc, occTitle, role, area, areaName, metric, value); err != nil {
t.Fatalf("seed wage band %s: %v", seriesID, err)
}
}
// seedRequirementForWage creates a requirement for one org carrying a title (so resolveSOC can bind the role to
// a SOC through the curated crosswalk) and a work_location (so resolveArea can bind the OEWS area), linked to no
// opportunity (the market leg is not the subject here, the price to win leg is). It uses the migrator so the
// seed crosses tenants for the RLS posture, and returns the requirement id.
func seedRequirementForWage(t *testing.T, org uuid.UUID, title, workLocation, level string) uuid.UUID {
t.Helper()
var id uuid.UUID
if err := migrator.QueryRow(context.Background(),
`INSERT INTO requirements (organization_id, title, work_location, required_level, required_poly)
VALUES ($1, $2, $3, $4, 'none') RETURNING id`,
org, title, workLocation, level).Scan(&id); err != nil {
t.Fatalf("seed wage requirement: %v", err)
}
return id
}
// TestM5PriceToWinResolvesTheOEWSBand is the live keystone proof of M5: a requirement whose title resolves to a
// Galapagos role (and thus a SOC through the curated crosswalk) and whose work_location resolves to a known
// OEWS area, with a seeded wage band for that occupation and area, makes the G6 price to win leg carry the REAL
// advisory OEWS annual mean and annual median dollars instead of the honest floor. It also proves the audit
// records price_resolved true (a boolean only, never the dollar value).
func TestM5PriceToWinResolvesTheOEWSBand(t *testing.T) {
org := seedOrg(t)
k := ai.ConfiguredSuppressionThreshold()
run := uuid.NewString()[:8]
// The Program Manager occupation (SOC 113021) in Hawaii, both metrics, unique series ids per run.
seedWageBand(t, "M5-MEAN-"+run, "113021", "Computer and Information Systems Managers", "Program Manager", "HI", "Hawaii", "annual_mean", "185000.00")
seedWageBand(t, "M5-MEDIAN-"+run, "113021", "Computer and Information Systems Managers", "Program Manager", "HI", "Hawaii", "annual_median", "172500.00")
// A requirement whose title carries the Program Manager role and whose work_location is Honolulu, Hawaii, so
// both resolvers bind and the wage band read finds the seeded HI band.
req := seedRequirementForWage(t, org, "Senior Program Manager, Space Systems", "Honolulu, Hawaii", "secret")
// A small bench so the bench legs run without changing the price to win subject of the test.
for i := 0; i < k; i++ {
seedCandidate(t, org, "secret", "active", true)
}
orch := ai.NewOrchestrator(appDB, nil, audit.New(appDB))
resp, err := orch.Answer(ctxOrg(org), "", ai.IntentCapturePictureForRequirement, []any{req.String()})
if err != nil {
t.Fatalf("capture picture answer: %v", err)
}
if resp.Refused || resp.Route != ai.RouteGraph {
t.Fatalf("a bound tenant capture question must answer on the graph route, got %+v", resp)
}
// The price to win leg carries the REAL advisory OEWS band, not the honest floor.
if strings.Contains(resp.Answer, "labor rate data not yet ingested") {
t.Errorf("a requirement with a resolvable role, state, and wage row must not show the honest floor, got %q", resp.Answer)
}
for _, want := range []string{"OEWS labor rate", "Program Manager", "Hawaii", "185000.00", "172500.00", "BLS OEWS", "advisory"} {
if !strings.Contains(resp.Answer, want) {
t.Errorf("the price to win leg must carry %q, got %q", want, resp.Answer)
}
}
// The audit records price_resolved true and carries no dollar value.
assertCaptureAudit(t, org, true, []string{"185000", "172500"})
}
// TestM5PriceToWinKeepsTheFloorWithoutWageData proves the honest floor holds when NO occupation resolves, in two
// cases: a non occupation title in a state with no state baseline (Virginia), and a non occupation title in a
// state that does have a baseline (Hawaii). With the national OEWS baseline present, every RESOLVABLE occupation
// now falls back to a US national band, so the floor is reached only when the title matches no occupation at all.
// In both cases the price to win leg stays the honest floor, no rate is fabricated, and the audit records
// price_resolved false.
func TestM5PriceToWinKeepsTheFloorWithoutWageData(t *testing.T) {
k := ai.ConfiguredSuppressionThreshold()
// Case one: a title that resolves to no occupation, so no SOC binds and the floor holds. With the national
// OEWS baseline present every RESOLVABLE occupation now falls back to a US national band, so the honest floor
// is reached only when the title matches no occupation at all. A short non occupation title matches nothing.
t.Run("title_resolves_to_no_occupation", func(t *testing.T) {
org := seedOrg(t)
req := seedRequirementForWage(t, org, "Zephyr Wrangler", "Arlington, Virginia", "secret")
for i := 0; i < k; i++ {
seedCandidate(t, org, "secret", "active", true)
}
orch := ai.NewOrchestrator(appDB, nil, audit.New(appDB))
resp, err := orch.Answer(ctxOrg(org), "", ai.IntentCapturePictureForRequirement, []any{req.String()})
if err != nil {
t.Fatalf("capture picture answer: %v", err)
}
if !strings.Contains(resp.Answer, "labor rate data not yet ingested") {
t.Errorf("a requirement whose title resolves to no occupation must keep the honest floor, got %q", resp.Answer)
}
if strings.Contains(resp.Answer, "OEWS labor rate") {
t.Errorf("no OEWS rate must be fabricated when no occupation resolves, got %q", resp.Answer)
}
assertCaptureAudit(t, org, false, nil)
})
// Case two: a known area (Hawaii) but a title that matches no Galapagos role, so the SOC does not resolve and
// the floor holds even though wage data exists for other occupations in Hawaii.
t.Run("title_matches_no_role", func(t *testing.T) {
org := seedOrg(t)
run := uuid.NewString()[:8]
// Seed a Hawaii band for an unrelated occupation so the state has data but not for this title's role.
seedWageBand(t, "M5-NOROLE-MEAN-"+run, "113021", "Computer and Information Systems Managers", "Program Manager", "HI", "Hawaii", "annual_mean", "185000.00")
req := seedRequirementForWage(t, org, "Underwater Welding Technician", "Honolulu, Hawaii", "secret")
for i := 0; i < k; i++ {
seedCandidate(t, org, "secret", "active", true)
}
orch := ai.NewOrchestrator(appDB, nil, audit.New(appDB))
resp, err := orch.Answer(ctxOrg(org), "", ai.IntentCapturePictureForRequirement, []any{req.String()})
if err != nil {
t.Fatalf("capture picture answer: %v", err)
}
if !strings.Contains(resp.Answer, "labor rate data not yet ingested") {
t.Errorf("a requirement whose title matches no role must keep the honest floor, got %q", resp.Answer)
}
assertCaptureAudit(t, org, false, nil)
})
}
// TestM5LaborRateBandIntentReturnsTheSeededBand proves the labor_rate_band read directly: seeded with the two
// metric rows for an occupation and area, LaborRateBand pivots them into one band carrying the exact mean and
// median as decimals (never float), the occupation title, the role, and the area name, and returns ok false
// for an occupation and area with no wage row so the honest floor holds upstream.
func TestM5LaborRateBandIntentReturnsTheSeededBand(t *testing.T) {
org := seedOrg(t)
run := uuid.NewString()[:8]
// The Systems Engineer occupation (SOC 151252) in New Mexico, both metrics.
seedWageBand(t, "M5-SE-MEAN-"+run, "151252", "Software Developers", "Systems Engineer", "NM", "New Mexico", "annual_mean", "132000.00")
seedWageBand(t, "M5-SE-MEDIAN-"+run, "151252", "Software Developers", "Systems Engineer", "NM", "New Mexico", "annual_median", "128000.00")
band, ok, err := ai.LaborRateBand(ctxOrg(org), appDB, "151252", "NM")
if err != nil {
t.Fatalf("labor rate band read: %v", err)
}
if !ok {
t.Fatal("the labor rate band read must find the seeded New Mexico band")
}
if band.SOC != "151252" || band.Role != "Systems Engineer" || band.AreaName != "New Mexico" {
t.Errorf("the band must carry the seeded SOC, role, and area name, got %+v", band)
}
if band.AnnualMean.StringFixed(2) != "132000.00" {
t.Errorf("the annual mean must be the exact seeded decimal, got %s", band.AnnualMean.StringFixed(2))
}
if band.AnnualMedian.StringFixed(2) != "128000.00" {
t.Errorf("the annual median must be the exact seeded decimal, got %s", band.AnnualMedian.StringFixed(2))
}
// An occupation and area with no wage row returns ok false so the honest floor holds upstream.
_, ok2, err := ai.LaborRateBand(ctxOrg(org), appDB, "999999", "NM")
if err != nil {
t.Fatalf("labor rate band read for a missing occupation: %v", err)
}
if ok2 {
t.Error("the labor rate band read must return ok false for an occupation with no wage row")
}
}
// assertCaptureAudit reads the aedt.ai.capture_answered audit payloads for an org and asserts price_resolved is
// the expected boolean, and that no forbidden dollar substring (a wage value) ever appears in the counts only
// audit. It renders the boolean the way Postgres serializes jsonb to text (a space after the colon).
func assertCaptureAudit(t *testing.T, org uuid.UUID, wantResolved bool, forbiddenValues []string) {
t.Helper()
var payloads []string
if err := appDB.RunInTenantTx(ctxOrg(org), func(ctx context.Context, tx pgx.Tx) error {
rows, qerr := tx.Query(ctx,
"SELECT new_values::text FROM audit_logs WHERE organization_id=$1 AND action='aedt.ai.capture_answered'", org)
if qerr != nil {
return qerr
}
defer rows.Close()
for rows.Next() {
var p string
if serr := rows.Scan(&p); serr != nil {
return serr
}
payloads = append(payloads, p)
}
return rows.Err()
}); err != nil {
t.Fatalf("read capture audit: %v", err)
}
if len(payloads) == 0 {
t.Fatal("a capture answer must emit an aedt.ai.capture_answered audit event")
}
wantBool := "\"price_resolved\": false"
if wantResolved {
wantBool = "\"price_resolved\": true"
}
var sawExpected bool
for _, p := range payloads {
if strings.Contains(p, wantBool) {
sawExpected = true
}
for _, forbidden := range forbiddenValues {
if strings.Contains(p, forbidden) {
t.Errorf("the capture audit must hold no dollar value, leaked %q in %q", forbidden, p)
}
}
}
if !sawExpected {
t.Errorf("the capture audit must record price_resolved %v", wantResolved)
}
}