ThatAIguyA world of ideas

THE CONSCIOUSNESS ATLAS
Read. Experiment. Follow the evidence.

ConsciousnessLearn · Explore · Joseph Anady

Janady13/missionmatch / internal/integration/staffing_integration_test.go

Source identity, revision, and recovered contents.

GitHub sourceSource text recovered

Source identity

FieldRecorded value
Source typeGitHub source
Original recordJanady13/missionmatch / internal/integration/staffing_integration_test.go
DateNot specified in source
RepositoryJanady13/missionmatch
Revision720d47fae476b0d38477ae4401697d372b1ea2bc
Branchfeature/opportunity-to-outcome
Path or archive memberinternal/integration/staffing_integration_test.go
Original SHA-256a16919282b2db3fb3cb27b4b475f1abccb7646716f353070d1f9e65ca764b299
Git blob SHAb9dec011e9a560e50f71904ec133599e94731d6b
Reading-copy SHA-256a16919282b2db3fb3cb27b4b475f1abccb7646716f353070d1f9e65ca764b299

Original source ↗

Every recorded occurrence

These 24 records contain identical original source bytes. Their paths and revisions remain part of the archive.

Original recordBranch or archiveRevision / identifierOriginal location
Janady13/missionmatch / internal/integration/staffing_integration_test.gofeature/opportunity-to-outcome720d47fae476b0d38477ae4401697d372b1ea2bcOpen original
Janady13/missionmatch / internal/integration/staffing_integration_test.goper-tenant-routing9bde0f9a74b89d01980fa658e5253acda7528d0cOpen original
Janady13/missionmatch / internal/integration/staffing_integration_test.gocollision-deconfliction4ee5a09972608ed89f8377c6665542d5f450f0a6Open original
Janady13/missionmatch / internal/integration/staffing_integration_test.gows6-retrieval6c56e29231ec05735927fa265c97d517499dfeafOpen original
Janady13/missionmatch / internal/integration/staffing_integration_test.gom5-price-to-win41000ad30fff4129fdaf5ec84e15ba14c27d4890Open original
Janady13/missionmatch / internal/integration/staffing_integration_test.gows1-ontology-syncb596f449a32a1016fbd403c36505cc00a1ac9ee6Open original
Janady13/missionmatch / internal/integration/staffing_integration_test.gomaster1e9249840a4302ec82e123b9c9cb6f75badea3e4Open original
Janady13/missionmatch / internal/integration/staffing_integration_test.gows8-teaching-loopc823f0fb6bb2aba0f39001eb6de96f4000d9321fOpen original
Janady13/missionmatch / internal/integration/staffing_integration_test.gow3-ai-staffing-recommendations43d56387270ef4da4cabd794d97ca6a49909bc7dOpen original
Janady13/missionmatch / internal/integration/staffing_integration_test.gomag-substrateb82c7100a492dec67dfd1eda6b3f53def859be35Open original
Janady13/missionmatch / internal/integration/staffing_integration_test.gows3-clearance4b8e7ce594c068621867f9c9deed0ec64ae6c553Open original
Janady13/missionmatch / internal/integration/staffing_integration_test.gophase2-eval-fairnessd361af254701975fe239927656ababb56374655eOpen original
Janady13/missionmatch / internal/integration/staffing_integration_test.gotime-to-fill-survivalb66e1e505863d4f17741a4b9ede73509e45bd6c6Open original
Janady13/missionmatch / internal/integration/staffing_integration_test.gographrag-foundationb0ddeb9f633fd138d09309d1a17b7d13bc3a67f7Open original
Janady13/missionmatch / internal/integration/staffing_integration_test.godeploy-and-opsbdacd9d0b4d5998d25fc74bf4007f4c3ec538c7aOpen original
Janady13/missionmatch / internal/integration/staffing_integration_test.gows9-bench-ingestionf585a9ef32fa554663ce1fba9a414a54b6e49cf0Open original
Janady13/missionmatch / internal/integration/staffing_integration_test.gows2-alias-relationshipe4dada4601c6eb101830f9d223a9655dfa120616Open original
Janady13/missionmatch / internal/integration/staffing_integration_test.gopresentation-readinesseb574acaa29d71ce4d0f852572e87c275c79fdb7Open original
Janady13/missionmatch / internal/integration/staffing_integration_test.govendor-intelligencefe9796a19c261951d3f2565206c0c1b5ac294465Open original
Janady13/missionmatch / internal/integration/staffing_integration_test.gows7-federal-signal6a9f6ce9cfb13345ffb47770d4960e7c2d9c17c2Open original
Janady13/missionmatch / internal/integration/staffing_integration_test.goai-brain-liveaac32fc49c878cc5bca099459307611562d0bac1Open original
Janady13/missionmatch / internal/integration/staffing_integration_test.gophase2-connectorse038d4c687aec16f8bd9bc4d907eea14d91f8704Open original
Janady13/missionmatch / internal/integration/staffing_integration_test.gofeature/aioe-upgrade2178e7298d0e5d9af83afa12402fd587f0ba6ed8Open original
Janady13/missionmatch / internal/integration/staffing_integration_test.gocapture-readinessbae6af7cb2997e819174a9e9cfff5e16067a1975Open original

