Source identity
| Field | Recorded value |
|---|---|
| Source type | GitHub source |
| Original record | Janady13/missionmatch / internal/modules/matching/engine/weights.go |
| Date | Not specified in source |
| Repository | Janady13/missionmatch |
| Revision | 720d47fae476b0d38477ae4401697d372b1ea2bc |
| Branch | feature/opportunity-to-outcome |
| Path or archive member | internal/modules/matching/engine/weights.go |
| Original SHA-256 | 23dc41688c3ac430b4dc260395e4eaa908c50cd5e6dd4a78742813d47e6f55a4 |
| Git blob SHA | 3d8dfd8cf675519adebb4ec8690f6d4460cfe7e5 |
| Reading-copy SHA-256 | 23dc41688c3ac430b4dc260395e4eaa908c50cd5e6dd4a78742813d47e6f55a4 |
Every recorded occurrence
These 2 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/engine/weights.go | feature/opportunity-to-outcome | 720d47fae476b0d38477ae4401697d372b1ea2bc | Open original |
| Janady13/missionmatch / internal/modules/matching/engine/weights.go | feature/aioe-upgrade | 2178e7298d0e5d9af83afa12402fd587f0ba6ed8 | Open original |
Recovered source transcript
Download complete source text ↓70 lines · 2.6 KB
package engine
import (
"fmt"
"github.com/shopspring/decimal"
)
// GlobalDefaultProfileVersion names the weight set every tenant scores on until the Adaptive
// Intelligence Optimization Engine has produced a tenant profile. It is stamped into results and
// audit rows so a served score always names the exact weights that produced it.
const GlobalDefaultProfileVersion = "global.default"
// Weights carries the six dimension weights the scorer applies. The engine stays pure and
// deterministic: weights are an INPUT, injected by the caller, decimal end to end. The fixed
// package constants (WeightClearance and friends) remain the frozen global default; a tenant
// profile from the AIOE layer arrives here already validated and clamped.
type Weights struct {
Clearance decimal.Decimal
Skills decimal.Decimal
Certifications decimal.Decimal
CustomerExperience decimal.Decimal
Experience decimal.Decimal
Location decimal.Decimal
}
// DefaultWeights returns the frozen global default weight set (CLAUDE.md fixed weights). Scoring
// with DefaultWeights is byte identical to the historical ScoreCandidate behavior; the frozen
// golden tests prove it.
func DefaultWeights() Weights {
return Weights{
Clearance: WeightClearance,
Skills: WeightSkills,
Certifications: WeightCerts,
CustomerExperience: WeightCustomer,
Experience: WeightExperience,
Location: WeightLocation,
}
}
// Sum returns the exact decimal sum of the six weights.
func (w Weights) Sum() decimal.Decimal {
return w.Clearance.Add(w.Skills).Add(w.Certifications).
Add(w.CustomerExperience).Add(w.Experience).Add(w.Location)
}
// Validate rejects any weight set that is not a well formed probability style allocation: every
// dimension strictly positive, none above one, and the total exactly 1 at four decimal places.
// The scorer refuses an invalid set and falls back to the global default, so a corrupt profile
// can degrade a tenant to defaults but can never distort a score.
func (w Weights) Validate() error {
one := decimal.NewFromInt(1)
for name, v := range map[string]decimal.Decimal{
"clearance": w.Clearance,
"skills": w.Skills,
"certifications": w.Certifications,
"customer_experience": w.CustomerExperience,
"experience": w.Experience,
"location": w.Location,
} {
if !v.IsPositive() || v.GreaterThan(one) {
return fmt.Errorf("engine: weight %s out of range: %s", name, v.String())
}
}
if !w.Sum().Round(4).Equal(one) {
return fmt.Errorf("engine: weights sum to %s, not 1", w.Sum().String())
}
return nil
}