Source identity
| Field | Recorded value |
|---|---|
| Source type | GitHub source |
| Original record | Janady13/missionmatch / internal/modules/matching/rerank.go |
| Date | Not specified in source |
| Repository | Janady13/missionmatch |
| Revision | 720d47fae476b0d38477ae4401697d372b1ea2bc |
| Branch | feature/opportunity-to-outcome |
| Path or archive member | internal/modules/matching/rerank.go |
| Original SHA-256 | 1555667f551040576f747360c341c5f29d107c8890f7bd953c4dc9a4af720588 |
| Git blob SHA | c36174e67e80a998ae84870cd5ad41da4ddd060a |
| Reading-copy SHA-256 | 1555667f551040576f747360c341c5f29d107c8890f7bd953c4dc9a4af720588 |
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/modules/matching/rerank.go | feature/opportunity-to-outcome | 720d47fae476b0d38477ae4401697d372b1ea2bc | Open original |
| Janady13/missionmatch / internal/modules/matching/rerank.go | collision-deconfliction | 4ee5a09972608ed89f8377c6665542d5f450f0a6 | Open original |
| Janady13/missionmatch / internal/modules/matching/rerank.go | master | 1e9249840a4302ec82e123b9c9cb6f75badea3e4 | Open original |
| Janady13/missionmatch / internal/modules/matching/rerank.go | mag-substrate | b82c7100a492dec67dfd1eda6b3f53def859be35 | Open original |
| Janady13/missionmatch / internal/modules/matching/rerank.go | time-to-fill-survival | b66e1e505863d4f17741a4b9ede73509e45bd6c6 | Open original |
| Janady13/missionmatch / internal/modules/matching/rerank.go | presentation-readiness | eb574acaa29d71ce4d0f852572e87c275c79fdb7 | Open original |
| Janady13/missionmatch / internal/modules/matching/rerank.go | vendor-intelligence | fe9796a19c261951d3f2565206c0c1b5ac294465 | Open original |
| Janady13/missionmatch / internal/modules/matching/rerank.go | phase2-connectors | e038d4c687aec16f8bd9bc4d907eea14d91f8704 | Open original |
| Janady13/missionmatch / internal/modules/matching/rerank.go | feature/aioe-upgrade | 2178e7298d0e5d9af83afa12402fd587f0ba6ed8 | Open original |
| Janady13/missionmatch / internal/modules/matching/rerank.go | capture-readiness | bae6af7cb2997e819174a9e9cfff5e16067a1975 | Open original |
Recovered source transcript
Download complete source text ↓67 lines · 2.7 KB
package matching
import (
"context"
"github.com/jackc/pgx/v5"
"github.com/shopspring/decimal"
"github.com/missionworkforce/missionmatch/internal/modules/matching/engine"
)
// rerankModelKey is the champion display order re ranker read at slate generation to order the members. It is
// the same model_key the MAG trainer (cmd/train-model -kind reranker) fits and the evaluator promotes.
const rerankModelKey = "slate_display_order"
// championRerankWeights reads the champion display order re ranker's utility weights keyed by feature name plus
// its version, from the global MAG coefficient store on the caller's tx. It is BEST EFFORT: on any absence or
// error it returns nil weights and version 0, and the caller keeps the frozen engine order (the re ranker only
// ever permutes an already scored slate, never blocks generating it). The prior only champion (version 1) holds
// the engine component weights, so the order is unchanged until a LEARNED challenger is promoted; generateSlate
// therefore applies the reorder only for a learned champion (version above 1), keeping the prior only order byte
// identical to the engine order.
func championRerankWeights(ctx context.Context, tx pgx.Tx) (map[string]float64, int) {
rows, err := tx.Query(ctx, `
SELECT c.feature_name, c.coefficient::float8, m.version
FROM aedt_learned_models m
JOIN aedt_model_coefficients c ON c.model_key = m.model_key AND c.version = m.version
WHERE m.model_key = $1 AND m.champion = true AND m.output_kind = 'display_order'`, rerankModelKey)
if err != nil {
return nil, 0
}
defer rows.Close()
weights := map[string]float64{}
version := 0
for rows.Next() {
var name string
var coef float64
var v int
if err := rows.Scan(&name, &coef, &v); err != nil {
return nil, 0
}
weights[name] = coef
version = v
}
if rows.Err() != nil || len(weights) == 0 {
return nil, 0
}
return weights, version
}
// rerankUtility is a candidate's display utility under the re ranker weights: the learned weight on each frozen
// engine sub score. The display order is this utility descending. It is NEVER a candidate score; it only orders
// an already scored slate, and the frozen engine Total remains the score shown. The feature names match the
// trainer's RerankFeatureOrder and map one to one onto the engine MatchResult sub scores.
func rerankUtility(weights map[string]float64, res engine.MatchResult) float64 {
term := func(name string, d decimal.Decimal) float64 {
v, _ := d.Float64()
return weights[name] * v
}
return term("clearance_score", res.Clearance) +
term("skills_score", res.Skills) +
term("certs_score", res.Certifications) +
term("customer_score", res.CustomerExperience) +
term("experience_score", res.Experience) +
term("location_score", res.Location)
}