Recovered source transcript

//go:build integration package integration import ( "context" "errors" "testing" "github.com/google/uuid" "github.com/jackc/pgx/v5" "github.com/missionworkforce/missionmatch/internal/modules/sourcing" "github.com/missionworkforce/missionmatch/internal/modules/staffing" "github.com/missionworkforce/missionmatch/internal/platform/audit" "github.com/missionworkforce/missionmatch/internal/platform/tenant" ) // newStaffingSvc builds the W3 service against the live app pool with an exact only matcher (nil) and NO // inference client, so every rationale takes the deterministic fallback (the faithfulness fallback path). func newStaffingSvc() *staffing.Service { return staffing.NewService(appDB, nil, audit.New(appDB), nil, staffing.DefaultConfig()) } func seedW3User(t *testing.T, org uuid.UUID) context.Context { t.Helper() var userID uuid.UUID if err := migrator.QueryRow(context.Background(), `INSERT INTO users (organization_id, email, full_name, role, status) VALUES ($1, $2, 'W3 Tester', 'owner', 'active') RETURNING id`, org, "w3-"+org.String()[:8]+"@example.com").Scan(&userID); err != nil { t.Fatalf("seed user: %v", err) } return tenant.WithUser(tenant.WithOrg(context.Background(), org.String()), tenant.Principal{UserID: userID.String(), Role: "owner"}) } func seedReq(t *testing.T, org uuid.UUID, level string, years, quantity int32) uuid.UUID { t.Helper() var id uuid.UUID if err := migrator.QueryRow(context.Background(), `INSERT INTO requirements (organization_id, title, labor_category, quantity, required_level, required_poly, required_years) VALUES ($1, 'W3 Role', 'W3 Role', $2, $3, 'none', $4) RETURNING id`, org, quantity, level, years).Scan(&id); err != nil { t.Fatalf("seed requirement: %v", err) } return id } // TestStaffingGapEndToEnd proves the gap view: a qualified, available candidate becomes an ASSIGN and the // unfilled slot becomes a SOURCE note, every non source recommendation references a real frozen // candidate_evaluations row, the run is audited, and (with no inference client) the rationale takes the // deterministic fallback while the recommendation still stands. func TestStaffingGapEndToEnd(t *testing.T) { ctx := context.Background() org := seedOrg(t) userCtx := seedW3User(t, org) req := seedReq(t, org, "secret", 5, 2) // two open slots strong := seedCandidate(t, org, "secret", "active", true) if _, err := migrator.Exec(ctx, "UPDATE candidates SET years_experience=10 WHERE id=$1", strong.ID); err != nil { t.Fatalf("enrich strong: %v", err) } seedCandidate(t, org, "none", "active", true) // below the floor (no clearance), no reskill path svc := newStaffingSvc() out, err := svc.GenerateGap(userCtx, req, staffing.GapRequest{}) if err != nil { t.Fatalf("GenerateGap: %v", err) } var assign, source int for _, r := range out.Recommendations { switch r.Action { case "assign": assign++ if r.CandidateID != strong.ID.String() { t.Fatalf("assign should be the strong candidate, got %s", r.CandidateID) } if r.RationaleSource != "deterministic" || r.Rationale == "" { t.Fatalf("with no plane the rationale must be a non empty deterministic fallback, got source=%s rationale=%q", r.RationaleSource, r.Rationale) } // Every non source recommendation references a real frozen evaluation. assertEvaluationExists(t, org, strong.ID, req) case "source": source++ if r.CandidateID != "" { t.Fatalf("a source recommendation must name no candidate, got %s", r.CandidateID) } } } if assign != 1 || source != 1 { t.Fatalf("want 1 assign + 1 source, got assign=%d source=%d (%d recs)", assign, source, len(out.Recommendations)) } // The run is audited (no PII), and the served score for the surfaced candidate is recorded. assertAuditCount(t, org, "aedt.staffing.recommended", 1) if n := auditCount(t, org, "aedt.score.served"); n < 1 { t.Fatalf("want at least one served score audit, got %d", n) } } // TestStaffingPortfolioEndToEnd proves the portfolio optimizer allocates the available bench across open // requirements, each assignment carrying a scaled value and a counterfactual. func TestStaffingPortfolioEndToEnd(t *testing.T) { org := seedOrg(t) userCtx := seedW3User(t, org) seedReq(t, org, "secret", 0, 1) // two open single slot requirements; the portfolio reads all open ones seedReq(t, org, "secret", 0, 1) c1 := seedCandidate(t, org, "secret", "active", true) c2 := seedCandidate(t, org, "secret", "active", true) svc := newStaffingSvc() out, err := svc.GeneratePortfolio(userCtx, staffing.PortfolioRequest{}) if err != nil { t.Fatalf("GeneratePortfolio: %v", err) } assigns := 0 assigned := map[string]bool{} for _, r := range out.Recommendations { if r.Action != "assign" { continue } assigns++ assigned[r.CandidateID] = true if r.ValueScore == nil || *r.ValueScore <= 0 { t.Fatalf("a portfolio assign must carry a positive scaled value, got %+v", r.ValueScore) } if len(r.Evidence) == 0 { t.Fatalf("a portfolio assign must carry counterfactual evidence") } } if assigns != 2 || !assigned[c1.ID.String()] || !assigned[c2.ID.String()] { t.Fatalf("both candidates should be allocated to the two open slots, got %d assigns %v", assigns, assigned) } assertAuditCount(t, org, "aedt.staffing.recommended", 1) } // TestStaffingProactiveEndToEnd proves the proactive recompute writes a bench watch the read endpoint // returns. func TestStaffingProactiveEndToEnd(t *testing.T) { org := seedOrg(t) seedReq(t, org, "secret", 0, 1) cand := seedCandidate(t, org, "secret", "active", true) svc := newStaffingSvc() n, err := svc.RecomputeProactive(ctxOrg(org)) if err != nil { t.Fatalf("RecomputeProactive: %v", err) } if n < 1 { t.Fatalf("expected at least one candidate watch, got %d", n) } pr, err := svc.ListProactive(ctxOrg(org), 0, 0) if err != nil { t.Fatalf("ListProactive: %v", err) } found := false for _, r := range pr.Recommendations { if r.CandidateID == cand.ID.String() && r.Action == "assign" && r.Status == "pending" { found = true } } if !found { t.Fatalf("the available candidate must appear in the bench watch, got %+v", pr.Recommendations) } } // TestStaffingDecisionAndConflict proves the human in the loop decision path: a pending recommendation can // be approved once, a second decision returns 409 (never overwriting a decided row), the decision is // audited, and nothing is auto rejected. func TestStaffingDecisionAndConflict(t *testing.T) { org := seedOrg(t) userCtx := seedW3User(t, org) req := seedReq(t, org, "secret", 5, 1) strong := seedCandidate(t, org, "secret", "active", true) if _, err := migrator.Exec(context.Background(), "UPDATE candidates SET years_experience=10 WHERE id=$1", strong.ID); err != nil { t.Fatalf("enrich strong: %v", err) } svc := newStaffingSvc() out, err := svc.GenerateGap(userCtx, req, staffing.GapRequest{}) if err != nil { t.Fatalf("GenerateGap: %v", err) } var assignID uuid.UUID for _, r := range out.Recommendations { if r.Action == "assign" { assignID = uuid.MustParse(r.ID) } if r.Status != "pending" { t.Fatalf("a fresh recommendation must be pending (never auto decided), got %s for %s", r.Status, r.Action) } } if assignID == uuid.Nil { t.Fatal("no assign recommendation to decide") } if _, err := svc.Decide(userCtx, assignID, staffing.DecisionRequest{Decision: "approved", Note: "strong fit"}); err != nil { t.Fatalf("first decision should succeed: %v", err) } // A second decision on the now decided row must conflict, not silently overwrite. if _, err := svc.Decide(userCtx, assignID, staffing.DecisionRequest{Decision: "rejected"}); !errors.Is(err, staffing.ErrConflict) { t.Fatalf("second decision must return ErrConflict, got %v", err) } assertAuditCount(t, org, "aedt.staffing.decided", 1) } // TestStaffingErasureRemovesRecommendations proves the right to erasure: anonymizing a candidate removes // their staffing recommendations (the FK cascade does not fire on anonymize in place, so the cleanup is // explicit). func TestStaffingErasureRemovesRecommendations(t *testing.T) { org := seedOrg(t) userCtx := seedW3User(t, org) req := seedReq(t, org, "secret", 5, 1) strong := seedCandidate(t, org, "secret", "active", true) if _, err := migrator.Exec(context.Background(), "UPDATE candidates SET years_experience=10 WHERE id=$1", strong.ID); err != nil { t.Fatalf("enrich strong: %v", err) } svc := newStaffingSvc() if _, err := svc.GenerateGap(userCtx, req, staffing.GapRequest{}); err != nil { t.Fatalf("GenerateGap: %v", err) } if n := recCountForCandidate(t, org, strong.ID); n < 1 { t.Fatalf("expected at least one recommendation for the candidate before erasure, got %d", n) } if err := sourcing.NewService(appDB, audit.New(appDB)).Delete(userCtx, strong.ID); err != nil { t.Fatalf("erasure: %v", err) } if n := recCountForCandidate(t, org, strong.ID); n != 0 { t.Fatalf("erasure must remove the candidate's recommendations, %d remain", n) } } // ---------- assertions ---------- func assertEvaluationExists(t *testing.T, org, cand, req uuid.UUID) { t.Helper() var n int if err := appDB.RunInTenantTx(ctxOrg(org), func(ctx context.Context, tx pgx.Tx) error { return tx.QueryRow(ctx, "SELECT count(*) FROM candidate_evaluations WHERE candidate_id=$1 AND requirement_id=$2", cand, req).Scan(&n) }); err != nil { t.Fatalf("count evaluations: %v", err) } if n != 1 { t.Fatalf("recommendation must reference exactly one frozen evaluation for (cand, req), got %d", n) } } func auditCount(t *testing.T, org uuid.UUID, action string) int { t.Helper() var n int if err := appDB.RunInTenantTx(ctxOrg(org), func(ctx context.Context, tx pgx.Tx) error { return tx.QueryRow(ctx, "SELECT count(*) FROM audit_logs WHERE organization_id=$1 AND action=$2", org, action).Scan(&n) }); err != nil { t.Fatalf("count audits %s: %v", action, err) } return n } func assertAuditCount(t *testing.T, org uuid.UUID, action string, want int) { t.Helper() if n := auditCount(t, org, action); n != want { t.Fatalf("want %d %s audit events, got %d", want, action, n) } } func recCountForCandidate(t *testing.T, org, cand uuid.UUID) int { t.Helper() var n int if err := appDB.RunInTenantTx(ctxOrg(org), func(ctx context.Context, tx pgx.Tx) error { return tx.QueryRow(ctx, "SELECT count(*) FROM staffing_recommendations WHERE candidate_id=$1", cand).Scan(&n) }); err != nil { t.Fatalf("count recs: %v", err) } return n }

Search equations, builds, manuscript text, and recovered sources.