ThatAIguyA world of ideas

THE CONSCIOUSNESS ATLAS
Read. Experiment. Follow the evidence.

ConsciousnessLearn · Explore · Joseph Anady

Janady13/missionmatch / internal/modules/matching/golden_test.go

Source identity, revision, and recovered contents.

GitHub sourceSource text recovered

Source identity

FieldRecorded value
Source typeGitHub source
Original recordJanady13/missionmatch / internal/modules/matching/golden_test.go
DateNot specified in source
RepositoryJanady13/missionmatch
Revisione4dada4601c6eb101830f9d223a9655dfa120616
Branchws2-alias-relationship
Path or archive memberinternal/modules/matching/golden_test.go
Original SHA-256fb0b6da6320bd6c8286aa07b9873e00ae916753d76551dae94d46ecef7b6e40f
Git blob SHAf187113349b7ad2f17ff40f04df81f50c1afd3ab
Reading-copy SHA-256fb0b6da6320bd6c8286aa07b9873e00ae916753d76551dae94d46ecef7b6e40f

Original source ↗

Recovered source transcript

package matching import ( "context" "testing" "github.com/shopspring/decimal" "github.com/missionworkforce/missionmatch/internal/modules/matching/engine" ) // TestGoldenAliasAndRelationship scores two new golden cases through the full engine with a // ChainedResolver wrapping an in-memory DeterministicAliasResolver (newResolverFromMaps). These // cases prove that alias resolution (exact canonical equivalence) and relationship resolution // (substitutes_for partial credit) both flow correctly from the curated ontology layer through // matchOne into the scored MatchResult. // // The three frozen golden cases in engine/golden_test.go are untouched and remain the contract // for the shared scoring weights and band cuts. // // Shared ontology maps for both cases: // // nameToID: "sigint" => sigintID // "skill b" => skillBID // "skill a" => skillAID // aliasToID: "signals intelligence" => sigintID // rels: skillAID => [{toID: skillBID, relation: "substitutes_for", strength: 0.80}] const ( sigintID = "00000000-0000-0000-0000-0000000000a1" skillBID = "00000000-0000-0000-0000-0000000000b1" skillAID = "00000000-0000-0000-0000-0000000000c1" ) func aliasGoldenMatcher() *ChainedResolver { nameToID := map[string]string{ "sigint": sigintID, "skill b": skillBID, "skill a": skillAID, } aliasToID := map[string]string{ "signals intelligence": sigintID, } rels := map[string][]relEdge{ skillAID: { {toID: skillBID, relation: "substitutes_for", strength: decimal.RequireFromString("0.80")}, }, } return NewChainedResolver(newResolverFromMaps(nameToID, aliasToID, rels), nil) } // aliasGoldenReq returns a requirement for exactly one skill (SIGINT by id) with no other // mandatory dimensions, so the skill subscore is isolated cleanly. func aliasGoldenReq() engine.Requirement { return engine.Requirement{ ID: "req-alias-golden", RequiredSkills: []engine.RequiredSkill{ {SkillID: sigintID, Name: "SIGINT", Mandatory: true}, }, } } // relationshipGoldenReq returns a requirement for exactly one skill (Skill B by id) with no // other mandatory dimensions. func relationshipGoldenReq() engine.Requirement { return engine.Requirement{ ID: "req-rel-golden", RequiredSkills: []engine.RequiredSkill{ {SkillID: skillBID, Name: "Skill B", Mandatory: true}, }, } } // TestGoldenAliasExactMatch proves that a candidate holding a skill named "Signals Intelligence" // (a curated alias for SIGINT) resolves through the ChainedResolver to a full match: the Skills // component is 100, AliasMatched is true, Similarity is 1.0, and the total is 100.00. // // Engine note: matchOne sets Exact=false for every sm-sourced match (the engine owns the match // flags; the matcher only supplies candidate side and similarity). The alias resolver returns // AliasMatched=true to distinguish this path from a semantic cosine match. func TestGoldenAliasExactMatch(t *testing.T) { matcher := aliasGoldenMatcher() req := aliasGoldenReq() cand := engine.Candidate{ ID: "cand-alias-golden", // No clearance required on this req so clearance scores 100 regardless. // No certs, no customer, 0 years required, no location: all dimensions score 100. Skills: []engine.CandidateSkill{ // No SkillID set; name is the alias text. The resolver maps "signals intelligence" // to sigintID which equals the required canonical id, triggering the alias path. {Name: "Signals Intelligence"}, }, Available: true, } res := engine.ScoreCandidate(context.Background(), cand, req, matcher) // Skills component: 1 of 1 required met (the alias resolved) => 100. if !res.Skills.Equal(decimal.NewFromInt(100)) { t.Fatalf("Skills = %s, want 100", res.Skills.String()) } // No gaps: the one mandatory skill was met via alias. if len(res.GapSummary) != 0 { t.Fatalf("gap count %d, want 0: %v", len(res.GapSummary), res.GapSummary) } // The matched skill record must carry AliasMatched=true and Similarity=1.0. The engine // sets Exact=false for all sm-sourced matches (not a bug; see matchOne in engine.go). if len(res.MatchedSkills) == 0 { t.Fatal("expected at least one MatchedSkills entry") } m := res.MatchedSkills[0] if !m.Matched { t.Error("Matched should be true") } if !m.AliasMatched { t.Error("AliasMatched should be true for a curated alias match") } if !m.Similarity.Equal(decimal.NewFromInt(1)) { t.Errorf("Similarity = %s, want 1", m.Similarity.String()) } if m.Exact { t.Error("Exact is false for sm-sourced matches: the engine sets it to false in matchOne") } // Golden total: all six dimensions are 100 (no clearance req, no certs req, no customer req, // 0 years req, no location req, candidate is available). Total = 100.00. if res.Total.StringFixed(2) != "100.00" { t.Fatalf("total = %s, want 100.00", res.Total.StringFixed(2)) } if res.Band != engine.BandGreen { t.Fatalf("band = %s, want Green", res.Band) } // AEDT invariant: trace components must re-sum to the total. sum := decimal.Zero for _, comp := range res.Trace { sum = sum.Add(comp.Weighted) } if !sum.Round(2).Equal(res.Total) { t.Fatalf("trace sum %s != total %s", sum.Round(2), res.Total) } } // TestGoldenRelationshipPartialCredit proves that a candidate holding Skill A (which has a // substitutes_for edge to Skill B at strength 0.80) satisfies the requirement for Skill B via // the ChainedResolver relationship path. // // Engine counting: matchOne returns ok=true for any sm.Match hit, so met increments to 1 and the // skill fraction is ratio(1,1)=100. The partial credit (0.80) lives in the SkillMatch.Similarity // field of the decision trace, not in the Skills sub-score denominator. The Skills component is // therefore 100, not 80, and the total is 100.00. The distinction is captured in the SkillMatch // record for AEDT explainability. func TestGoldenRelationshipPartialCredit(t *testing.T) { matcher := aliasGoldenMatcher() req := relationshipGoldenReq() cand := engine.Candidate{ ID: "cand-rel-golden", Skills: []engine.CandidateSkill{ // Skill A has a substitutes_for edge to Skill B at strength 0.80 in the rels map. {SkillID: skillAID, Name: "Skill A"}, }, Available: true, } res := engine.ScoreCandidate(context.Background(), cand, req, matcher) // Skills component: ratio(1,1) = 100. The relationship strength is in the SkillMatch record, // not in the sub-score fraction. See scoreSkills: it counts ok-matches, not weighted by similarity. if !res.Skills.Equal(decimal.NewFromInt(100)) { t.Fatalf("Skills = %s, want 100", res.Skills.String()) } // No mandatory gap: the relationship match satisfied the one required skill. if len(res.GapSummary) != 0 { t.Fatalf("gap count %d, want 0: %v", len(res.GapSummary), res.GapSummary) } // The matched skill record must carry Similarity=0.80, Exact=false, AliasMatched=false. if len(res.MatchedSkills) == 0 { t.Fatal("expected at least one MatchedSkills entry") } m := res.MatchedSkills[0] if !m.Matched { t.Error("Matched should be true") } if m.AliasMatched { t.Error("AliasMatched should be false for a relationship match") } if !m.Similarity.Equal(decimal.RequireFromString("0.80")) { t.Errorf("Similarity = %s, want 0.80", m.Similarity.String()) } if m.Exact { t.Error("Exact should be false for a relationship match") } // Golden total: same logic as alias case (no dimensions have active requirements except // skills, which resolved to 100). Total = 100.00. if res.Total.StringFixed(2) != "100.00" { t.Fatalf("total = %s, want 100.00", res.Total.StringFixed(2)) } if res.Band != engine.BandGreen { t.Fatalf("band = %s, want Green", res.Band) } // AEDT invariant. sum := decimal.Zero for _, comp := range res.Trace { sum = sum.Add(comp.Weighted) } if !sum.Round(2).Equal(res.Total) { t.Fatalf("trace sum %s != total %s", sum.Round(2), res.Total) } }

Mathematical records from this source

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